function Load_Menu(strSrc,intMenu)
{
	if (intMenu == 2)
	{
		var Search = document.getElementById("divSearch")
		if (null != Search)
		{
			Search.style.display = "";
		}	
	}
	else
	{
		var Basket = document.getElementById("divBasket")
		if (null == Basket)
		{
			var Search = document.getElementById("divSearch")
			if (null != Search)
			{
				Search.style.display = "none";
			}
		}	
	}
	//Redirect to the page
	document.location.replace(strSrc);
}

function updateCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return -1;
}


function Display_Menu(intMenu)
{
	//Hide all to start with
	for (var i = 1; i < 7; i ++)
	{
		//Check Menu is there
		var object = document.getElementById("menu" + document.getElementById("mnu" + i).value);
		if (eval(object))
		{
			//Set to hidden
			document.getElementById("menu" + document.getElementById("mnu" + i).value).style.visibility = "hidden";
		}
	}
	//When no menus are to be shown check if need to show buyer default
	if (intMenu ==0)
	{
		var object = document.getElementById("menu" + document.getElementById("mnu2").value);
		if (eval(object))
		{
			var object = document.getElementById("menu" + document.getElementById("mnu5").value);
			if (null == object)
			{
				intMenu = 2;
				var Search = document.getElementById("divSearch")
				if (null != Search)
				{
					Search.style.display = "";
				}	
			}
		}
	}
	
	if (intMenu !=0)
	{
		//Show the appropriate menu
		var object = document.getElementById("menu" + document.getElementById("mnu" + intMenu).value);
		if (eval(object))
		{
			//Get the Heading Height
			var objHeader = document.getElementById("tblHeading");
			if (eval(objHeader))
			{
				var intHeight = document.getElementById("tblHeading").offsetHeight;
				//Add original position offset and extra for spacing
				intHeight = intHeight + 7		
				//Add offset for Search panel if visible
				var object = document.getElementById("divSearch");
				if (eval(object))
				{
					if (document.getElementById("divSearch").style.visibility != "hidden")
					{
						if(document.getElementById("divSearch").style.display != "none")
						{
							intHeight = intHeight + document.getElementById("divSearch").offsetHeight;
						}
						else
						{
							intHeight = intHeight + 21	
						}	
					}				
				}
				else
					intHeight = intHeight + 21
			}
			else
			{
				intHeight = 135;
			}
			
			document.getElementById("menu" + document.getElementById("mnu" + intMenu).value).style.top = intHeight;
			document.getElementById("menu" + document.getElementById("mnu" + intMenu).value).style.left = 100;
			document.getElementById("menu" + document.getElementById("mnu" + intMenu).value).style.visibility = "";
			//document.getElementById("frame1").style.width = 640;
			
			if (intMenu==2)
			{
				//Show the Alt Product Menu
				//document.getElementById("menu" + document.getElementById("mnu6").value).style.visibility = "";
			}
		}
	}
	else
	{
		//document.getElementById("frame1").style.width = 644;
	}
}

function Reset_Basket()
{
	
	var Basket = document.getElementById("divBasket")
	if (null != Basket)
	{
		var intItem = document.getElementById("intBasket").value
		
		document.getElementById("txtBasket").value = intItem + " items"
		if (intItem == 0)
		{
			document.getElementById("Img1").src = "images/bing_Empty.gif"
		}
		else
		{
			document.getElementById("Img1").src = "images/bing_Full.gif"
		}
	}
}	

function Set_Selected(intMenuID,intCount)
{
	//Highlight
	mmItemActivateByNumber(intMenuID)
	//Reset all
	for (i=1;i<=intCount;i++)
	{
		if (i != intMenuID)
		{ 
			mmItemDeActivateByNumber(i)
		}	
	}
}

function mmItemDeActivateByNumber(_i)
{
	//Replace the image
	if (_mi[_i][46] == "images/L_Selected_white.jpg")
	{
		_mi[_i][46] = "images/L_Menu_Back.jpg";
		itemOff(_i);
		itemOff(_i);	
	}	
}

function Get_Pos()
{
	//Get the Scroll position
	//intTop = document.getElementById("intScroll_Pos").value;
	//document.getElementById("intSave_Pos").value = intTop;
}

function Set_Pos(intValue)
{
	//Get the Scroll position
	//document.getElementById("intScroll_Pos").value = intValue;
}

function getkey(e)
{
	//Function to capture the press of the enter key in the free text box
	if (window.event)
	{
		if (window.event.keyCode == 13)
		{
		   document.getElementById("btnSearch").click();
		}
	}
	else if (e)
	{
		if (e.which == 13)
		{
	   
		}
	}
}

function IgnoreEvents(e)
{return false}

function Free_Search(strSrc)
{
    var Free = strSrc.match(/Free_Search=/gi);
	if (null != Free)
	{
		var obj = document.getElementById("_ctl0:txtFree");
		if (eval(obj))
		{
		    strSrc = strSrc + obj.value;
		    obj.value = "";
		}
	}
	
	//Redirect to the search page
    document.location.replace(strSrc);
}

function Show_Calc_Window(txtForm,txtDate)
{
var strURL ="Calendar.aspx"

intWidth = 200
intHeight = 220

if (navigator.appName.toUpperCase().match(/MICROSOFT INTERNET EXPLORER/) != null)
{
    strURL = strURL + "?type=modal"
    var answer = window.showModalDialog(strURL ,null,'status=no;help=no;dialogWidth=' + intWidth + 'px;dialogHeight=' + intHeight + 'px')
    if (answer != undefined)
    {
        document.getElementById(txtDate).value = answer
    }    
}
else
{
var winModalWindow

intWidth = 190
intHeight = 170

//add the flag for Netscape
strURL = strURL + "?type=win&field=" + txtDate + "&form=" + txtForm
//Get the Center screen coordinates
intLeft = (screen.availWidth - intWidth) / 2
intTop = (screen.availHeight - intHeight) / 2
window.top.captureEvents(Event.CLICK|Event.FOCUS)
window.top.onclick=IgnoreEvents
window.top.onfocus=HandleFocus
winModalWindow = window.open(strURL,"window","dependent=yes,width=" + intWidth + ",height=" + intHeight + ",top=" + intTop + ",left=" + intLeft + ",resizable=0,menubar=0,status=0")
winModalWindow.focus()
}
}

function HandleFocus()
{
	try
	{
		if (!winModalWindow.closed)
		{
		winModalWindow.focus()
		}
		else
		{
		window.top.releaseEvents(Event.CLICK|Event.FOCUS)
		window.top.onclick=""
		}
	}
	catch(e)
	{
		window.top.releaseEvents(Event.CLICK|Event.FOCUS)
		window.top.onclick=""
	}
	return false
}

function Set_Height()
{
   
   
var objCPH = document.getElementById("ctl00_pnlContent")
    var objSide = document.getElementById("td_Main3")
    var objSpacer = document.getElementById("td_Spacer")
    try
    {
        if (objCPH.scrollHeight < objSide.scrollHeight)
        {
            var strHeight = objSide.scrollHeight - objCPH.scrollHeight
            objSpacer.height = strHeight + "px"
        }
    }
    catch(e)
    {}
    return true
}