var geoip=false;

/*
JavaScript Document

Includes all javascripts for the market specific site.

Section 1: Open Window scripts
Section 2: Form Verification Scripts
Section 3: Image Preload/Swapping Scripts
Section 4: Basket Scripts ***************************************************************************
Section 5: Customize functions
Section 6: AJAX Functions
*/

//Section 1: Open Window cripts ***************************************************************************
function flexiJersey(txtCode) {
	var x=screen.width;
	var y=screen.height;
	var maxW=500;
	var maxH=300;
	var newWidth;
	var newHeight;
	if (x<maxW)
		newWidth=x-10;
	else
		newWidth=maxW;
	if (y<maxH)
		newHeight=y-10;
	else
		newHeight=maxH;
	var left=(screen.width-newWidth)/2;			
	var top=(screen.height-newHeight)/2-15;
	var linkText="http://gtmsportswear.com/gtm/images/flexiPages/jersey"+txtCode+".jpg"
	var winName="viewFlexiJersey";
	var newWindow=window.open(linkText,winName,"left=" + left + ",top=" + top + ",resizable=yes,toolbar=no,location=no,width=" + newWidth + ",height=" + newHeight + ",status=yes,scrollbars=yes");
	newWindow.focus();
}
function openProductImageViewer(u) {
	var x=screen.width;
	var y=screen.height;
	var maxW=650;
	var maxH=650;
	var newWidth;
	var newHeight;
	if (x<maxW)
		newWidth=x-10;
	else
		newWidth=maxW;
	if (y<maxH)
		newHeight=y-10;
	else
		newHeight=maxH;
	var left=(screen.width-newWidth)/2;			
	var top=(screen.height-newHeight)/2-15;
	var linkText=u;
	var winName="viewProductImage";
	var newWindow=window.open(linkText,winName,"left=" + left + ",top=" + top + ",resizable=yes,toolbar=no,location=no,width=" + newWidth + ",height=" + newHeight + ",status=yes,scrollbars=yes");
	newWindow.focus();
}
function openMelcoPreviewProduct(u) {
	var x=screen.width;
	var y=screen.height;
	var maxW=650;
	var maxH=650;
	var newWidth;
	var newHeight;
	if (x<maxW)
		newWidth=x-10;
	else
		newWidth=maxW;
	if (y<maxH)
		newHeight=y-10;
	else
		newHeight=maxH;
	var left=(screen.width-newWidth)/2;			
	var top=(screen.height-newHeight)/2-15;
	var linkText=u;
	var winName="MelcoPreviewProduct";
	var newWindow=window.open(linkText,winName,"left=" + left + ",top=" + top + ",resizable=yes,toolbar=no,location=no,width=" + newWidth + ",height=" + newHeight + ",status=yes,scrollbars=yes");
	newWindow.focus();
}
function openLPviewer(p,m,idx) {
	var x=screen.width;
	var y=screen.height;
	var maxW=650;
	var maxH=650;
	var newWidth;
	var newHeight;
	if (x<maxW)
		newWidth=x-10;
	else
		newWidth=maxW;
	if (y<maxH)
		newHeight=y-10;
	else
		newHeight=maxH;
	var left=(screen.width-newWidth)/2;			
	var top=(screen.height-newHeight)/2-15;
	var linkText="http://"+location.host+"/lp/view.asp?p="+p+"&m="+m+"&idx="+idx;
	var winName="viewLP";
	var newWindow=window.open(linkText,winName,"left=" + left + ",top=" + top + ",resizable=yes,toolbar=no,location=no,width=" + newWidth + ",height=" + newHeight + ",status=yes,scrollbars=yes");
	newWindow.focus();
}
function superQuikPop() {
	var x=screen.width;
	var y=screen.height;
	var maxW=400;
	var maxH=400;
	var newWidth;
	var newHeight;
	if (x<maxW)
		newWidth=x-10;
	else
		newWidth=maxW;
	if (y<maxH)
		newHeight=y-10;
	else
		newHeight=maxH;
	var left=(screen.width-newWidth)/2;			
	var top=(screen.height-newHeight)/2-15;
	var linkText="http://"+location.host+"/gtm/superQuikInfo.html";
	var winName="superQuikInfo";
	var newWindow=window.open(linkText,winName,"left=" + left + ",top=" + top + ",resizable=yes,toolbar=no,location=no,width=" + newWidth + ",height=" + newHeight + ",status=yes,scrollbars=yes");
	newWindow.focus();
}
function viewCheerInStockTeeDesigns(id) {
	var x=screen.width;
	var y=screen.height;
	var maxW=800;
	var maxH=400;
	var newWidth;
	var newHeight;
	if (x<maxW)
		newWidth=x-10;
	else
		newWidth=maxW;
	if (y<maxH)
		newHeight=y-10;
	else
		newHeight=maxH;
	var left=(screen.width-newWidth)/2;			
	var top=(screen.height-newHeight)/2-15;
	var linkText="http://gtmsportswear.com/gtm/images/cheerInStockTeeDesigns/"+id+".jpg";
	var winName="inStockCheerDesigns";
	var newWindow=window.open(linkText,winName,"left=" + left + ",top=" + top + ",resizable=yes,toolbar=no,location=no,width=" + newWidth + ",height=" + newHeight + ",status=yes,scrollbars=yes");
	newWindow.focus();
}
function makeuptips() {
	var x=screen.width;
	var y=screen.height;
	var newWidth;
	var newHeight;
	if (x<600)
		newWidth=x-10;
	else
		newWidth=600;
	if (y<700)
		newHeight=y-10;
	else
		newHeight=700;
	var left=(screen.width-newWidth)/2;			
	var top=(screen.height-newHeight)/2-15;
	var linkText="http://"+location.hostname+"/gtm/makeuptips.html";
	var winName="makeupkits";
	var newWindow=window.open(linkText,winName,"left=" + left + ",top=" + top + ",resizable=yes,toolbar=no,location=no,width=" + newWidth + ",height=" + newHeight + ",status=yes,scrollbars=yes");
	newWindow.focus();
}
function openChUniformTerms() {
	var x=screen.width;
	var y=screen.height;
	var newWidth;
	var newHeight;
	if (x<600)
		newWidth=x-10;
	else
		newWidth=600;
	if (y<700)
		newHeight=y-10;
	else
		newHeight=700;
	var left=(screen.width-newWidth)/2;			
	var top=(screen.height-newHeight)/2-15;
	var linkText="http://"+location.hostname+"/gtm/chUniformTerms.html";
	var winName="chUniformTerms";
	var newWindow=window.open(linkText,winName,"left=" + left + ",top=" + top + ",resizable=yes,toolbar=no,location=no,width=" + newWidth + ",height=" + newHeight + ",status=yes,scrollbars=yes");
	newWindow.focus();
}
function openAdvancedCustomerForm() {
	window.open("https://gtmsportswear.com/gtm/acf.asp","custclient","width=600,height=500,scrollbars=0");
}
function openAdvancedCustomerForm12482() {
	window.open("https://gtmsportswear.com/gtm/acf12482.asp","custclient","width=600,height=500,scrollbars=0");
}
function openTipsForMeasuring() {
	var x=screen.width;
	var y=screen.height;
	var newWidth;
	var newHeight;
	if (x<600)
		newWidth=x-10;
	else
		newWidth=600;
	if (y<700)
		newHeight=y-10;
	else
		newHeight=700;
	var left=(screen.width-newWidth)/2;			
	var top=(screen.height-newHeight)/2-15;
	var linkText="http://"+location.hostname+"/gtm/tipsForMeasuring.html";
	var winName="tipsForMeasuring";
	var newWindow=window.open(linkText,winName,"left=" + left + ",top=" + top + ",resizable=yes,toolbar=no,location=no,width=" + newWidth + ",height=" + newHeight + ",status=yes,scrollbars=yes");
	newWindow.focus();
}

//shows list of names and numbers for a certain created art from art lab
function openNN(aid,isYouth) {
	var x=screen.width;
	var y=screen.height;
	var newWidth;
	var newHeight;
	if (x<400)
		newWidth=x-10;
	else
		newWidth=400;
	if (y<400)
		newHeight=y-10;
	else
		newHeight=400;
	var left=(screen.width-newWidth)/2;			
	var top=(screen.height-newHeight)/2-15;
	var linkText="nnPu.asp?aid="+aid+"&isYouth="+isYouth;
	var winName="nnPu";
	var newWindow=window.open(linkText,winName,"left=" + left + ",top=" + top + ",resizable=yes,toolbar=no,location=no,width=" + newWidth + ",height=" + newHeight + ",status=yes,scrollbars=yes");
	newWindow.focus();
}

//shows glitz design
function show_image(w,h,u,n) {
	var x=screen.width;
	var y=screen.height;
	var newWidth;
	var newHeight;
	if (x<w)
		newWidth=x-10;
	else
		newWidth=w;
	if (y<h)
		newHeight=y-10;
	else
		newHeight=h;
	var left=(screen.width-newWidth)/2;			
	var top=(screen.height-newHeight)/2-15;
	var linkText=u;
	var winName=n;
	var newWindow=window.open(linkText,winName,"left=" + left + ",top=" + top + ",resizable=yes,toolbar=no,location=no,width=" + newWidth + ",height=" + newHeight + ",status=yes,scrollbars=yes");
	newWindow.focus();
}
function show_glitz(u) {
	var x=screen.width;
	var y=screen.height;
	var newWidth;
	var newHeight;
	if (x<400)
		newWidth=x-10;
	else
		newWidth=400;
	if (y<400)
		newHeight=y-10;
	else
		newHeight=400;
	var left=(screen.width-newWidth)/2;			
	var top=(screen.height-newHeight)/2-15;
	var linkText=u;
	var winName="glitz";
	var newWindow=window.open(linkText,winName,"left=" + left + ",top=" + top + ",resizable=yes,toolbar=no,location=no,width=" + newWidth + ",height=" + newHeight + ",status=yes,scrollbars=yes");
	newWindow.focus();
}

//this function opens the color charts for threads(1) or screen colors(2)
function colorChart(a,f) {
	var f1,fp1=0;
	if (f==null)
		f1=1;
	else
		f1=f;
	var x=screen.width;
	var y=screen.height;
	var newWidth;
	var newHeight;
	if (x<500)
		newWidth=x-10;
	else
		newWidth=500;
	if (y<400)
		newHeight=y-10;
	else
		newHeight=400;
	var left=(screen.width-newWidth)/2;			
	var top=(screen.height-newHeight)/2-15;
	if ((a==4)||(a==5))
		var linkText="http://"+location.hostname+"/gtm/acct/swatchtwill.asp?f="+f1+"&artType=" + a;
	else
		var linkText="http://"+location.hostname+"/gtm/acct/swatch.asp?f="+f1+"&artType=" + a;
	var winName="colorChart";
	var newWindow=window.open(linkText,winName,"left=" + left + ",top=" + top + ",resizable=yes,toolbar=no,location=no,width=" + newWidth + ",height=" + newHeight + ",status=yes,scrollbars=yes");
	newWindow.focus();
}

//this function opens the color charts for threads(1) or screen colors(2)
function colorChart2(a,f,fp) {
	var f1,fp1=0;
	if (f==null)
		f1=1;
	else
		f1=f;
	if (fp==null)
		fp1=0;
	else
		fp1=fp;
	var x=screen.width;
	var y=screen.height;
	var newWidth;
	var newHeight;
	if (x<500)
		newWidth=x-10;
	else
		newWidth=500;
	if (y<400)
		newHeight=y-10;
	else
		newHeight=400;
	var left=(screen.width-newWidth)/2;			
	var top=(screen.height-newHeight)/2-15;
	if ((a==4)||(a==5))
		var linkText="http://"+location.hostname+"/gtm/acct/swatchtwill.asp?f="+f1+"&artType="+a+"&fp="+fp1;
	else
		var linkText="http://"+location.hostname+"/gtm/acct/swatch.asp?f="+f1+"&artType="+a+"&fp="+fp1;
	var winName="colorChart";
	var newWindow=window.open(linkText,winName,"left=" + left + ",top=" + top + ",resizable=yes,toolbar=no,location=no,width=" + newWidth + ",height=" + newHeight + ",status=yes,scrollbars=yes");
	newWindow.focus();
}

//this function opens the online catalog
function openCatalogCH() {
	var newwin=window.open("http://"+location.hostname+"/gtm/catalogCH.asp")
	newwin.focus();
}
//this function opens the online catalog
function openCatalogZZ() {
	var newwin=window.open("http://"+location.hostname+"/gtm/catalogZZ.asp")
	newwin.focus();
}
// This function allows for viewing of customization of an item on the order confirmation page.
// confirm.asp
function viewCst(i_id, p_id) {
	var x=screen.width;
	var y=screen.height;
	var newWidth;
	var newHeight;
	if (x<400)
		newWidth=x-10;
	else
		newWidth=400;
	if (y<400)
		newHeight=y-10;
	else
		newHeight=400;
	var left=(screen.width-newWidth)/2;			
	var top=(screen.height-newHeight)/2-15;
	var linkText="view_cust.asp?i_id="+ i_id + "&p_id=" + p_id;
	var winName="view_cust";
	var newWindow=window.open(linkText,winName,"left=" + left + ",top=" + top + ",resizable=yes,toolbar=no,location=no,width=" + newWidth + ",height=" + newHeight + ",status=yes,scrollbars=yes");
	newWindow.focus();
}
/*This fucntion opens a window to request a catalog or enter drawing for $250 in merchandise*/
// utilities.asp
// menu_top.asp
/*This fucntion displays a particular color for a product*/
// prd_include.asp
// set_include.asp
function displayColor(id,code,color,front,bck) {
	var x=screen.width;
	var y=screen.height;
	var newWidth;
	var newHeight;
	if (x<500)
		newWidth=x-10;
	else
		newWidth=500;
	if (y<700)
		newHeight=y-10;
	else
		newHeight=500;
	var left=(screen.width-newWidth)/2;			
	var top=(screen.height-newHeight)/2-15;
	var linkText="http://"+location.hostname+"/gtm/displaycolor.asp?id=" + id + "&color=" + color + "&code=" + code + "&front=" + front + "&back=" + bck;
	var winName="Color";
	var newWindow=window.open(linkText,winName,"left=" + left + ",top=" + top + ",resizable=yes,toolbar=no,location=no,width=" + newWidth + ",height=" + newHeight + ",status=yes,scrollbars=yes");
	newWindow.focus();
	
}

function openCatalog() {
	var newWidth=400;
	var newHeight=400;
	var left=(screen.width-newWidth)/2;			
	var top=(screen.height-newHeight)/2-15;
	var loc="http://" + (location.href.indexOf("www.")>=0?"www.":"") + location.hostname+"/gtm/catalog_request_acct.asp";
	var catWin=window.open(loc,"catWin","left=" + left + ",top=" + top + ",resizable=yes,toolbar=no,location=no,width=" + newWidth + ",height=" + newHeight + ",status=yes,scrollbars=yes");
	if(catWin.focus) catWin.focus();
}

// Opens the contact us form
// contactinfo.asp
function openRegSelContact() {
	var x=screen.width;
	var y=screen.height;
	var newWidth;
	var newHeight;
	if (x<670)
		newWidth=x-10;
	else
		newWidth=670;
	if (y<610)
		newHeight=y-10;
	else
		newHeight=610;
  var left=(screen.width-newWidth)/2;			
	var top=(screen.height-newHeight)/2-15;
	var linkText="region_select.asp?r=contact_form";
	var winName="contact";
	var newWindow=window.open(linkText,winName,"left=" + left + ",top=" + top + ",resizable=yes,toolbar=no,location=no,width=" + newWidth + ",height=" + newHeight + ",status=yes,scrollbars=yes");
	newWindow.focus();
}
function openContact(reg) {
	var x=screen.width;
	var y=screen.height;
	var newWidth;
	var newHeight;
	if (x<670)
		newWidth=x-10;
	else
		newWidth=670;
	if (y<610)
		newHeight=y-10;
	else
		newHeight=610;
  var left=(screen.width-newWidth)/2;			
	var top=(screen.height-newHeight)/2-15;
	var linkText="contactform.asp?region=" + reg;
	var winName="contact";
	var newWindow=window.open(linkText,winName,"left=" + left + ",top=" + top + ",resizable=yes,toolbar=no,location=no,width=" + newWidth + ",height=" + newHeight + ",status=yes,scrollbars=yes");
	newWindow.focus();
}
// Opens FAQs
// contactinfo.asp
function openFAQ() {
	var x=screen.width;
	var y=screen.height;
	var newWidth;
	var newHeight;
	if (x<750)
		newWidth=x-10;
	else
		newWidth=750;
	if (y<500)
		newHeight=y-10;
	else
		newHeight=500;
  	var left=(screen.width-newWidth)/2;			
	var top=(screen.height-newHeight)/2-15;
	var linkText="faqs.asp";
	var winName="FAQs";
	var newWindow=window.open(linkText,winName,"left=" + left + ",top=" + top + ",resizable=yes,toolbar=no,location=no,width=" + newWidth + ",height=" + newHeight + ",status=yes,scrollbars=yes");
	newWindow.focus();
}
// shows size specs for a product
// prd.asp
// set.asp
function showSpecs(id, catID) {
	var theURL="http://"+location.hostname+"/gtm/sizespecs.asp?id=" + id + "&catID="  + catID;
	var winName="Specs";
	var w=800;
	var h=400;
	var l=(screen.width-w)/2;
	var t=(screen.height-h)/2;
	var newWindow=window.open(theURL,winName,"left=" + l + ",top=" + t + ",width=" + w + ",height=" + h + ",scrollbars=yes,resizable=yes,status=yes");
	newWindow.focus();
}
// shows size specs for a product
// prd.asp
// set.asp
function showSpecsTest(id, catID) {
	var theURL="http://" + location.hostname + "/gtm/sizespecstest.asp?id=" + id + "&catID="  + catID;
	var winName="Specs";
	var w=800;
	var h=400;
	var l=(screen.width-w)/2;
	var t=(screen.height-h)/2;
	var newWindow=window.open(theURL,winName,"left=" + l + ",top=" + t + ",width=" + w + ",height=" + h + ",scrollbars=yes,resizable=yes,status=yes");
	newWindow.focus();
}
// shows size specs for a product
// prd.asp
// set.asp
function showSpecsTest2(id, catID) {
	var theURL="http://" + location.hostname + "/gtm/measurementsBAK.asp?id=" + id + "&catID="  + catID;
	var winName="Specs";
	var w=800;
	var h=600;
	var l=(screen.width-w)/2;
	var t=(screen.height-h)/2;
	var newWindow=window.open(theURL,winName,"left=" + l + ",top=" + t + ",width=" + w + ",height=" + h + ",scrollbars=yes,resizable=yes,status=yes");
	newWindow.focus();
}
// shows size specs for a product
// prd.asp
// set.asp
function showSpecs2(id, catID) {
	var theURL="http://" + location.hostname + "/gtm/measurements.asp?id=" + id + "&catID="  + catID;
	var winName="Specs";
	var w=800;
	var h=600;
	var l=(screen.width-w)/2;
	var t=(screen.height-h)/2;
	var newWindow=window.open(theURL,winName,"left=" + l + ",top=" + t + ",width=" + w + ",height=" + h + ",scrollbars=yes,resizable=yes,status=yes");
	newWindow.focus();
}
function showCarissaSpecs(id, catID) {
	var theURL="http://" + location.hostname + "/gtm/bak/sizespecs.asp?id=" + id + "&catID="  + catID;
	var winName="Specs";
	var w=800;
	var h=600;
	var l=(screen.width-w)/2;
	var t=(screen.height-h)/2;
	var newWindow=window.open(theURL,winName,"left=" + l + ",top=" + t + ",width=" + w + ",height=" + h + ",scrollbars=yes,resizable=yes,status=yes");
	newWindow.focus();
}
// opens the screen print calculator for a certain product
// prd.asp
// set.asp
function OpenCalculator(id) {
	var theURL="http://" + location.hostname + "/gtm/calculator/screen.asp?id=" + id;
	var winName="Calculator";
	var w=750;
	var h=600;
	var l=(screen.width-w)/2;
	var t=(screen.height-h)/2;
	var newWindow=window.open(theURL,winName,"left=" + l + ",top=" + t + ",width=" + w + ",height=" + h + ",scrollbars=yes,resizable=yes,status=yes");
	newWindow.focus();
}
// shows the design
// used in customize.asp
function viewDesign(id) {
	if (id!="") {
		var theURL="my_design_view.asp?graphic_id="
		//var g_id=document.prd_add[loc].value;
		var newWindow=window.open(theURL + id);
		newWindow.focus();
	} else
		alert("No design is selected for this location.");
}
// opens a symbol/logo (embroidered) in its own window.
// used in symbols.asp
function openDesign(des_type,des_id,tag_cat) {
	var theURL="http://" + location.hostname + "/gtm/print_design.asp?des_type="+des_type+"&des_id="+des_id+"&tag_cat="+tag_cat;
	var left=(screen.width-412)/2;			
	var top=(screen.height-412)/2-15;
	var winName="print_design";
	var designWindow=window.open(theURL,winName,"left="+left+",top="+top+",width=412,height=412,scrollbars=yes,resizable=yes,status=yes,menubar=yes,toolbar=no");
	designWindow.focus();
}
// opens a symbol/logo (embroidered) in its own window.
// used in symbols.asp
function openDesignCS(des_type,des_id,tag_cat) {
	var theURL="http://" + location.hostname + "/gtm/print_design.asp?des_type="+des_type+"&des_id="+des_id+"&tag_cat="+tag_cat;
	var left=(screen.width-412)/2;			
	var top=(screen.height-412)/2-15;
	var winName="print_design";
	var designWindow=window.open(theURL,winName,"left="+left+",top="+top+",width=412,height=412,scrollbars=yes,resizable=yes,status=yes,menubar=yes,toolbar=no");
	designWindow.focus();
}
//opens quote calculator for screen pring
function openQuote() {
	var theURL="calculator/default.asp"
	var winName="Calculator";
	var w=750;
	var h=600;
	var l=(screen.width-w)/2;
	var t=(screen.height-h)/2;
	var newWindow=window.open(theURL,winName,"left=" + l + ",top=" + t + ",width=" + w + ",height=" + h + ",scrollbars=yes,resizable=yes,status=yes");
	newWindow.focus();
}
// opens personalizatio download form
function openPers() {
	var newWindow=window.open("../hs/personalization.pdf","pdfview");
	newWindow.focus();
}
// opens order download form
function openOrderForm() {
	var newWindow=window.open("../hs/orderform.pdf","pdfview");
	newWindow.focus();
}

// End Section 1: Open Window scripts ***************************************************************************




// Section 2: Form Verification Scripts ***************************************************************************
// verifies register / signup information
// sign-up.asp my_profile.asp
function verify_shell() {
			return true;
}
function verify_sign_up(frm)
{
	var returnValue=false;
	var radIndex;
	var tempState;
	tempState=frm.State.value;

	if (frm.Email.value=="")
	{
		alert("Please enter your email address.");
		frm.Email.focus();
		return false;				
	}
	else if (frm.First_Name.value=="")
	{
		alert("Please enter your first name.");
		frm.First_Name.focus();
		return false;				
	}
	else if (frm.slcMarkets.value=="")
	{
		alert("Please select a market which most closely defines your team/organization");
		frm.slcMarkets.focus();
		return false;
	}
	return true;
}
// verifies register information
// register.asp
function verify_register(frm)
{
	var returnValue=false;
	var radIndex;
	var tempState;
	tempState=frm.State.value;

	if (frm.Client_ID.value=="")
	{
		alert("Please enter a User ID.");
		frm.Client_ID.focus();
		return false;				
	}
	else if (frm.Password.value=="")
	{
		alert("Please enter a Password.");
		frm.Password.focus();
		return false;				
	}
	else if (frm.Verify.value=="")
	{
		alert("Please verify your Password.");
		frm.Verify.focus();
		return false;				
	}
	else if (frm.First_Name.value=="")
	{
		alert("Please enter your first name.");
		frm.First_Name.focus();
		return false;				
	}
	else if (frm.Last_Name.value=="")
	{
		alert("Please enter your last name.");
		frm.Last_Name.focus();
		return false;				
	}
	else if (frm.Email.value=="")
	{
		alert("Please enter your email address.");
		frm.Email.focus();
		return false;				
	}
	else if (tempState=="0")
	{
		alert("Please select a state.");
		frm.State.focus();
		return false;
	}
	else
	{
		for (radIndex=0;radIndex<29;radIndex++)
		{
			if (frm.Market[radIndex].checked)
			{
				returnValue=true;
			}
		}
		if (!(returnValue))
		{
			alert("Please Select a Market");
			frm.Market[0].focus();
			return false;
		}
	}

	if (frm.Verify.value!=frm.Password.value)
	{
		alert("The verification of your password didn't match the password.  Please enter the same value in the password and verify password field.")
		frm.Password.focus();
		return false;
	}	
	return true;
}
// verifies that email is entered on search for orders
// used in utilities.asp
// login.asp
function verify_email(frm) {
	if (frm.email.value=="") {
		alert("Please enter your email address.");
		frm.email.focus();
		return false;
	}
	return true;
}
// validate makes sure that a non numeric character is not entered in a text box
// login_bar.asp
// login.asp
function ValidateLogin(frm) {
	if (frm.id.value=="") {
		alert("Please enter your Client ID.");
		frm.id.focus();
		return false;
	} else if (frm.pass.value=="") {
		alert("Please enter your Password.");
		frm.pass.focus();
		return false;
	}
	return true;
}
function ValidateLoginNew(frm) {
	if (frm.email.value=="") {
		alert("Please enter your email address.");
		frm.email.focus();
		return false;
	}
	return true;
}
function isNum(val){
	var valid="0123456789"
	for (var i=0;i<val.length;i++) {
		temp="" + val.substring(i, i+1);
		if (valid.indexOf(temp)=="-1") return false;
	}
	return true;
}
function validate(field) {
	var valid="0123456789"
	var ok="yes";
	var temp;
	if (field.name=="email")
		return true;
	
	if (field.type=='text' || field.type=='hidden')
		for (var i=0;i<field.value.length;i++) {
			temp="" + field.value.substring(i, i+1);
			if (valid.indexOf(temp)=="-1") ok="no";
		}
	
	if (ok=="no") {
		field.value=1;
   		return true;
		//alert("This field only accepts numbers.");
		//field.focus();
		//field.select();
		//return false;
   }
   else {
   		return true;
   }
}
function validate_numb_only(field) {
	var valid="0123456789"
	var ok="yes";
	var temp;
	
	for (var i=0;i<field.value.length;i++) {
		temp="" + field.value.substring(i, i+1);
		if (valid.indexOf(temp)=="-1") ok="no";
	}
	
	if (ok=="no") {
		field.value=1;
		//alert("This field only accepts numbers.");
		//field.focus();
		//field.select();
		//return false;
   }
   else {
   		return true;
   }
}
function showAddToCartError(msg){
	var e=document.getElementById('errorMessage');
	e.innerHTML=msg;
	e.style.visibility="visible";
}
function hideAddToCartError(){
	var e=document.getElementById('errorMessage');
	e.innerHTML="";
	e.style.visibility="hidden";
}

// this verifies the data entered for product to be added to the basket
// used in set.asp
function verify_set(frm,checkInventory,checkTopBottomEqual,minQty,maxQty){
	var verifyMinMessage=' ';
	var verifyTBE=false;
	var verifyMin=0;
	var verifyMaxMessage=' ';
	var verifyMax=0;

	if (checkTopBottomEqual==undefined)
		verifyTBE=false;
	else if (checkTopBottomEqual==null)
		verifyTBE=false;
	else
		verifyTBE=checkTopBottomEqual;

	if (minQty==undefined)
		verifyMin=0;
	else if (minQty==null)
		verifyMin=0;
	else
		verifyMin=minQty;
		
	if (maxQty==undefined)
		verifyMax=0;
	else if (maxQty==null)
		verifyMax=0;
	else
		verifyMax=maxQty;
		
	if (verifyMin>0){verifyMinMessage=' of at least '+verifyMin+' ';}
	if (verifyMax>0){verifyMaxMessage=' of at most '+verifyMin+' ';}
		
	var tq=0;
	var bq=0;
	var non_numeric=false;
	var top_adult_added=false;
	var top_youth_added=false;
	var bottom_adult_added=false;
	var bottom_youth_added=false;
	var i=0;
	//Check to make sure data in text boxes is a number
	for (i=0;i<frm.elements.length;i++) {
		if (frm.elements[i].type=="text")
			if (!validate(frm.elements[i]))
				non_numeric=true;
	}
	if (non_numeric)
		return false;
	else { 
		var non_zero=false;
		for (var i=0;i<frm.elements.length;i++) {
			if (frm.elements[i].type=="text")
				if (frm.elements[i].value!="0" && frm.elements[i].value!="")
					non_zero=true;
		}
		if (!non_zero) {
			showAddToCartError('Please enter a quantity'+verifyMinMessage+'for the '+frm.topLabel.value.toLowerCase()+' and '+frm.bottomLabel.value.toLowerCase()+' to continue.');
			frm.top_size0.focus();
			return false;
		}
	}
	//End Check for non numeric values
	//if we have to keep entries<inventory numbers
	if (checkInventory) {
		for (i=0;i<frm.top_size_count.value;i++)
			if (Number(frm["top_size"+i].value)>Number(frm["inv_top_qty"+i].value) && Number(frm["inv_top_qty"+i].value)>=0) {
				showAddToCartError("Please change your order quantity to the quantity listed in red or lower.");
				frm["top_size"+i].focus();
				return false;
			}
		for (i=0;i<frm.top_youth_size_count.value;i++)
			if (Number(frm["top_youth_size"+i].value)>Number(frm["inv_youth_top_qty"+i].value) && Number(frm["inv_youth_top_qty"+i].value)>=0) {
				showAddToCartError("Please change your order quantity to the quantity listed in red or lower.");
				frm["top_youth_size"+i].focus();
				return false;
			}
		for (i=0;i<frm.bottom_size_count.value;i++)
			if (Number(frm["bottom_size"+i].value)>Number(frm["inv_bottom_qty"+i].value) && Number(frm["inv_bottom_qty"+i].value)>=0) {
				showAddToCartError("Please change your order quantity to the quantity listed in red or lower.");
				frm["bottom_size"+i].focus();
				return false;
			}
		for (i=0;i<frm.bottom_size_count.value;i++)
			if (Number(frm["bottom_youth_size"+i].value)>Number(frm["inv_youth_bottom_qty"+i].value) && Number(frm["inv_youth_bottom_qty"+i].value)>=0) {
				showAddToCartError("Please change your order quantity to the quantity listed in red or lower.");
				frm["bottom_youth_size"+i].focus();
				return false;
			}
	}
	//End Inventory Check
	//Check to see if youth top/bottom and/or adult top/bottom sizes have been added
	for (var i=0;i<frm.elements.length;i++) {
		if (frm.elements[i].type=="text") {
			if (frm.elements[i].name.substring(0,5)=="top_s") {
				if (frm.elements[i].value!="0" && frm.elements[i].value!="") {
					tq += Number(frm.elements[i].value)
					top_adult_added=true;
				}
			} else if (frm.elements[i].name.substring(0,5)=="top_y") {
				if (frm.elements[i].value!="0" && frm.elements[i].value!="") {
					tq += Number(frm.elements[i].value)
					top_youth_added=true;
				}
			} else if (frm.elements[i].name.substring(0,8)=="bottom_s") {
				if (frm.elements[i].value!="0" && frm.elements[i].value!="") {
					bq += Number(frm.elements[i].value)
					bottom_adult_added=true;
				}
			} else if (frm.elements[i].name.substring(0,8)=="bottom_y") {
				if (frm.elements[i].value!="0" && frm.elements[i].value!="") {
					bq += Number(frm.elements[i].value)
					bottom_youth_added=true;
				}
			}
		}
	}
	if (verifyTBE) {
		if (tq!=bq) {
			if (minQty>0)
				showAddToCartError("You must enter equal quantities of each of these with a minimum of "+minQty+" to proceed.");
			else
				showAddToCartError("Please enter equal quantities for the "+frm.topLabel.value.toLowerCase()+" and "+frm.bottomLabel.value.toLowerCase()+" to continue");
			frm.top_size0.focus();
			return false;
		}
		if (tq<verifyMin) {
			showAddToCartError("You must enter at least "+verifyMin+" of this group to proceed.");
			frm.top_size0.focus();
			return false;
		}
		if (tq>verifyMax&&verifyMax>0) {
			showAddToCartError("You can only enter a maximum of "+verifyMax+" of this group to proceed.");
			frm.top_size0.focus();
			return false;
		}
	}
	//If top adult sizes added make sure top adult color is selected
	if (top_adult_added)
		if (frm.top_adult_color.value=="") {
			showAddToCartError('Please choose your '+frm.topLabel.value.toLowerCase()+' color to continue.');
			frm.top_adult_color.focus();
			return false;
		}
	//If top youth sizes added make sure top youth color is selected
	if (top_youth_added)
		if (frm.top_youth_color.value=="") {
			showAddToCartError('Please choose your youth '+frm.topLabel.value.toLowerCase()+' color to continue.');
			frm.top_youth_color.focus();
			return false;
		}
	//If bottom adult sizes added make sure bottom adult color is selected
	if (bottom_adult_added)
		if (frm.bottom_adult_color.value=="") {
			showAddToCartError('Please choose your '+frm.bottomLabel.value.toLowerCase()+' color to continue.');
			frm.bottom_adult_color.focus();
			return false;
		}
	//If bottom youth sizes added make sure bottom youth color is selected
	if (bottom_youth_added)
		if (frm.bottom_youth_color.value=="") {
			showAddToCartError('Please choose your youth '+frm.bottomLabel.value.toLowerCase()+' color to continue.');
			frm.bottom_youth_color.focus();
			return false;
		}
	return true;
}
// this verifies the data entered for product to be added to the basket
// used in prd.asp
function verify_prd(frm,checkInventory,pkg){
	var adult_added=false;
	var youth_added=false;
	var ladies_added=false;
	var non_numeric=false;
	var totalEntered=0;
	//Check to make sure data in text boxes is a number
	for (var i=0;i<frm.elements.length;i++) {
		if (frm.elements[i].type=="text")
			if (!validate(frm.elements[i]))
				non_numeric=true;
	}
	if (non_numeric)
		return false;
	else { 
		var non_zero=false;
		for (var i=0;i<frm.elements.length;i++) {
			if (frm.elements[i].type=="text")
				if (frm.elements[i].value!="0" && frm.elements[i].value!="") {
					totalEntered+=Number(frm.elements[i].value);
					non_zero=true;
				}
		}
		if (!non_zero) {
			showAddToCartError("Please select a color and enter a quantity to continue.");
			frm.size0.focus();
			return false;
		} else {
			if (totalEntered>maxQty && maxQty>0) {
				//showAddToCartError("You can only enter a total quantity of "+maxQty+" free polos.  One per $200 in your basket.");
				if (pkg.toLowerCase()=='futw'||pkg.toLowerCase()=='ftwp')
					showAddToCartError("You are only allowed "+maxQty+" free tees.");
				else if (pkg.toLowerCase()=='pkg140')
					showAddToCartError("You are only allowed 1 free polo per customer.");
				else if (pkg.toLowerCase()=='pkg141')
					showAddToCartError("You can only enter a total quantity of "+maxQty+" free tees.  One per warm-up in your basket.");
				else if (pkg.toLowerCase()=='pkg142')
					showAddToCartError("You can only enter a total quantity of "+maxQty+" free tees.  18 per $500 in your basket.");
				frm.size0.focus();
				return false;
			}
		}
	}
	//End Check for non numeric values
	//if we have to keep entries<inventory numbers
	if (checkInventory) {
		for (i=0;i<frm.size_count.value;i++) {
			if (Number(frm["size"+i].value)>Number(frm["inv_qty"+i].value) && Number(frm["inv_qty"+i].value)>=0) {
				showAddToCartError("Please change your order quantity to the quantity listed in red or lower.");
				frm["size"+i].focus();
				return false;
			}
		}
		for (i=0;i<frm.youth_size_count.value;i++)
			if (Number(frm["youth_size"+i].value)>Number(frm["inv_youth_qty"+i].value) && Number(frm["inv_youth_qty"+i].value)>=0) {
				showAddToCartError("Please change your order quantity to the quantity listed in red or lower.");
				frm["youth_size"+i].focus();
				return false;
			}
	}
	//End Inventory Check
	//Check to see if youth and/or adult sizes have been added
	for (var i=0;i<frm.elements.length;i++) {
		if (frm.elements[i].type=="text") {
			if (frm.elements[i].name.substring(0,4)=="size") {
				if (frm.elements[i].value!="0" && frm.elements[i].value!="")
					adult_added=true;
			} else if (frm.elements[i].name.substring(0,5)=="youth") {
				if (frm.elements[i].value!="0" && frm.elements[i].value!="")
					youth_added=true;
			} else if (frm.elements[i].name.substring(0,6)=="ladies") {
				if (frm.elements[i].value!="0" && frm.elements[i].value!="")
					ladies_added=true;
			}
		}
	}
	//If adult sizes added make sure adult color is selected
	if (adult_added)
		if (frm.adult_color.value=="") {
			showAddToCartError("Please select a color to continue.");
			frm.adult_color.focus();
			return false;
		}
	//If youth sizes added make sure youth color is selected
	if (youth_added)
		if (frm.youth_color.value=="") {
			showAddToCartError("Please select a youth color to continue.");
			frm.youth_color.focus();
			return false;
		}
	if (ladies_added)
		if (frm.ladies_color.value=="") {
			showAddToCartError("Please select a ladies color to continue.");
			frm.ladies_color.focus();
			return false;
		}
	return true;
}
// used to validate personalization entry
// used on personalize.asp
function validate_pers(frm) {
	if (frm.P_Font.value=="-1") {
		alert("Please select a font.");
		frm.P_Font.focus();
		return false;
	} else if (frm.P_Location.value=="-1") {
		alert("Please select a location for your personalization.");
		frm.P_Location.focus();
		return false;
	} else if (frm.P_Color.value=="-1") {
		alert("Please select a color for your personalization.");
		frm.P_Color.focus();
		return false;
	} else {
		return validateText(frm);
	}
}

function validate_numb_digit(frm) {
	var nonnumber;
	for (var i=0;i<frm.elements.length;i++) 
		if (frm.elements[i].type=="text" && frm.elements[i].name.substr(0,2)=="nb")
			if (frm.elements[i].value!="") {
				nonnumber=validate_numb_only(frm.elements[i]);
				if (!nonnumber)
					return false;
			}
	return true;
}

// used to validate numbers added to jerseys
// used on add_numbers.asp
function validate_numb(frm) {
	if (frm.N_Color.value=="-1") {
		alert("Please select a color for your numbers.");
		frm.N_Color.focus();
		return false;
	} else {
		return validate_numb_text(frm);
	}
}
//validates at least one number entered and only numbers allowed for validate_numb()
function validate_numb_text(frm) {
	var allBlank=true;
	var nonnumber;
	for (var i=0;i<frm.elements.length;i++) 
		if (frm.elements[i].type=="text")
			if (frm.elements[i].value!="") {
				allBlank=false;
				nonnumber=validate_numb_only(frm.elements[i]);
				if (!nonnumber)
					return false;
			}
	if (allBlank) {
		alert("Please fill in at least one name before hitting the 'add' button.");
		return false;
	} else
		return true;
}
//validates at least one name entered on for validate_pers()
function validateText(frm) {
	var allBlank=true;
	for (var i=0;i<frm.elements.length;i++) 
		if (frm.elements[i].type=="text")
			if (frm.elements[i].value!="")
				allBlank=false;
	if (allBlank) {
		alert("Please fill in at least one name before hitting the 'add' button.");
		return false;
	} else
		return true;
}
// validates form for checkout
// checkout.asp
function write_pdg_cookies()
{
	writeCookie("Type","new_cart",null,"." +  location.hostname,"/");
	var phone_num=document.UserInfo.passPhone.value;
	writeCookie("Orders_Phone",phone_num,null,"." +  location.hostname,"/");
	var PONum=document.UserInfo.passPO.value;
	writeCookie("PO",PONum,null,"." +  location.hostname,"/");
	var Instr=document.UserInfo.Instructions.value;
	writeCookie("Instructions",Instr,null,"." +  location.hostname,"/");
	if (document.UserInfo.shiptores.checked==true)
		writeCookie("ShipToRes","yes",null,"." +  location.hostname,"/");
	else
		writeCookie("ShipToRes","no",null,"." +  location.hostname,"/");
}
function noVerify() {
	ver=false;
	location.replace("http://" +  location.hostname + "/gtm/my_basket.asp");
}
function verify_checkout() {
if (ver) {
		var returnValue=false;
		var radIndex;
		var tempState;
		tempState=document.UserInfo.billstate.value;
	
		//if (document.UserInfo.contactname.value=="")
		//{
			//alert("Please enter a Contact Name.");
			//document.UserInfo.contactname.focus();
			//return false;				
		//}
		//else if (document.UserInfo.contactemail.value=="")
		if (document.UserInfo.contactemail.value=="")
		{
			alert("Please enter a Contact Email.");
			document.UserInfo.contactemail.focus();
			return false;				
		}
		else if (document.UserInfo.passPhone.value=="")
		{
			alert("Please enter a phone number so your rep can contact you if they have questions about your order.");
			document.UserInfo.passPhone.focus();
			return false;				
		}
		else if (document.UserInfo.billfirstname.value=="")
		{
			alert("Please verify the first name for billing.");
			document.UserInfo.billfirstname.focus();
			return false;				
		}
		else if (document.UserInfo.billlastname.value=="")
		{
			alert("Please enter the last name for billing.");
			document.UserInfo.billlastname.focus();
			return false;				
		}
		else if (document.UserInfo.billstreet1.value=="")
		{
			alert("Please enter your billing address.");
			document.UserInfo.billstreet1.focus();
			return false;				
		}
		else if (document.UserInfo.billcity.value=="")
		{
			alert("Please enter your billing city.");
			document.UserInfo.billcity.focus();
			return false;				
		}
		else if (document.UserInfo.billzip.value=="")
		{
			alert("Please enter your billing postal code.");
			document.UserInfo.billzip.focus();
			return false;				
		}
		else if (document.UserInfo.billzip.value.length<5)
		{
			alert("Please enter a valid billing postal code.");
			document.UserInfo.billzip.focus();
			return false;				
		}
		else if (tempState=="0")
		{
			alert("Please select a billing state.");
			document.UserInfo.billstate.focus();
			return false;
		}
		if (document.UserInfo.shiptobilladdr.checked==false) // make sure all ship values are valid
		{
			if (document.UserInfo.shipname.value=="")
			{
				alert("Please enter your shipping name.");
				document.UserInfo.shipname.focus();
				return false;				
			}
			else if (document.UserInfo.shipstreet1.value=="")
			{
				alert("Please enter your shipping street.");
				document.UserInfo.shipstreet1.focus();
				return false;				
			}
			else if (document.UserInfo.shipcity.value=="")
			{
				alert("Please enter your shipping city.");
				document.UserInfo.shipcity.focus();
				return false;				
			}
			else if (document.UserInfo.shipzip.value=="")
			{
				alert("Please enter your shipping postal code.");
				document.UserInfo.shipzip.focus();
				return false;				
			}
		else if (document.UserInfo.shipzip.value.length<5)
		{
			alert("Please enter a valid shipping postal code.");
			document.UserInfo.shipzip.focus();
			return false;				
		}
			else if (document.UserInfo.shipstate.value=="0")
			{
				alert("Please enter your shipping state.");
				document.UserInfo.shipstate.focus();
				return false;				
			}
		}
		else		// write all bill values to ship values
		{
			document.UserInfo.shipname.value=document.UserInfo.billfirstname.value + " " + document.UserInfo.billlastname.value;
			document.UserInfo.shipstreet1.value=document.UserInfo.billstreet1.value
			document.UserInfo.shipstreet2.value=document.UserInfo.billstreet2.value
			document.UserInfo.shipcity.value=document.UserInfo.billcity.value
			document.UserInfo.shipstate.value=document.UserInfo.billstate.value
			document.UserInfo.shipzip.value=document.UserInfo.billzip.value
			document.UserInfo.shipcountry.value=document.UserInfo.billcountry.value
		}
		if (document.UserInfo.billmethod.value==1)
		{
			// ensure po number entered
			if (document.UserInfo.passPO.value=="")
			{	
				alert("Please enter your purchase order number");
				document.UserInfo.passPO.focus();
				return false;
			}
		}
		else
		{
			// ensure cc number entered
			if (document.UserInfo.cardnumber.value=="")
			{
				alert("Please enter your credit card number.")
				document.UserInfo.cardnumber.focus();
				return false;
			}
			else if (document.UserInfo.cardexp.value=="")
			{
				alert("Please enter your credit card expiration date.")
				document.UserInfo.cardexp.focus();
				return false;
			}
		}
		write_pdg_cookies();
		return true;
	} else {
		return true;
	}
}

// End Section 2: Form Verification Scripts ***************************************************************************





// Section 3: Image Preload/Swapping Scripts ***************************************************************************
// ImageReady Preload Script (GTMCheer Shell.psd) -->
function newImage(arg) {
	if (document.images) {
		rslt=new Image();
		rslt.src=arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images) {
		for (var i=0;i<changeImages.arguments.length;i+=2) {
			document[changeImages.arguments[i]].src=changeImages.arguments[i+1];
		}
	}
}
// End Preload Script

//Macromedia image swapping scripts
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.01
  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 && d.getElementById) x=d.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_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];}
		}
	}
}
// my own swap image script
function swapImage(a,b) {
   document.getElementById(a).src=b;
	return false;
}

// End Macromedia image swapping scripts
// End Section 3: Image Preload/Swapping Scripts ***************************************************************************

// Section 4: Basket Scripts ***************************************************************************
// sets cookie for pdg redirect back to checkout??
// End Section 4: Basket Scripts ***************************************************************************

// Section 5: Customize functions
function verify_locs(frm) {
	return true;
}
function verify_create(frm) {
	return true;
}
/* the create function starts the process of adding a design to your product
		-checks the kind of designs you want to add and redirects to the appropriate page */
function create(cat, p_id, i_id) {
	var loc=window.document.placement.location.value;
	if (loc!="0") {
		var cust_link="*";
		if (cat=="min" || cat=="lo") {
			cust_link="cust_layouts.asp?cat=" + cat + "&loc=" + loc + "&p_id=" + p_id + "&i_id=" + i_id;
			location.href=cust_link;
		} else if (cat=="txt") {
			if (loc=="FB" || loc=="FF") {
				alert("Text only designs may not be placed on the Full Front of Full Back of products.");
			} else {
				cust_link="layout_txt.asp?cat=" + cat + "&loc=" + loc + "&p_id=" + p_id + "&i_id=" + i_id + "&id=txtonly&a=bsk&mas_category=-1";
				location.href=cust_link;
			}
		} else if (cat=="mas") {
			if (loc=="FB" || loc=="FF") {
				alert("Mascot/Logo only designs may not be placed on the Full Front of Full Back of products.");
			} else {
				cust_link="layout_mas.asp?cat=" + cat + "&loc=" + loc + "&p_id=" + p_id + "&i_id=" + i_id + "&id=masonly&a=bsk&mas_category=-1";
				location.href=cust_link;
			}
		} else if (cat=="prs") {
			cust_link="personalize.asp?p_id=" + p_id + "&i_id=" + i_id;
			location.href=cust_link;
		}
		//alert(cust_link);
		//location.href=cust_link;
	} else {
		alert("Please select a placement for your design.");
		window.document.placement.location.focus();
	}
}
// opens the mascots window when customizing a layout
// used in layout.asp
function loadMascotsDrop(sel,from) {
	var x=screen.width;
	var y=screen.height;
	var newWidth;
	var newHeight;
	if (x<425)
		newWidth=x-10;
	else
		newWidth=425;
	if (y<500)
		newHeight=y-10;
	else
		newHeight=500;
  	var left=(screen.width-newWidth)/2;			
	var top=(screen.height-newHeight)/2-15;
	if (from=="sel") {
		if (sel.value!="-1") {
			var linkText="http://" + location.hostname + "/gtm/emb_mascots.asp?sel_value=" + cats[sel.value] + "&sel_desc=" + des[sel.value];
			//alert(linkText);
			var winName="Choose_Mascot";
			var newWindow=window.open(linkText,winName,"left=" + left + ",top=" + top + ",resizable=yes,toolbar=no,location=no,width=" + newWidth + ",height=" + newHeight + ",status=yes,scrollbars=yes");
			newWindow.focus();
		}
	} //else
}
// deletes a design from my designs.
function delete_layout(g_id, c_name) {
	var delete_graphic=confirm("Do you wish to delete your custom design named " + c_name + "?");
	if (delete_graphic) {
		location.href="my_designs.asp?del_id=" + g_id;
	}
}
// End Section 5: Customize functions

function set_market(sel) {
		window.document.select_market.submit();
}



/*

   Reloads the parent window and close the popup window

*/

function parentReload() {
	window.opener.location.href=window.opener.location.href;
    window.close();
}

function copyBillingAddress() {
			document.UserInfo.shipname.value=document.UserInfo.billfirstname.value+ " " +document.UserInfo.billlastname.value;
			document.UserInfo.shipstreet1.value=document.UserInfo.billstreet1.value;
			document.UserInfo.shipstreet2.value=document.UserInfo.billstreet2.value;
			document.UserInfo.shipcity.value=document.UserInfo.billcity.value;
			document.UserInfo.shipstate.value=document.UserInfo.billstate.value;
			document.UserInfo.shipzip.value=document.UserInfo.billzip.value;
			document.UserInfo.shipcountry.value=document.UserInfo.billcountry.value;
}

function changeShipMethod() {
	window.document.UserInfo.action="checkout.asp";
	window.document.UserInfo.form_action.value="chg_shipping";
	window.document.UserInfo.submit();
}

//Cookie scripts

function writeCookie(cookieName, cookieValue, days, domain, path, secureFlag) {
	var date=new Date();
	date.setTime(date.getTime()+(days*24*60*60*1000));
	var expires=";expires="+date.toGMTString();
	{
		if (cookieName)
		{
			var cookieDetails=cookieName + "=" + escape(cookieValue);
			cookieDetails += (expires ? ";expires=" + expires: '');
			cookieDetails += (domain ? ";domain=" + domain: '');
			cookieDetails += (path ? ";path=" + path: '');
			cookieDetails += (secureFlag ? ";secure": '');
			document.cookie=cookieDetails;
		}
	}
}
function readUnescapedCookie(cookieName)
{
	var cookieValue=document.cookie;
	var cookieRegExp=new RegExp("\\b" + cookieName + "=([^;]*)");
	cookieValue=cookieRegExp.exec(cookieValue);

	if (cookieValue!=null)
	{
		cookieValue=cookieValue[1];
	}
	return cookieValue;
}
function readCookie(cookieName)
{
	cookieValue=readUnescapedCookie(cookieName);

	if (cookieValue!=null)
	{
		cookieValue=unescape(cookieValue);
	}
	return cookieValue;
}
function deleteCookie(cookieName)
{
	writeCookie(cookieName, "", -100);
	writeCookie(cookieName, "", -100,"." +  location.hostname,"/");
}
function writeMultiValueCookie( cookieName, multiValueName, value, expires, domain, path, secureFlag)
{
	var cookieValue=readUnescapedCookie(cookieName);
	if (cookieValue)
	{	
		var stripAttributeRegExp=new RegExp("(^|&)" + multiValueName + "=[^&]*&?");
		cookieValue=cookieValue.replace(stripAttributeRegExp, "$1");
		if (cookieValue.length!=0)
		{
			cookieValue += "&";
		}
	}
	else
		cookieValue="";

	cookieValue += multiValueName + "=" + escape(value);
	var cookieDetails=cookieName + "=" + cookieValue;
	cookieDetails += (expires ? ";expires=" + expires.toGMTString(): '');
	cookieDetails += (domain ? ";domain=" + domain: '');
	cookieDetails += (path ? ";path=" + path: '');
	cookieDetails += (secureFlag ? ";secure": '');
	document.cookie=cookieDetails;
}
function readMultiValueCookie(cookieName, multiValueName)
{
	var cookieValue=readUnescapedCookie(cookieName);
	var extractMultiValueCookieRegExp=new RegExp("\\b" + multiValueName + "=([^;&]*)");
	cookieValue=extractMultiValueCookieRegExp.exec(cookieValue);

	if (cookieValue!=null)
	{
		cookieValue=unescape(cookieValue[1]);
	}

	return cookieValue;
}
function deleteMultiValueCookie(cookieName, multiValueName, expires, domain, path, secureFlag)
{
	var cookieValue=readUnescapedCookie(cookieName);
	if (cookieValue)
	{
		var stripAttributeRegExp=new RegExp("(^|&)" + multiValueName + "=[^&]*&?");
		cookieValue=cookieValue.replace(stripAttributeRegExp,"$1");
		if (cookieValue.length!=0)
		{
			var cookieDetails=cookieName + "=" + cookieValue;
			cookieDetails += (expires ? ";expires=" + expires.toGMTString(): '');
			cookieDetails += (domain ? ";domain=" + domain: '');
			cookieDetails += (path ? ";path=" + path: '');
			cookieDetails += (secureFlag ? ";secure": '');
			document.cookie=cookieDetails;
		}
		else
		{
			deleteCookie(cookieName)
		}
	}
}
function cookiesEnabled()
{
	var cookiesEnabled=window.navigator.cookieEnabled;

	if (!cookiesEnabled)
	{
		document.cookie="cookiesEnabled=True";
		cookiesEnabled=new Boolean(document.cookie).valueOf();
	}
	return cookiesEnabled;
}
function checkEmail (strng) {
	var emailFilter=/^.+@.+\..{2,3}$/;
	if (!(emailFilter.test(strng)))
		return false;
	else { //test email for illegal characters
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
		if (strng.match(illegalChars))
			return false;
	}
	return true;   
}

/**
 * DHTML phone number validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

// Declaring required variables
var digits="0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters="()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars=phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber=10;

function isInteger(s)
{   var i;
    for (i=0;i<s.length;i++)
    {   
        // Check that current character is number.
        var c=s.charAt(i);
        if (((c<"0") || (c>"9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString="";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i=0;i<s.length;i++)
    {   
        // Check that current character isn't whitespace.
        var c=s.charAt(i);
        if (bag.indexOf(c)==-1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}
 
 /** END
 * DHTML phone number validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */



/* auto flash embed javascripts from dreamweaver */
//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?')!=-1)
    return src.replace(/\?/, ext+'?');
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str='<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret=
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret=
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret=new Object();
  ret.embedAttrs=new Object();
  ret.params=new Object();
  ret.objAttrs=new Object();
  for (var i=0;i<args.length;i=i+2){
    var currArg=args[i].toLowerCase();   

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]]=args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1]=AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"]=args[i+1];
        ret.params[srcParamName]=args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]]=args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]]=ret.objAttrs[args[i]]=args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]]=ret.params[args[i]]=args[i+1];
    }
  }
  ret.objAttrs["classid"]=classid;
  if (mimeType) ret.embedAttrs["type"]=mimeType;
  return ret;
}
//v1.1
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AX_RunContent(){
  var ret=AC_AX_GetArgs(arguments);
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_AX_GetArgs(args){
  var ret=new Object();
  ret.embedAttrs=new Object();
  ret.params=new Object();
  ret.objAttrs=new Object();
  for (var i=0;i<args.length;i=i+2){
    var currArg=args[i].toLowerCase();   

    switch (currArg){	
      case "pluginspage":
      case "type":
      case "src":
        ret.embedAttrs[args[i]]=args[i+1];
        break;
      case "data":
      case "codebase":
      case "classid":
      case "id":
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
        ret.objAttrs[args[i]]=args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]]=ret.objAttrs[args[i]]=args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]]=ret.params[args[i]]=args[i+1];
    }
  }
  return ret;
}
function genBodyLoad() {
	//if (blnPopup) {popupWindow.focus();}
	//sli_init();
	var x;
}
function previewIdeaDesign(id,theme,fkEmbType) {
	var x=screen.width;
	var y=screen.height;
	var newWidth;
	var newHeight;
	if (x<1000)
		newWidth=x-10;
	else
		newWidth=1000;
	if (y<550)
		newHeight=y-10;
	else
		newHeight=500;
	var left=(screen.width-newWidth)/2;			
	var top=(screen.height-newHeight)/2-15;
	if (fkEmbType==1)
		var linkText="http://"+location.hostname+"/gtm/campwear2008/splayout.asp?id="+id+"&theme="+theme;//window.location.hostname
	else
		var linkText="http://"+location.hostname+"/gtm/campwear2008/emblayout.asp?id="+id+"&theme="+theme;
	var winName="previewCA";
	var newWindow=window.open(linkText,winName,"left=" + left + ",top=" + top + ",resizable=yes,toolbar=no,location=no,width=" + newWidth + ",height=" + newHeight + ",status=yes,scrollbars=yes");
	newWindow.focus();
}
// shows created art preview front and back images if they exist
function previewCA(aid) {
	var x=screen.width;
	var y=screen.height;
	var newWidth;
	var newHeight;
	if (x<1000)
		newWidth=x-10;
	else
		newWidth=1000;
	if (y<550)
		newHeight=y-10;
	else
		newHeight=500;
	var left=(screen.width-newWidth)/2;			
	var top=(screen.height-newHeight)/2-15;
	var linkText="http://"+location.host+"/gtm/previewCA.asp?aid="+aid
	var winName="previewCA";
	var newWindow=window.open(linkText,winName,"left=" + left + ",top=" + top + ",resizable=yes,toolbar=no,location=no,width=" + newWidth + ",height=" + newHeight + ",status=yes,scrollbars=yes");
	newWindow.focus();
}


//Section 6: AJAX Functions ***************************************************************************

function ajaxCheckSizeAvailability(fldNamePrefix,frm,txtItemNo,txtCode) {
	var itemNo="";
	if (txtItemNo=='T100G' && txtCode=='WHT')
		itemNo='TW100G'
	else if (txtItemNo=='YT100G' && txtCode=='WHT') 
		itemNo='YTW100G'
	else if (txtItemNo=='LT100G' && txtCode=='WHT') 
		itemNo='LTW100G'
	else
		itemNo=txtItemNo
	var xmlHttp;
	try { // Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e) { // Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				return false;
			}
		}
	}
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			setColorSizeBoxes(fldNamePrefix,frm,xmlHttp.responseText.split(","));// have to call another function to execute rest of script.  can't use return keyword on event handler function
		}
	}
	xmlHttp.open("GET","http://"+location.host+"/gtm/ajaxCheckSizeAvailability.asp?txtItemNo="+itemNo+"&txtCode="+txtCode,true);
	xmlHttp.send(null);
}
function setColorSizeBoxes(fldNamePrefix,frm,sizeArr) {
	var el;
	for (var i=0;i<sizeArr.length;i++) {
		//var el=document.getElementById(fldNamePrefix+i);
		if (sizeArr[i]==0) {
			frm[fldNamePrefix+i].disabled=false;
			frm[fldNamePrefix+i].readonly=false;
			el=document.getElementById(fldNamePrefix+String(i));
			if (el) {el.style.background='#cccccc';el.style.backgroundColor='#cccccc'}
			frm[fldNamePrefix+i].value="0";
			frm[fldNamePrefix+i].readonly=true;
			frm[fldNamePrefix+i].disabled=true;
		} else {
			frm[fldNamePrefix+i].disabled=false;
			frm[fldNamePrefix+i].readonly=false;
			el=document.getElementById(fldNamePrefix+String(i));
			if (el) {el.style.background='#ffffff';el.style.backgroundColor='#ffffff';}
		}
	}
}
function ajaxQrySubTerritories(fk_lngTerritory) {
	var xmlHttp;
	try { // Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e) { // Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				return false;
			}
		}
	}
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			setSubTerritories(xmlHttp.responseText);// have to call another function to execute rest of script.  can't use return keyword on event handler function
		}
	}
	xmlHttp.open("GET","../ajaxQrySubTerritories.asp?t="+fk_lngTerritory);
	xmlHttp.send(null);
}

function setSubTerritories(x) {
	var arrSubTerritories=x.split(":|:");
	var elSel=document.getElementById("selFK_lngSubTerritory");
	for (var i=elSel.length-1;i>=0;i--)
		elSel.remove(i);
	for (i=0;i<arrSubTerritories.length;i++) {
		elSel.options[i]=new Option(arrSubTerritories[i].split(":-:")[1],arrSubTerritories[i].split(":-:")[0]);
		if (arrSubTerritories.length==2) elSel.options[1].selected='1';
	}
	if (arrSubTerritories.length>0) elSel.disabled=false;
}
var timerID=null;
var timerRunning=false;
function writeDate() {
	var months=new  Array(13);
	months[1]="January";
	months[2]="February";
	months[3]="March";
	months[4]="April";
	months[5]="May";
	months[6]="June";
	months[7]="July";
	months[8]="August";
	months[9]="September";
	months[10]="October";
	months[11]="November";
	months[12]="December";
	var time=new Date();
	var lmonth=months[time.getMonth() + 1];
	var date=time.getDate();
	var year=time.getYear();
	if (year < 2000)   
	year=year + 1900;
	return lmonth + " " + date + ", " + year;
}
function showtime ()  {
	var timeValue;
	var now=new Date();
	var hours=now.getHours();
	var minutes=now.getMinutes();
	var seconds=now.getSeconds()
	var timeValue="" + ((hours >12) ? hours -12 :hours)
	if (timeValue == "0") timeValue=12;
	timeValue += ((minutes < 10) ? ":0" : ":") + minutes;
	timeValue += ((seconds < 10) ? ":0" : ":") + seconds;
	timeValue += (hours >= 12) ? " P.M." : " A.M.";
	if (hours==0 && minutes<1){updateDate();}
	return timeValue;
}
function updateClock() {
	stopclock();
	var el=document.getElementById('showTime');
	el.innerHTML=showtime();
	timerID=setTimeout("updateClock()",1000);
}
function updateDate() {
	var el=document.getElementById('showDate');
	el.innerHTML=writeDate();
}
function startClock() {
	stopclock();
	timerID=setTimeout("updateClock()",1000);
}
function stopclock (){
	if(timerRunning)
	clearTimeout(timerID);
	timerRunning=false;
}
function chgcolor(a) {
		document.getElementById(a).style.background = "#a04132";
		document.getElementById(a).style.display = "block"
}

function checkKeyPressed(e) {
	if (window.event)  {
		if (event.keyCode == 34) 
			event.returnValue=false; }
	else {
	if (e.which == 34) 
		e.preventDefault() }
}
function getFormParams(frm) {
	var postText='';
	var amp='';
	for(i=0;i<frm.elements.length;i++){
		if (i>0) amp='&';
		if(frm.elements[i].type=='text' || frm.elements[i].type=='textarea' || frm.elements[i].type=='hidden'){
			postText+=amp+frm.elements[i].name+'='+encodeURIComponent(frm.elements[i].value);
		} else if (frm.elements[i].type=='checkbox') {
			postText+=amp+frm.elements[i].name+'='+frm.elements[i].checked;
		} else if (frm.elements[i].type=='select-one') {
			postText+=amp+frm.elements[i].name+'='+frm.elements[i].options[frm.elements[i].selectedIndex].value;
		}
		amp='&';
		}
	return postText;
}

function loadQS(re) {
	var arr=re.split(':+:');
	var str='';
	for (var z=1;z<arr.length;z++) str+=arr[z].split(':|:')[0]+'='+arr[z].split(':|:')[1]+'&';
	return str
}

function submitenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
   myfield.form.submit();
   return false;
   }
else
   return true;
}
