if (document.layers) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove=hide;

var current_sub='';	
var current_img='';
var img_height=49;
var img_width=32;
var xOffset=-10;
var yOffset=-28;


function hideDivs(sub_menu) {
	if(current_sub != '' && current_sub != sub_menu){
		changeObjectVisibility(current_sub,'hidden');
		current_sub='';
	}			
}


function show(sel_img,sub_menu){
	var x = getImageLeft(sel_img) + xOffset;
	var y = getImageTop(sel_img) - yOffset;


	hideDivs(sub_menu);
	
	current_sub=sub_menu;
	current_img=sel_img;

	moveXY(sub_menu, x, y);
	changeObjectVisibility(sub_menu,'visible');
}


function hide(e) {
	if(current_sub!='') {
		var xTopLeftCorner = getImageLeft(current_img) + xOffset;
		var yTopLeftCorner = getImageTop(current_img) + yOffset;
		var xBottomRightCorner = xTopLeftCorner + getElementWidth(current_sub);
		var yBottomRightCorner = yTopLeftCorner + getElementHeight(current_sub) + img_height;		

		var xmouse;
		var ymouse;	
		
		if (document.layers){
			xmouse=e.pageX;
			ymouse=e.pageY;			  
		}else if(document.all){
			xmouse=event.clientX;
			ymouse=event.clientY+document.documentElement.scrollTop;
		}else{ 
			xmouse=e.pageX;
			ymouse=e.pageY;						
		}

		if(!(xmouse>=xTopLeftCorner && xmouse<=xBottomRightCorner && ymouse>=yTopLeftCorner && ymouse<=yBottomRightCorner)){
			changeObjectVisibility(current_sub,'hidden');
			current_sub='';
		}					
	}
}

function popUp(picPath,picWidth,picHeight){
	pw=picWidth;
	var winLeft = screen.availWidth;
	winLeft=(winLeft/2)-(picWidth/2);
			
	newwin=window.open("/showpic.asp?picPath="+picPath+"&w="+picWidth+"&h="+picHeight,"Informations","width=" + picWidth + ",height=" + picHeight + ",left=" + winLeft + ",top=0,menubar=0,location=0,toolbar=0,personalbar=0,status=0,resizable=1,scrollbars=0");
}

function put_pic(src,w,img){
	img.src = src;
}	

function openWin(url){
	var winWidth = 780;
	var winHeight = 433;
	var winLeft = screen.availWidth;
	winLeft=(winLeft/2)-(winWidth/2)-16;
	window.open(url,"HomeInProgress","width=" + winWidth + ",height=" + winHeight + ",left=" + winLeft + ",top=150,menubar=0,location=0,toolbar=0,personalbar=0,status=0,resizable=1,scrollbars=0");
}

function openTool(url){
	var winWidth = 440;
	var winHeight = 350;
	var winLeft = screen.availWidth;
	winLeft=(winLeft/2)-(winWidth/2)-16;
	window.open(url,"Tools","width=" + winWidth + ",height=" + winHeight + ",left=" + winLeft + ",top=0,menubar=0,location=0,toolbar=0,personalbar=0,status=0,resizable=1,scrollbars=0");
}
		
function addBookmark(title,url) {
	if (window.sidebar) { 
		window.sidebar.addPanel(title, url,""); 
	}else if( document.all ) {
		window.external.AddFavorite( url, title);
	} else if( window.opera && window.print ) {
		return true;
	}
}	


String.prototype.right = function (numOf) { 
	var tmp = "";
	for (i=this.length-numOf; i<this.length; i++) {
		tmp += this.charAt(i);
	}
	return tmp;
};

function validDOC(docSrc){
	var isValid=false;
	docSrc = docSrc.toLowerCase();
	
	for(x=0;x<validExt.length;x++){
		if(docSrc.right(validExt[x].length)==validExt[x]){
			isValid=true;
			break;
		}
	}
	
	return isValid;
}			

function trim(strText) {
	// this will get rid of leading spaces
	while (strText.substring(0,1) == ' ')
		strText = strText.substring(1, strText.length);

	// this will get rid of trailing spaces
	while (strText.substring(strText.length-1,strText.length) == ' ')
		strText = strText.substring(0, strText.length-1);

	return strText;
}



function changeCategory(strLocation, strCategory) {
  if (strCategory != '') {
    cat = strCategory.substring(0,1);
    id = strCategory.substring(1);
    //"<%=SITE_URL%>" + 
    switch(cat) {
      case 'a':
          window.location=strLocation + "shoponlineandsave/displaysupercategory.asp?ID=" + id;
          break;
      case 'c':
          window.location=strLocation + "shoponlineandsave/displaycategory.asp?ID=" + id;
          break;
      case 's':
          window.location=strLocation + "shoponlineandsave/displaysubcategory.asp?ID=" + id;
          break;
      case 'u':
          window.location=strLocation + "shoponlineandsave/displayproducts.asp?ID=" + id;
          break;
    }
  }
}




function changeSortOrder(strOrderBy, strSection, intID, strLocation) {
  switch(strSection) {
    case 'super':
        window.location=strLocation + "shoponlineandsave/displaysupercategory.asp?ID=" + intID + "&order=" + strOrderBy;
        break;
    case 'cat':
        window.location=strLocation + "shoponlineandsave/displaycategory.asp?ID=" + intID + "&order=" + strOrderBy;
        break;
    case 'sub':
        window.location=strLocation + "shoponlineandsave/displaysubcategory.asp?ID=" + intID + "&order=" + strOrderBy;
        break;
    case 'subsub':
        window.location=strLocation + "shoponlineandsave/displayproducts.asp?ID=" + intID + "&order=" + strOrderBy;
        break;
  }
}