/*	Project 						:	DAMS
	Language 						: 	PHP 5
	Database 						: 	Mysql
	Author							:	jineesh M.G
	Development Center				:	AlignMinds Technologies Pvt. Ltd.
	*/
   
/* JavaScript Document*/

/*function for Enable/Disable prepaid registration login box
 *
 */
function __fncEnablePrepaid()
{
    if(trim($('cboRegType').value) !='')
    {
        if(trim($('cboRegType').value)=='P')
        {
            $('divPrepaidValidation').style.display = 'block';
           
            $('divFirstContainer').style.display    = 'none';
        }
        else
        {
            $('divPrepaidValidation').style.display = 'none';
           
            $('divFirstContainer').style.display = 'block';
        }
    }
    return true;
}

function __fncCheckPrepaidActivation()
{

  
    
    if(trim($('txtPractId').value)=='')
    {
        alert("Enter Doctor Id");
       
        $('txtPractId').focus();
        return false;
    }
    else if(isNaN(trim($('txtPractId').value)))
    {
        alert("Invalid Practitioner Id");
       
        $('txtPractId').focus();
        return false;
    }
    else if(trim($('txtActivation').value)=='')
    {
        alert("Enter the Activation Code ");
        
        $('txtActivation').focus();
        return false;
    }


  var url = "ajaxpost.php";
    

  new Ajax.Request(url, {
          method: 'get',
          parameters: {action: 'checkPrepaidCode', drid: $('txtPractId').value,actcode: $('txtActivation').value},
          onLoading : function(){$('divAjaxPrepaid').style.display='block';},
          onSuccess : __fncCheckPrepaidActivationResult,
          onError   : fncError
          });

    
    return true;
}

function __fncCheckPrepaidActivationResult(reqObj)
{

    $('divAjaxPrepaid').style.display='none';

    
    var arr = reqObj.responseText.split(_SEPERATOR);
    
    if(arr[1]=='0')
    {
       
        alert("Invalid Practitioner ID");
        return false;
    }
    else if(arr[1]=='-1')
    {
        
        alert("Invalid Activation Code");
        return false;
    }
    else if(arr[1]=='2')
    {
        
        alert("Already Activated");
        return false;
    }

    else if(arr[1]=='1')
    {
        //Practitioner Id and Activation Code varifcation success
        $('divPrepaidValidation').style.display = 'none';
        $('divFirstContainer').style.display = 'block';
        $('divRegTypeSelection').style.display = 'none';
    }
   
    return false;

}

function __fncCheckUserNameAvailabilty()
{
    var url = "ajaxpost.php";

   
    if(trim($('txtusername').value) == '')
    {
        return false ;
    }
    else if(trim($('txtusername').value).length < 3)
    {
        
        alert("Minimum 3 characters required. ");
        $('txtusername').focus(); return false ;
    }
    else if(!isValidUserName($('txtusername').value))
    {
        
        alert("Invalid user name. ");
        $('txtusername').focus(); return false;
    }



    new Ajax.Request(url, {
              method: 'get',
              parameters: {action: 'checkUserAvailable', username: $('txtusername').value },
              onLoading : function(){$('divAjaxUserName').style.display='block';},
              onSuccess : __fncCheckUserNameAvailabiltyResult,
              onError   : fncError
              });

                 
   

    return true;
}

function __fncCheckUserNameAvailabiltyResult(reqObj)
{

    
    var arr = reqObj.responseText.split(_SEPERATOR);

    $('divAjaxUserName').style.display='none';
    if(arr[1]=="OK")
        {
            alert("User Name already exist.");
            $('txtusername').focus();
            return false;
            
        }
    
   return true;

}


/*function loadDistrict(url)
{
    //Here we are filling the district field in practice location also
    if ($('cboState').value != '')
    {
        $('imgDistrict').style.visibility = 'visible';
      
        var	params = 'action=LOADDISTRICT&STATE_ID='+ escape($('cboState').value);
        
        new Ajax.Request(url,{
            method:"get",
            parameters:params,
            onSuccess:updateDistrict,
            onFailure:dispError
        })
       
    }
    else
    {
        return;
    }
}
*/
/*function updateDistrict(reqObj)
{
  
    //alert(trim(reqObj.responseText));

    
    //	$("divDistrict").innerHTML = trim(reqObj.responseText);
    //
    //    $('divDistrict').innerHTML = trim(reqObj.responseText);

    $('cboDistrict').update(trim(reqObj.responseText));

    //$("cboDistrict").innerHTML = trim(reqObj.responseText);

    
    //Load same districts in Location district field also

    $('cboLocationDistrict').update(trim(reqObj.responseText));

   

    //$("divLocationDistrict").innerHTML = reqObj.responseText;

    $('imgDistrict').style.visibility = 'hidden';

/*
    if(trim($('hidDistrict').value)=='0')
        {
            $('divNoDistrictErr').innerHTML = "no data available"
            $('divNoDistrictErr').style.display = "block";
        }
     else
         $('divNoDistrictErr').style.display = "none";
    * /
}
*/

/*function loadPostOffice(url){
    
    if ($('cboDistrict').value != ''){
        $('imgPostoffice').style.visibility = 'visible';
        var	params = 'action=LOADPOSTOFFICE&DISTRICT_ID='+ escape($('cboDistrict').value);
        new Ajax.Request(url,{
            method:"get",
            parameters:params,
            onSuccess:updatePostofffice,
            onFailure:dispError
        })
    }else{
        return;
    }
}
*/
/*function updatePostofffice(reqObj){
    //alert(reqObj.responseText);
    $("divPostOffice").innerHTML = reqObj.responseText;
    $('imgPostoffice').style.visibility = 'hidden';

    if(trim($('hidPost').value)=='0')
    {
        $('divNoPostErr').innerHTML = "no data available"
        $('divNoPostErr').style.display = "block";
    }
    else
        $('divNoPostErr').style.display = "none";
}
*/
/*function changePincode(url)
{
    if ($('cboState').value != ''){
        $('imgPincode').style.visibility = 'visible';
        var	params = 'action=LOADPINCODE&POST_OFFICE='+ escape($('cboPostoffice').value);
        new Ajax.Request(url,{
            method:"get",
            parameters:params,
            onSuccess:updatePincode,
            onFailure:dispError
        })
    }else{
        return;
    }
	
}
*/
/*function updatePincode(reqObj){
    //alert(reqObj.responseText);
    if(trim(reqObj.responseText)=='')
    {
        $("txtPincode").value = '';
        $('divNoPINErr').innerHTML = "no data available"
        $('divNoPINErr').style.display = "block";

    }
    else
    {
        $("txtPincode").value = reqObj.responseText;
        $('divNoPINErr').style.display = "none";
    }
       
    $('imgPincode').style.visibility = 'hidden';
}
*/

/**
 * Ajax Load local Body
 **/
/*function loadLocalBody(url)
{
    // alert($('hiddenLbType').value);
   
    if ($('cboLocationDistrict').value != '')
    {
        $('imgLocalBody').style.visibility = 'visible';

        var	params = 'action=LOAD_LOCAL_BODY&DISTRICT_ID='+ escape($('cboLocationDistrict').value)+'&LB_TYPE='+escape($('hiddenLbType').value);
        new Ajax.Request(url,{
            method:"get",
            parameters:params,
            onSuccess:setLocalBodyNames,
            onFailure:dispError
        })
    }else{
        return;
    }
}
*/
/*function setLocalBodyNames(reqObj)
{
    //alert(reqObj.responseText);
    if(reqObj.responseText=='')
        return false;
    else
    {
        $('cboLocalBody').update(trim(reqObj.responseText));

        $('imgLocalBody').style.visibility = 'hidden';
        return true;
    }
}
function enableLbtype(lbtype,url)
{
    $('hiddenLbType').value=lbtype;

    loadLocalBody(url);


}
*/


/**
 * Ajax Load local Body For Hospital 
 **/
/*function loadLocalBodyForHospital(url)
{
    // alert($('hiddenLbType').value);

    if ($('cboDistrict').value != '')
    {
        $('imgLocalBodyHs').style.visibility = 'visible';

        var	params = 'action=LOAD_LOCAL_BODY&DISTRICT_ID='+ escape($('cboDistrict').value)+'&LB_TYPE='+escape($('hiddenLbTypeForHs').value);
        new Ajax.Request(url,{
            method:"get",
            parameters:params,
            onSuccess:setLocalBodyNamesForHospital,
            onFailure:dispError
        })
    }else{
        return;
    }
}*/

/*function setLocalBodyNamesForHospital(reqObj)
{
    //alert(reqObj.responseText);
    if(reqObj.responseText=='')
        return false;
    else
    {
        $('cboLocalBodyForHs').update(trim(reqObj.responseText));

        $('imgLocalBodyHs').style.visibility = 'hidden';
        return true;
    }
}
function enableLbtypeForHs(lbtype,url)
{
    $('hiddenLbTypeForHs').value=lbtype;

    loadLocalBodyForHospital(url);


}

function fncLoadHospital(url)
{
    //Change on Aug 28
    //Cahange on Aug 31 - Load all hospitals in a district Now

    $('txtHospitalAddress').value = '';


    if($('cboDistrictforHs').value=='')
        return false;
    else
    {

        $('imgHospital').style.visibility = 'visible';
        var	params = 'action=LOAD_HOSPITAL&DISTRICT_ID='+ escape($('cboDistrictforHs').value);

        new Ajax.Request(url,{
            method:"get",
            parameters:params,
            onSuccess:setHospital,
            onFailure:dispError
        })
    }


    return true;
}

*/
/*function setHospital(reqObj)
{
    //alert(reqObj.responseText);

    $('imgHospital').style.visibility = 'hidden';
    $('txtHospitalName').update(trim(reqObj.responseText));

}
*/

/*function fncLoadHospitalAddress(url)
{
    $('imgHospitalAddress').style.visibility = 'visible';

    //alert($('txtHospitalName').value);
    
    if($('txtHospitalName').value=='')
        return false;
    else
    {
        var	params = 'action=LOAD_HOSPITAL_ADDRESS&HS_ID='+ escape($('txtHospitalName').value);

        new Ajax.Request(url,{
            method:"get",
            parameters:params,
            onSuccess:setHospitalAddress,
            onFailure:dispError
        })
    }


    return true;
}
*/
/*function setHospitalAddress(reqObj)
{

    $('imgHospitalAddress').style.visibility = 'hidden';
    $('txtHospitalAddress').value = (trim(reqObj.responseText));

}
*/
function __fncSetSalutation(thisvar)
{
    if(thisvar.value	==	'M'){
        if($('cboSalutation').value == 'Mrs.' || $('cboSalutation').value == 'Ms.'){
            $('cboSalutation').selectedIndex ='0';
        }
    }else{
        if($('cboSalutation').value == 'Mr.' ){
            $('cboSalutation').selectedIndex ='1';
        }
    }
}





/*function __fncLoadTelephoneCode(id)
{
    
    if ($('cboType'+id).value	==	'1')
    {

        $('txtTelcode'+id).style.display = 'none';
		
        //$('txtTelNo'+id).focus();
    }else{
        $('txtTelcode'+id).style.display = 'block';
	
        $('txtTelcode'+id).value = '';
        $('txtTelcode'+id).focus();
    }
}*/
/*function  __fncAddRowToTable()
{
    var tbl = document.getElementById('tblPhoneNumbers');
    var lastRow = tbl.rows.length;
    // if there's no header row in the table, then iteration = lastRow + 1

    var iteration = lastRow;
    var row = tbl.insertRow(lastRow);
    document.getElementById('hiddencounter').value = parseInt(document.getElementById('hiddencounter').value) + 1;
    //var addval = document.getElementById('hiddencounter').value;
    // left cell

    var cellRight = row.insertCell(0);
    var sel = document.createElement('select');
    sel.name 		= 'cboType' + iteration;
    sel.id 		= 'cboType' + iteration;
    sel.onchange	=	function(){
        __fncLoadTelephoneCode(iteration);
    };
    sel.options[0] = new Option('Land Phone', '0');
    sel.options[1] = new Option('Mobile Phone', '1');
    cellRight.appendChild(sel);
    //  sel.className = 'inputclass';
    cellRight.appendChild(sel);
    // el.onkeypress = keyPressTest;
    cellRight = row.insertCell(1);
    var el = document.createElement('input');
    el.type = 'text';
    el.name = 'txtTelcode' + iteration;
    el.id = 'txtTelcode' + iteration;
    el.maxLength=6;
    el.style.width = '80px';
    el.className = 'txtRegInputBox';

    // el.onkeypress = keyPressTest;
    cellRight.appendChild(el);



    var cellRightSel = row.insertCell(2);
    el = document.createElement('input');
    el.type = 'text';
    el.name = 'txtTelNo' + iteration;
    el.id = 'txtTelNo' + iteration;
    el.className = 'txtRegInputBox';
    el.maxLength=12;
    cellRightSel.appendChild(el);
    // right cell

    // cellRight.appendChild(el);

    cellRight = row.insertCell(3);
    sel = document.createElement('select');
    sel.name = 'cboLocation' + iteration;
    sel.id = 'cboLocation' + iteration;
    sel.options[0] = new Option('Residence', '1');
    sel.options[1] = new Option('Office', '0');

    // right cell

    cellRight.appendChild(sel);

    $('removePhone').style.visibility = 'visible';
    $( 'txtTelcode' + iteration).focus();

}
*/

/*function removeRowFromTable()
{
    var tbl = document.getElementById('tblPhoneNumbers');
    if($('hiddencounter').value > 0){
        $('hiddencounter').value	=	parseInt($('hiddencounter').value,10) - 1;
    }
    var lastRow = tbl.rows.length;
    if (lastRow > 2) {
        var rowval = parseInt(lastRow);
        var correctval = rowval-1;
        var valuethere = document.getElementById('txtTelcode'+correctval).value;
        if(valuethere != ""){
            if(confirm("Are you sure you want to remove the number?")){
                tbl.deleteRow(lastRow - 1);

                if((lastRow-2) == 1)
                {
                    $('removePhone').style.visibility = 'hidden';
                }
            }
            else{
        }
        }
        else {
            if((lastRow-2) == 1)
            {
                $('removePhone').style.visibility = 'hidden';
            }

            tbl.deleteRow(lastRow - 1);
        }
    }


}*/

/*function __fncContinueRegistration()

{

    $('divPasswordErr').style.display               = 'none';
    $('divConfirmPassErr').style.display            = 'none';
    $('divUserAvailableErr').style.display          = 'none';
    $('divNameErr').style.display                   = 'none';
    $('divEmailErr').style.display                  = 'none';
    $('divSpecialityErr').style.display             = 'none';
    $('divPhoneErr').style.display                  = 'none';
    $('divPractIdError').style.display              = 'none';
    $('divCodeErr').style.display                   = 'none';
    $('divPrepaidValidationErr').style.display      = 'none';
    $('divNoStateErr').style.display                = 'none';
    $('divNoDistrictErr').style.display             = 'none';
    $('divBasicDiplomaErr').style.display           = 'none';
    $('divBasicDegreeErr').style.display            = 'none';
    $('divPGDiplomaErr').style.display              = 'none';
    $('divPGDegreeErr').style.display               = 'none';
    $('divSuperSpecialityErr').style.display        = 'none';
    $('divRoyalCouncilErr').style.display           = 'none';
    $('divRegNumErr').style.display                 = 'none';
    $('divStreamErr').style.display                 = 'none';
    $('divstate_select1Err').style.display                 = 'none';
    $('divselect_district1Err').style.display                 = 'none';
       
    var categoryvalues = $$('input:checked[type="radio"]').pluck('value');
    var streamvalues = $$('input:checked[type="checkbox"]').pluck('value');

    if(trim($('txtusername').value) == ''){
        $('divUserAvailableErr').style.display ='block';
        $('divUserAvailableErr').innerHTML="Please enter username.";
        $('txtusername').focus(); return false;
    } else if(trim($('txtusername').value).length < 3)
    {
        $('divUserAvailableErr').style.display ='block';
        $('divUserAvailableErr').innerHTML="Minimum 3 characters required. ";
        $('txtusername').focus(); return false;
    }else if(!isValidUserName($('txtusername').value))
    {
        $('divUserAvailableErr').style.display ='block';
        $('divUserAvailableErr').innerHTML="Invalid user name. ";
        $('txtusername').focus(); return false;
    } else if(trim($('txtPassword').value) == ''){

        $('divPasswordErr').style.display ='block';
        $('divPasswordErr').innerHTML="Please enter password.";
        $('txtPassword').focus(); return false;
    }else if(trim($('txtPassword').value).length <6){
     
        $('divPasswordErr').style.display ='block';
        $('divPasswordErr').innerHTML="Minimum 6 characters ! ";
        $('txtPassword').focus(); return false;
    }else if(trim($('txtConPassword').value) == ''){

        $('divConfirmPassErr').style.display ='block';
        $('divConfirmPassErr').innerHTML="Please enter confirm password.";
        $('txtConPassword').focus(); return false;
    }else if(trim($('txtConPassword').value) != trim($('txtPassword').value)){
    
        $('divConfirmPassErr').style.display ='block';
        $('divConfirmPassErr').innerHTML="Password mismatch";
        $('txtConPassword').focus();
        return false;
    }else if(trim($('txtName').value) == ''){
        $('divNameErr').style.display ='block';
        $('divNameErr').innerHTML="Please enter your name.";
        $('txtName').focus(); return false;
    }else if(trim($('txtName').value).length <3){
        $('divNameErr').style.display ='block';
        $('divNameErr').innerHTML="Minimum 3 characters required.";
        $('txtName').focus(); return false;
    }else if(!isValidName(trim($('txtName').value))){
        $('divNameErr').style.display ='block';
        $('divNameErr').innerHTML="Invalid name.";
        $('txtName').focus(); return false;
    }
    else if(trim($('cboMedCouncil').value)==''){
        $('divRegNumErr').style.display ='block';
        $('divRegNumErr').innerHTML="Please select a medical council.";
        $('cboMedCouncil').focus(); return false;
    }
    else if(trim($('cboMedCouncil').value)==''){
        $('divNameErr').style.display ='block';
        $('divNameErr').innerHTML="Please select a medical council.";
        $('txtName').focus(); return false;
    }
    else if(trim($('txtEmailId').value) != '')
    {
        //If it is not null check It is valid or not

        if(! isValidEmail(trim($('txtEmailId').value)))
        {
            $('divEmailErr').style.display ='block';
            $('divEmailErr').innerHTML="Please enter a valid email-id";
            $('txtEmailId').focus(); return false;

        }

    }
    else if (streamvalues == '')
    {
        alert("Please select a stream.");
        $('cboStream').focus();
        return false;
    }
    else if($('cboBasicProfDegree0').value=='')
    {
        $('divBasicDegreeErr').style.display ='block';
        $('divBasicDegreeErr').innerHTML="Please select a basic prof. degree.";
        $('cboBasicProfDegree0').focus(); return false;
    }
  

    else if (  categoryvalues[1] == 0)
    {
        for(var countspec=0; countspec < $('hiddenspeciality').value; countspec++)
        {
            var varSpec		=	$('cboSpeciality'+countspec).value;


            if(varSpec == '')
            {
                $('divSpecialityErr').style.display ='block';
                $('divSpecialityErr').innerHTML="Please select a speciality";
                return false;
            }
            else  if( $('hiddenspeciality').value > 1 )
            {
                for(var checkcount=countspec+1; checkcount < $('hiddenspeciality').value; checkcount++)
                {

                    var varcheck     =   $('cboSpeciality'+checkcount).value;

                    if(varcheck == varSpec)
                    {
                        $('divSpecialityErr').style.display ='block';
                        $('divSpecialityErr').innerHTML="Please select different specialities";
                        return false;

                    }
                }

            }
        }
    }



    else if(trim($('cboState').value)==''){
        $('divNoStateErr').style.display ='block';
        $('divNoStateErr').innerHTML="Please select state ";
        $('cboState').focus(); return false;
    }
    else if(trim($('cboDistrict').value)==''){
        $('divNoDistrictErr').style.display ='block';
        $('divNoDistrictErr').innerHTML="Please select district";
        $('cboDistrict').focus(); return false;
    }
    else if(trim($('state_select1').value)==''){
        $('divstate_select1Err').style.display ='block';
        $('divstate_select1Err').innerHTML="Please select state";
        $('state_select1').focus(); return false;
    }
    else if(trim($('select_district1').value)==''){
        $('divselect_district1Err').style.display ='block';
        $('divselect_district1Err').innerHTML="Please select district";
        $('select_district1').focus(); return false;
    }


   


    for( var countqual=0; countqual < $('hiddenbasicprofdiploma').value; countqual++)
    {
        $('divBasicDiplomaErr').style.display ='none';
        var varQual		=	$('cboBasicProfDiploma'+countqual).value;

        if( $('hiddenbasicprofdiploma').value > 1 )
        {
            for( checkcount=countqual+1; checkcount < $('hiddenbasicprofdiploma').value; checkcount++)
            {

                varcheck     =   $('cboBasicProfDiploma'+checkcount).value;

                if(varcheck == varQual)
                {
                    $('divBasicDiplomaErr').style.display ='block';
                    $('divBasicDiplomaErr').innerHTML="Please select different qualifications";
                    return false;

                }
            }

        }
    }


    for(  countqual=0; countqual < $('hiddenbasicprofdegree').value; countqual++)
    {
        $('divBasicDegreeErr').style.display ='none';
        varQual		=	$('cboBasicProfDegree'+countqual).value;

        if( $('hiddenbasicprofdegree').value > 1 )
        {
            for( checkcount=countqual+1; checkcount < $('hiddenbasicprofdegree').value; checkcount++)
            {

                varcheck     =   $('cboBasicProfDegree'+checkcount).value;

                if(varcheck == varQual)
                {
                    $('divBasicDegreeErr').style.display ='block';
                    $('divBasicDegreeErr').innerHTML="Please select different qualifications";
                    return false;

                }
            }

        }
    }

    for(  countqual=0; countqual < $('hiddenPGDiploma').value; countqual++)
    {
        $('divPGDiplomaErr').style.display ='none';
        varQual		=	$('cboPGDiploma'+countqual).value;


        if( $('hiddenPGDiploma').value > 1 )
        {
            for( checkcount=countqual+1; checkcount < $('hiddenPGDiploma').value; checkcount++)
            {

                varcheck     =   $('cboPGDiploma'+checkcount).value;

                if(varcheck == varQual)
                {
                    $('divPGDiplomaErr').style.display ='block';
                    $('divPGDiplomaErr').innerHTML="Please select different qualifications";
                    return false;

                }
            }

        }
    }

    for(  countqual=0; countqual < $('hiddenPGDegree').value; countqual++)
    {
        $('divPGDegreeErr').style.display ='none';
        varQual		=	$('cboPGDegree'+countqual).value;

        if( $('hiddenPGDegree').value > 1 )
        {
            for( checkcount=countqual+1; checkcount < $('hiddenPGDegree').value; checkcount++)
            {

                varcheck     =   $('cboPGDegree'+checkcount).value;

                if(varcheck == varQual)
                {
                    $('divPGDegreeErr').style.display ='block';
                    $('divPGDegreeErr').innerHTML="Please select different qualifications";
                    return false;

                }
            }

        }
    }

    for(  countqual=0; countqual < $('hiddenSuperSpeciality').value; countqual++)
    {
        $('divSuperSpecialityErr').style.display ='none';
        varQual		=	$('cboSuperSpeciality'+countqual).value;

        if( $('hiddenSuperSpeciality').value > 1 )
        {
            for( checkcount=countqual+1; checkcount < $('hiddenSuperSpeciality').value; checkcount++)
            {

                varcheck     =   $('cboSuperSpeciality'+checkcount).value;

                if(varcheck == varQual)
                {
                    $('divSuperSpecialityErr').style.display ='block';
                    $('divSuperSpecialityErr').innerHTML="Please select different qualifications";
                    return false;

                }
            }

        }
    }

    for(  countqual=0; countqual < $('hiddenRoyalCouncil').value; countqual++)
    {
        $('divRoyalCouncilErr').style.display ='none';
        varQual		=	$('cboRoyalCouncil'+countqual).value;

        if( $('hiddenRoyalCouncil').value > 1 )
        {
            for( checkcount=countqual+1; checkcount < $('hiddenRoyalCouncil').value; checkcount++)
            {

                varcheck     =   $('cboRoyalCouncil'+checkcount).value;

                if(varcheck == varQual)
                {
                    $('divRoyalCouncilErr').style.display ='block';
                    $('divRoyalCouncilErr').innerHTML="Please select different qualifications";
                    return false;

                }
            }

        }
    }


    //alert($('hiddencounter').value);
    for(var varpass=1; varpass <= $('hiddencounter').value; varpass++)
    {
        var varPhone		=	$('txtTelNo'+varpass).value;
        var varCode			=	$('txtTelcode'+varpass).value;
        var type			=	$('cboType'+varpass).value;

        if(varPhone == '')
        {
            $('divPhoneErr').style.display ='block';
            $('divPhoneErr').innerHTML="Please enter a phone number";

            $('txtTelNo'+varpass).focus();return false;
        }
        if(type==0 & varCode	==	''){

            $('divPhoneErr').style.display ='block';
            $('divPhoneErr').innerHTML="Please Enter  telephone code ";

            $('txtTelcode'+varpass).focus();return false;
        }else if(isNaN(varCode)){

            $('divPhoneErr').style.display ='block';
            $('divPhoneErr').innerHTML="Telephone code must be a number";


            $('txtTelcode'+varpass).focus();return false;
        }else if(varPhone	==	''){

            $('divPhoneErr').style.display ='block';
            $('divPhoneErr').innerHTML="Please Enter a telephone Number";


            $('txtTelNo1').focus();return false;
        }else if(isNaN(varPhone)){

            $('divPhoneErr').style.display ='block';
            $('divPhoneErr').innerHTML="Telephone number must be a number";


            $('txtTelNo'+varpass).focus();return false;
        }
        if(CheckPhoneNumber(varPhone,type) )
        {

        }else{
            $('divPhoneErr').style.display ='block';
            $('divPhoneErr').innerHTML="Please enter a valid telephone number";

            $('txtTelNo'+varpass).focus();return false;

        }
    }

    if($("state_select1").disabled==true)
    {
        $("state_select1").disabled=false;
    }
    if($("select_district1").disabled==true)
    {
        $("select_district1").disabled=false;
    }
    if($("txtlocalbody1").disabled==true)
    {
        $("txtlocalbody1").disabled=false;
    }
    if($("txtPracticeLocation").disabled==true)
    {
        $("txtPracticeLocation").disabled=false;
    }

    thisForm.txtWhat2Do.value = 'ADDUSER';
    thisForm.submit();

}
*/

function __fncGenerateHoliday()
{
    
    count		=	parseInt($('holidayCount').value,10)+1;
  
    if(count > 6){
        alert("You can only set seven days as Weekly holidays ");
        $('cboDay1').focus();return;
    }
   
    for(btncount=2;btncount<=parseInt($('holidayCount').value,10);btncount++){
        $('remove'+btncount).style.display='none';

    }
    $('holidayCount').value	= count;

    var tbl = document.getElementById('tblHoliday');
    
    var rowcount = tbl.rows.length;

    var row = tbl.insertRow(rowcount);

    var cellLeft = row.insertCell(0);

    var cboType = document.createElement('select');
    cboType.name = 'cboDay' + count;
    cboType.id = 'cboDay' + count;
    cboType.className = 'holidayoption';
    cboType.options[0] = new Option('Monday', 1);
    cboType.options[1] = new Option('Tuesday', 2);
    cboType.options[2] = new Option('Wednesday', 3);
    cboType.options[3] = new Option('Thursday', 4);
    cboType.options[4] = new Option('Friday', 5);
    cboType.options[5] = new Option('Saturday', 6);
    cboType.options[6] = new Option('Sunday', 7);
    
    cellLeft.appendChild(cboType);

    var cellRight = row.insertCell(1);
    var removeButton   = document.createElement('input');
    removeButton.type  = 'button';
    removeButton.name  = 'remove'+count;
    removeButton.id    = 'remove'+count;
    removeButton.value = 'Remove';
    removeButton.className = 'telephoneaddbtn';
    removeButton.onclick = function() {
        removeOption();
    };
    cellRight.appendChild(removeButton);
     
	
}

function removeOption()
{
    id	= parseInt($('holidayCount').value,10);
    btncount	= parseInt(id	,10)-1;
    
    $('holidayCount').value	=	 btncount;
   
    if(btncount != 1){
        $('remove'+btncount).style.display='block';
    }
    
    var tbl = document.getElementById('tblHoliday');

    tbl.deleteRow(btncount);

    $('tblHoliday').removeChild(varchildid);
    $('tblHoliday').removeChild(btnchildid);
	
}

function __fncGoBacktoFirstForm()
{
    $('divSecondContainer').style.display	=	'none';
    $('divRegTypeSelection').style.display = 'none';
    $('divFirstContainer').style.display	=	'block';
}

/*function __fncRegister(){

    $('divPatientsPerSlotErr').style.display    = 'none';
    $('divMedRepsErr').style.display            = 'none';
    $('divTokenErr').style.display              = 'none';
    $('divLocalBodyErr').style.display          = 'none';
            
    if(trim($('txtNoclients').value) == '' ){
           	
        $('divPatientsPerSlotErr').style.display ='block';
        $('divPatientsPerSlotErr').innerHTML=" enter no. of clients in each slot";
        $('txtNoclients').value ='';
        $('txtNoclients').focus(); return;
    }else if(isNaN(trim($('txtNoclients').value)))
    {
            
        $('divPatientsPerSlotErr').style.display ='block';
        $('divPatientsPerSlotErr').innerHTML=" enter a valid number";
        $('txtNoclients').value ='';
        $('txtNoclients').focus(); return;
    }
    else if(parseInt($('txtNoclients').value,10) > parseInt($('txtTimeslot').value))
    {
			
        $('divPatientsPerSlotErr').style.display ='block';
        $('divPatientsPerSlotErr').innerHTML="must be less than slot period";
        $('txtNoclients').value ='';
        $('txtNoclients').focus(); return;
    }
    else if(isNaN(trim($('txtNoMedReps').value)))
    {
            
        $('divMedRepsErr').style.display ='block';
        $('divMedRepsErr').innerHTML=" enter a valid number";
        $('txtNoMedReps').value='';
        $('txtNoMedReps').focus(); return;
    }
    else if(parseInt($('txtNoMedReps').value,10) > parseInt($('txtTimeslot').value))
    {
			
        $('divMedRepsErr').style.display ='block';
        $('divMedRepsErr').innerHTML="must be less than slot period";
        $('txtNoMedReps').value='';
        $('txtNoMedReps').focus(); return;
    }else if(trim($('txtTokenPrefix').value) == '' ){

        $('divTokenErr').style.display ='block';
        $('divTokenErr').innerHTML=" enter token prefix";
        $('txtTokenPrefix').value ='';
        $('txtTokenPrefix').focus(); return;
    }else if(isNaN(trim($('txtTokenPrefix').value)))
    {
        $('divTokenErr').style.display ='block';
        $('divTokenErr').innerHTML=" enter a valid number";
        $('txtTokenPrefix').value ='';
        $('txtTokenPrefix').focus(); return;

    }else if(trim($('txtTokenPrefix').value).length!=2)
    {
        $('divTokenErr').style.display ='block';
        $('divTokenErr').innerHTML=" Must be 2 digits";
        $('txtTokenPrefix').value ='';
        $('txtTokenPrefix').focus(); return;
    }
         
    else if($('cboLocalBody').value=='')
    {
        $('divLocalBodyErr').style.display ='block';
        $('divLocalBodyErr').innerHTML ="Please Select Local Body";
        $('cboLocalBody').focus();
        return;
    }

 
    for(btnoutercount=1;btnoutercount<=parseInt($('holidayCount').value,10);btnoutercount++){
        for(btncount=1;btncount<=parseInt($('holidayCount').value,10);btncount++){
            if(btnoutercount !=  btncount){
                if($('cboDay'+btnoutercount).selectedIndex == $('cboDay'+btncount).selectedIndex){
                    $('divHolidayErr').style.display ='block';
                    $('divHolidayErr').innerHTML="select Different Days ";
                    $('cboDay'+btnoutercount).focus();return;
                }
            }
        }
    }
    if ($('rdolicenceDecline').checked == true	)
    {
        alert("Sorry, You can register with EatherWay only if you sign up the Declaration by selecting the \'I Agree\' radio button");
        $('rdolicenceDecline').focus();return;
    }

    //TODO Remove it Later Plzzzzzzzz
        
    /*if($('recaptcha_response_field').value=='')
        {
            alert("Enter the code");
            $('recaptcha_response_field').focus();
            return ;
        }
        * /
	
    thisForm.txtWhat2Do.value = 'ADDUSER';
    thisForm.submit();
}
*/

/**
 *
 */

    

function divDisplayBlockAndNoneDiv(div_id){
    if($(div_id).style.display == 'none'){
        $(div_id).style.display	=	"block";
    }
    else{
        $(div_id).style.display	=	"none";
    }

}


/////New Functions added by Jasmu on 8-11-2009
///For New practiioner Registeration

/*function showStreamwiseSpeciality()
{

    var url = "ajaxRegistration.php";

    var streamValues = $$('input:checked[type="checkbox"]').pluck('value');

    var params = 'action=STREAMWISE_SPECIALITY&STREAMS='+streamValues;
    new Ajax.Request(url,{
        method:"get",
        parameters:params,
        onSuccess:loadStreamwiseSpeciality,
        onFailure:dispError
    })

}
*/


/*function loadStreamwiseSpeciality(reqObj)
{
    //alert(reqObj.responseText);
    $('RemoveSpec').style.visibility = 'hidden';
    $('cboSpeciality0').update(reqObj.responseText);
    $('pgSpeciality0').update(reqObj.responseText);
    $('superSpeciality0').update(reqObj.responseText);

    $('pgSpeciality0').style.width='60%';
    $('superSpeciality0').style.width='60%';

    var countspec =$('hiddenspeciality').value;
    for(var i=countspec; i>1 ; i--)
    {
        __fncremoveRowFromSpeciality('tblSpeciality');
    }




}*/

/*function  __fncAddRowToSpeciality(tablename,hiddenValue,selectboxid,removeId,errorId)
{

    var tbl = $(tablename);
    var lastRow = tbl.rows.length;
    // if there's no header row in the table, then iteration = lastRow + 1

    var iteration = lastRow;



    var previousindex = iteration-1;

    // alert($(hiddenValue).value);

    var numberofoptions=$(selectboxid+'0').length;

    if((lastRow < numberofoptions-1)  && ($(selectboxid+previousindex).value!=''))
    {
        var row = tbl.insertRow(lastRow);

        var cellRight = row.insertCell(0);
        var selbox = document.createElement('select');
        selbox.name 		= selectboxid + iteration;
        selbox.id 		=  selectboxid + iteration;
        selbox.className = 'txtRegInputBox'

        selbox.onchange	=	function(){
            __fncCheckRepeatEntry(selectboxid,iteration,errorId);
        };

        var optionList = $(selectboxid+'0').getElementsByTagName('option');
        var nodes = $A(optionList);

        var iterate = 0;
        nodes.each(function(node)
        {
            // alert(node.value + ': ' + node.innerHTML );

            var optionname  = node.innerHTML;
            // alert(optionname);
            var optionvalue = node.value;
            //alert(optionvalue);
            selbox.options[iterate] = new Option(optionname, optionvalue);

            iterate++;

        });

        cellRight.appendChild(selbox);
        $(removeId).style.visibility = 'visible';
        $(hiddenValue).value = parseInt($(hiddenValue).value,10) + 1;
    }

}
*/
/*function  __fncCheckRepeatEntry(selectboxid,iteration,errorId)
{
    $(errorId).style.display ='none';

    for (var i=0; i<iteration; i++)
    {

        if( $(selectboxid+iteration).value == $(selectboxid+i).value)
        {
            $(errorId).style.display ='block';
            $(errorId).innerHTML="Please select a different value";
            return;
        }
    }



}
*/

/*function __fncremoveRowFromSpeciality()
{


    var tbl = document.getElementById('tblSpeciality','RemoveSpec');

    //alert($('hiddenspeciality').value);
    var lastRow = tbl.rows.length;
    if (lastRow > 1)
    {
        tbl.deleteRow(lastRow - 1);
        $('hiddenspeciality').value	=	parseInt($('hiddenspeciality').value,10) - 1;

        if((lastRow-1) == 1)
        {
            $('RemoveSpec').style.visibility= 'hidden';
        }


    }

}
*/

/*function showQualification()
{


    var url = "ajaxRegistration.php";

    var streamValues = $$('input:checked[type="checkbox"]').pluck('value');

    $('hiddencboStream').value=streamValues;

    var params = 'action=QUALIFICATION&STREAMS='+streamValues;

    new Ajax.Request(url,{
        method:"get",
        parameters:params,
        onSuccess:loadQualification,
        onFailure:dispError
    })

}
*/
/*function loadQualification(reqObj)
{
    //  alert(reqObj.responseText);

    var qualArray = reqObj.responseText;

    var qualifications = qualArray.split("^");


    $('removeDiploma').style.visibility = 'hidden';
    $("cboBasicProfDiploma0").update(qualifications[0]);
    var countdiploma = $('hiddenbasicprofdiploma').value;

    for(var i=countdiploma; i>1; i--)
    {
        removeRowFromQualification('tblBasicProfDiploma','hiddenbasicprofdiploma','removeDiploma');

    }

    $('removeDegree').style.visibility = 'hidden';
    $("cboBasicProfDegree0").update(qualifications[1]);
    var countdegree = $('hiddenbasicprofdegree').value;

    for( i=countdegree; i>1; i--)
    {
        removeRowFromQualification('tblBasicProfDegree','hiddenbasicprofdegree','removeDegree');
    }


    $('removePGDiploma').style.visibility = 'hidden';
    $("cboPGDiploma0").update(qualifications[2]);
    var countpgdiploma = $('hiddenPGDiploma').value;
    for( i=countpgdiploma; i>1; i--)
    {
        removeRowFromQualification('tblPGDiploma','hiddenPGDiploma','removePGDiploma');
    }

    $('removePGDegree').style.visibility = 'hidden';
    $("cboPGDegree0").update(qualifications[3]);
    var countpgdegree = $('hiddenPGDegree').value;
    for( i=countpgdegree; i>1; i--)
    {
        removeRowFromQualification('tblPGDegree','hiddenPGDegree','removePGDegree');
    }

    $('removeSuperSpec').style.visibility = 'hidden';
    $("cboSuperSpeciality0").update(qualifications[4]);
    var countsuperspec = $('hiddenSuperSpeciality').value;
    for( i=countsuperspec; i>1; i--)
    {
        removeRowFromQualification('tblSuperSpeciality','hiddenSuperSpeciality','removeSuperSpec');
    }

    $('removeRoyalCouncil').style.visibility = 'hidden';
    $("cboRoyalCouncil0").update(qualifications[5]);
    var countroyalcouncil = $('hiddenRoyalCouncil').value;
    for( i=countroyalcouncil; i>1; i--)
    {
        removeRowFromQualification('tblRoyalCouncil','hiddenRoyalCouncil','removeRoyalCouncil');
    }

}

*/

/*function __fncAddRowToQualification(tablename,hiddenValue,selectboxid,removeId,errorId)
{

    var tbl = document.getElementById(tablename);
    var lastRow = tbl.rows.length;
    // if there's no header row in the table, then iteration = lastRow + 1

    var iteration = lastRow;


    // alert(iteration);
    //alert($(hiddenValue).value);

    var numberofoptions=$(selectboxid+'0').length;

    var previousindex = iteration-1;

    if((lastRow < numberofoptions-1) && ($(selectboxid+previousindex).value!='') )
    {
        var row = tbl.insertRow(lastRow);


        /*   var cellRight = row.insertCell(0);
  //     var labl =  document.createElement('nbsp');
    var labl =  document.createTextNode('\u00A0');* /




        cellRight = row.insertCell(0);
        var selbox = document.createElement('select');
        selbox.name 		= selectboxid + iteration;
        selbox.id 		=  selectboxid + iteration;
        selbox.className = 'txtRegInputBox'

        selbox.onchange	=	function(){
            __fncCheckRepeatEntry(selectboxid,iteration,errorId);
        };

        var optionList = $(selectboxid+'0').getElementsByTagName('option');
        var nodes = $A(optionList);

        var iterate = 0;
        nodes.each(function(node)
        {
            // alert(node.value + ': ' + node.innerHTML );

            optionname  = node.innerHTML;
            // alert(optionname);
            optionvalue = node.value;
            //alert(optionvalue);
            selbox.options[iterate] = new Option(optionname, optionvalue);

            iterate++;

        });


        //     cellRight.appendChild(labl);
        cellRight.appendChild(selbox);
        $(removeId).style.visibility = 'visible';
        $(hiddenValue).value = parseInt($(hiddenValue).value,10) + 1;

    }

}
*/


/*function removeRowFromQualification(tablename,hiddenValue,removeId)
{
    // alert(tablename);
    // alert($(hiddenValue).value);
    // alert(selectboxid);

    var tbl = $(tablename);

    var lastRow = tbl.rows.length;
    //alert(lastRow);
    if (lastRow > 1)
    {
        tbl.deleteRow(lastRow - 1);
        $(hiddenValue).value	=	parseInt($(hiddenValue).value,10) - 1;

        if((lastRow-1) == 1)
        {
            $(removeId).style.visibility= 'hidden';
        }

    }
}*/

/*function loadDistrictforHs(url)
{
    //alert($('cboStateforHs').value);
    if ($('cboStateforHs').value != '')
    {
        $('imgDistrictforHs').style.visibility = 'visible';

        var	params = 'action=LOADDISTRICTFORHS&STATE_ID_FOR_HS='+ escape($('cboStateforHs').value);

        new Ajax.Request(url,{
            method:"get",
            parameters:params,
            onSuccess:updateDistrictforHs,
            onFailure:dispError
        })

    }
    else
    {
        return;
    }
}*/

/*function updateDistrictforHs(reqObj)
{

    // alert(reqObj.responseText);
    $('cboDistrictforHs').update(reqObj.responseText);

    //Load same districts in Location district field also

    $('imgDistrictforHs').style.visibility = 'hidden';


}
*/



/*function enableLbtypeForHospitalSelect(lbtype,url)
{
    $('hiddenLbTypeforHospital').value=lbtype;
    loadLocalBodyForHospitalSelect(url);
}
*/
/*function loadLocalBodyForHospitalSelect(url)
{

    if ($('cboDistrictforHs').value != '')
    {
        $('imgLocalBodyForHs').style.visibility = 'visible';

        var	params = 'action=LOAD_LOCAL_BODY_FOR_HS&DISTRICT_ID_FOR_HS='+ escape($('cboDistrictforHs').value)+'&LB_TYPE='+escape($('hiddenLbTypeforHospital').value);
        //    alert(params);
        new Ajax.Request(url,{
            method:"get",
            parameters:params,
            onSuccess:setLocalBodyNamesforHospital,
            onFailure:dispError
        })
    }else{
        return;
    }
}
*/
/*function setLocalBodyNamesforHospital(reqObj)
{
    //alert(reqObj.responseText);
    if(reqObj.responseText=='')
        return false;
    else
    {
        $('cboLocalBodyForHospital').update(trim(reqObj.responseText));

        $('imgLocalBodyForHs').style.visibility = 'hidden';
        return true;
    }
}
*/

/*function enableLbtypeForPracticeLocation(lbtype,url)
{
    $('hiddenLbTypeForPl').value=lbtype;

    loadLocalBodyForPl(url);


}*/




/*function loadDistrictforAddress(url)
{
    //Here we are filling the district field in practice location also
    if ($('cboState').value != '')
    {
        $('imgDistrict').style.visibility = 'visible';

        var	params = 'action=LOADDISTRICT&STATE_ID='+ escape($('cboState').value);

        new Ajax.Request(url,{
            method:"get",
            parameters:params,
            onSuccess:updateDistrictforAddress,
            onFailure:dispError
        })

    }
    else
    {
        return;
    }
}*/

/*function updateDistrictforAddress(reqObj)
{


    $('cboDistrict').update(trim(reqObj.responseText));


    $('imgDistrict').style.visibility = 'hidden';


}*/



/*function loadLocalBodyForAddress(url)
{
    // alert($('hiddenLbType').value);

    if ($('cboDistrict').value != '')
    {
        $('imgLocalBodyforAddress').style.visibility = 'visible';

        var	params = 'action=LOAD_LOCAL_BODY&DISTRICT_ID='+ escape($('cboDistrict').value)+'&LB_TYPE='+escape($('hiddenLbTypeForAddress').value);
        new Ajax.Request(url,{
            method:"get",
            parameters:params,
            onSuccess:setLocalBodyNamesForAddress,
            onFailure:dispError
        })
    }else{
        return;
    }
}*/

/*function setLocalBodyNamesForAddress(reqObj)
{
    //alert(reqObj.responseText);
    if(reqObj.responseText=='')
        return false;
    else
    {
        $('cboLocalBodyForAddress').update(trim(reqObj.responseText));

        $('imgLocalBodyforAddress').style.visibility = 'hidden';
        return true;
    }
}
function enableLbtypeForAddress(lbtype,url)
{
    $('hiddenLbTypeForAddress').value=lbtype;

    loadLocalBodyForAddress(url);

}
*/
// This function added by Jinesh Mani on 31-12-2009



/*function __fncAddRowToSpecialQualification(tablename,hiddenValue,selectboxid,secondBoxid,removeId,errorId)
{

    var tbl = document.getElementById(tablename);
    var lastRow = tbl.rows.length;
    // if there's no header row in the table, then iteration = lastRow + 1

    var iteration = lastRow;


    // alert(iteration);
    //alert($(hiddenValue).value);

    var numberofoptions=$(selectboxid+'0').length;

    var previousindex = iteration-1;

    if((lastRow < numberofoptions-1) && ($(selectboxid+previousindex).value!='') )
    {
        var row = tbl.insertRow(lastRow);


        /*   var cellRight = row.insertCell(0);
  //     var labl =  document.createElement('nbsp');
    var labl =  document.createTextNode('\u00A0');* /




        cellRight = row.insertCell(0);
        var selbox = document.createElement('select');
        selbox.name 		= selectboxid + iteration;
        selbox.id 		=  selectboxid + iteration;
        selbox.style.width = '20%';

        /*selbox.onchange	=	function(){
            __fncCheckRepeatEntry(selectboxid,iteration,errorId);
        };* /

        var optionList = $(selectboxid+'0').getElementsByTagName('option');
        var nodes = $A(optionList);

        var iterate = 0;
        nodes.each(function(node)
        {
            // alert(node.value + ': ' + node.innerHTML );

            optionname  = node.innerHTML;
            // alert(optionname);
            optionvalue = node.value;
            //alert(optionvalue);
            selbox.options[iterate] = new Option(optionname, optionvalue);

            iterate++;

        });

        cellRight.appendChild(selbox);
       
        var selSpecialbox = document.createElement('select');
        selSpecialbox.name 		= secondBoxid + iteration;
        
        selSpecialbox.id 		=  selectboxid + iteration;
        //selSpecialbox.className = 'txtRegInputBox'
        selSpecialbox.style.width = '60%';
//        selSpecialbox.onchange	=	function(){
//            __fncCheckRepeatEntry(secondBoxid,iteration,errorId);
//        };
        
        var optionvalues = $(secondBoxid+'0').getElementsByTagName('option');
        var newnodes = $A(optionvalues);

        iterate = 0;

        newnodes.each(function(node)
        {
            // alert(node.value + ': ' + node.innerHTML );

            optionname  = node.innerHTML;
            // alert(optionname);
            optionvalue = node.value;
            //alert(optionvalue);
            selSpecialbox.options[iterate] = new Option(optionname, optionvalue);

            iterate++;

        });

        cellRight.appendChild(selSpecialbox);



        $(removeId).style.visibility = 'visible';
        $(hiddenValue).value = parseInt($(hiddenValue).value,10) + 1;

    }

}
*/



/**Modified on 31st JULY 2010*/



/*Add multiple speciality*/






function fncError()
{
    alert("Ajax Common Error");
}
