
function GetObjRef(form, objname) {
	var objref = null;	
	for (i=0; i < form.elements.length; i++) {
		if (form.elements[i].name.indexOf(objname) != -1) {
			objref = form.elements[i];
			break;
		}		
	}
	return objref;
}

function brwByBrand(control) {

	var index = control.selectedIndex;
	var base	= "brands.aspx?brn=";
	var dest;
	
	if (index > 0 && index < control.options.length) {	
		dest = base + control.options[index].value;	
		top.location = dest;
	}
}

function brwByCtgy(control) {

	var index = control.selectedIndex;
	var base	= "categories.aspx?cat=";
	var dest;
	
	if (index > 0 && index < control.options.length) {	
		dest = base + control.options[index].value;
		top.location = dest;
	}
}


function formatTwoDigits(value) {

	var sReturn;

	if (value < 10) {
		sReturn = "0" + value;
	} else {
		sReturn = value;
	}
	
	return sReturn;
}

function resetSelection(element, value) {

	var i;
	
	if (value  == -1) {
		for (i=0; i<element.options.length;i++) {
			if (element.options[i].value == value) {
				element.options[i].selected = true;
			}
		}
	} else {
		element.options[0].selected = true;
	}
}	

function selectAllItems(control){

   var i;
   
   for (i=0; i<control.options.length;i++) {
      control.options[i].selected = true;
   }
}

function isAlpha(value) {

	var i;
	var bReturn;
	var sTest;
	
	bReturn = true;
	
	for (i=0; i<value.length; i++) {
		sTest = value.substring(i, i+1);
		bReturn = bReturn && isNaN(sTest);	
	}
	
	return bReturn;
}

function highlight(row, value) {
	
	switch (value) {
		case 0:
			row.style.backgroundColor = "#dcdcdc";
			break;
		case 1:
			row.style.backgroundColor = "#f7f6f4";
			break;
	}
}

function highlightmenu(row, value) {
	
	switch (value) {
		case 0:
			row.style.background = "#0000FF";
			break;
		case 1:
			row.style.background = "transparent";
			break;
	}
}

function highlightnav(row, value) {
	
	switch (value) {
		case 0:
			row.style.background = "#E0E0E0";
			break;
		case 1:
			row.style.background = "transparent";
			break;
	}
}

function trimString(sValue) {
	sReturn = "";
	
	if (sValue.indexOf(' ') != -1) {
		for (i=0; i < sValue.length - 1; i++) {
			if (sValue.charAt(i) != ' ') {
				sReturn = sReturn + sValue.charAt(i);
			}
		}
	} else {
		sReturn = sValue;
	}
	return sReturn;
}

function saveNavMenu(menu) {

	var cookexp;
		if (isMicrosoft(6)) 
			cookexp = "End of Session";
		else
			cookexp = "";

	
	if (menu != null) {
		for (var i = 0; i < menu.Groups.length; i++) {
			setCookie(menu.Groups[i].Key, menu.Groups[i].getExpanded(),cookexp,"/");
		}
	}
}

	function setCookie(name, value, expires, path, domain, secure) {
	
		var oCookie = name + "=" + value +
           ((expires) ? "; expires=" + expires : "") +
           ((path) ? "; path=" + path : "") +
           ((domain) ? "; domain=" + domain : "") +
           ((secure) ? "; secure" : "");
         
        //alert(oCookie);
		document.cookie = oCookie;
	}
   
   function loadNavMenu(menu) {
		
		if (menu != null && menu.Groups != null) {	
			for (var i = 0; i < menu.Groups.length; i++) {
				if (getCookie(menu.Groups[i].Key) == "true") {
					menu.Groups[i].setExpanded(true);
				}
			}
		}
	}
   
	function getCookie(byname) {
		
		byname=byname+"=";
		nlen = byname.length;
		fromN = document.cookie.indexOf(byname)+0;

	    if((fromN) != -1) {
			
			fromN +=nlen;
			toN=document.cookie.indexOf(";",fromN)+0;
	        
	        if(toN == -1) { 
				toN=document.cookie.length;
			}
	        
	        return document.cookie.substring(fromN,toN);
		}
	}
   
	function isNetscape(v) {
		return isBrowser("Netscape", v);
	}

	function isMicrosoft(v) {
		return isBrowser("Microsoft", v);
	}

	function isBrowser(b,v) {
	  
		browserOk = false;
		versionOk = false;

		browserOk = (navigator.appName.indexOf(b) != -1);
		
		if (v == 0) 
			versionOk = true;
		else  
			versionOk = (v <= parseInt(navigator.appVersion));
	   
	   return browserOk && versionOk;
	}

	function updateItemNo(control) {
		
		var index	= control.selectedIndex;

		var itmno	= document.getElementById("ctlProdview_prod_No");
		var noDsp	= document.getElementById("itmno_Dsply");
		var price	= document.getElementById("price_Dsply");
		
		if (index >= 0 && index < control.options.length) {
		
			var temp	= control.options[index].value;
			var arrData	= temp.split(":");
			
			itmno.value		= arrData[0];
			
			if (noDsp != null) {
				noDsp.innerHTML = "<b>" + arrData[0] + "</b>";
			}
			
			if (price != null) {
				price.innerHTML	= "<b>" + arrData[1] + "</b>";
			}
		}
	}
	
	function OnProductOptionSelect(control)
	{   
	    var index	= control.selectedIndex;

		var hfIndex	= document.getElementById("hfIndex");
		
		hfIndex.value = index;
	}
	
	function ChildWindow(url) {	
	
		window.open(url, '_blank','height=500,width=655,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,dependent=yes');
	}
	
	/*
	var interval = 5; // delay between rotating images (in seconds)
    var random_display = 1; // 0 = no, 1 = yes
    interval *= 1000;

	function imageItem(image_location, link) 
	{
		this.image_item = new Image();
		this.image_item.src = image_location;
		this.image_item.link = link; 
	}
	
    var image_index = 0;
    image_list = new Array();
    image_list[image_index++] = new imageItem('/images_flash/Go-Camping.gif','/categories.aspx?cat=00000081');
    image_list[image_index++] = new imageItem('/images_flash/Go-Explore.gif','/categories.aspx?cat=00000081');
    image_list[image_index++] = new imageItem('/images_flash/Go-Hiking.gif','/categories.aspx?cat=00000081');
	image_list[image_index++] = new imageItem('/images_flash/Go-Kayaking.jpg','/categories.aspx?cat=00000081');
    	
    var number_of_image = image_list.length;
    
    function generate(x, y) 
    {
        var range = y - x + 1;
        return Math.floor(Math.random() * range) + x;
    }
    
    function getNextImage() 
    {
        if (random_display) 
        {
            image_index = generate(0, number_of_image-1);
        }
        else 
        {
            image_index = (image_index+1) % number_of_image;
        }
        var new_image = image_list[image_index];
        return(new_image);
    }
    function rotateImage() 
    {
        var new_image = getNextImage();
        document.getElementById('rotatingImage').src = new_image.image_item.src;
		document.getElementById('rotatingLink').href = new_image.image_item.link;
        setTimeout("rotateImage()", interval);
    }*/
