/* Common JavaScript Functions */


function popWin(theURL,w,h,opt) { 

	if (opt == 1 ){
		// scrollbars + toolbar
		popW=window.open(theURL,'popUp','width=100,height=100,resizable,scrollbars,toolbar,menubar=yes');
	} else if (opt == 2 ){
		// scrollbars
		popW=window.open(theURL,'popUp','width=100,height=100,resizable,scrollbars');
	} else {
		popW=window.open(theURL,'popUp','width=100,height=100,resizable');
	}
	
	// Move to window centre
	popW.moveTo((screen.width-w)/2,(screen.height-h)/2);
	
	// resize window and brint to front
	popW.resizeTo(w,h);
	popW.focus();
	
}



//window.onresize=viewAds;

/* Macromedia Functions */

// Select Menu

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

/* Image Rollovers */

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);

}

function navigateForm(obj)
  {
    if(obj.selectedIndex != -1 && obj.options[obj.selectedIndex].value)
      top.location.href = obj.options[obj.selectedIndex].value;
    return false;
}
//function DoCustomValidationi() {

//  var frm = document.forms["form1"];

//  if (!frm.card.checked){
//    alert('Please Click for Acceptance Policy ...');
//    return false;
//  } else if (!frm.cheque.checked) {
//    alert('Please Click for Terms and Conditions...');
//    return false;
//  } else {
//    return true;
//  }
//}

//function validate(card){
//  if (card.checked == 1)
//    alert("Thank You");
//  else
//    alert("You didn't check the Policy Acceptance! Let me check it for you.")
//    card.checked = 1;
//}

//function validate(cheque){
//  if (cheque.checked == false)
//    alert("Thank You");
//  else
//    alert("You didn't check the Terms and Conditions! Let me check it for you.")
//    cheque.checked = 2;


function DoCustomValidation() {

  var frm = document.forms["form1"];

  if (!frm.policy.checked){
    alert('Please Click for Acceptance Policy ...');
    return false;
  } else if (!frm.termscond.checked) {
    alert('Please Click for Terms and Conditions...');
    return false;
  } else {
    return true;
  }
}

function validate(policy){
  if (policy.checked == 1)
    alert("Thank You");
  else
    alert("You didn't check the Policy Acceptance! Let me check it for you.")
    policy.checked = 1;
}

function validate(termscond){
  if (termscond.checked == false)
    alert("Thank You");
  else
    alert("You didn't check the Terms and Conditions! Let me check it for you.")
    termscond.checked = 2;
}
  
function processForm(url) {

  var x = document.getElementById('EPS_REFERENCEID').value;
  var a = document.getElementById('EPS_NAMEONCARD').value;
  var b = document.getElementById('EPS_CARDNUMBER').value;
  var c = document.getElementById('EPS_CARDTYPE').value;
  var d = document.getElementById('EPS_EXPIRYMONTH').value;
  var e = document.getElementById('EPS_EXPIRYYEAR').value;

  if (x=="cheque" || x=="direct_deposit") {
    document.forms["form1"].action = url+"/signup-payment-results.php";
    document.forms["form1"].method = "POST";
    return true;
  } else if (x=="card") {
    if (a=="") {
      alert("Please enter Name on Card.");
      return false;
    }

    if (b=="") {
      alert("Please enter a Card Number");
      return false;
    }

    if (c=="choose") {
      alert("Please select a Credit Card Type");
      return false;
    }

    if (d=="choose") {
      alert("Please select a option for Expiry Month");
      return false;
    }

    if (e=="choose") {
      alert("Please select a option for Expiry Year");
      return false;
    }

    return true;
  }

  alert('Please select a payment method');
  
  return false;
}



