

//--drop down menu

//content = new Array ();

//content [0] = new Array (
//false, 							 
//new Array('sub_0_1','sub_0_2','sub_0_3','sub_0_4')   
//);
//content [1] = new Array (
//false, 							 
//new Array('sub_1_1','sub_1_2','sub_1_3','sub_1_4','sub_1_5','sub_1_6')   
//);
//content [2] = new Array (
//false, 							 
//new Array('sub_2_1','sub_2_2','sub_2_3')   
//);
//content [3] = new Array (
//false, 							 
//new Array('sub_3_1','sub_3_2','sub_3_3','sub_3_4','sub_3_5','sub_3_6')   
//);

isOPERA = (navigator.userAgent.indexOf('Opera') >= 0)? true : false;
isIE    = (document.all && !isOPERA)? true : false;
isDOM   = (document.getElementById && !isIE && !isOPERA)? true : false;

function Get_Cookie(name) 
{
 				var start = document.cookie.indexOf(name+"=");
 				var len = start+name.length+1;
 				if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
 				if (start == -1) return null;
 				var end = document.cookie.indexOf(";",len);
 				if (end == -1) end = document.cookie.length;
 				return unescape(document.cookie.substring(len,end));
}

function Set_Cookie(name,value,expires,path,domain,secure) 
{
  				document.cookie = name + "=" +escape(value) +
      			( (expires) ? ";expires=" + expires.toGMTString() : "") +
      			( (path) ? ";path=" + path : "") + 
      			( (domain) ? ";domain=" + domain : "") +
      			( (secure) ? ";secure" : "");
	}

function Delete_Cookie(name,path,domain)
{
	if (Get_Cookie(name)) document.cookie = name + "=" +
        ( (path) ? ";path=" + path : "") +
	( (domain) ? ";domain=" + domain : "") +
     			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}


function swapImage(image_name, image_src){
	window.document[image_name].src = image_src;
}

function processTreeJTM(row_id_list, image_name, image_src, image_src_mo, image_src_down, image_src_mo_down, cookie_name, child_id_list){
	var row_array = row_id_list.split(",");
	var expanded = false;
	for (x = 0; x < row_array.length; x++){
		//var row = document.all[row_array[x]];
		var row = document.getElementById(row_array[x]);
		if (row !=null){
			if(row.style.display == "block" || row.style.display == ""){
				row.style.display = "none";
				expanded = false;
			}
			else{
				row.style.display = "block";
				expanded = true;
			}
		}
	}
	
	if((image_name) && (image_src) && (image_src_down)){
		if(expanded){
			window.document[image_name].src = image_src_down;
		}
		else{
			window.document[image_name].src = image_src;			
		}
	}
	
	if (cookie_name){
		var cookie_value = Get_Cookie(cookie_name);
		var cookie_value_array = cookie_value.split(",");
		var child_id_array = child_id_list.split(",");
		for(x=0; x< child_id_array.length; x++){
			if(expanded){
				var in_list = false;
				for(y=0; y < cookie_value_array.length && in_list == false; y++){
					if (cookie_value_array[y] == child_id_array[x]) in_list = true;
				}
				if (!in_list) cookie_value_array.push(child_id_array[x]);
			}
			else{
				for(y=0; y < cookie_value_array.length; y++){
					if (cookie_value_array[y] == child_id_array[x]){
						cookie_value_array.splice(y,1);
					}
				}
			}
		}
		cookie_value = cookie_value_array.join();
		
		Set_Cookie(cookie_name, cookie_value); //Use Session Cookie Only
	}
	
}


function processTree (id)
{
	if (content [id][0])
	{
		for (i = 0; i < content [id][1].length; i++)
			hide (content [id][1][i]);

		content [id][0] = false;
	}
	else
	{
		for (i = 0; i < content [id][1].length; i++)
			show (content [id][1][i], 'table-row');

		content [id][0] = true;
	}

	return false;
}

function show (id, displayValue)
{
	if (isDOM)
		document.getElementById(id).style.display = (displayValue)? displayValue : "block";
	else if (isIE)
		document.all[id].style.display = "block";
}

function hide (id)
{
	if (isDOM)
		document.getElementById(id).style.display = "none";
	else if (isIE)
		document.all[id].style.display = "none";
}
if (isDOM || isIE)
{
	document.writeln('<style type="text/css">');
	document.writeln('.SubItemRow \{ display: none; \}');
	document.writeln('</style>');
}

// -->
// image swapping (rollovers)
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_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];}}
}

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];}
}

// shipping window popup
function openshippingwindow()
{
	newwin = window.open('/_checkout/index.cfm?fuseaction=shipping_info','shippingwindow','width=450,height=500,scrollbars=yes,resizable=yes');
	newwin.creator = self;
};

// submit keyword search
function submitkeywords()
{
	var keywords = window.document.keywordsearchform.dropkeywords.options[window.document.keywordsearchform.dropkeywords.selectedIndex].value;
	var newkeywords = keywords.replace(/ /g, ",");
	window.location.href='/index.cfm?fa=s&keywords='+newkeywords;
};
