/*function loadinitorder(x,y)
{
	document.getElementById("trans").src = "https://www.rvercomplete.com/underfolder/orderyoursupply.php?aff=" + x + "&sesid=" + y  ;	

}
*/


function transdonnee()
{
	document.getElementById('f_n2').value = document.getElementById('f_n').value ;
	document.getElementById('l_n2').value = document.getElementById('l_n').value ;
	document.getElementById('adr2').value = document.getElementById('adr').value ;
	document.getElementById('cyt2').value = document.getElementById('cyt').value ;
	document.getElementById('z_p2').value = document.getElementById('z_p').value ;
}
function loadinfos(choice)
{
var xhr=null;
if (window.XMLHttpRequest)
	  
	  { 
		  xhr = new XMLHttpRequest();
	  }
	  else if (window.ActiveXObject) 
	  {
		  xhr = new ActiveXObject("Microsoft.XMLHTTP");
	  }

	 //http://rvercomplete.com/Rver-index/
	 
	 var adress = "menuitem/" + choice ;
			  
	  xhr.open("POST", adress ,true);
  //alert(choice);
	  xhr.onreadystatechange = function() 
	  {   
		if(xhr.readyState == 4) 
		{   
			var txt = xhr.responseText ; 
			document.getElementById('innerContent').innerHTML = txt ;
			
		}
	  }
		
	   xhr.send(null);
		//var t=setTimeout(window.close(),10000);

}
function loadinfos2(choice)
{
var xhr=null;
if (window.XMLHttpRequest)
	  
	  { 
		  xhr = new XMLHttpRequest();
	  }
	  else if (window.ActiveXObject) 
	  {
		  xhr = new ActiveXObject("Microsoft.XMLHTTP");
	  }

	 //http://rvercomplete.com/Rver-index/
	 
	 var adress = choice ;
	 
	  var f_n = document.getElementById('first_name').value ;
	  var l_n = document.getElementById('last_name').value ;
	  var adr = document.getElementById('address').value ;
	  var cyt = document.getElementById('city').value ;
	  var sta = document.getElementById('state').value ;
	  var z_p = document.getElementById('zip').value ;
	  var aer = document.getElementById('aera').value ;
	  var ind = document.getElementById('indic').value ;
	  var num = document.getElementById('numero').value ;
	  var ema = document.getElementById('email').value ;
	  
	  var str = "?fn=" + f_n + "&ln=" + l_n + "&ad=" + adr + "&cy=" + cyt + "&st=" + sta  + "&zp=" + z_p  + "&ae=" +  aer + "&in=" + ind + "&nm=" + num + "&em=" + ema ;
	  
	  xhr.open("POST", adress + str,true);
  //alert(choice);
	  xhr.onreadystatechange = function() 
	  {   
		if(xhr.readyState == 4) 
		{   
			var txt = xhr.responseText ; 
			document.getElementById('innerContent').innerHTML = txt ;
			
		}
	  }
		
	   xhr.send(null);
		//var t=setTimeout(window.close(),10000);

}

function loadtopinfo(choice)
{
var xhr=null;
if (window.XMLHttpRequest)
	  
	  { 
		  xhr = new XMLHttpRequest();
	  }
	  else if (window.ActiveXObject) 
	  {
		  xhr = new ActiveXObject("Microsoft.XMLHTTP");
	  }

	 //http://rvercomplete.com/Rver-index/

	 var adress = "menuitem/" +  choice ;
			  
	  xhr.open("POST", adress ,true);
  
	  xhr.onreadystatechange = function() 
	  {   
		if(xhr.readyState == 4) 
		{   
			var txt = xhr.responseText ; 
			document.getElementById('innerTitle').innerHTML = txt ;
			
		}
	  }
		
	   xhr.send(null);
		//var t=setTimeout(window.close(),10000);

}
//##########################################################################################

function validateZIP(field)

{
/*var testc = document.getElementById("country").value ;
if (testc == "US")
	{
	var valid = "0123456789-";
	var hyphencount = 0;
	
	if (field.length!=5 && field.length!=10) {
	alert("Zip Code! Please enter 5 digit or 5 digit+4.");
	return false;
	}
	for (var i=0; i < field.length; i++) {
	temp = "" + field.substring(i, i+1);
	if (temp == "-") hyphencount++;
	if (valid.indexOf(temp) == "-1") {
	alert("Invalid characters in your zip code.  Please try again.");
	return false;
	}
	if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {
	alert("Zip Code: 5 digits  or five digits + 4, like '12345-6789'.");
	return false;
	   }
	
	}
	else
	}*/
	
	return true;
	
	//}
	
}

//##########################################################################################


function CheckNombre(n) 
 {
	// retourne vrai si c'est un nombre et false sinon
	//efface la boîte si non numerique 
	  var no = n ;
	  if (no == 1) 
	  {
		  document.getElementById("aera").value
		  var nb = document.getElementById("aera").value ;
		  var lg = nb.length ;
		  
		   if((isNaN(nb)) == true)
		   {
			 if(lg > 0)
			 {
				 document.getElementById("aera").value =  nb.substring(0,lg-1);
			 }
			 else
			 {
			 	document.getElementById("aera").value = "" ;
			 }
		   }
		   
	  }
	    
	  if (no == 2) 
	  {
		 
		  var nb = document.getElementById("indic").value ;
		  var lg = nb.length ;
		  
		   if((isNaN(nb)) == true)
		   {
			 if(lg > 0)
			 {
				 document.getElementById("indic").value =  nb.substring(0,lg-1);
			 }
			 else
			 {
			 	document.getElementById("aera").value = "" ;
			 }
		   }
		  
		  
		  
		  
		  
		 
	  }
	  
	  
	  if (no == 3) 
	  {
		 var nb = document.getElementById("numero").value ;
		  var lg = nb.length ;
		  
		   if((isNaN(nb)) == true)
		   {
			 if(lg > 0)
			 {
				 document.getElementById("numero").value =  nb.substring(0,lg-1);
			 }
			 else
			 {
			 	document.getElementById("numero").value = "" ;
			 }
		   } 
	  }
	  
	  
	 
}

//##########################################################################################

function validate()
{
	
	var verif = "0" ;
	//var tr = document.getElementById("acpt").checked ;
	
	
	document.getElementById("fn").innerHTML ="First Name:" ;
	document.getElementById("phon").innerHTML ="Phone Number:" ;
	document.getElementById("em").innerHTML ="Email Addresse:" ;
	document.getElementById("ad").innerHTML ="Address:" ;
	document.getElementById("cy").innerHTML ="City:" ;	 
	document.getElementById("zp").innerHTML ="Zip/Postal:" ;
	
	
	if ((document.getElementById("first_name").value=="") )
	{
			
			document.getElementById("fn").innerHTML ="* First Name:" ;
			verif = "1" ;	
				
				//return false	;	
	}	
	
	
	if ((document.getElementById("last_name").value=="") )
	{
			
			document.getElementById("fn").innerHTML ="* First Name:" ;
			verif = "1" ;	
				
				//return false	;	
	}	
	
	
	
	if (document.getElementById("address").value=="")
	{
			document.getElementById("ad").innerHTML ="* Address:" ;
			verif = "1" ;			
	}
	
	
	
	if (document.getElementById("city").value=="")
	{
			document.getElementById("cy").innerHTML ="* City:" ;
			verif = "1" ;	
	}
	
	
	if (document.getElementById("zip").value=="")	
	{
			document.getElementById("zp").innerHTML ="* Zip/Postal:" ;
			verif = "1" ;	
		
	
	}
	if (document.getElementById("aera").value=="")	
	{
			document.getElementById("phon").innerHTML ="* Phone:" ;
			verif = "1" ;	
	}
	if (document.getElementById("indic").value=="")	
	{
			document.getElementById("phon").innerHTML ="* Phone:" ;
			verif = "1" ;	
	}
	if (document.getElementById("numero").value=="")
	{
			document.getElementById("phon").innerHTML ="* Phone:" ;
			verif = "1" ;	
		
	}	
if (document.getElementById("email").value=="")
	{
			document.getElementById("em").innerHTML ="* Email:" ;
			verif = "1" ;		
	}
	
	if (verif == 1)
		{
			alert ("Please fill all the fields marked with * ")	;
			return false	;	
		}
	
	var mail = document.getElementById("email").value;
	
	if ((mail.indexOf("@")>=0)&&(mail.indexOf(".")>=0)) 
	{
	 
  	} 
	else 
	{
	 alert("Email invalid! Please enter a valid email address. We will email you an Order Confirmation number");
	 return false;
  	}
	

	
	if (!document.getElementById("accepte").checked )
	{
		 alert("To continue, please check the box  to agree with the Terms & Conditions and the Privacy Policy. ") ;
		 return false	;
	}
	
	//loadinfos2('payment_creditcard.php');
	
	
	/*if(tr == false)
		{
				alert ("Privacy Policy: To continue, you must check Privacy Policy box")	;	
				return false	;	
		}	*/

	recTransact();
}
//#####################################################################################
function validate1()
{
	
	var verif = "0" ;
	
	
	document.getElementById("cn").innerHTML ="Card Number:" ;
	document.getElementById("exm").innerHTML ="Expiration: Month" ;	 
	document.getElementById("cv").innerHTML ="CVV" ;
	//alert "cooco" ;	
	
	if (document.getElementById("CardNumber").value=="")
	{
			
			document.getElementById("cn").innerHTML ="* Card Number:" ;
			verif = "1" ;	
				
				//return false	;	
	}	
	

	if (document.getElementById("ExpYear").value=="")
	{
			document.getElementById("exm").innerHTML ="*Expiration: Month" ;
			verif = "1" ;	
			
	}
	
	
	
	
	if (document.getElementById("cvv").value=="")
	{
			document.getElementById("cv").innerHTML ="*CVV" ;
			verif = "1" ;		
	}
	
	
	

	if (verif == 1)
		{
			alert ("Please fill all the fields marked with * ")	;
			return false	;	
		}
	
	
	if((!document.form1.elements["acpt"].checked))
		{
				alert ("You must Agread to the Terms & Condition and the Privacy Policy  to continue")	;	
				return false	;	
			
		}	
		
		
	
}


function callculatesh1()
{
	//document.form1.elements["hosted_button_id"].value = "10062472";
	//var cond = document.getElementById("av").checked ;
	/*var client = document.getElementById("clId").value ;
	var contr = document.getElementById("country").value;	
	if(contr == ""){ contr = "US" ; }*/
	var pr = "69.95" ;

	var shipp = "0.00" ;
	var tota = "0.00" ;
	//if (contr == "US")
	//{
		shipp = 4.95 ;
	/*}
	else
	{
		shipp = 6.95 ;
	}*/

	document.getElementById("prod").value = "1 x R'Ver Complete";
	pr = parseFloat(pr) ;
	//ups = parseFloat(ups) ;
	shipp =parseFloat(shipp) ;
	//alert(pr + ups + shipp);
	tota = pr + shipp ;
	tota = parseFloat(tota);

	document.getElementById("tot").value= "$"  +  tota.toFixed(2);
	document.getElementById("sh").value= "$"  +  shipp ;

}

function callculatesh2()
{
	//document.form1.elements["hosted_button_id"].value = "10062472";
	//var cond = document.getElementById("av").checked ;
	//var client = document.getElementById("clId").value ;
	//var contr = document.getElementById("country").value;	
	//if(contr == ""){ contr = "US" ; }
	var pr = "111.92" ;
	
	var shipp = "0.00" ;
	var tota = "0.00" ;
	/*if (contr == "US")
	{*/
		shipp = 4.95 ;
	/*}
	else
	{
		shipp = 7.95 ;
	}*/
	
	pr = parseFloat(pr) ;

	shipp =parseFloat(shipp) ;
	
	tota = pr +  shipp ;
	tota = parseFloat(tota);
	document.getElementById("prod").value = "2 x R'Ver Complete";
	document.getElementById("tot").value= "$"  +  tota.toFixed(2);
	document.getElementById("sh").value= "$"  +  shipp ;
	
}
function callculatesh3()
{
	//document.form1.elements["hosted_button_id"].value = "10062472";
	//var cond = document.getElementById("av").checked ;
	//var client = document.getElementById("clId").value ;
	//var contr = document.getElementById("country").value;	
	//if(contr == ""){ contr = "US" ; }
	var pr = "209.85" ;

	var shipp = "0.00" ;
	var tota = "0.00" ;
	/*if (contr == "US")
	{*/
		shipp = 4.95 ;
	/*}
	else
	{
		shipp = 8.95 ;
	}*/
		
	pr = parseFloat(pr) ;
	
	shipp =parseFloat(shipp) ;
	
	tota = pr +  shipp ;
	tota = parseFloat(tota);
	document.getElementById("prod").value = "3 x + 1 Free   R'Ver Complete";
	document.getElementById("tot").value= "$"  +  tota.toFixed(2);
	document.getElementById("sh").value= "$"  +  shipp ;
	
}
//Calcul des prix si avgt est choisi ou pas
function callculforcountry()
{
	//document.form1.elements["hosted_button_id"].value = "10062472";
	//var client = document.getElementById("clId").value ;
	var contr = document.getElementById("country").value;		
	var tik = "0" ;
	//var cond = document.getElementById("av").checked ;
	if(document.getElementById("rad1").checked == true )
	{
		
		tik = 1 ;
	}
	if(document.getElementById("rad2").checked )
	{
		tik = 2 ;
	}
	if(document.getElementById("rad3").checked)
	{
		tik = 3 ;
	}

	if(tik == 1)
	  {	
		 if (contr == "US")
		  {
			  document.form1.elements["sh"].value= "$5.95" ;
			  document.form1.elements["tot"].value= "$79.90" ;
			  document.form1.elements["shipping"].value ="5.95";
		  }
		  else
		  {
			  document.form1.elements["sh"].value= "$6.95" ;
			  document.form1.elements["tot"].value= "$80.90" ;
			  document.form1.elements["shipping"].value ="6.95";
		  }
		  
		  document.form1.elements["prod"].value = "1 x R'Ver Complete";
				  //setSession("1AVGT") ;
		}
	  
	  
	  if(tik == 2)
	  
	  {	
	  if (contr == "US")
		  {
			  document.form1.elements["sh"].value= "$6.95" ;
			  document.form1.elements["tot"].value= "$118.87" ;
			  document.form1.elements["shipping"].value ="6.95";
		  }
		  else
		  {
			  document.form1.elements["sh"].value= "$7.95" ;
			  document.form1.elements["tot"].value= "$119.87" ;
			  document.form1.elements["shipping"].value ="7.95";
		  }
		  
		  document.form1.elements["prod"].value = "2 x R'Ver Complete";
				  //setSession("2AVGT") ;
			
	  }
	  
	  if(tik == 3)
	  {	
	  
	  if (contr == "US")
		  {
			  document.form1.elements["sh"].value= "$7.95" ;
			  document.form1.elements["tot"].value= "$217.80" ;
			  document.form1.elements["shipping"].value ="7.95";
		  }
		  else
		  {
			 document.form1.elements["sh"].value= "$8.95" ;
			 document.form1.elements["tot"].value= "$218.80" ;
			 document.form1.elements["shipping"].value ="8.95";
		  }
		document.form1.elements["prod"].value = "4 x R'Ver Complete";
		//setSession("4AVGT") ;
	  }
	  
}

function change_state_list()
{
    var index = -1;
	var myselect = document.getElementById("state");
	var copyselect;
	//alert(myselect);
	while(myselect.length>0)
	{
		myselect.remove(0);
	}
	var country = document.getElementById("country").options[document.getElementById("country").selectedIndex].value;
	
	if(country == 'US')
	{
		copyselect = document.getElementById("us");
	} else if(country == 'CA')
	{
		copyselect = document.getElementById("ca");
	} 
	index = 0;
	while(copyselect[index])
	{
		try {
			myselect.add(new Option(copyselect[index].innerHTML,copyselect[index].value), null);
			} 
			catch (ex) 
			{
				myselect.add(new Option(copyselect[index].innerHTML,copyselect[index].value));
			}
			index++;
	}
	var statecode = '';
	for (var count=0;count<document.forms[0].state.options.length;count++)
	{
		if (document.forms[0].state.options[count].value==statecode && statecode!="")
		{
			document.forms[0].state.options[count].selected = true;
		}
	}
	
callculforcountry();
}

function openpopup()
	{
	  var popurl= "http://rvercomplete.com/term.html"
	  winpopsA=window.open(popurl,"win1","width=520,height=500,scrollbars")
	  winpopsA.focus()
	}
function openpopup2()
	{
	  var popur2= "http://rvercomplete.com/privacy.html"
	  winpopsB2=window.open(popur2,"win2","width=520,height=500,scrollbars")
	  winpopsB2.focus()
	}
function openpopup3()
	{
	  var popur3= "http://rvercomplete.com/contactus.html"
	  winpopsB3=window.open(popur3,"win3","width=520,height=500")
	  winpopsB3.focus()
	}
function openpopupred(x)
	{
	  var popur3= x;
	  winpopsB3=window.open(popur3,"win4","width=540,height=500 ,scrollbars")
	  winpopsB3.focus()
	}	

function validaterms()
{
	//var tst = document.getElementById("tt").value ;
	var ac = document.getElementById("accepte").checked ;
	/*var av = document.getElementById("av").checked ;
	if(tst == "$0.00" )
	{
	     if(av == true & tst == "$0.00")
	  {
		   alert("AVGT is only available in conjunction with R'Ver Complete on your first order. Please select one option for R'Ver Complete at the top of the page.") ;
		   return false	;
	  }
	 else
	  {
		  alert("Please select one option for R'Ver Complete at the top of the page") ;
		  return false	;
	  }
}*/
alert(ac) ;
	if (!document.getElementById("accepte").checked )
	{
		 alert("To continue, please check the box  to agree with the Terms & Conditions and the Privacy Policy. ") ;
		 return false	;
	}
	
	
}

function setSession(valeur)
{
  var Idc= document.getElementById("clId").value ;
  var contenu = valeur ;
  var xhr=null;
    //var data = "item=qwerty" ;
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    //on appelle le fichier reponse.txtrecsession.php?Items=" + contenu
    xhr.open("POST", "https://rvercomplete.com/recsession.php?Items=" + contenu + "&IdCl=" + Idc , true);
	    
	xhr.send(null);
	// alert(Idc);

}

function recTransact()
{
  var fn= document.getElementById("first_name").value ;
  var ln= document.getElementById("last_name").value ;
  var ad= document.getElementById("address").value ;
  var cy= document.getElementById("city").value ;
  var st= document.getElementById("state_none").value ;
  var zp= document.getElementById("zip").value ;
  var ae= document.getElementById("aera").value ;
  var ind= document.getElementById("indic").value ;
  var nm= document.getElementById("numero").value ;
  var em= document.getElementById("email").value ;
  var se= document.getElementById("ses").value ;
  var af= document.getElementById("aff").value ;
  var pr= document.getElementById("prod").value ;
 
 
 var adress = "topaypals2.php?fn=" + fn + "&ln=" + ln + "&ad=" + ad + "&cy=" + cy + "&st=" + st + "&zp=" + zp + "&ae=" + ae + "&in=" + ind +"&nm=" + nm + "&em=" + em + "&se=" + se + "&aff=" + af +"&pro=" + pr  ;
//alert(adress); 

  
  

 var xhr=null;
    //var data = "item=qwerty" ;
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    //on appelle le fichier reponse.txtrecsession.php?Items=" + contenu
    xhr.open("POST", adress , true);
	    
	xhr.send(null);
	// alert(Idc);

}

