function toggleT(_w,_h,oInnerHTML) {
	var oSpan;
	if (document.all) { // is IE
		oSpan = eval("document.all."+_w);
		if (_h=='s')
		{
			oSpan.style.visibility='visible';
			oSpan.innerHTML = oInnerHTML;
		}
		if (_h=='h')
		{
			oSpan.style.visibility='hidden';
			oInnerHTML = oSpan.innerHTML;
			oSpan.innerHTML = '';
			
		}
	} else { // is NS? 
		oSpan = eval(document.layers['"+_w+"']);
		if (_h=='s')
		{
			oSpan.visibility='show';
		}
		if (_h=='h')
		{
			oSpan.visibility='hide';
		}
	}
	return(oInnerHTML);
}

function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function toggleItem(wsLayerName, wsImageName, wsCookieName, oInnerHTML)
{
	if (getCookie(wsCookieName) == '0'){
		var oInnerHTML = maximizeItem(wsLayerName, wsImageName, wsCookieName,oInnerHTML);
	} else {
		var oInnerHTML =minimizeItem(wsLayerName, wsImageName, wsCookieName,oInnerHTML);
	}
	return(oInnerHTML);
}

function maximizeItem(wsLayerName, wsImageName, wsCookieName,oInnerHTML)
{
	setCookie(wsCookieName, "1");
	return(toggleT(wsLayerName,'s',oInnerHTML));
}

function minimizeItem(wsLayerName, wsImageName, wsCookieName, oInnerHTML)
{
	setCookie(wsCookieName, "0");
	return(toggleT(wsLayerName,'h',oInnerHTML));
}


// Search Script

function objDropDownListItems(Value,Text,Selected){
	this.Value = Value;
	this.Text = Text;
	this.Selected = Selected;
}

function clearDropDownList(objDropDownList){
	objDropDownList.options.length = 0;
}

function addItemToDropDownList(objDropDownList, newItemValue, newItemText, newItemSelected){
	objDropDownList.options.length++;
	objDropDownList.options[objDropDownList.options.length-1].value = newItemValue;
	objDropDownList.options[objDropDownList.options.length-1].text = newItemText;
	objDropDownList.options[objDropDownList.options.length-1].selected = newItemSelected;
}

function fillDropDownListFromArray(objDropDownList, arrDropDownListItems, valueSelectCondition){
	clearDropDownList(objDropDownList);
	
	for(i=0;i<arrDropDownListItems.length;i++){
		addItemToDropDownList(objDropDownList,arrDropDownListItems[i].Value, arrDropDownListItems[i].Text,(arrDropDownListItems[i].Value == valueSelectCondition ? true : false));
	}
}




// SIZE SELECTOR
function SizeDetail(Id,  Length, Height, SleeveLength){
	this.Id= Id;
	this.Length = Length;
	this.Height = Height;
	this.SleeveLength = SleeveLength;
}

function ShowSizeDetails(Id, TypeId)
{
	var eShirtHeight;
	var eShirtLength;
	var eShirtSleeveLength;
	
	if(document.all)
	{
		eShirtHeight = document.all['shirtHeight'];
		eShirtLength = document.all['shirtLength'];
		eShirtSleeveLength = document.all['shirtSleeveLength'];
	}
	else
	{
		eShirtHeight = document.getElementById('shirtHeight');
		eShirtLength = document.getElementById('shirtLength');
		eShirtSleeveLength = document.getElementById('shirtSleeveLength');
	}
	
	if (eShirtHeight) eShirtHeight.innerHTML = '';
	if (eShirtLength) eShirtLength.innerHTML = '';
	if (eShirtSleeveLength) eShirtSleeveLength.innerHTML = '';
					
	for(i=0;i<shirtsize.length;i++){
		if(shirtsize[i].Id == Id){
			if (eShirtHeight && shirtsize[i].Height != 0) eShirtHeight.innerHTML = shirtsize[i].Height;
			if (eShirtLength && shirtsize[i].Length != 0) eShirtLength.innerHTML = shirtsize[i].Length;
			if (eShirtSleeveLength && shirtsize[i].SleeveLength != 0 && TypeId==1) eShirtSleeveLength.innerHTML = shirtsize[i].SleeveLength;
			break;
		}
	}
}

