function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


var cbDefaultFieldBackground;
function submitbutton(mfrm) {
	var me = mfrm.elements;
	var r = new RegExp("^[a-zA-Z](([\.\-a-zA-Z0-9@])?[a-zA-Z0-9]*)*$", "i");
	var errorMSG = '';
	var iserror=0;
	if (cbDefaultFieldBackground === undefined) cbDefaultFieldBackground = ((me['username'].style.getPropertyValue) ? me['username'].style.getPropertyValue("backgroundColor") : me['username'].style.backgroundColor);
	if (me['username'].value == "") {
		errorMSG += "Please enter a user name.\n";
		me['username'].style.backgroundColor = "red";
		iserror=1;
	} else if (!r.exec(me['username'].value) || (me['username'].value.length < 3)) {
		errorMSG += "Please enter a valid Username:.  No spaces, more than 2 characters and contain 0-9,a-z,A-Z\n";
		me['username'].style.backgroundColor = "red";
		iserror=1;
	} else if (me['username'].style.backgroundColor.slice(0,3)=="red") { me['username'].style.backgroundColor = cbDefaultFieldBackground;
	} 
	/*if (!r.exec(me['password'].value) || (me['password'].value.length < 6)) {
		errorMSG += "Please enter a valid Password:.  No spaces, more than 6 characters and contain 0-9,a-z,A-Z\n";
		me['password'].style.backgroundColor = "red";
		iserror=1;
	} else if ((me['password'].value != "") && (me['password'].value != me['verifyPass'].value)){
		errorMSG += "Password and verification do not match, please try again.\n";
		me['password'].style.backgroundColor = "red"; me['verifyPass'].style.backgroundColor = "red";
		iserror=1;
	} else {
		if (me['password'].style.backgroundColor.slice(0,3)=="red") me['password'].style.backgroundColor = cbDefaultFieldBackground;
		if (me['verifyPass'].style.backgroundColor.slice(0,3)=="red") me['verifyPass'].style.backgroundColor = cbDefaultFieldBackground;
	}*/
	// loop through all input elements in form
	for (var i=0; i < me.length; i++) {
		// check if element is mandatory; here mosReq="1"
		if ( (typeof(me[i].getAttribute('mosReq')) != "undefined") && ( me[i].getAttribute('mosReq') == 1) ) {
			if (me[i].type == 'radio' || me[i].type == 'checkbox') {
				var rOptions = me[me[i].getAttribute('name')];
				var rChecked = 0;
				if(rOptions.length > 1) {
					for (var r=0; r < rOptions.length; r++) {
						if (rOptions[r].checked) {
							rChecked=1;
						}
					}
				} else {
					if (me[i].checked) {
						rChecked=1;
					}
				}
				if(rChecked==0) {
					// add up all error messages
					errorMSG += me[i].getAttribute('mosLabel') + ' : This field is required!\n';
					// notify user by changing background color, in this case to red
					me[i].style.backgroundColor = "red";
					iserror=1;
				} else if (me[i].style.backgroundColor.slice(0,3)=="red") me[i].style.backgroundColor = cbDefaultFieldBackground;
			}
			if (me[i].value == '') {
				// add up all error messages
				errorMSG += me[i].getAttribute('mosLabel') + ' : This field is required!\n';
				// notify user by changing background color, in this case to red
				me[i].style.backgroundColor = "red";
				iserror=1;
			} else if (me[i].style.backgroundColor.slice(0,3)=="red") me[i].style.backgroundColor = cbDefaultFieldBackground;
		}
	}
	if(iserror==1) {
		alert(errorMSG);
		return false;
	} else {
		return true;
	}
}
function submitfrm(mfrm) {
	var me = mfrm.elements;
	var r = new RegExp("^[a-zA-Z](([\.\-a-zA-Z0-9@])?[a-zA-Z0-9]*)*$", "i");
	var errorMSG = '';
	var iserror=0;
 	 
	// loop through all input elements in form
	for (var i=0; i < me.length; i++) {
		// check if element is mandatory; here mosReq="1"
 if ( (typeof(me[i].getAttribute('mosReq')) != "undefined") && ( me[i].getAttribute('mosReq') == 1) ) {
			if (me[i].value == '') { 
				// add up all error messages
				errorMSG += me[i].getAttribute('mosLabel') + ' : This field is required!\n';
				// notify user by changing background color, in this case to red
				me[i].style.backgroundColor = "red";
				iserror=1;
			} else if (me[i].style.backgroundColor.slice(0,3)=="red") me[i].style.backgroundColor = '#FFFFFF';
 }
		}
 	if(iserror==1) {
		alert(errorMSG);
		return false;
	} else {
		return true;
	}
}
function showHideSubCat(id)
{
	if(document.getElementById('tbody_'+id).style.display=="none")
		document.getElementById('tbody_'+id).style.display = '';
	else
	{
		location.href = 'doctor.php?specid='+id;
		//document.getElementById('tbody_'+id).style.display = 'none';
	}
}
function showHideDiv(show,hide,body,id, link)
	{
		if(document.getElementById(body+id).style.display=='none')
		{
		document.getElementById(body+id).style.display=''
		if(hide!='' && link!='')
		document.getElementById(link+id).innerHTML=hide
		}else
		{
		document.getElementById(body+id).style.display='none'
		if(show !=''  && link!='')
		document.getElementById(link+id).innerHTML=show
		}
	}
function showHideAll2(id,num,prefix)
{
for(var i=1;i<=num;i++)
	{
document.getElementById(prefix+i).style.display='none'
	}
	document.getElementById(prefix+id).style.display=''
}

function sendrequest(http_request,divid)
	{
		if(http_request.readyState ==4)
		   { 
			   if(http_request.status ==200)
			   {
				resText=http_request.responseText;
				document.getElementById(divid).innerHTML=resText;
			   }
			    else {
			document.getElementById(divid).innerHTML = "<FONT SIZE='4' COLOR='red'>Query not submitted!</FONT>";
					}
		   }
	}

	function callStates(id,op,divid)
{	 
var cid='';
 	  if(document.getElementById('country'))
	{
	  cid=document.getElementById('country').value;
	  }
	   if(document.getElementById('cb_hospitalcountry'))
	{
	  cid=document.getElementById('cb_hospitalcountry').value;
	  }
		var url= 'ajax.php?op='+op+'&id='+id+'&divid='+divid+'&cid='+cid;
		//alert(url);
 		var post_data=url;

		document.getElementById(divid).innerHTML = "<FONT SIZE='2' COLOR='red'><img src='images/ajax-loader-clock.gif' border='0'></font>";
		if(window.XMLHttpRequest)
		{
			http_request=new XMLHttpRequest();
		if(http_request.overrideMimeType)
		{
			http_request.overrideMimeType('text/html');
			}
			
		}else if(window.ActiveXObject)
		{
			try{
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
				}catch(e)
				{
				try{
					http_request = new ActiveXObject("Microsoft.XMLHTTP");
					}catch(e){}
				}
		
		}
	
	http_request.onreadystatechange=function(){sendrequest(http_request,divid);};
	http_request.open('GET',url,true);
	http_request.send(null);
	
	}

	function openPopup(url)
	{
		
		window.open(url,'enlarge','width=350,height=250,toolbar=no, status=no,menubar=no,scrollbars=yes,copyhistory=no, resizable=yes'); 
	}
	function openPopuplogin(url)
	{
		
		window.open(url,'enlarge','width=700,height=350,toolbar=no, status=no,menubar=no,scrollbars=NO,copyhistory=no, resizable=NO,fullscreen=no'); 
	}
	function highlight(objcell,flag){
			if(flag){
				objcell.style.backgroundColor="lightBlue"
			}else{
				objcell.style.backgroundColor=""
			}
		}
