var parameters="", objAjx=false;
function ajxAssuVeri(){
  if(objAjx.readyState==4){if(objAjx.status==200){
    $('assuredcontact').style.display="none";
    var phonetxt = objAjx.responseText, phonesplittxt = phonetxt.split("~");
    if(phonesplittxt[0]=='1')
      RefreshPage='Y';
    $('assuredcontactresult').innerHTML=phonesplittxt[1];
  }else alert('There was a problem with the request.');}
}


function ajxMdy(){
  if(objAjx.readyState==4){if(objAjx.status==200){
    var phonetxt = objAjx.responseText, phonesplittxt = phonetxt.split("~");
    if(phonesplittxt[0]=='1')
      RefreshPage='Y';
    $('assuredcontactmodify').style.display="none";$('assuredcontactconfirm').style.display="none";
    $('assuredcontactmodifyresult').innerHTML=phonesplittxt[1];}else alert('There was a problem with the request.');}
}
function phonecomplainttimeout(){
  $('assuredthanks').innerHTML="";$('assuredthanks').style.display="none";
}
function fnopenphonecomplaint(){
  document.frmphonecomplaint.complaint.value="";$('assuredcomplaint').style.display="";
  $('assuredthanks').style.display="none";$("complaint").focus();
}
//using functions - starts
function fnPhoneConfirmModify(){
    var frmName=document.frmassuredcontact, sCtyName = frmName.assuredcountry.value;
    var oldCountry = frmName.hidCountry.value, oldArea = frmName.hidArea.value, oldLandline = frmName.hidLandline.value;
    var oldMobile = frmName.hidMobile.value, country = frmName.assuredcountry.value, area = frmName.area.value;
    var phoneno = frmName.phoneno.value, mobileno = frmName.MOBILENO.value;
      parameters='assuredcountry='+country+'&area='+area+'&phoneno='+phoneno+'&MOBILENO='+mobileno+'&NAME='+frmName.NAME.value+'&RELTYPE='+frmName.reltype.value+'&time='+frmName.time.value+'&comm='+frmName.comm.value+'&hidPhoneno='+frmName.hidPhoneno.value+'&verified='+frmName.hidverified.value+'&ctyname='+sCtyName;
      var argUrl='http://'+frmName.getDomainInfo.value+'/assuredcontact/assuredcontactupdatephone.php';     
	  $.ajax({
	   type: "POST",
	   url: argUrl,
	   data: parameters,
	   success: function(msg){			  
		 $('#cboxLoadedContent').html(msg);
		$.colorbox.resize();
		var originalClose = $.colorbox.close;
		$.colorbox.close = function(){
			var response;
			if($('#cboxLoadedContent').find('div.assured_BfrVerifyPhone').length > 0){
				originalClose();
				window.location.href='http://'+frmName.getDomainInfo.value+'/profiledetail/myprofile.php';
			}
			originalClose();
		}; 
	   }
	 });
}
function funphonemodify(){		
  if(validate()){
    var frmName=document.frmassuredcontact, sCtyName = frmName.assuredcountry.value;
    var oldCountry = frmName.hidCountry.value, oldArea = frmName.hidArea.value, oldLandline = frmName.hidLandline.value;
    var oldMobile = frmName.hidMobile.value, country = frmName.assuredcountry.value, area = frmName.area.value;
    var phoneno = frmName.phoneno.value, mobileno = frmName.MOBILENO.value;	
    if((oldCountry==country) && (oldArea==area) && (oldLandline==phoneno) && (oldMobile==mobileno)){	      
	  parameters='assuredcountry='+country+'&area='+area+'&phoneno='+phoneno+'&MOBILENO='+mobileno+'&NAME='+frmName.NAME.value+'&RELTYPE='+frmName.reltype.value+'&time='+frmName.time.value+'&comm='+frmName.comm.value+'&hidPhoneno='+frmName.hidPhoneno.value+'&verified='+frmName.hidverified.value+'&ctyname='+sCtyName;
      var argUrl='http://'+frmName.getDomainInfo.value+'/assuredcontact/assuredcontactupdatephone.php';	     
	  $.ajax({
	   type: "POST",
	   url: argUrl,
	   data: parameters,
	   success: function(msg){			  
		$('#cboxLoadedContent').html(msg);	
		$.colorbox.resize();
	   }
	 });
    }else{				
		dgebid('assuredcontactmodify').style.display = 'none';
		dgebid('assuredcontactconfirm').style.display = 'block';
		$.colorbox.resize();
	}
  }
}
function funphoneverify(){		
  if(validate()){    
    var frmName=document.frmassuredcontact, sCtyName = frmName.assuredcountry.value;	parameters='assuredcountry='+frmName.assuredcountry.value+'&area='+frmName.area.value+'&phoneno='+frmName.phoneno.value+'&MOBILENO='+frmName.MOBILENO.value+'&NAME='+frmName.NAME.value+'&reltype='+frmName.reltype.value+'&time='+frmName.time.value+'&comm='+frmName.comm.value+'&hidPhoneno='+frmName.hidPhoneno.value;
    var argUrl='http://'+frmName.getDomainInfo.value+'/assuredcontact/phoneverify.php';		
	$.ajax({
	   type: "POST",
	   url: argUrl,
	   data: parameters,
	   success: function(msg){			  
		 $('#cboxLoadedContent').html(msg);
		var originalClose = $.colorbox.close;
		$.colorbox.close = function(){
			var response;
			if($('#cboxLoadedContent').find('div.assured_BfrVerifyPhone').length > 0){
				originalClose();
				window.location.href='http://'+frmName.getDomainInfo.value+'/profiledetail/myprofile.php';
			}
			originalClose();
		}; 

	   }
	 });
  }
}
function fnphonepaidview(){
  var frmName=document.frmphoneinsert;
  var parameters='matid='+frmName.matid.value+'&userphoneavailable='+frmName.userphoneavailable.value;
  var argUrl='http://'+frmName.getDomainInfo.value+'/assuredcontact/assuredinsertphonerequest.php';
  $.ajax({
   type: "POST",
   url: argUrl,
   data: parameters,
   success: function(msg){
	 $('#cboxLoadedContent').html(msg);
	 $.colorbox.resize();
   }
 });
}
function fnPhoneHideSendMail(matid,domainpath){  
  var argUrl='http://'+domainpath+'/inbox/inbcontact.php';
  var parameters='rand='+genNumbers()+'&EID='+matid+'&all=1';
  $.ajax({
   type: "GET",
   url: argUrl,
   data: parameters,
   success: function(msg){
	 $('#cboxLoadedContent').html(msg);
	 $.colorbox.resize();
   }
 });
}
function fnphonecomplaint(){
  var frmName=document.frmphonecomplaint;
  if(frmName.complaint.value==''){
	dgebid('assuredthanks').innerHTML="Please select the reason";
	$.colorbox.resize();
  }else{
  var argUrl='http://'+frmName.getDomainInfo.value+'/assuredcontact/assuredthanks.php'; 
  var parameters='matriid='+frmName.matriid.value+'&phone='+frmName.phone.value+'&memid='+frmName.memid.value+'&complaint_id='+frmName.complaint.value+'&complaint='+dgebid("complaint").options[dgebid("complaint").selectedIndex].text;  
  jqajaxRequest(argUrl,'POST',parameters,'assuredthanks');
  $.colorbox.resize();
  }
}

function fnassuredphonemodify(){  
  dgebid('assuredcontactmodify').style.display = 'block';
  dgebid('assuredcontacthome').style.display = 'none';
  $.colorbox.resize();
}
function fnhidemobile(){
  var icountry=dgebid('assuredcountry').value, area=dgebid('area').value, phoneno=dgebid('phoneno').value;
  if(icountry==91){if(area!=""||phoneno!=""){
      dgebid('MOBILENO').disabled=true;dgebid('MOBILENO').value="";dgebid('errmobileno').innerHTML="&nbsp;";
    }else{dgebid('MOBILENO').disabled=false;}
  }else{dgebid('MOBILENO').disabled=false;}
  if(phoneno!=""){dgebid('MOBILENO').disabled=true;dgebid('MOBILENO').value="";dgebid('errmobileno').innerHTML="&nbsp;";}
  else{dgebid('MOBILENO').disabled=false;}
}
function fnCountryValidate(){
  if(document.frmassuredcontact.assuredcountry.value=="0"){dgebid('errcountry').innerHTML="Please select a Country";return false;}else{dgebid('errcountry').innerHTML="&nbsp;";}
}
function fnAreaOptional(){	
	var sCtyName = dgebid("assuredcountry").options[dgebid("assuredcountry").selectedIndex].text;
  fnerrorhide();
  if(sCtyName == "India"){
	  dgebid('areaoptional').className="clr1 boldtxt";
  }else{
	  dgebid('areaoptional').className="clr4";
	  dgebid('errarea').innerHTML="&nbsp;";
 }
}
function validate(){
  fnerrorhide();
  var frmName=document.frmassuredcontact, sCtyName = dgebid("assuredcountry").options[dgebid("assuredcountry").selectedIndex].text;
  if(frmName.assuredcountry.value=="0"){dgebid('errcountry').innerHTML="Please select a Country";dgebid('errcountry').style.display='';frmName.assuredcountry.focus();return false;}else{dgebid('errcountry').innerHTML="&nbsp;";}if(IsEmpty(dgebid("area"),'text')&&IsEmpty(dgebid("phoneno"),'text')&&IsEmpty(dgebid("MOBILENO"),'text')){dgebid('errphoneno').innerHTML="Please enter Phone Number / Mobile number";dgebid('errphoneno').style.display='';dgebid("area").focus();return false;}else{dgebid('errphoneno').innerHTML="&nbsp;";}if(IsEmpty(dgebid("phoneno"),'text')&&IsEmpty(dgebid("MOBILENO"),'text')){dgebid('errphoneno').innerHTML="You have to enter either Phone / Mobile number";dgebid('errphoneno').style.display='';dgebid("phoneno").focus();return false;}else{dgebid('errphoneno').innerHTML="&nbsp;";}if(!IsEmpty(dgebid("phoneno"),'text')){if(CompareValue(dgebid("phoneno").value,"0123456789 ")==false){dgebid('errphoneno').innerHTML="Invalid Phone Number";dgebid('errphoneno').style.display='';dgebid("phoneno").focus();return false;}else{dgebid('errphoneno').innerHTML="&nbsp;";}}if(!IsEmpty(dgebid("phoneno"),'text')){if(IsEmpty(dgebid("area"),'text') && (sCtyName == "India")){dgebid('errarea').innerHTML="Please enter Area / STD Code";dgebid('errarea').style.display='';dgebid("area").focus();return false;}else{dgebid('errarea').innerHTML="&nbsp;";}if(CompareValue(dgebid("area").value,"0123456789 ")==false){dgebid('errarea').innerHTML="Invalid Area / STD Code";dgebid('errarea').style.display='';dgebid("area").focus();return false;}else{dgebid('errarea').innerHTML="&nbsp;";}if(!IsEmpty(dgebid("area"),'text')){if(dgebid("area").value.length<2){dgebid('errarea').innerHTML="Your Area / STD Code should be atleast 2 digits";dgebid('errarea').style.display='';dgebid("area").focus();return false;}else{dgebid('errarea').innerHTML="&nbsp;";}if(dgebid("area").value.length>5){dgebid('errarea').innerHTML="Your area/STD code should not exceed 5 digits";dgebid('errarea').style.display='';dgebid("area").focus();return false;}else{dgebid('errarea').innerHTML="&nbsp;";}}if(dgebid("phoneno").value.length<5){dgebid('errphoneno').innerHTML="Your Phone Number should be atleast 5 digits";dgebid('errphoneno').style.display='';dgebid("phoneno").focus();return false;}else{dgebid('errphoneno').innerHTML="&nbsp;";}}if(!IsEmpty(dgebid("MOBILENO"),'text')&&dgebid("assuredcountry").options[dgebid("assuredcountry").selectedIndex].value!="91"){if(!IsEmpty(dgebid("area"),'text')){if(CompareValue(dgebid("area").value,"0123456789 ")==false){dgebid('errarea').innerHTML="Invalid Area / STD Code";dgebid('errarea').style.display='';dgebid("area").focus();return false;}else{dgebid('errarea').innerHTML="&nbsp;";}if(dgebid("area").value.length<2){dgebid('errarea').innerHTML="Your Area / STD Code should be atleast 2 digits";dgebid('errarea').style.display='';dgebid("area").focus();return false;}else{dgebid('errarea').innerHTML="&nbsp;";}if(dgebid("area").value.length>5){dgebid('errarea').innerHTML="Your area/STD code should not exceed 5 digits";dgebid('errarea').style.display='';dgebid("area").focus();return false;}else{dgebid('errarea').innerHTML="&nbsp;";}}}if(!IsEmpty(dgebid("phoneno"),'text')&&!IsEmpty(dgebid("MOBILENO"),'text')){dgebid('errphoneno').innerHTML="Enter either Phone Number / Mobile number";dgebid('errphoneno').style.display='';dgebid("area").focus();return false;}else{dgebid('errphoneno').innerHTML="&nbsp;";}if(!IsEmpty(dgebid("MOBILENO"),'text')){if(CompareValue(dgebid("MOBILENO").value,"0123456789 ")==false){dgebid('errmobileno').innerHTML="Invalid Mobile Number";dgebid('errmobileno').style.display='';dgebid("MOBILENO").focus();return false;}else{dgebid('errmobileno').innerHTML="&nbsp;";}}if(!IsEmpty(dgebid("MOBILENO"),'text')){if(dgebid("assuredcountry").options[dgebid("assuredcountry").selectedIndex].value=="91"){if(dgebid("MOBILENO").value.length<9){dgebid('errmobileno').innerHTML="Your Mobile Number must be between 9 and 11 digits only";dgebid('errmobileno').style.display='';dgebid("MOBILENO").focus();return false;}else{dgebid('errmobileno').innerHTML="&nbsp;";}}else{if(dgebid("MOBILENO").value.length<7){dgebid('errmobileno').innerHTML="Your Mobile Number must be between 7 and 10 digits only";dgebid('errmobileno').style.display='';dgebid("MOBILENO").focus();return false;}else{dgebid('errmobileno').innerHTML="&nbsp;";}}}if(frmName.reltype.value==0){dgebid('errreltype').innerHTML="Please select Whom to Contact";dgebid('errreltype').style.display='';frmName.reltype.focus();return false;}else{dgebid('errreltype').innerHTML="&nbsp;";}if(IsEmpty(dgebid("NAME"),'text')){dgebid('errname').innerHTML="Enter name of the Contact Person";dgebid('errname').style.display='';dgebid("NAME").focus();return false;}else{dgebid('errname').innerHTML="&nbsp;";}if(IsEmpty(dgebid("time"),'text')){dgebid('errtime').innerHTML="Enter a Convenient time to call";dgebid('errtime').style.display='';dgebid("time").focus();return false;}else{dgebid('errtime').innerHTML="&nbsp;";}return true;
}
function fnerrorhide(){
  var arrErrorIds=new Array("errcountry","errphoneno","errarea","errmobileno","errname","errtime","errreltype");
  for(i=0;i<arrErrorIds.length;i++)$(arrErrorIds[i]).innerHTML="&nbsp;";
}
function fnAreaValidate(){
  var sCtyName = dgebid("assuredcountry").options[dgebid("assuredcountry").selectedIndex].text;
  if(IsEmpty(dgebid("area"),'text')&&IsEmpty(dgebid("phoneno"),'text')&&IsEmpty(dgebid("MOBILENO"),'text')){
    dgebid('errphoneno').innerHTML="Please enter Phone Number / Mobile number";return false;
  }else{dgebid('errphoneno').innerHTML="&nbsp;";}
  if(!IsEmpty(dgebid("area"),'text')){if(dgebid("area").value.length<2){dgebid("area").value="0"+dgebid("area").value;}}
  if(!IsEmpty(dgebid("phoneno"),'text')){if(IsEmpty(dgebid("area"),'text') && (sCtyName == "India")){
      dgebid('errarea').innerHTML="Please enter Area / STD Code";dgebid('errarea').style.display='';return false;
    }else{dgebid('errarea').innerHTML="&nbsp;";}
    if(dgebid("area").value.length>5){
      dgebid('errarea').innerHTML="Your area/STD code should not exceed 5 digits";dgebid('errarea').style.display='';return false;
    }else{dgebid('errarea').innerHTML="&nbsp;";}
  }
}
function fnPhoneValidate(){
  var sCtyName = dgebid("assuredcountry").options[dgebid("assuredcountry").selectedIndex].text;
  if(IsEmpty(dgebid("area"),'text')&&IsEmpty(dgebid("phoneno"),'text')&&IsEmpty(dgebid("MOBILENO"),'text')){
    dgebid('errphoneno').innerHTML="Please enter Phone Number / Mobile number";dgebid('errarea').innerHTML="&nbsp;";return false;
  }else{dgebid('errphoneno').innerHTML="&nbsp;";}
  if(!IsEmpty(dgebid("phoneno"),'text')){if(IsEmpty(dgebid("area"),'text') && (sCtyName == "India")){dgebid('errarea').innerHTML="Please enter Area / STD Code";dgebid('errarea').style.display='';return false;}else{dgebid('errarea').innerHTML="&nbsp;";}if(dgebid("area").value.length>5){dgebid('errarea').innerHTML="Your area/STD code should not exceed 5 digits";dgebid('errarea').style.display='';return false;}else{dgebid('errarea').innerHTML="&nbsp;";}}if(dgebid("area").value!=""&&dgebid("phoneno").value!=""){dgebid('errphoneno').innerHTML="&nbsp;";}
}
function fnMobileValidate(){
  if(IsEmpty(dgebid("phoneno"),'text')&&IsEmpty(dgebid("MOBILENO"),'text')){dgebid('errphoneno').innerHTML="You have to enter either Phone / Mobile number";dgebid('errmobileno').innerHTML="&nbsp;";dgebid('errarea').innerHTML="&nbsp;";return false;}else{dgebid('errphoneno').innerHTML="&nbsp;";}if(!IsEmpty(dgebid("MOBILENO"),'text')){if(CompareValue(dgebid("MOBILENO").value,"0123456789 ")==false){dgebid('errmobileno').innerHTML="Invalid Mobile Number";dgebid('errarea').innerHTML="&nbsp;";return false;}else{dgebid('errmobileno').innerHTML="&nbsp;";}if(dgebid("assuredcountry").options[dgebid("assuredcountry").selectedIndex].value=="91"){if(dgebid("MOBILENO").value.length<9){dgebid('errmobileno').innerHTML="Your Mobile Number must be between 9 and 11 digits only";dgebid('errarea').innerHTML="&nbsp;";return false;}else{dgebid('errmobileno').innerHTML="&nbsp;";}}else{if(dgebid("MOBILENO").value.length<7){dgebid('errmobileno').innerHTML="Your Mobile Number must be between 7 and 10 digits only";dgebid('errarea').innerHTML="&nbsp;";return false;}else{dgebid('errmobileno').innerHTML="&nbsp;";}}}
}
function fnWhomToContactValidate(){
  if(document.frmassuredcontact.reltype.value==0){dgebid('errreltype').innerHTML="Please select Whom to Contact";return false;}
  else{dgebid('errreltype').innerHTML="&nbsp;";}
}
function fnConatctPersonValidate(){
  if(IsEmpty(dgebid("NAME"),'text')){dgebid('errname').innerHTML="Enter name of the Contact Person";dgebid('errname').style.display='';return false;}
  else{dgebid('errname').innerHTML="&nbsp;";}
}
function fnContactTimeValidate(){
  if(IsEmpty(dgebid("time"),'text')){dgebid('errtime').innerHTML="Enter a Convenient time to call";dgebid('errtime').style.display='';return false;}
  else{dgebid('errtime').innerHTML="&nbsp;";}
}

function funphonehidden(){	
  var frmName = document.frmassuredcontacthide, argUrl = 'http://'+frmName.getDomainInfo.value+'/assuredcontact/phonehide.php';
  parameters='';
  $.ajax({
   type: "POST",
   url: argUrl,
   data: parameters,
   success: function(msg){
	 $('#cboxLoadedContent').html(msg);
	 $.colorbox.resize();
   }
 });

}

//using functions - ends
function ajxPaidView(){
  if(objAjx.readyState==4){if(objAjx.status==200){
    $('assuredphonepaidview').style.display="none";$('assuredphonepaidviewresults').innerHTML=objAjx.responseText;
  }else alert('There was a problem with the request.');}
}




function fnassuredphoneviewer(){
  $('assuredcontactphoneview').style.display='';$('assuredcontacthome').style.display='none';
}

function phoneview(argMatriId,argDomain){
  argUrl='http://'+argDomain+'/assuredcontact/phoneviewer.php';parameters='matid='+argMatriId;loadAssuredprofiles(1);
  objAjx=createajax_opac();MakePostRequest_opac(argUrl,parameters,"ajxPhView",objAjx);
}
function ajxPhView(){
  if(objAjx.readyState==4){if(objAjx.status==200){$('assuredphoneview').innerHTML=objAjx.responseText;}
    else alert('There was a problem with the request.');}
}

function ajxPhHide(){
  if(objAjx.readyState==4){if(objAjx.status==200){
      dv("mailcontent").innerHTML=objAjx.responseText;
      dv("hidepaid").innerHTML="";
      dv("phviewoutdiv").style.padding='0px 3px 0px 0px';
    } else{alert('There was a problem with the request.');}
  }
}

 
function go_entsub_phone(e,pos)
{  
 var agt, isIe, isGecko, key;var keychar;var splcheck;
 
 agt = navigator.userAgent.toLowerCase();
 
 isIE    = ((agt.indexOf("msie")  != -1) && (agt.indexOf("opera") == -1));
 isGecko = ((agt.indexOf('gecko') != -1) && (agt.indexOf("khtml") == -1));
 ischrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
 
 if (isIE)
 {
  key = window.event.keyCode;
  if (key == 13){gotophonepg(pos);event.keyCode = 0;}
 }
 
 if(isGecko)
 {
  key = e.which;
  if (key == 13){gotophonepg(pos);(e.which) ? e.which : 0;return false;}
 }
 
 if(ischrome)
 {
  key = e.which;
  if (key == 13){gotophonepg(pos);(e.which) ? e.which : 0;return false;}
 }
 
 keychar = String.fromCharCode(key)
 splcheck = /\'|\"/
 return !splcheck.test(keychar);
}
 
function goto_ltrim(str, chars) {
 chars = chars || "\\s";
 return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function gotophonepg(pos)
{

	if (pos == 1)
	{
		var fname='gototxttop';
	} else {
		var fname='gototxtbot';
	}
 var upg_val=goto_ltrim(dgebid(fname).value, "0");
 
 if(IsEmpty(dgebid(fname), "text"))
 {alert("Enter page number");dgebid(fname).focus();}
 else if(upg_val=="")
 {alert("Enter page number");dgebid(fname).focus();}
 else if(!CompareValue(dgebid(fname).value,"1234567890"))
 {alert("Invalid page number");dgebid(fname).focus();}
 else
 {
 var usr_pgval=parseInt(goto_ltrim(dgebid(fname).value, "0"));
  var tot_mod=parseInt(JSG_alldivs%10);
 
 if(tot_mod!=0){tot_pg=parseInt(JSG_alldivs)+1;}
 
  if(usr_pgval > JSG_alldivs){alert ("Page number exceeding number of results");dgebid(fname).focus();}
 else
 {	 
	var startval = (upg_val-1)*10;
	var senderparams = 'start='+startval+partialpharam;
	jqajaxRequest(phoneurl, 'GET', senderparams, 'container');
 }
 }
}
