function ValidateGatewayForm(formName)
{
	
	var elem = document.getElementsByName("cardNumber");
	//alert(elem.length + " elements!")
	//alert( document.gateway.expirationYear.length);
	if (elem.length) {
		if (document.gateway.firstName.value == "") {
			alert("Please enter your First Name.");
			document.gateway.firstName.focus();
			return false;
		}	
		if (document.gateway.lastName.value == "") {
			alert("Please enter your Last Name.");
			document.gateway.lastName.focus();
			return false;
		}		
		if (document.gateway.cardNumber.value == "") {
			alert("Please enter your Credit Card Number.");
			document.gateway.cardNumber.focus();
			return false;
		}
		if (document.gateway.expirationMonth.value == "") {
			alert("Please enter your Expiration Month.");
			document.gateway.expirationMonth.focus();
			return false;
		}
		if (document.gateway.expirationYear.value == "") {
			alert("Please enter your Expiration Year.");
			document.gateway.expirationYear.focus();
			return false;
		}
		if (document.gateway.expirationYear.value.length < 4) {
			alert("Please enter a valid 4-digit Expiration Year.");
			document.gateway.expirationYear.focus();
			return false;
		}	
		if (document.gateway.cvc2.value == "") {
			alert("Please enter your Security Code \n(located on back of your card).");
			document.gateway.cvc2.focus();
			return false;
		}
		if (document.gateway.emailAddress.value == "") {
			alert("Please enter your Email Address.");
			document.gateway.emailAddress.focus();
			return false;
		}		
		if (document.gateway.addr1.value == "") {
			alert("Please enter your Address.");
			document.gateway.addr1.focus();
			return false;
		}
		if (document.gateway.city.value == "") {
			alert("Please enter your City.");
			document.gateway.city.focus();
			return false;
		}		
		if (document.gateway.state.value == "") {
			alert("Please enter your State.");
			document.gateway.state.focus();
			return false;
		}			
		if (document.gateway.postalCode.value == "") {
			alert("Please enter your Postal Code.");
			document.gateway.postalCode.focus();
			return false;
		}				
		if (document.gateway.country.value == "") {
			alert("Please choose your Country.");
			document.gateway.country.focus();
			return false;
		}			
							
	}
	findObj(formName).submit(); 
}


// display decision alert box
function decision(message, url){
	if(confirm(message)) location.href = url;
}

// open browser window
function openPopUp(url, windowName, w, h, scrollbar) {

           var winl = (screen.width - w) / 2;
           var wint = (screen.height - h) / 2;
           winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scrollbar ;
		   win = window.open(url, windowName, winprops);
           if (parseInt(navigator.appVersion) >= 4) { 
              	win.window.focus(); 
           } 
}

function jumpMenu(target,object,restore){ 
  eval(target+".location='"+object.options[object.selectedIndex].value+"'");
  if (restore) object.selectedIndex=0;
}

function findObj(n, d) {
  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=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function getImage(imageName)
{
		findObj('img').src = imageName;
}

function submitDocRetailer(formName, value) { 
	//alert(formName + "--" + value);
  var obj;

	if (obj=findObj(formName)!=null) 
	{
		
	     if (value <15 ){
			alert("You must purchase a minimum of 15 per item.");
		}else{		
			findObj(formName).submit(); 
		}
	}
	else 
	{
		alert('The form you are attempting to submit called \'' + formName + '\' couldn\'t be found. Please make sure the submitDoc function has the correct id and name.');
	}

}

function submitDoc(formName) { 
  var obj;
	//alert(formName);
	if (obj=findObj(formName)!=null) 
	{
		ValidateGatewayForm(formName);
		
	}
	else 
	{

		alert('The form you are attempting to submit called \'' + formName + '\' couldn\'t be found. Please make sure the submitDoc function has the correct id and name.');
	}

}