var curSubMenu = 0 ;
var bIE4 = false ;

function fnBrowserCheck()
{
	var agent = navigator.userAgent.toUpperCase();
	if (agent.indexOf("MSIE") != -1)
	{
		if (parseInt(navigator.appVersion) >= 4)
			bIE4 = true ;
	}
}

function fnErrorMsg(sMsg, sUrl, sLine)
{
	window.alert("Error:" + sMsg + "\nFile: "  + sUrl + "\nLine: " + sLine)
}

window.onerror = fnErrorMsg ;


function fnResize(oObj)
{
/*	window.status = oObj.clientHeight ; */
}

function fnSubMenu(iObj)
{
	var oDiv = document.getElementById("SubMenu" + iObj) ;
	oDiv.style.visibility = "visible" ;
}

function fnShowSubMenu(iObj)
{
	fnHideSubMenu() ;
	if (iObj != 0)
	{
		curSubMenu = iObj ;
		var oDiv = document.getElementById("subMenu" + iObj) ;
		var oMenu = document.getElementById("iMenu" + iObj) ;
		var oBaseMenu = document.getElementById("BaseMenu") ;

		oMenu.style.borderTopColor = "#FF0000" ;
		oMenu.style.borderRightColor = "#800000" ;
		oMenu.style.borderBottomColor = "#800000" ;
		oDiv.style.top = oMenu.offsetTop  + oBaseMenu.offsetTop + 2;
		oDiv.style.left = oMenu.offsetLeft + oMenu.offsetWidth  + oBaseMenu.offsetLeft + 2;
		oDiv.style.visibility = "visible" ;
	}
}

function fnHideSubMenu()
{
	if (curSubMenu != 0)
	{
		var oDiv = document.getElementById("subMenu" + curSubMenu) ;
		var oMenu = document.getElementById("iMenu" + curSubMenu) ;

		oMenu.style.borderRightColor = "Red" ;
		oMenu.style.borderBottomColor = "Red" ;
		oMenu.style.borderTopColor = "#800000" ;
		oDiv.style.visibility = "hidden" ;
		curSubMenu = 0 ;
	}


}

function fnHideMenu(iMenu)
{
	var oMenu = document.getElementById('SubMenu' + iMenu) ;
	if (oMenu)
		oMenu.style.visibility = 'hidden' ;
}

function fnHideMenus(iMenu)
{
	if (iMenu != 1) fnHideMenu(1) ;
	if (iMenu != 2) fnHideMenu(2) ;
	if (iMenu != 3) fnHideMenu(3) ;
}

function fnSendMail(n,p)
{
	var l ;
	l = p.length ;
	location.href = "Mailto:" + n + "@" + p.slice(2,l-4) ;
}

function fnShow(Target, Prompt)
{
	var oTarget = document.getElementById(Target) ;
	var oPrompt = document.getElementById(Prompt) ;
	if (oTarget.style.display == "none")
	{
		oTarget.style.display = "inline"
		oPrompt.style.display = "none"
	}
	else
	{
		oTarget.style.display = "none"
		oPrompt.style.display = "inline"
	}
}

function fnConfirmDelete(ID)
{
	if (confirm ("Are you sure you want to permanently delete this item?"))
		location.href = "EditProduct.asp?Cmd=5&amp;ID=" + ID ;
}

function $$(obj)
{
	return document.getElementById(obj) ;
}

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_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_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];}
}

function fnSearch(oForm)
{
	var oSel = oForm.search ;
	var iSel = oSel.selectedIndex ;
	var strTarget = "prodsearch" ;
	if (oForm.search.value != "0")
	{
		strTarget = oForm.search.value ;
	}
	location.href= strTarget + ".asp?term=" + $("#prodsearchterm option:selected").text() ;
}

$(document).ready(function() {
  $(".buttonSide").bind('mouseenter', fnButtonBlue) ;
  $(".buttonSide").bind('mouseleave', fnButtonRed) ;
  $(".buttona").bind('mouseenter', fnButtonBlue) ;
  $(".buttona").bind('mouseleave', fnButtonRed) ;
});


function fnButtonRed(){
	var p = $(this).parent() ;
	p.children().show() ;
	p.children().slice(0,1).attr('src', 'img/button_l.gif') ;
	p.children().slice(1,2).children().first().css('background-image', 'url(img/button_m.gif)') ;
	p.children().slice(2).attr('src', 'img/button_r.gif') ;
}

function fnButtonBlue(){
	var p = $(this).parent() ;
	p.children().slice(0,1).attr('src', 'img/button_l2.gif') ;
	p.children().slice(1,2).children().first().css('background-image', 'url(img/button_m2.gif)') ;
	p.children().slice(2).attr('src', 'img/button_r2.gif') ;
}



