	function isBlank(s)
	{
		for(var i=0; i < s.length; i++)
		{
			var c = s.charAt(i);
			if((c!=' ')&&(c!="\n")&&(c!="\t"))
			return false;
		}
		return true;
    }
	function spWin(win_nm,nm,w,h)
	{
        	var hs=screen.height; hs=hs-80;
        	var ws=screen.width; ws=ws-10;
	        if(h>hs) h = hs ;
	        if(w>ws) w = ws ;
        	var myfeatures = 'directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no,resizable=yes,scrollbars=yes,width='+w+',height='+h+',left=0,top=0';
	        var newImg = open(win_nm,nm,myfeatures);
        	newImg.focus();
	}
	function spWinWithoutResize(win_nm,nm,w,h)
	{
        	var hs=screen.height; hs=hs-80;
        	var ws=screen.width; ws=ws-10;
	        if(h>hs) h = hs ;
	        if(w>ws) w = ws ;
        	var myfeatures = 'directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no,resizable=no,scrollbars=no,width='+w+',height='+h+',left=0,top=0';   
	        var newImg = open(win_nm,nm,myfeatures);
        	newImg.focus();
	}
	function openWin(win_nm,nm)
	{
        	var h=screen.height;
	        h=h-80;

        	var myfeatures = 'directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no,resizable=yes,scrollbars=no,width=650,height=550,left=0,top=0';

	        var newImg = open(win_nm,nm,myfeatures);
        	newImg.focus();
	}
	function smallWin(win_nm,nm)
	{
        	var h=screen.height;
	        h=h-80;

	       	var myfeatures = 'directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no,resizable=yes,scrollbars=no,width=500,height=220,left=0,top=0';

	        var newImg = open(win_nm,nm,myfeatures);
        	newImg.focus();
	}
	function confirmDel(ref)
	{
		if(confirm(msgDelConfirm))
			window.location.replace(ref);
		return;
	}

	function submitf(ref,id,id_ri)
	{
		document.sform.id_rc.value=id;
		document.sform.id_ri.value=id_ri;
		document.sform.action = ref;
		document.sform.submit();
	}

 	function validString(s) {
 		if((s.match(/^['&#\/,.a-zA-Z0-9 !@\?åÅäÄöÖ\n\r\f-]*$/) || s==""))
                	return true;
		else
			return false ;
	}
	function delAttach(id)
	{
		if(confirm(msgDelConfirm))
		{
			document.dform.id_attach.value=id;
			document.dform.submit();
		}
	}

    	function getLength(s) {
		return s.length ;
    	}

	function checkData(str, max){
		if( getLength(s) > 0 && getLength(s) <= max){
			return true ;
		} else if( getLength(s) > max) {
			alert(msgMaxCharExceeded);
			return false ;
		}
		return true ;
	}

	function isFloat(s) {
		if(!s.match(/^\d{0,10}[,]{0,1}\d{0,2}$/))
			return false;
		else
			return true ;
    	}

    	function isNumber(s) {
		if(s.match(/^\d{0,10}$/) && s <= 2147483647)
			return true;
		else
			return false ;
    	}

	function spDelete(loc){
		if(confirm(msgDelConfirm)){
			document.location.href=loc;
			return true;
		}
	}

	function spOld(loc){
		if(confirm(msgOldConfirm)){
			document.location.href=loc;
			return true;
		}
	}

	function spActive(loc){
		if(confirm(msgActiveConfirm)){
			document.location.href=loc;
			return true;
		}
	}
	function isValidChar(s) {
		if(!validString(s)) {
			alert(msgValidCharAllowed);
			return false ;
		}
		else
			return true ;
    	}
function checkDelete(src,langNameAlert)
{
	conString = msgDelConfirm +" "+ langNameAlert;
	if(confirm(conString))
		window.location.replace(src);
}
function groupOfUrlFun(formName,category,winWidth,winHeight)
{
	cform = document.forms[formName] ;
	val = cform.groupOfUrl.checked ;
  if(val)
  {
  	spWin("addGroupUrl.php?category="+category,"myinyt",winWidth,winHeight);
	}
}
function groupofDocumentFun(formName,category,winWidth,winHeight)
{
	cform = document.forms[formName] ;
	val = cform.groupOfDocument.checked ;
  if(val)
  {
  	spWin("addGroupDocument.php?category="+category,"myinyt",winWidth,winHeight);
	}
}
function submitPageForLinkDocAndUrl(formNameForLink,item,winW,winH)
{
	cform = document.forms[formNameForLink];
	cform.linkToAdd.value=item;
	cform.winWidth.value=winW;
	cform.winHeight.value=winH;
	cform.submit();
}
function canclePageRedirect(formName)
{
	cform = document.forms[formName] ;
	val = cform.phpName.value;
	window.location = val;

}
function isEmailValid(email) {

    var ok = true;
    if (!(/^.+@.+\..{2,3}$/.test(email))) {
           ok = false;
    }

    if (email.match(/[\(\)\<\>\,\;\:\\\/\?\*\!\¤\%\&\'\$\#\"\[\]]/)) {
       ok = false;
    }
    return ok;
}//emailvalid
function isTimeValid(time) {

    var ok = true;
    if(!(/^[0-2][0-9]:[0-5][0-9]$/.test(time))){
        ok = false;
    }
    return ok;
}//timevalid

function urlValid(curl)
{
    var ok = true;
    if(!(/^.*\.(.*)\..{2,3}$/.test(curl)))
        ok = false;
    return ok;
}//urlvalid..over
function checkDeleteWithScroll(src,langNameAlert,ev) {
	conString = msgDelConfirm +" "+ langNameAlert;
	if(confirm(conString)) {		
		goToWithScroll(src,ev);
		//window.location.replace(src);
	}
		
}

function isPosNumber(s) {
	if(s < 0)
		return true;
	else
		return false;
	
}
function validStringName(s) 
{
 		if((s.match(/^[a-zA-Z0-9 åÅäÄöÖ_-]*$/)))
         	return true;
		else
			return false ;
}
function createXml()
{
  var xmlhttp;
	if(navigator.appName.indexOf("Microsoft") == 0)
		xmlhttp = new ActiveXObject('microsoft.xmlhttp');
	else
		xmlhttp = new XMLHttpRequest();
		
	return xmlhttp;
		
}
function callAjax(xmlhttp,reqFile,eleName,divName,funcName)
{
	var rand = new Date().getTime();
	var param = unescape(reqFile).substring(1).split("?");
	if(param.length > 1)
		reqFile += "&rand="+rand;
	else
		reqFile += "?rand="+rand;
	xmlhttp.open('get',reqFile,'true');

  if(!funcName)
  {
  	  xmlhttp.onreadystatechange = function(){
  		if(xmlhttp.readyState == 4)
  		{
  			if(xmlhttp.status == 200)
  			{
  				var resText = xmlhttp.responseText;
  				if(eleName)
  				{
  					document.getElementById(eleName).value = '';
  					document.getElementById(eleName).value = resText;
  				}
  				else if(divName)
  				{
  					document.getElementById(divName).innerHTML= resText;
  				}
  			}
  		}
  	}
  }
  else
  {  
    xmlhttp.onreadystatechange = eval(funcName);
  }  
    	
	xmlhttp.send(null);
}

function callAjaxMultiResponse(xmlhttp,reqFile,eleName,divName,funcName)
{
	var rand = new Date().getTime();
	var param = unescape(reqFile).substring(1).split("?");
	if(param.length > 1)
		reqFile += "&rand="+rand;
	else
		reqFile += "?rand="+rand;
	xmlhttp.open('get',reqFile,'true');
  var responseDivision = divName.split('|');
  if(!funcName)
  {
  	  xmlhttp.onreadystatechange = function(){
  		if(xmlhttp.readyState == 4)
  		{
  			if(xmlhttp.status == 200)
  			{
  				var resText = xmlhttp.responseText;
  				if(eleName)
  				{
  					document.getElementById(eleName).value = '';
  					document.getElementById(eleName).value = resText;
  				}
  				else if(divName)
  				{
					var responseObj = resText.split("|||||||");
  					document.getElementById(responseDivision[0]).innerHTML = responseObj[0];
					if( responseObj[1] && responseDivision[1]){
						$("#listRecipents").hide();
	  					document.getElementById(responseDivision[1]).innerHTML= responseObj[1];
					}else if(responseDivision[1]){
						document.getElementById(responseDivision[1]).innerHTML= "";
						$("#listRecipents").hide();
					}

  				}
  			}
  		}
  	}
  }
  else
  {  
    xmlhttp.onreadystatechange = eval(funcName);
  }  
    	
	xmlhttp.send(null);
}

function checkBasicValidation(uname,email,password,fname,lname,confirmpwd)
{
	var myArr = new Array();
	var myString = new String();
	var fnametextbox = document.getElementById("fname"); 
	var lnametextbox = document.getElementById("lname"); 
	var unametextbox = document.getElementById("uname"); 
	var emailtextbox = document.getElementById("email"); 
	var pwdtextbox = document.getElementById("password"); 	
	var confirmpwdtextbox = document.getElementById("confirmpwd"); 	
   
   if(isBlank(fname)){
		alert(msgEnterFirstname);
		document.getElementById("fname").value='';
		fnametextbox.focus();
		return false;   
   }   
   if(isBlank(lname)){
		alert(msgEnterLastname);
		document.getElementById("lname").value='';
		lnametextbox.focus();
		return false;   
   }
   if(isBlank(uname)){
		alert(msgEnterUserName);
		unametextbox.focus();
		return false;
	}  
   if(isBlank(password)){
		alert(msgEnterPassword);
		document.getElementById("password").value='';
		pwdtextbox.focus();
		return false;   
   }   
   if(isBlank(confirmpwd)){
		alert(msgEnterConfirmPassword);
		document.getElementById("confirmpwd").value='';
		confirmpwdtextbox.focus();
		return false;   
   }   
   if(password != confirmpwd){
	alert(msgPwdAndConfirmpasswordNotMatch)
	document.getElementById("confirmpwd").value='';
	confirmpwdtextbox.focus();
	return false;
   }
   if(isBlank(email)){
		alert(msgEnterEmail);
		emailtextbox.focus();
		return false;
   }
   if(!isEmailValid(email)){
	alert(msgEnterValidEmail);
	emailtextbox.value = '';
	emailtextbox.focus();
	return false;
   }
  
  var xmlhttp = false;
  if(navigator.appName == "Microsoft Internet Explorer") {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } else {
   xmlhttp = new XMLHttpRequest();
  }
	
  url="registration.php?username="+uname+"&emails="+email
  xmlhttp.open("GET",url,true);
  xmlhttp.onreadystatechange=function() {
  
   if (xmlhttp.readyState==4 && xmlhttp.status == 200) {  
	myString = xmlhttp.responseText;		
	myArr = myString.split(",_,");	
	if(myArr[1] == 'User exist'){
		document.getElementById('userExist').innerHTML = myArr[0]
		document.getElementById('usermsgshowhide').style.display = '';
		document.getElementById('emailmsgshowhide').style.display = 'none';	
		return false;
    }
	if(myArr[1] == 'Email exist'){		
		document.getElementById('emailExist').innerHTML = myArr[0]
		document.getElementById('emailmsgshowhide').style.display = '';	
		document.getElementById('usermsgshowhide').style.display = 'none';
		document.getElementById('userExist').innerHTML = '';
		return false;
    }
	if(xmlhttp.responseText != 'Email exist' && xmlhttp.responseText != 'User exist'){ 
		document.getElementById('userExist').innerHTML = '';
		document.getElementById('emailExist').innerHTML = '';
		document.getElementById('usermsgshowhide').style.display = 'none';
		document.getElementById('emailmsgshowhide').style.display = 'none';	
		document.registration.submit();		
	}	
   }   
  }
 
  xmlhttp.send(url);  
}

function goToNext(){ 
		var noRadio = 'Y';		
		//alert(document.purposeacute.purposename.length)
		//alert(document.purposeacute.purposename.checked)
		if(document.purposeacute.purposename.checked == true){		
			noRadio = 'N';	
			return true;
		}
		
		
		for (index=0; index < document.purposeacute.purposename.length; index++) {
			if (document.purposeacute.purposename[index].checked) {
				noRadio = 'N';								
				var radioValue = document.purposeacute.purposename[index].value;
				//alert(radioValue);
				return true;
			}
		}
		
		if(noRadio == 'Y'){
			 alert(msgSelctOneRadio);
			 return false;
		}	
	}
	
function checkedRadio(idPurpose){ //alert(document.purposeacute.purposename.length)
	if(Number(idPurpose)){
		var nottocame = 'N';			
		for (index=0; index < document.purposeacute.purposename.length; index++) {
		var myString = document.purposeacute.purposename[index].value
		var myResArr = myString.split(",");	
				if (myResArr[0] == idPurpose) 
					document.purposeacute.purposename[index].checked = true;
			var nottocame = 'Y';		
		}		
		if(idPurpose && nottocame == 'N'){		
			document.purposeacute.purposename.checked = true;
		}
	}
}

function goToBack(id_dentist_group){
	window.location = "clientDentistInfo.php?id_dentist_group="+id_dentist_group;
}

function upperFirstName()
{
	var fnmletter = "";
	var fnmletter1 = "";
	fnmletter = document.getElementById("fname").value.substr(0,1);
	fnmletter1 = document.getElementById("fname").value.substr(1);
	document.getElementById("fname").value = fnmletter.toUpperCase() + fnmletter1;
}
function upperLastName()
{
	var lnmletter = "";
	var lnmletter1 = "";
	lnmletter = document.getElementById("lname").value.substr(0,1);
	lnmletter1 = document.getElementById("lname").value.substr(1);
	document.getElementById("lname").value = lnmletter.toUpperCase() + lnmletter1;
}
