var WindowObjectReference; 
var PreviousUrl;
	function openPopup(strUrl) 
		{
			if(WindowObjectReference == null || WindowObjectReference.closed)
					{
						WindowObjectReference = window.open(strUrl, "NjoyPopUpWindow","resizable=yes,scrollbars=no,status=no,toolbar=no");
					}
			else if(previousUrl != strUrl)
					{
						WindowObjectReference = window.open(strUrl, "NjoyPopUpWindow","resizable=yes,scrollbars=no,status=no,toolbar=no");
						WindowObjectReference.focus();
					}
				else
					{
						WindowObjectReference.focus();
					};
						PreviousUrl = strUrl;
		}
		


		function confirmChoice() {
			question = confirm("Are you sure you want to decline the Terms of Use? Click Cancel to continue with registration."); 
			if (question == true) { 
				var newlocation = '';
				newlocation+='http://www.njoyonline.com';
				newlocation+=''; 
				location = newlocation;
			}
		} 


var checkobj

function agreesubmit(el){
checkobj=el
if (document.all||document.getElementById){
for (i=0;i<checkobj.form.length;i++){  //hunt down submit button
var tempobj=checkobj.form.elements[i]
if(tempobj.type.toLowerCase()=="submit")
tempobj.disabled=!checkobj.checked
}
}
}

function defaultagree(el){
if (!document.all&&!document.getElementById){
if (window.checkobj&&checkobj.checked)
return true
else{
alert("Please read/accept terms to submit form")
return false
}
}
}


function setchecked(chk)
{
 //document.forms[0].payment_method[chk].checked = true;
 for (i=0;i<document.forms[0].billtype.length;i++)
 {
	if (document.forms[0].billtype[i].value == chk)
	{
		document.forms[0].billtype[i].checked = true;
	}
 }
}

function getSelectedRadio(buttonGroup) {
   // returns the array number of the selected radio button or -1 if no button is selected
   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            return i
         }
      }
   } else {
      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
   }
   // if we get to this point, no radio button is selected
   return -1;
} // Ends the "getSelectedRadio" function

function getSelectedRadioValue(buttonGroup) {
   // returns the value of the selected radio button or "" if no button is selected
   var i = getSelectedRadio(buttonGroup);
   if (i == -1) {
      return "";
   } else {
      if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
         return buttonGroup[i].value;
      } else { // The button group is just the one button, and it is checked
         return buttonGroup.value;
      }
   }
} // Ends the "getSelectedRadioValue" function

function ShowDetails()
{
    active = getSelectedRadioValue(document.forms[0].elements['billtype']);
	HideAll();
	switch (active){
	case "PayPal":
	  ExpandSection('paypal');
	  break;
	case "Bank":
	  ExpandSection('bank');
	  break;
	case "PrePaid":
	  ExpandSection('prepaid');
	  break;
	case "MoneyTransfer":
	  ExpandSection('moneytransfer');
	  break;
	default : 
	  ExpandSection('paypal');
	  break;
   }
}

function HideAll()
{
	  ContractSection('paypal');
	  ContractSection('bank');
	  ContractSection('prepaid');
	  ContractSection('moneytransfer');
}

function ExpandSection(idVariable)
{
 idVariable = document.getElementById(idVariable); 
 if(idVariable!=null)
  if (idVariable.style.display=="none") idVariable.style.display="";
}

function ContractSection(idVariable){
 idVariable = document.getElementById(idVariable); 
 if(idVariable!=null) 
  if (idVariable.style.display=="") idVariable.style.display="none";
}

function ToggleUSAStates()
{
  country  = document.getElementById('country');
  if((country!=null) && (country.value=='US'))
  {
    ExpandSection("pdState")
	ContractSection("pdProvince");
  }
 else
  {
    ExpandSection("pdProvince")
	ContractSection("pdState");
  }
}

						function insertIntl(form) {
						 inputPrefix2=form.intlPrefix.options[form.intlPrefix.selectedIndex].value;
						 form.mobile_no.value=inputPrefix2;
						 form.mobile_no.focus();
						}
