/***India Starts Here***/
var objoffer='';
var global_offer_ajax=0;
var global_member_offer=0;
var requestrenewloffer=0;
function superpackage(){fade('payopts','payopts1','dispdiv','600','200','','http://'+DOMAINARRAY['domainnameweb']+'/sitedata/inter-super-pop.html','','dispcontent','','','');}
function pluspackage()	{fade('payopts','payopts1','dispdiv','600','200','','http://'+DOMAINARRAY['domainnameweb']+'/sitedata/inter-plus-pop.html','','dispcontent','','','');}
function classicpackage(){fade('payopts','payopts1','dispdiv','600','200','','/sitedata/inter-classic-pop.html','','dispcontent','','','');}
function memschemepop(){fade('payopts','payopts1','dispdiv','625','700','','/sitedata/compare-memscheme-popup.html','','dispcontent','','','')}
function privpop(){fade('payopts','payopts1','dispdiv','525','700','','/sitedata/privilege-service-popup.html','','dispcontent','','','')}
var payopts="";var redirect="1";var bm_assit_val=0;
var submitbtcon='<div class="fright" align="center" style="padding:10px;"><input type="submit" class="button pntr" id="continuepayment" name="continue" value="Continue"></div>';
function mempac()
{
	var PayMemberpack = this.document.PayMemberpack;
	if ( !PayMemberpack.category[0].checked && !PayMemberpack.category[1].checked && !PayMemberpack.category[2].checked && !PayMemberpack.category[3].checked && !PayMemberpack.category[4].checked && !PayMemberpack.category[5].checked && !PayMemberpack.category[6].checked && !PayMemberpack.category[7].checked && !PayMemberpack.category[8].checked && !PayMemberpack.category[9].checked && !PayMemberpack.category[10].checked)
	{alert( "Please select the membership package" );PayMemberpack.category[3].focus( );return false;}
}

function pay_assit(amt,duration)
{  
	var PayMemberpack = this.document.PayMemberpack;
	var onemonthprivpack;
	if(PayMemberpack.category[10]){
	if(PayMemberpack.category[10].checked==true){onemonthprivpack="1";}else{onemonthprivpack="0";}
	}if(PayMemberpack.category[9].checked==true || onemonthprivpack=="1")
	{$('fasttrack').style.display="none";$('fasttrackamt').innerHTML="&nbsp";PayMemberpack.bmassist.checked=false;PayMemberpack.bmassist.disabled=true;	
	if(document.getElementById('renewaloffer')) {
	$('renewaloffer').style.display="none";	
	$('choosepackidnorm').style.display="block";
	$('choosepackidoffer').style.display="none";
	requestrenewloffer=0;
	}
	}
	else{PayMemberpack.bmassist.disabled=false;$('fasttrack').style.display="block";$('fasttrackamt').innerHTML="<font class='smalltxt'>"+amt+"&nbsp;"+duration+"</font>";
	if(document.getElementById('renewaloffer')) {
	$('renewaloffer').style.display="block";
	$('choosepackidnorm').style.display="none";
	$('choosepackidoffer').style.display="block";
	requestrenewloffer=1;
	}
	}
}

function check_assit()
{
	var PayMemberpack = this.document.PayMemberpack;
	if(PayMemberpack.bmassist.checked==true){bm_assit_val=PayMemberpack.bmassist.value;}else{bm_assit_val=0;}
	return bm_assit_val;
}

function paymentoptchk()
{
	var PayMemberpack = this.document.PayMemberpack;

	var objlen=document.PayMemberpack.elements.length;
	for(i=0;i<objlen;i++)
	{
		if(document.PayMemberpack.elements[i].name=="PAYMENTOPT")
		{
			if(document.PayMemberpack.elements[i].checked==true){paycount=0;break}else{paycount=1}
		}
	}

	return paycount;
}

function renewaloffervalue(){
	if(paycatvalue()=='48' || paycatvalue()=='56'){
		return '0';
	}

	var PayMemberpackOffer = this.document.PayMemberpack;
	var objlenoffer=document.PayMemberpack.elements.length;
	for(i=0;i<objlenoffer;i++)
	{
		if(document.PayMemberpack.elements[i].name=="member_offer")
		{
			if(document.PayMemberpack.elements[i].checked==true){return document.PayMemberpack.elements[i].value;}
		}
	}
	return '0';
}

function paycatvalue()
{	
	var PayMemberpack = this.document.PayMemberpack;
	var objlen=document.PayMemberpack.elements.length;

	for(i=0;i<objlen;i++)
	{
		if(document.PayMemberpack.elements[i].name=="category")
		{
			if(document.PayMemberpack.elements[i].checked==true){var paycatval=document.PayMemberpack.elements[i].value;break}
		}
	}
	return paycatval;
}

var logck=GetCookie('LOGININFO');var MatriID='';if (logck!="" && logck!=null){MatriID=logck.substring(0,logck.indexOf('^'));}

function ValidateIndia( )
{	
	mempac();
	var paycount=paymentoptchk();

	if(paycount==1){alert( "Please select the payment mode" );PayMemberpack.PAYMENTOPT[0].focus();return false;}
	
	if($('PAYMENTOPT1').checked==true)
	{

		if (MatriID.length > 0)
		{
			var sendto = "https://bharatmatrimony.com/"+DOMAINARRAY['domainnameshort']+"matrimony/payments/ccredirectpayment.php?MatrimonyId="+MatriID+"&category="+paycatvalue()+"&POWERPACK=0&bmassist="+check_assit()+"&renewaloffer="+renewaloffervalue();
			document.PayMemberpack.action=sendto;
		}
		else
		{
			var sendto = "http://"+DOMAINARRAY['domainmodule']+"/payments/paymentcc.php?bmassist="+check_assit();
			document.PayMemberpack.action=sendto;
		}
	}
	else if($('PAYMENTOPT10').checked==true)
	{
		if (MatriID.length > 0)
		{
		var sendto = "http://"+DOMAINARRAY['domainnameweb']+"/payments/paymentthroughivrs.php?category="+paycatvalue()+"&POWERPACK=0&bmassist="+check_assit()+"&renewaloffer="+renewaloffervalue();
		document.PayMemberpack.action=sendto;
		}
		else
		{
			var sendto = "http://"+DOMAINARRAY['domainmodule']+"/payments/paymentcc.php?bmassist="+check_assit();
			document.PayMemberpack.action=sendto;
		}
	}
	else if($('PAYMENTOPT2').checked==true)
	{
			if (MatriID.length > 0 )
			{
				var sendto = "http://"+DOMAINARRAY['domainnameweb']+"/payments/ccgatwayredirect.php?MatrimonyId="+MatriID+"&category="+paycatvalue()+"&Cardtype=1&POWERPACK=0&bmassist="+check_assit();
				document.PayMemberpack.action=sendto;
			}
			else
			{
				var sendto = "http://"+DOMAINARRAY['domainmodule']+"/payments/paymentcc.php?bmassist="+check_assit();
				document.PayMemberpack.action=sendto;
			}
	}
	else
	{
		var sendto = "http://"+DOMAINARRAY['domainmodule']+"/payments/paymentoptiondetail.php";
		document.PayMemberpack.action=sendto;
	}
	
	return true;
}

/*function makeRequest1(){var u="/cgi-bin/citicheck.cgi?"+genNumbers();payopts=MakeGetRequest(u,'payoptscript');}

function payoptscript()
{
	if (payopts.readyState == 4) 
	{
	 if (payopts.status == 200) {if(payopts.responseText!=null && payopts.responseText!=""){redirect = payopts.responseText;}} 
	 else {alert('There was a problem with the request.');}
  }
}*/

/***India Ends Here***/

function validate()
{
	if(global_member_offer==1){
		glb_payment_senc=false;
		submitoffer();
	}
	 if(country=="98"){return ValidateIndia();}
	 else if(country=="220"){return ValidateUae();}
	 else if(country=="21"){return ValidateEuro();}
	 else if(country=="221"){return ValidateUk();}
	 else{return ValidateUs();} 
}

function submitoffer() {
	objoffer=createajax();
	MakePostRequest_opac('http://'+DOMAINARRAY['domainnameweb']+'/payments/paymentoffers.php','productid='+paycatvalue()+'&ccode='+country+'&offercat='+renewaloffervalue()+'&matriid='+MatriID,'offerresult',objoffer);	
	
}
function offerresult(){
	if((objoffer.readyState==4)&&(objoffer.status==200)) {
		global_offer_ajax=1;
	}
}
/***USA Starts Here***/
function ValidateUs( )
{

	var PayMemberpack = this.document.PayMemberpack;

	mempac();
	var paycount=paymentoptchk();

	if(paycount==1){alert( "Please select the payment mode" );	PayMemberpack.PAYMENTOPT[0].focus();return false;}

	if($('PAYMENTOPT1').checked==true)
	{
		if (MatriID.length > 0)
		{
			var sendto = "https://bharatmatrimony.com/"+DOMAINARRAY['domainnameshort']+"matrimony/payments/usupgrade.php?MatrimonyId="+MatriID+"&category="+paycatvalue()+"&CN="+country+"&POWERPACK=0&bmassist="+check_assit()+"&renewaloffer="+renewaloffervalue();
			document.PayMemberpack.action=sendto;return true;
		}
		else
		{
			var sendto = "http://"+DOMAINARRAY['domainmodule']+"/payments/paymentcc.php?bmassist="+check_assit();
			document.PayMemberpack.action=sendto;
		}
		return true;
	}else if(document.getElementById('PAYMENTOPT3')){
		if($('PAYMENTOPT3').checked==true){

		if (MatriID.length > 0)
		{
			var sendto = "https://bharatmatrimony.com/payments/usupgradation.php?MatrimonyId="+MatriID+"&category="+paycatvalue()+"&CN="+country+"&POWERPACK=0&bmassist="+check_assit()+"&renewaloffer="+renewaloffervalue();
			document.PayMemberpack.action=sendto;return true;
		}
		else
		{
			var sendto = "http://"+DOMAINARRAY['domainmodule']+"/payments/paymentcc.php?bmassist="+check_assit();
			document.PayMemberpack.action=sendto;
		}
		return true;
	}else{
			var sendto = "http://"+DOMAINARRAY['domainmodule']+"/payments/paymentoptiondetail.php";
			document.PayMemberpack.action=sendto;
	}
	}
	else
	{
		var sendto = "http://"+DOMAINARRAY['domainmodule']+"/payments/paymentoptiondetail.php";
		document.PayMemberpack.action=sendto;
	}

}
/***USA Ends Here***/

/***UK Starts Here***/
function ValidateUk( )
{
	var PayMemberpack = this.document.PayMemberpack;

	mempac();
	var paycount=paymentoptchk();

	if(paycount==1){alert( "Please select the payment mode" );	PayMemberpack.PAYMENTOPT[0].focus();return false;}

	if($('PAYMENTOPT1').checked==true)
	{
		if (MatriID.length > 0)
		{
			var sendto = "https://bharatmatrimony.com/"+DOMAINARRAY['domainnameshort']+"matrimony/payments/usupgrade.php?MatrimonyId="+MatriID+"&category="+paycatvalue()+"&CN="+country+"&POWERPACK=0&bmassist="+check_assit()+"&renewaloffer="+renewaloffervalue();
			document.PayMemberpack.action=sendto;return true;
		}
		else
		{
			var sendto = "http://"+DOMAINARRAY['domainmodule']+"/payments/paymentcc.php?bmassist="+check_assit();
			document.PayMemberpack.action=sendto;
		}
		return true;
	}else if(document.getElementById('PAYMENTOPT3')){
		if($('PAYMENTOPT3').checked==true){
		if (MatriID.length > 0)
		{
			var sendto = "https://bharatmatrimony.com/payments/usupgradation.php?MatrimonyId="+MatriID+"&category="+paycatvalue()+"&CN="+country+"&POWERPACK=0&bmassist="+check_assit()+"&renewaloffer="+renewaloffervalue();
			document.PayMemberpack.action=sendto;return true;
		}
		else
		{
			var sendto = "http://"+DOMAINARRAY['domainmodule']+"/payments/paymentcc.php?bmassist="+check_assit();
			document.PayMemberpack.action=sendto;
		}
		return true;
	}else
	{
		var sendto = "http://"+DOMAINARRAY['domainmodule']+"/payments/paymentoptiondetail.php";
		document.PayMemberpack.action=sendto;
	}
	}
	else
	{
		var sendto = "http://"+DOMAINARRAY['domainmodule']+"/payments/paymentoptiondetail.php";
		document.PayMemberpack.action=sendto;
	}

}
/***UK Ends Here***/

/***UAE Starts Here***/
function ValidateUae( )
{
	var PayMemberpack = this.document.PayMemberpack;
	mempac();
	var paycount=paymentoptchk();

	if(paycount==1){alert( "Please select the payment mode" );	PayMemberpack.PAYMENTOPT[0].focus();return false;}

	if($('PAYMENTOPT1').checked==true)
	{

		if (MatriID.length > 0)
		{			
				var sendto = "https://bharatmatrimony.com/"+DOMAINARRAY['domainnameshort']+"matrimony/payments/usupgrade.php?MatrimonyId="+MatriID+"&category="+paycatvalue()+"&CN="+country+"&POWERPACK=0&bmassist="+check_assit()+"&renewaloffer="+renewaloffervalue();
				document.PayMemberpack.action=sendto;
				return true;
		}
		else
		{
			var sendto = "http://"+DOMAINARRAY['domainmodule']+"/payments/paymentcc.php?bmassist="+check_assit();
			document.PayMemberpack.action=sendto;
		}
		return true;
	}else if(document.getElementById('PAYMENTOPT8')) {
		
		if($('PAYMENTOPT8').checked==true){

		if (MatriID.length > 0)
		{			
				var sendto = "https://bharatmatrimony.com/payments/usupgradation.php?MatrimonyId="+MatriID+"&category="+paycatvalue()+"&CN="+country+"&POWERPACK=0&bmassist="+check_assit()+"&renewaloffer="+renewaloffervalue();
				document.PayMemberpack.action=sendto;
				return true;
		}
		else
		{
			var sendto = "http://"+DOMAINARRAY['domainmodule']+"/payments/paymentcc.php?bmassist="+check_assit();
			document.PayMemberpack.action=sendto;
		}
		return true;
	}else
	{var sendto = "http://"+DOMAINARRAY['domainmodule']+"/payments/paymentoptiondetail.php";document.PayMemberpack.action=sendto;}
	}
	else
	{var sendto = "http://"+DOMAINARRAY['domainmodule']+"/payments/paymentoptiondetail.php";document.PayMemberpack.action=sendto;}
}
/***UAE Ends Here***/

/***EURO Starts Here***/
function ValidateEuro( )
{
	var PayMemberpack = this.document.PayMemberpack;
	mempac();
	
	var paycount=paymentoptchk();

	if(paycount==1){alert( "Please select the payment mode" );	PayMemberpack.PAYMENTOPT[0].focus();return false;}

	if($('PAYMENTOPT1').checked==true)
	{
		if (MatriID.length > 0)
		{
			var sendto = "https://bharatmatrimony.com/"+DOMAINARRAY['domainnameshort']+"matrimony/payments/usupgrade.php?MatrimonyId="+MatriID+"&category="+paycatvalue()+"&CN="+country+"&POWERPACK=0&bmassist="+check_assit()+"&renewaloffer="+renewaloffervalue();
			document.PayMemberpack.action=sendto;return true;
		}
		else
		{
			var sendto = "http://"+DOMAINARRAY['domainmodule']+"/payments/paymentcc.php?bmassist="+check_assit();
			document.PayMemberpack.action=sendto;
		}
		return true;
	}else if(document.getElementById('PAYMENTOPT2')) {
		if($('PAYMENTOPT2').checked==true){
		if (MatriID.length > 0)
		{
			var sendto = "https://bharatmatrimony.com/payments/usupgradation.php?MatrimonyId="+MatriID+"&category="+paycatvalue()+"&CN="+country+"&POWERPACK=0&bmassist="+check_assit()+"&renewaloffer="+renewaloffervalue();
			document.PayMemberpack.action=sendto;return true;
		}
		else
		{
			var sendto = "http://"+DOMAINARRAY['domainmodule']+"/payments/paymentcc.php?bmassist="+check_assit();
			document.PayMemberpack.action=sendto;
		}
		return true;
	}
	}
}

function payoptsubbtn()
{
	var PayMemberpack = this.document.PayMemberpack;
	var objlen=document.PayMemberpack.elements.length;
	var divnamebtn;
	for(i=0;i<objlen;i++)
	{
		if(document.PayMemberpack.elements[i].name=="PAYMENTOPT")
		{
			divnamebtn=document.PayMemberpack.elements[i].id+'BTNDIV';
			if(document.PayMemberpack.elements[i].checked==true){				
				document.getElementById(divnamebtn).innerHTML=submitbtcon;
			    document.getElementById('continuepayment').focus();
				SetpaybuttonCookie("PAYBUTTONCOOKIE",document.PayMemberpack.elements[i].id);
			}else{				
				document.getElementById(divnamebtn).innerHTML='';
			}

		}
	}

}

function SetpaybuttonCookie(cookieName,cookieValue) {
 var today = new Date();
 var expire = new Date();
 expire.setTime(today.getTime() + 3600000*24);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}

function getpaybuttonCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    var cookgetpayval= unescape(document.cookie.substring(c_start,c_end));
	document.getElementById(cookgetpayval).checked=true;
	var divnamegetbtn=cookgetpayval+'BTNDIV';
	document.getElementById(divnamegetbtn).innerHTML=submitbtcon;
    }
  }
}

/***EURO Ends Here***/