var bonsecoursireland = {
	Forms : {
		PayOnline : {
			Validate:function() {
				if( $("firstname").value.blank() ) {
					bonsecoursireland.Forms.HAL("firstname");
					return false;
				}
				if( $("lastname").value.blank() ) {
					bonsecoursireland.Forms.HAL("lastname");
					return false;
				}
				if( $("euro").value.blank() ) {
					bonsecoursireland.Forms.HAL("euro");
					return false;
				}
				if( $("cent").value.blank() ) {
					bonsecoursireland.Forms.HAL("cent");
					return false;
				}
				if( $("invoiceNumber").value.blank() ) {
					bonsecoursireland.Forms.HAL("invoiceNumber");
					return false;
				}
				if( $("patientNumber").value.blank() ) {
					bonsecoursireland.Forms.HAL("patientNumber");
					return false;
				}
				return true;
			}
		},
		HAL:function(id) {
			new Effect.Highlight( $(id) );
			$(id).focus();
		}
	},
	ShowHomeVideo:function(){
		$("flashcontent").style.display="none";
		Lightbox.onCloseCallBack = bonsecoursireland.OnCloseHomeVideo;
		Lightbox.showBoxByID( "videoHolder", 650, 550, true );
		setTimeout( bonsecoursireland.InitHomeVideoFlash, 1500 );
		return false;
	}
	,OnCloseHomeVideo:function(){
		$("flashcontent").style.display="block";
	},
	InitHomeVideoFlash:function(){
		var so = new SWFObject("swf/BonsVideo.swf", "bonsVideo", "640", "530", "9", "#333333");
		if( document.all == null ) so.addParam("wmode", "transparent");
		so.write("videoHolder2");
	},
	SendPatientMessage:function(hospital){
		Lightbox.showBoxByAJAX( "index.cfm?action=showSendPatientMessage", 650, null, true );
		return false;
	}
	,ShowSendPatientMessage:function(){
		Lightbox.showBoxByID( "twSendPatientform", 550, null, true );
		return false;
	}
}

function FormIsNumberKey(evt){
	var charCode = (evt.which) ? evt.which : event.keyCode;
	if (charCode > 31 && (charCode < 48 || charCode > 57)) {
		return false;
	}
	return true;
}

String.prototype.isEmail = function () { 
	var rx = new RegExp("\\w+([-+.\’]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"); 
	var matches = rx.exec(this); 
	return (matches != null && this == matches[0]); 
}

function isNumeric(str) { 
	var y=parseInt(str); 
	if (isNaN(y)) {
	   return false; 
	} else {
		return true;
	}
} 
function LoadingAjax(txt) {
	if(typeof(txt)=="undefined") {
		txt = "Loading...";
	}
	return "<div class='ajaxMsg' id='widgetAjaxMsg'> "+txt+"</div>";
}

function parseJSON( json ){
	var o = eval('(' + json + ')');
	if( o.redirectURL )
	{
		document.location = o.redirectURL;
		return;
	}
	if( $("message") != null ) new Element.remove( "message" );
	if( o.errMsg )
	{
		if( o.errMsgTitle == null ) o.errMsgTitle = "Error";
		if( o.errMsgTimer == null ) o.errMsgTimer = 5000;
		tw.ShowMessage( o.errMsgTitle, o.errMsg, "error", o.errMsgTimer, o.errMsgPosition );
		return o;
	}
	if( o.msgTitle || o.msg )
	{
		if( o.msgTimer == null ) o.msgTimer = 5000;
		tw.ShowMessage( o.msgTitle, o.msg, o.msgClass, o.msgTimer, o.msgPosition );
	}
	return o;
}

var errFunc = function(t) {
	var win = window.open("", "win", "width=1024,height=700,resizable=yes,scrollbars=yes,status=no"); // a window object
	win.document.open("text/html", "replace");
	win.document.write( "<html><body style='margin:0'><div style='border-bottom:1px solid #222;background:#666;padding:10px;'><h1 style='color:#FFF;margin:0;padding:0;'>Digital Crew Ajax Error</h1></div><div style='padding:10px;'>"+t.responseText.replace(/^\s+|\s+$/, '') + "</div></body></html>" );
	win.document.close();
	win.focus();
}

