//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;
}

//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;
}

<!-- Initialize the XMLHttpRequest Object -->

	var xmlhttp=false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.
	 try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }
	 }
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	  xmlhttp = new XMLHttpRequest();
	}
	
<!-- End XMLHttpRequest Initialization -->

function viewInfo(prodID) {

	myurl = "/includes/additional_info_ajax.php?prodid=" + prodID;

	xmlhttp.open("GET", myurl,true);
	xmlhttp.onreadystatechange=function() {
	if (xmlhttp.readyState==4) {

		if ( xmlhttp.responseText == "" ) {
		
		} else {
			
			document.getElementById("extended_info").innerHTML = xmlhttp.responseText;
		
		}					   
	    
	}
	}
	xmlhttp.send(null);

}

<!-- Initialize the XMLHttpRequest Object -->

	var xmlhttp=false;

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	  xmlhttp = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
<!-- End XMLHttpRequest Initialization -->

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=640,height=480,left = 400,top = 210');");
}

function popUpb(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=320,height=200,left = 400,top = 210');");
}

function updateSearch() {

	searchfield = document.searchform.searchfield.value;
	searchlist = document.searchform.searchlist.value;
	domain = document.searchform.domain.value;
	
	searchlength = searchfield.length;
	
	if ( searchlength > 1 ) {
	
		ajaxURL = "/actions/search.php?cat=" + searchlist + "&query=" + searchfield + "&domain=" + domain;
		
		xmlhttp.open("GET", ajaxURL, true);
		xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
	
			if ( xmlhttp.responseText == "" ) {
			
			} else {
				
	    	  ajaxResponse = xmlhttp.responseText;					

			  document.getElementById("display-main").innerHTML = ajaxResponse;

			}					   
		    
		}
		}
		xmlhttp.send(null);
	
	}

}

<!-- Initialize the XMLHttpRequest Object -->

	var xmlhttp=false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.
	 try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }
	 }
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	  xmlhttp = new XMLHttpRequest();
	}
	
<!-- End XMLHttpRequest Initialization -->

function viewReviews(prodID) {

	myurl = "/includes/reviews.php?prodid=" + prodID;

	xmlhttp.open("GET", myurl,true);
	xmlhttp.onreadystatechange=function() {
	if (xmlhttp.readyState==4) {

		if ( xmlhttp.responseText == "" ) {
		
		} else {
			
			document.getElementById("extended_info").innerHTML = xmlhttp.responseText;
		
		}					   
	    
	}
	}
	xmlhttp.send(null);

}

function viewRelated(catID, prodID) {

	myurl = "/includes/related_products.php?catid=" + catID + "&prodid=" + prodID;

	xmlhttp.open("GET", myurl,true);
	xmlhttp.onreadystatechange=function() {
	if (xmlhttp.readyState==4) {

		if ( xmlhttp.responseText == "" ) {
		
		} else {
			
			document.getElementById("extended_info").innerHTML = xmlhttp.responseText;
		
		}					   
	    
	}
	}
	xmlhttp.send(null);

}

function catRollOver(catID) {

	var obj = document.getElementById(catID);
	obj.style.backgroundColor = "#990100";

}

function catRollOut(catID) {

	var obj = document.getElementById(catID);
	obj.style.backgroundColor = "#DFDFDF";

}

function calc() {

	var theForm = document.orderform;
	
	mylength = theForm.elements.length;
	
	mystring = "";
	
	mycounter = 0;
	
	tmpcounter = 0;
	
	while ( mycounter < mylength ) {
	
		mytype = theForm.elements[mycounter].type;
	
		if ( mytype == "select-one" ) {
		
			myname = theForm.elements[mycounter].name;
			myvalue = theForm.elements[mycounter].value;
			
			attr_search = myname.search("attr-");
			
			if ( attr_search == 0 ) {
			
				if ( tmpcounter == 0 ) {
				
					mystring = myname + "," + myvalue;
				
				} else {
				
					mystring = mystring + "zzz" + myname + "," + myvalue;
				
				}
				
				tmpcounter = tmpcounter + 1;

			}
		
		}
		
		mycounter = mycounter + 1;
	
	}
	


	prodid = document.orderform.prodid.value;

	totalquant = document.orderform.myquantity.value;

	if ( tmpcounter > 0 ) {

		ajaxURL = "/actions/pricecalc.php?action=single&prodid=" + prodid + "&totalquant=" + totalquant + "&optionstring=" + mystring;

	} else {

		ajaxURL = "/actions/pricecalc.php?action=single&prodid=" + prodid + "&totalquant=" + totalquant;

	}

	document.orderform.ajaxURL.value = ajaxURL;

	xmlhttp.open("GET", ajaxURL, true);
	xmlhttp.onreadystatechange=function() {
	if (xmlhttp.readyState==4) {

		if ( xmlhttp.responseText == "" ) {
		
		} else {
		
			ajaxResponse = xmlhttp.responseText;

			is_error = ajaxResponse.indexOf('Error');
			
			if ( is_error == -1 ) {

				// There was not an error.

				result_array = ajaxResponse.split('zzz');

				document.getElementById("yourpricediv").innerHTML = result_array[0];
				document.orderform.yourprice.value = result_array[0];
				document.orderform.ppu.value = result_array[1];
				document.orderform.pricecharges.value = result_array[2];
				document.orderform.tq.value = result_array[3];
				document.getElementById("yourpricediv").innerHTML = "";

			} else {

				// There was an error.

				document.getElementById("yourpricediv").innerHTML = ajaxResponse;
				document.orderform.yourprice.value = "";

			}

		}					   
	    
	}
	}
	xmlhttp.send(null);

}

function unisexCalc() {

	var theForm = document.orderform;
	
	mylength = theForm.elements.length;
	
	mystring = "";
	
	mycounter = 0;
	
	tmpcounter = 0;
	
	while ( mycounter < mylength ) {
	
		mytype = theForm.elements[mycounter].type;
	
		if ( mytype == "select-one" ) {
		
			myname = theForm.elements[mycounter].name;
			myvalue = theForm.elements[mycounter].value;
			
			attr_search = myname.search("attr-");
			
			if ( attr_search == 0 ) {
			
				if ( tmpcounter == 0 ) {
				
					mystring = myname + "," + myvalue;
				
				} else {
				
					mystring = mystring + "zzz" + myname + "," + myvalue;
				
				}
				
				tmpcounter = tmpcounter + 1;

			}
		
		}
		
		mycounter = mycounter + 1;
	
	}

	prodid = document.orderform.prodid.value;
	
	totalquant = 0;
	
	if ( document.orderform.unisex_xs ) {
		
		xs = document.orderform.unisex_xs.value;
		
		if ( xs == "" ) {
			xs = 0;
		}
		
		xs = xs * 1;
		
		totalquant = totalquant + xs;
		
	}
	
	if ( document.orderform.unisex_small ) {
		
		small = document.orderform.unisex_small.value;
		
		if ( small == "" ) {
			small = 0;
		}
		
		small = small * 1;
		
		totalquant = totalquant + small;
	
	}
	
	if ( document.orderform.unisex_medium ) {
		
		medium = document.orderform.unisex_medium.value;
		
		if ( medium == "" ) {
			medium = 0;
		}
		
		medium = medium * 1;
		
		totalquant = totalquant + medium;
	
	}
	
	if ( document.orderform.unisex_large ) {
		
		large = document.orderform.unisex_large.value;
		
		if ( large == "" ) {
			large = 0;
		}
		
		large = large * 1;
		
		totalquant = totalquant + large;
	
	}
	
	if ( document.orderform.unisex_xl ) {
		
		xl = document.orderform.unisex_xl.value;
		
		if ( xl == "" ) {
			xl = 0;
		}
		
		xl = xl * 1;
		
		totalquant = totalquant + xl;

	}
	
	if ( document.orderform.unisex_2xl ) {

		xl2 = document.orderform.unisex_2xl.value;
		
		if ( xl2 == "" ) {
			xl2 = 0;
		}
		
		xl2 = xl2 * 1;
		
		totalquant = totalquant + xl2;
	
	}
	
	if ( document.orderform.unisex_3xl ) {
		
		xl3 = document.orderform.unisex_3xl.value;
		
		if ( xl3 == "" ) {
			xl3 = 0;
		}
		
		xl3 = xl3 * 1;
		
		totalquant = totalquant + xl3;
		
	}
	
	if ( document.orderform.unisex_4xl ) {
		
		xl4 = document.orderform.unisex_4xl.value;
		
		if ( xl4 == "" ) {
			xl4 = 0;
		}
		
		xl4 = xl4 * 1;
		
		totalquant = totalquant + xl4;
	
	}
	
	if ( document.orderform.unisex_5xl ) {
		
		xl5 = document.orderform.unisex_5xl.value;
		
		if ( xl5 == "" ) {
			xl5 = 0;
		}
		
		xl5 = xl5 * 1;
		
		totalquant = totalquant + xl5;
	
	}
	
	if ( document.orderform.unisex_6xl ) {
		
		xl6 = document.orderform.unisex_6xl.value;
		
		if ( xl6 == "" ) {
			xl6 = 0;
		}
		
		xl6 = xl6 * 1;
		
		totalquant = totalquant + xl6;
		
	}
	
	if ( typeof(xs) == 'undefined' ) {
		xs = 0;
	}
	
	if ( typeof(small) == 'undefined' ) {
		small = 0;
	}
	
	if ( typeof(medium) == 'undefined' ) {
		medium = 0;
	}
	
	if ( typeof(large) == 'undefined' ) {
		large = 0;
	}
	
	if ( typeof(xl) == 'undefined' ) {
		xl = 0;
	}
	
	if ( typeof(xl2) == 'undefined' ) {
		xl2 = 0;
	}
	
	if ( typeof(xl3) == 'undefined' ) {
		xl3 = 0;
	}
	
	if ( typeof(xl4) == 'undefined' ) {
		xl4 = 0;
	}
	
	if ( typeof(xl5) == 'undefined' ) {
		xl5 = 0;
	}
	
	if ( typeof(xl6) == 'undefined' ) {
		xl6 = 0;
	}

	if ( tmpcounter > 0 ) {
	
	ajaxURL = "/actions/pricecalc.php?action=unisex&prodid=" + prodid + "&xs=" + xs + "&small=" + small + "&medium=" + medium + "&large=" + large + "&xl=" + xl + "&xl2=" + xl2 + "&xl3=" + xl3 + "&xl4=" + xl4 + "&xl5=" + xl5 + "&xl6=" + xl6 + "&totalquant=" + totalquant + "&optionstring=" + mystring;
	
	} else {
	
	ajaxURL = "/actions/pricecalc.php?action=unisex&prodid=" + prodid + "&xs=" + xs + "&small=" + small + "&medium=" + medium + "&large=" + large + "&xl=" + xl + "&xl2=" + xl2 + "&xl3=" + xl3 + "&xl4=" + xl4 + "&xl5=" + xl5 + "&xl6=" + xl6 + "&totalquant=" + totalquant;
	
	}

	document.orderform.ajaxURL.value = ajaxURL;

	xmlhttp.open("GET", ajaxURL, true);
	xmlhttp.onreadystatechange=function() {
	if (xmlhttp.readyState==4) {

		if ( xmlhttp.responseText == "" ) {
		
		} else {
		
			ajaxResponse = xmlhttp.responseText;

			is_error = ajaxResponse.indexOf('Error');
			
			if ( is_error == -1 ) {

				// There was not an error.

				result_array = ajaxResponse.split('zzz');

				document.orderform.yourprice.value = result_array[0];
				document.getElementById("yourpricediv").innerHTML = result_array[0];

			} else {

				// There was an error.

				document.getElementById("yourpricediv").innerHTML = ajaxResponse;
				document.orderform.yourprice.value = "";

			}

		}					   
	    
	}
	}
	xmlhttp.send(null);
	
}

function womensCalc() {

	var theForm = document.orderform;
	
	mylength = theForm.elements.length;
	
	mystring = "";
	
	mycounter = 0;
	
	tmpcounter = 0;
	
	while ( mycounter < mylength ) {
	
		mytype = theForm.elements[mycounter].type;
	
		if ( mytype == "select-one" ) {
		
			myname = theForm.elements[mycounter].name;
			myvalue = theForm.elements[mycounter].value;
			
			attr_search = myname.search("attr-");
			
			if ( attr_search == 0 ) {
			
				if ( tmpcounter == 0 ) {
				
					mystring = myname + "," + myvalue;
				
				} else {
				
					mystring = mystring + "zzz" + myname + "," + myvalue;
				
				}
				
				tmpcounter = tmpcounter + 1;

			}
		
		}
		
		mycounter = mycounter + 1;
	
	}

	prodid = document.orderform.prodid.value;
	
	totalquant = 0;
	
	if ( document.orderform.womens_xs ) {
		
		xs = document.orderform.womens_xs.value;
		
		if ( xs == "" ) {
			xs = 0;
		}
		
		xs = xs * 1;
		
		totalquant = totalquant + xs;
		
	}
	
	if ( document.orderform.womens_small ) {
		
		small = document.orderform.womens_small.value;
		
		if ( small == "" ) {
			small = 0;
		}
		
		small = small * 1;
		
		totalquant = totalquant + small;
	
	}
	
	if ( document.orderform.womens_medium ) {
		
		medium = document.orderform.womens_medium.value;
		
		if ( medium == "" ) {
			medium = 0;
		}
		
		medium = medium * 1;
		
		totalquant = totalquant + medium;
	
	}
	
	if ( document.orderform.womens_large ) {
		
		large = document.orderform.womens_large.value;
		
		if ( large == "" ) {
			large = 0;
		}
		
		large = large * 1;
		
		totalquant = totalquant + large;
	
	}
	
	if ( document.orderform.womens_xl ) {
		
		xl = document.orderform.womens_xl.value;
		
		if ( xl == "" ) {
			xl = 0;
		}
		
		xl = xl * 1;
		
		totalquant = totalquant + xl;

	}
	
	if ( document.orderform.womens_2xl ) {

		xl2 = document.orderform.womens_2xl.value;
		
		if ( xl2 == "" ) {
			xl2 = 0;
		}
		
		xl2 = xl2 * 1;
		
		totalquant = totalquant + xl2;
	
	}
	
	if ( document.orderform.womens_1xplus ) {
		
		xplus1 = document.orderform.womens_1xplus.value;
		
		if ( xplus1 == "" ) {
			xplus1 = 0;
		}
		
		xplus1 = xplus1 * 1;
		
		totalquant = totalquant + xplus1;
		
	}

	if ( document.orderform.womens_2xplus ) {
		
		xplus2 = document.orderform.womens_2xplus.value;
		
		if ( xplus2 == "" ) {
			xplus2 = 0;
		}
		
		xplus2 = xplus2 * 1;
		
		totalquant = totalquant + xplus2;
		
	}
	
	if ( typeof(xs) == 'undefined' ) {
		xs = 0;
	}
	
	if ( typeof(small) == 'undefined' ) {
		small = 0;
	}
	
	if ( typeof(medium) == 'undefined' ) {
		medium = 0;
	}
	
	if ( typeof(large) == 'undefined' ) {
		large = 0;
	}
	
	if ( typeof(xl) == 'undefined' ) {
		xl = 0;
	}
	
	if ( typeof(xl2) == 'undefined' ) {
		xl2 = 0;
	}
	
	if ( typeof(xplus1) == 'undefined' ) {
		xplus1 = 0;
	}
	
	if ( typeof(xplus2) == 'undefined' ) {
		xplus2 = 0;
	}
	
	if ( tmpcounter > 0 ) {
	
	ajaxURL = "/actions/pricecalc.php?action=womens&prodid=" + prodid + "&xs=" + xs + "&small=" + small + "&medium=" + medium + "&large=" + large + "&xl=" + xl + "&xl2=" + xl2 + "&xplus1=" + xplus1 + "&xplus2=" + xplus2 + "&totalquant=" + totalquant + "&optionstring=" + mystring;
	
	} else {
	
	ajaxURL = "/actions/pricecalc.php?action=womens&prodid=" + prodid + "&xs=" + xs + "&small=" + small + "&medium=" + medium + "&large=" + large + "&xl=" + xl + "&xl2=" + xl2 + "&xplus1=" + xplus1 + "&xplus2=" + xplus2 + "&totalquant=" + totalquant;
	
	}
	
	document.orderform.ajaxURL.value = ajaxURL;

	xmlhttp.open("GET", ajaxURL, true);
	xmlhttp.onreadystatechange=function() {
	if (xmlhttp.readyState==4) {

		if ( xmlhttp.responseText == "" ) {
		
		} else {
		
			ajaxResponse = xmlhttp.responseText;

			is_error = ajaxResponse.indexOf('Error');
			
			if ( is_error == -1 ) {

				// There was not an error.

				result_array = ajaxResponse.split('zzz');

				document.orderform.yourprice.value = result_array[0];
				document.getElementById("yourpricediv").innerHTML = result_array[0];

			} else {

				// There was an error.

				document.getElementById("yourpricediv").innerHTML = ajaxResponse;
				document.orderform.yourprice.value = "";

			}

		}					   
	    
	}
	}
	xmlhttp.send(null);

}

function youth1Calc() {

	var theForm = document.orderform;
	
	mylength = theForm.elements.length;
	
	mystring = "";
	
	mycounter = 0;
	
	tmpcounter = 0;
	
	while ( mycounter < mylength ) {
	
		mytype = theForm.elements[mycounter].type;
	
		if ( mytype == "select-one" ) {
		
			myname = theForm.elements[mycounter].name;
			myvalue = theForm.elements[mycounter].value;
			
			attr_search = myname.search("attr-");
			
			if ( attr_search == 0 ) {
			
				if ( tmpcounter == 0 ) {
				
					mystring = myname + "," + myvalue;
				
				} else {
				
					mystring = mystring + "zzz" + myname + "," + myvalue;
				
				}
				
				tmpcounter = tmpcounter + 1;

			}
		
		}
		
		mycounter = mycounter + 1;
	
	}

	prodid = document.orderform.prodid.value;
	
	totalquant = 0;
	
	if ( document.orderform.youth1_xs ) {
		
		xs = document.orderform.youth1_xs.value;
		
		if ( xs == "" ) {
			xs = 0;
		}
		
		xs = xs * 1;
		
		totalquant = totalquant + xs;
		
	}
	
	if ( document.orderform.youth1_small ) {
		
		small = document.orderform.youth1_small.value;
		
		if ( small == "" ) {
			small = 0;
		}
		
		small = small * 1;
		
		totalquant = totalquant + small;
	
	}
	
	if ( document.orderform.youth1_medium ) {
		
		medium = document.orderform.youth1_medium.value;
		
		if ( medium == "" ) {
			medium = 0;
		}
		
		medium = medium * 1;
		
		totalquant = totalquant + medium;
	
	}
	
	if ( document.orderform.youth1_large ) {
		
		large = document.orderform.youth1_large.value;
		
		if ( large == "" ) {
			large = 0;
		}
		
		large = large * 1;
		
		totalquant = totalquant + large;
	
	}
	
	if ( document.orderform.youth1_xl ) {
		
		xl = document.orderform.youth1_xl.value;
		
		if ( xl == "" ) {
			xl = 0;
		}
		
		xl = xl * 1;
		
		totalquant = totalquant + xl;

	}
	
	if ( typeof(xs) == 'undefined' ) {
		xs = 0;
	}
	
	if ( typeof(small) == 'undefined' ) {
		small = 0;
	}
	
	if ( typeof(medium) == 'undefined' ) {
		medium = 0;
	}
	
	if ( typeof(large) == 'undefined' ) {
		large = 0;
	}
	
	if ( typeof(xl) == 'undefined' ) {
		xl = 0;
	}
	
	if ( tmpcounter > 0 ) {
	
	ajaxURL = "/actions/pricecalc.php?action=unisex&prodid=" + prodid + "&xs=" + xs + "&small=" + small + "&medium=" + medium + "&large=" + large + "&xl=" + xl + "&totalquant=" + totalquant + "&optionstring=" + mystring;
	
	} else {
	
	ajaxURL = "/actions/pricecalc.php?action=unisex&prodid=" + prodid + "&xs=" + xs + "&small=" + small + "&medium=" + medium + "&large=" + large + "&xl=" + xl + "&totalquant=" + totalquant;
	
	}
	
	document.orderform.ajaxURL.value = ajaxURL;

	xmlhttp.open("GET", ajaxURL, true);
	xmlhttp.onreadystatechange=function() {
	if (xmlhttp.readyState==4) {

		if ( xmlhttp.responseText == "" ) {
		
		} else {
		
			ajaxResponse = xmlhttp.responseText;

			is_error = ajaxResponse.indexOf('Error');
			
			if ( is_error == -1 ) {

				// There was not an error.

				result_array = ajaxResponse.split('zzz');

				document.orderform.yourprice.value = result_array[0];
				document.orderform.ppu.value = result_array[1];
				document.orderform.pricecharges.value = result_array[2];
				document.orderform.tq.value = result_array[3];
				document.getElementById("yourpricediv").innerHTML = "";

			} else {

				// There was an error.

				document.getElementById("yourpricediv").innerHTML = ajaxResponse;
				document.orderform.yourprice.value = "";

			}

		}					   
	    
	}
	}
	xmlhttp.send(null);

}

function youth2Calc() {

	var theForm = document.orderform;
	
	mylength = theForm.elements.length;
	
	mystring = "";
	
	mycounter = 0;
	
	tmpcounter = 0;
	
	while ( mycounter < mylength ) {
	
		mytype = theForm.elements[mycounter].type;
	
		if ( mytype == "select-one" ) {
		
			myname = theForm.elements[mycounter].name;
			myvalue = theForm.elements[mycounter].value;
			
			attr_search = myname.search("attr-");
			
			if ( attr_search == 0 ) {
			
				if ( tmpcounter == 0 ) {
				
					mystring = myname + "," + myvalue;
				
				} else {
				
					mystring = mystring + "zzz" + myname + "," + myvalue;
				
				}
				
				tmpcounter = tmpcounter + 1;

			}
		
		}
		
		mycounter = mycounter + 1;
	
	}

	prodid = document.orderform.prodid.value;
	
	totalquant = 0;
	
	if ( document.orderform.youth2_xs ) {
		
		xs = document.orderform.youth2_xs.value;
		
		if ( xs == "" ) {
			xs = 0;
		}
		
		xs = xs * 1;
		
		totalquant = totalquant + xs;
		
	}
	
	if ( document.orderform.youth2_small ) {
		
		small = document.orderform.youth2_small.value;
		
		if ( small == "" ) {
			small = 0;
		}
		
		small = small * 1;
		
		totalquant = totalquant + small;
	
	}
	
	if ( document.orderform.youth2_medium ) {
		
		medium = document.orderform.youth2_medium.value;
		
		if ( medium == "" ) {
			medium = 0;
		}
		
		medium = medium * 1;
		
		totalquant = totalquant + medium;
	
	}
	
	if ( document.orderform.youth2_large ) {
		
		large = document.orderform.youth2_large.value;
		
		if ( large == "" ) {
			large = 0;
		}
		
		large = large * 1;
		
		totalquant = totalquant + large;
	
	}
	
	if ( document.orderform.youth2_xl ) {
		
		xl = document.orderform.youth2_xl.value;
		
		if ( xl == "" ) {
			xl = 0;
		}
		
		xl = xl * 1;
		
		totalquant = totalquant + xl;

	}
	
	if ( typeof(xs) == 'undefined' ) {
		xs = 0;
	}
	
	if ( typeof(small) == 'undefined' ) {
		small = 0;
	}
	
	if ( typeof(medium) == 'undefined' ) {
		medium = 0;
	}
	
	if ( typeof(large) == 'undefined' ) {
		large = 0;
	}
	
	if ( typeof(xl) == 'undefined' ) {
		xl = 0;
	}
	
	if ( tmpcounter > 0 ) {
	
	ajaxURL = "/actions/pricecalc.php?action=unisex&prodid=" + prodid + "&xs=" + xs + "&small=" + small + "&medium=" + medium + "&large=" + large + "&xl=" + xl + "&totalquant=" + totalquant + "&optionstring=" + mystring;
	
	} else {
	
	ajaxURL = "/actions/pricecalc.php?action=unisex&prodid=" + prodid + "&xs=" + xs + "&small=" + small + "&medium=" + medium + "&large=" + large + "&xl=" + xl + "&totalquant=" + totalquant;
	
	}
	
	document.orderform.ajaxURL.value = ajaxURL;

	xmlhttp.open("GET", ajaxURL, true);
	xmlhttp.onreadystatechange=function() {
	if (xmlhttp.readyState==4) {

		if ( xmlhttp.responseText == "" ) {
		
		} else {
		
			ajaxResponse = xmlhttp.responseText;

			is_error = ajaxResponse.indexOf('Error');
			
			if ( is_error == -1 ) {

				// There was not an error.

				result_array = ajaxResponse.split('zzz');

				yourprice = result_array[0];
				yourprice = yourprice.replace("$", "");
				document.orderform.yourprice.value = yourprice;
				document.orderform.ppu.value = result_array[1];
				document.orderform.pricecharges.value = result_array[2];
				document.orderform.tq.value = result_array[3];
				document.getElementById("yourpricediv").innerHTML = "";

			} else {

				// There was an error.

				document.getElementById("yourpricediv").innerHTML = ajaxResponse;
				document.orderform.yourprice.value = "";

			}

		}					   
	    
	}
	}
	xmlhttp.send(null);

}

function addCart() {

	yourprice = document.orderform.yourprice.value;
	
	yourprice = yourprice.replace("$", "");
	
	ajaxURL = document.orderform.ajaxURL.value;

	if ( yourprice != "" && yourprice != "0" && yourprice != "0.00" ) {
	
		// The user has generated a valid price. This item can be added to the cart.
		
		document.orderform.submit();
	
	} else {
	
		// The user has not generated a valid price.
		
		document.getElementById("yourpricediv").innerHTML = "<b><span style='color: red;'>Error:</span></b> Please calculate a price for this product before adding it to your cart.";
	
	}

}

addEvent(window, "load", sortables_init);

var SORT_COLUMN_INDEX;

function sortables_init() {
    // Find all tables with class sortable and make them sortable
    if (!document.getElementsByTagName) return;
    tbls = document.getElementsByTagName("table");
    for (ti=0;ti<tbls.length;ti++) {
        thisTbl = tbls[ti];
        if (((' '+thisTbl.className+' ').indexOf("sortable") != -1) && (thisTbl.id)) {
            //initTable(thisTbl.id);
            ts_makeSortable(thisTbl);
        }
    }
}

function ts_makeSortable(table) {
    if (table.rows && table.rows.length > 0) {
        var firstRow = table.rows[0];
    }
    if (!firstRow) return;
    
    // We have a first row: assume it's the header, and make its contents clickable links
    for (var i=0;i<firstRow.cells.length;i++) {
        var cell = firstRow.cells[i];
        var txt = ts_getInnerText(cell);
        cell.innerHTML = '<a href="#" class="sortheader" '+ 
        'onclick="ts_resortTable(this, '+i+');return false;">' + 
        txt+'<span class="sortarrow">&nbsp;&nbsp;&nbsp;</span></a>';
    }
}

function ts_getInnerText(el) {
	if (typeof el == "string") return el;
	if (typeof el == "undefined") { return el };
	if (el.innerText) return el.innerText;	//Not needed but it is faster
	var str = "";
	
	var cs = el.childNodes;
	var l = cs.length;
	for (var i = 0; i < l; i++) {
		switch (cs[i].nodeType) {
			case 1: //ELEMENT_NODE
				str += ts_getInnerText(cs[i]);
				break;
			case 3:	//TEXT_NODE
				str += cs[i].nodeValue;
				break;
		}
	}
	return str;
}

function ts_resortTable(lnk,clid) {
    // get the span
    var span;
    for (var ci=0;ci<lnk.childNodes.length;ci++) {
        if (lnk.childNodes[ci].tagName && lnk.childNodes[ci].tagName.toLowerCase() == 'span') span = lnk.childNodes[ci];
    }
    var spantext = ts_getInnerText(span);
    var td = lnk.parentNode;
    var column = clid || td.cellIndex;
    var table = getParent(td,'TABLE');
    
    // Work out a type for the column
    if (table.rows.length <= 1) return;
    var itm = ts_getInnerText(table.rows[1].cells[column]);
    sortfn = ts_sort_caseinsensitive;
    if (itm.match(/^\d\d[\/-]\d\d[\/-]\d\d\d\d$/)) sortfn = ts_sort_date;
    if (itm.match(/^\d\d[\/-]\d\d[\/-]\d\d$/)) sortfn = ts_sort_date;
    if (itm.match(/^[£$]/)) sortfn = ts_sort_currency;
    if (itm.match(/^[\d\.]+$/)) sortfn = ts_sort_numeric;
    SORT_COLUMN_INDEX = column;
    var firstRow = new Array();
    var newRows = new Array();
    for (i=0;i<table.rows[0].length;i++) { firstRow[i] = table.rows[0][i]; }
    for (j=1;j<table.rows.length;j++) { newRows[j-1] = table.rows[j]; }

    newRows.sort(sortfn);

    if (span.getAttribute("sortdir") == 'down') {
        ARROW = '&nbsp;&nbsp;&uarr;';
        newRows.reverse();
        span.setAttribute('sortdir','up');
    } else {
        ARROW = '&nbsp;&nbsp;&darr;';
        span.setAttribute('sortdir','down');
    }
    
    // We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones
    // don't do sortbottom rows
    for (i=0;i<newRows.length;i++) { if (!newRows[i].className || (newRows[i].className && (newRows[i].className.indexOf('sortbottom') == -1))) table.tBodies[0].appendChild(newRows[i]);}
    // do sortbottom rows only
    for (i=0;i<newRows.length;i++) { if (newRows[i].className && (newRows[i].className.indexOf('sortbottom') != -1)) table.tBodies[0].appendChild(newRows[i]);}
    
    // Delete any other arrows there may be showing
    var allspans = document.getElementsByTagName("span");
    for (var ci=0;ci<allspans.length;ci++) {
        if (allspans[ci].className == 'sortarrow') {
            if (getParent(allspans[ci],"table") == getParent(lnk,"table")) { // in the same table as us?
                allspans[ci].innerHTML = '&nbsp;&nbsp;&nbsp;';
            }
        }
    }
        
    span.innerHTML = ARROW;
}

function getParent(el, pTagName) {
	if (el == null) return null;
	else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase())	// Gecko bug, supposed to be uppercase
		return el;
	else
		return getParent(el.parentNode, pTagName);
}
function ts_sort_date(a,b) {
    // y2k notes: two digit years less than 50 are treated as 20XX, greater than 50 are treated as 19XX
    aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
    bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
    if (aa.length == 10) {
        dt1 = aa.substr(6,4)+aa.substr(3,2)+aa.substr(0,2);
    } else {
        yr = aa.substr(6,2);
        if (parseInt(yr) < 50) { yr = '20'+yr; } else { yr = '19'+yr; }
        dt1 = yr+aa.substr(3,2)+aa.substr(0,2);
    }
    if (bb.length == 10) {
        dt2 = bb.substr(6,4)+bb.substr(3,2)+bb.substr(0,2);
    } else {
        yr = bb.substr(6,2);
        if (parseInt(yr) < 50) { yr = '20'+yr; } else { yr = '19'+yr; }
        dt2 = yr+bb.substr(3,2)+bb.substr(0,2);
    }
    if (dt1==dt2) return 0;
    if (dt1<dt2) return -1;
    return 1;
}

function ts_sort_currency(a,b) { 
    aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g,'');
    bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g,'');
    return parseFloat(aa) - parseFloat(bb);
}

function ts_sort_numeric(a,b) { 
    aa = parseFloat(ts_getInnerText(a.cells[SORT_COLUMN_INDEX]));
    if (isNaN(aa)) aa = 0;
    bb = parseFloat(ts_getInnerText(b.cells[SORT_COLUMN_INDEX])); 
    if (isNaN(bb)) bb = 0;
    return aa-bb;
}

function ts_sort_caseinsensitive(a,b) {
    aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).toLowerCase();
    bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).toLowerCase();
    if (aa==bb) return 0;
    if (aa<bb) return -1;
    return 1;
}

function ts_sort_default(a,b) {
    aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
    bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
    if (aa==bb) return 0;
    if (aa<bb) return -1;
    return 1;
}


function addEvent(elm, evType, fn, useCapture)
// addEvent and removeEvent
// cross-browser event handling for IE5+,  NS6 and Mozilla
// By Scott Andrew
{
  if (elm.addEventListener){
    elm.addEventListener(evType, fn, useCapture);
    return true;
  } else if (elm.attachEvent){
    var r = elm.attachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be removed");
  }
}