var N   = (document.layers) ? true:false;                 // netscape 4
var I   = (document.all) ? true:false;                    // ie4+
var N6 = ((document.getElementById)&&(!I))?true:false;   // ns6 etc.
var go = (document.getElementById)?true:false;

function imprintInfo(type) {
	var fc=	document.frmQuote.front_colors;
	var bc= document.frmQuote.back_colors;
	fc.value= "";
	fc.length = 0;
	bc.value= "";
	bc.length = 0;
	var x=0;
  if (type == "screen") {
	fc.options[x] = new Option("Select # of colors", "");
	bc.options[x++] = new Option("Select # of colors", "");
	fc.options[x] = new Option("None - No Front Imprint","None");
	bc.options[x++] = new Option("None - No Back Imprint","Nsone");
	for (x; x<=9; x++){
		bc.options[x] = new Option(x-1 + " color\(s\)", x-1);
		fc.options[x] = new Option(x-1 + " color\(s\)", x-1);
	}
	fc.options[x] = new Option("4 Color Process","4 Color Process");
	bc.options[x++] = new Option("4 Color Process","4 Color Process");
	fc.options[x] = new Option("Simulated Process on Black","Simulated Process on Black");
	bc.options[x] = new Option("Simulated Process on Black","Simulated Process on Black");
  }
  if (type == "trans" ) {
	bc.options[0] = new Option("Select imprint type", "");
	bc.options[1] = new Option("None - No Back Imprint", "None - No Back Imprint");
	bc.options[2] = new Option("Full Color Transfer", "Full Color Transfer");
	fc.options[0] = new Option("Select imprint type", "");
	fc.options[1] = new Option("None - No Front Imprint", "None - No Front Imprint");
	fc.options[2] = new Option("Full Color Transfer", "Full Color Transfer");
  }
  if (type == "emb"){
	bc.options[0] = new Option("Select imprint type", "");
	bc.options[1] = new Option("None - No Back Imprint", "None - No Back Imprint");
	bc.options[2] = new Option("Emb. Text Only", "Emb. Text Only");
	bc.options[3] = new Option("Emb. Logo", "Emb. Logo");
	fc.options[0] = new Option("Select imprint type", "");
	fc.options[1] = new Option("None - No Front Imprint", "None - No Front Imprint");
	fc.options[2] = new Option("Emb. Text Only", "Emb. Text Only");
	fc.options[3] = new Option("Emb. Logo", "Emb. Logo");
  }
	//document.frmQuote.brands.options[x+1] = new Option(brand[styleId], styleId);
}
function fillStyle() {
	var cat = document.frmQuote.category.options[document.frmQuote.category.selectedIndex].value;
	var st=	document.frmQuote.garment_style;
	st.value= "";
	st.length = 0;
	if (cat == "SportShirt" || cat== "Outerwear" ) {
		st.options[0] = new Option("Please enter a catalog number or Explain your item","NA");
	}
	if (cat=="T-shirt"){
		var x = 0;
		st.options[x++] = new Option("100% Cotton Heavyweight 6oz+ Tee","100% Cotton Heavyweight 6oz+ Tee");
		st.options[x++] = new Option("100% Cotton Midweight 5.6oz Tee","100% Cotton Midweight 5.6oz Tee");
		st.options[x++] = new Option("50/50 Midweight 5.6oz Tee","50/50 Midweight 5.6oz Tee");
		st.options[x++] = new Option("100% Cotton Long Sleeve Tee","100% Cotton Long Sleeve Tee");
		st.options[x++] = new Option("50/50 Long Sleeve Tee","50/50 Long Sleeve Tee");
		st.options[x++] = new Option("3 Button Henley Long Sleeve","3 Button Henley Long Sleeve");
		st.options[x++] = new Option("3 Button Henley Shortsleeve","3 Button Henley Shortsleeve");
		st.options[x++] = new Option("\"Ringer\" Tee","Ringer Tee");
		st.options[x++] = new Option("3/4 Sleeve Tee (Baseball Tee)","3/4 Sleeve Tee (Baseball Tee)");
		st.options[x++] = new Option("Sleeveless Tee","Sleeveless Tee");
		st.options[x++] = new Option("Ladies Babydoll Tee","Ladies Babydoll Tee");
		st.options[x++] = new Option("Other - Please Explain","Other");
	}
	if (cat=="Sweatshirt"){
		var x = 0;
		st.options[x++] = new Option("100% Cotton Superweight 11oz+ Sweat","100% Cotton Superweight 11oz+ Sweat");
		st.options[x++] = new Option("100% Cotton Midweight 9oz Sweat","100% Cotton Midweight 9oz Sweat");
		st.options[x++] = new Option("50/50 Midweight 9oz Sweat","50/50 Midweight 9oz Sweat");
		st.options[x++] = new Option("50/50 Lightweight 7.5oz Sweat","50/50 Lightweight 7.5oz Sweat");
		st.options[x++] = new Option("Superweight Hooded Pullover","Superweight Hooded Pullover");
		st.options[x++] = new Option("Midweight Hooded Pullover","Midweight Hooded Pullover");
		st.options[x++] = new Option("Lightweight Hooded Pullover","Lightweight Hooded Pullover");
		st.options[x++] = new Option("Other - Please Explain","Other");
	}
	if (cat=="Athletic"){
		var x = 0;
		st.options[x++] = new Option("Basketball Jersey MicroMesh","Basketball Jersey MicroMesh");
		st.options[x++] = new Option("Basketball Jersey Reverseable MicroMesh","Basketball Jersey Reverseable MicroMesh");
		st.options[x++] = new Option("Baseball Jersey - 2 button","Baseball Jersey - 2 button");
		st.options[x++] = new Option("Baseball Jersey - Full Button*","Baseball Jersey - Full Button");
		st.options[x++] = new Option("Baseball 3/4 Sleeve Undershirt","Baseball 3/4 Sleeve Undershirt");
		st.options[x++] = new Option("Hockey/Lacross Jersey*","Hockey/Lacross Jersey");
		st.options[x++] = new Option("Football Practice Jersey MicroMesh*","Football Practice Jersey MicroMesh");
		st.options[x++] = new Option("Football Game Jersey MicroMesh*","Football Game Jersey MicroMesh");
		st.options[x++] = new Option("Soccer Jersey*","Soccer Jersey*");
		st.options[x++] = new Option("Shorts/Pants - Please Explain*","Shorts/Pants - Please Explain");
		st.options[x++] = new Option("Other - Please Explain","Other");
	}	
	if (cat=="Hat"){
		var x = 0;
		st.options[x++] = new Option("Wool 6 Pannel Fitted","Wool 6 Pannel Fitted");
		st.options[x++] = new Option("Unconstructed 6 Pannel*","Unconstructed 6 Pannel");
		st.options[x++] = new Option("6 Pannel Pro Style*","6 Pannel Pro Style");
		st.options[x++] = new Option("5 Pannel Golf","5 Pannel Golf");
		st.options[x++] = new Option("Other - Please Explain","Other");
	}
	if (cat=="Bag"){
		var x = 0;
		st.options[x++] = new Option("Totebag*","Totebage");
		st.options[x++] = new Option("Duffel*","Duffel");
		st.options[x++] = new Option("\"Bat\" Bag*","Bat Bag");
		st.options[x++] = new Option("Other - Please Explain","Other");
	}
	if (cat=="Denim_Dress"){
		var x = 0;
		st.options[x++] = new Option("Long Sleeve Denim Shirt","Long Sleeve Denim Shirt");
		st.options[x++] = new Option("Short Sleeve Denim","Short Sleeve Denim");
		st.options[x++] = new Option("Long Sleeve Chambray","Long Sleeve Chambray");
		st.options[x++] = new Option("Long Sleeve Oxford","Long Sleeve Oxford");
		st.options[x++] = new Option("Other - Please Explain","Other");
	}	
}
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 tmt_regExpValidator(f,re,eMsg,ru,r){
	var myErr="";var fv=MM_findObj(f).value;var rex=new RegExp(unescape(re));
	var t=eval(ru+rex.test(fv));if(r){if(fv.length<=0||!t){alert(unescape(eMsg));myErr+="eMsg";}}
	else if(fv.length>0&&!t){alert(unescape(eMsg));myErr+="eMsg";}document.MM_returnValue=(myErr=="");
}

	function isEmpty(s) { 
	return ((s == null) || (s.length == 0)) 
}

/****************************************************************/

function isWhitespace (s) {
	var i;

	// Is s empty?
	if (isEmpty(s)) return true;

	// Search through string's characters one by one
	// until we find a non-whitespace character.
	// When we do, return false; if we don't, return true.

	for (i = 0; i < s.length; i++)
	{
		// Check that current character isn't whitespace.
		//var c = s.charAt(i);
		var c = s.charCodeAt(i);

		//if (whitespace.indexOf(c) == -1) return false;
		if(c != 32) return false;
	}

	// All characters are whitespace.
	return true;
}



function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // getStyleObject
 
function hideshowDiv(DivID) {	
	var objDiv = getStyleObject(DivID)
	if (objDiv.display == 'none'){
		getStyleObject(DivID).display = '';
	}else{
		getStyleObject(DivID).display = 'none';
	}
	
}
function hideDiv(DivID){getStyleObject(DivID).display = 'none';}


 function ChkFields(){
  //change this to the form name
  var frmFields = document.frmQuote
  var i
  var strMessage
  var strTemp

  for (i = 0; i < frmFields.elements.length; i++){
       strTemp =frmFields.elements[i].id
       strTemp = strTemp.slice(0,1)

            if (strTemp == 'r' || strTemp == 'e'){
				 if (strTemp == 'r'){
					 if (isWhitespace(frmFields.elements[i].value)){
					    strMessage = frmFields.elements[i].id
					    strMessage = strMessage.slice(1,strMessage.length);
						alert(strMessage);
						frmFields.elements[i].focus();
						return false;
		
						 }
				}else{
					if (isNotValidEmail(frmFields.elements[i].value)){
				    strMessage = frmFields.elements[i].id
					strMessage = strMessage.slice(1,strMessage.length);
					alert(strMessage);
					frmFields.elements[i].focus();
					return false;
					
					
					
					}
				}
           }
 }

return true;
 }
 
 function isNotValidEmail(src) {

	var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
  		
	// var str = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
	// var reg = new RegExp(str);

	if (isWhitespace(src))
	  return true;
	else {

		if (src.toLowerCase() == "none".toLowerCase()) 
		  return false;
		else {

			if (!reg1.test(src) && reg2.test(src))
			  return false;
			else
			  return true;
		}

	}
}
 

//-- end -->
