// JavaScript Document
var ns4, ie4, ie5, moz;
ns4 = (document.layers)? true:false;
ie4 = (document.all)? true:false;
ie5 = (document.getElementByID && document.all)? true:false;
moz = (document.getElementById)?true:false;

function checkForm(frm) {
 	if (frm.affiliate_name.value =='') {
		alert("Please Enter Your Name");				
		frm.affiliate_name.focus();
		return false;
	}			
 	if (frm.streetAddress.value =='') {
		alert("Please Enter Your Street Address Number");				
		frm.streetAddress.focus();
		return false;		
	}
 	if (frm.city.value =='') {
		alert("Please Enter City Name");				
		frm.city.focus();
		return false;		
	}
 	if (frm.state.value =='') {
		alert("Please Select State Name");				
		frm.state.focus();
		return false;		
	}	
 	if (frm.country.value =='') {
		alert("Please Enter Country Name");				
		return false;		
	}
 	if (frm.zip.value =='') {
		alert("Please Enter Zip Code");				
		frm.zip.focus();
		return false;		
	}
 	if (frm.phone.value =='') {
		alert("Please Enter Phone Number");				
		frm.phone.focus();
		return false;		
	}
//	if(!validate_phone(frm.phone, "Phone Number"))
//		   {   return false;  }						
	if(!validate_email(frm.affiliate_email)) {
		return false;   
	}

	if (!validate_password(frm.affiliate_pwd)) {
		return false;
	}
/*
	if (frm.affiliate_pwd.value =='') {
		alert("Please Enter Password");		
		frm.affiliate_pwd.focus();
		return false;		
	}
	if (frm.affiliate_pwd.value.length <6) {
		alert("Password Should Not be Less than Six Characters");		
		frm.affiliate_pwd.focus();
		return false;		
	}
*/
 	if (frm.affiliate_pwd_re.value =='') {
		alert("Please Re-Enter Your Password");				
		frm.affiliate_pwd_re.focus();
		return false;		
	}
 	if (frm.affiliate_pwd_re.value != frm.affiliate_pwd.value) {
		alert("Your Password Did Not Match with Re-Entered Password");		
		frm.affiliate_pwd_re.focus();
		return false;		
	}
}


function trim(str) {
  while (str.charAt(0) == ' ')
    str = str.substring(1);
  while (str.charAt(str.length - 1) == ' ')
    str = str.substring(0, str.length - 1);
  return str;
}

function validate_phone(field, caption) {	
		var ssearch=field.value.indexOf(".")+1;
		var slength=field.value.length;
		var flag=0;	
		var svalue = field.value;
		
		for(i=0;i<parseInt(slength);i++) {
			if((svalue.charCodeAt(i)<48)||(svalue.charCodeAt(i)>57)) {
				if((svalue.charCodeAt(i)!=32)&&(svalue.charCodeAt(i)!=40)&&(svalue.charCodeAt(i)!=41)&&(svalue.charCodeAt(i)!=45)) {
					alert(caption + " can have 0 to 9, space, -, ( )");
					field.focus();
					field.select();
					return false;
				}
			}
	 	}
		return true;
	}

function validate_email(strng) {
	//var emailFilter=/^.+@.+\..{2,3}$/;
	var emailFilter=/^(\w|[-])+(\.(\w|[-])+)*@((\[([0-1]?\d?\d|2[0-4]\d|25[0-5])\.([0-1]?\d?\d|2[0-4]\d|25[0-5])\.([0-1]?\d?\d|2[0-4]\d|25[0-5])\.([0-1]?\d?\d|2[0-4]\d|25[0-5])\])|((([a-zA-Z0-9])+(([-])+([a-zA-Z0-9])+)*\.)+([a-zA-Z])+(([-])+([a-zA-Z0-9])+)*))$/;
	var strEmail=strng.value;
	if (!(emailFilter.test(strEmail))) { 
		alert("Please enter a valid email address.");
		strng.focus();
		return false;
	}
	return true;
}

function validate_password(strng) {
	var psswordFilter=/^(?=.*\d)(?=.*[a-zA-Z\.\-])[a-zA-Z0-9_\.\-\$\@\*]{6,}$/;
	var strpassword=strng.value;
	if (!(psswordFilter.test(strpassword))) { 
		alert("Please enter a valid password. It must contain 6 characters with at least one letter and one number. Some punctuation is not allowed (ex. #).");
		strng.focus();
		return false;
	}
	return true;
}
/*************************************************/
/*  General - US State Dropdown Box */
/*************************************************/
function StateList(sSelected) {
	var sItems="";
	var sSelectedItem="";
	if (sSelected=="")
		sSelected="FFFFFF";
	var sList1="Non-US,Alabama,Alaska,Arizona,Arkansas,California,Colorado,Connecticut,Delaware,Florida,Georgia,Hawaii,Idaho,Illinois,Indiana,Iowa,Kansas,Kentucky,Louisiana,Maine,Maryland,Massachusetts,Michigan,Minnesota,Mississippi,Missouri,Montana,Nebraska,Nevada,New Hampshire,New Jersey,New Mexico,New York,North Carolina,North Dakota,Ohio,Oklahoma,Oregon,Pennsylvania,Puerto Rico,Rhode Island,South Carolina,South Dakota,Tennessee,Texas,Utah,Vermont,Virginia,Washington,Washington DC,West Virginia,Wisconsin,Wyoming";
	var sList2="XX,AL,AK,AZ,AR,CA,CO,CT,DE,FL,GA,HI,ID,IL,IN,IA,KS,KY,LA,ME,MD,MA,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,PA,PR,RI,SC,SD,TN,TX,UT,VT,VA,WA,DC,WV,WI,WY";
	aNameArray=sList1.split(",");
	aValueArray=sList2.split(",");
	for (var ijk in aNameArray) {
		if (sSelected==aValueArray[ijk] || sSelected==aNameArray[ijk])
			sSelectedItem=" selected";
		else
			sSelectedItem="";
		sItems=sItems+"<option"+sSelectedItem+" value='"+aValueArray[ijk]+"'> "+aNameArray[ijk]+"</option>";
	}
	return sItems;	
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//******************************************************************************
function ShowCountryMSG() {
	sBody="<BR><span class='t1Copia'>Monthly payments made to store owners residing in countries other than the United States will be made via <a href='http://www.paypal.com/' target='_blank' class='estilonombre2'>Paypal.com</a> (http://www.paypal.com).&nbsp; <BR><BR>Paypal.com supports all countries served by E-Shirt.com.&nbsp; In order to receive payments for sales made, your E-Shirt.com e-mail address <u><b>must</b></u> match the E-mail address for your Paypal account.&nbsp; If it does not, you will not receive your store owner sales payments.</span>";
	//sBody = sBody + "<BR><BR><center><B><a target='_blank' href='http://www.paypal.com/' class='estilonombre2'>Open Paypal</a></B></center>"
	if(is.ns4 || is.ns6) {
		return overlib(sBody, FIXX, CenterXPos()-120, FIXY, CenterYPos()-120, WIDTH, 402, HEIGHT, 277, BACKGROUND, "http://e-shirt.com/images/announcement.gif", PADX, 35, 10, PADY, 40, 10);
	} else {
		alert("Monthly payments made to store owners residing in countries other than the United States will be made via Paypal.com (http://www.paypal.com). Paypal.com supports all countries served by E-Shirt.com.  In order to receive payments for sales made, your E-Shirt.com e-mail address must match the E-mail address for your Paypal account. If it does not, you will not receive your store owner sales payments.");
	}
}
