// PRODUCT MENU DISPLAY/HIDE
function SelectMenu( id, imagePath )
{
	deleteCookie("selCategoryId");

    if (document.getElementById('Menu' + id).className == 'Hide')
    {
        document.getElementById('Menu' + id).className = 'Show'
        document.images["MenuImage" + id].src = imagePath + "Minus.gif";
        
        // only save the cookie if showing the menu
        setCookie("selCategoryId", id);
    }
    else
    {
		document.getElementById("Menu" + id).className = 'Hide'
        document.images["MenuImage" + id].src = imagePath + "Plus.gif";
    }
}

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;
}

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 deleteCookie(name, path, domain) {
	if (getCookie(name)) {
		document.cookie = name + "=" +
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

// PRODUCT MENU CURRENT CATEGORY COOKIE
// current menu selection
var CurrSection = document.getElementById( getCookie('CURRSECTION') );

// Image popup
function openIMGwin(imgURL) {
	var Wname = "popped";
	var exec = 'window.open("';
	// Set name of common html file here
	var URL = "ImagePopup.htm?"+imgURL;
	exec+= URL;      exec+= '", "';
	exec+= Wname;    exec+= '", "';
	// default dimensions set next line
	exec+='width=200,height=200';
	// 0,0 positions to top left
	// top=0,left=0 does for MSIE
	// screenX=0,screenY=0 does for Netscape
	// other attributes set for a very plain window
	// note that resizable=1 because
	// Netscape 4.x users will have to resize manually
	// NN6.x ??
	exec+=',top=0,left=0,screenX=0,screenY=0,toolbar=0,location=0';
	exec+=',directories=0,resizable=0,status=0,menubar=0,scrollbars=0")';
	// eval() takes the string called exec built and executes as code
	eval (exec);
}

// OPENS THE WINDOW TO THE UPPER LEFT HAND SIDE TO THE SCREEN
function openWindow(width,height,strurl,winName,scrollb) {
    x = (640 - width)/2, y = (480 - height)/10;

    if (screen) {
        y = (screen.availHeight - height)/10;
        x = (screen.availWidth - width)/10;
    }
    
    if (screen.availWidth > 1800) { 
	x = ((screen.availWidth/2) - width)/10; 
    } 
	window.open(strurl,winName,'width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x+',scrollbars='+scrollb);
}

// OPENS THE WINDOW IN THE CENTER OF THE SCREEN
function openWindowM(width,height,strurl,winName,scrollb) {
    x = (640 - width)/2, y = (480 - height)/2;

    if (screen) {
        y = (screen.availHeight - height)/2;
        x = (screen.availWidth - width)/2;
    }
    
    if (screen.availWidth > 1800) { 
	x = ((screen.availWidth/2) - width)/2; 
    } 
	window.open(strurl,winName,'width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x+',scrollbars='+scrollb);
}

