var newdiv;
var newstep;
var gType;
var link;

function showMenu(type,where)
{	
	if(where=="itself")
	{
		gTypeOld=gType;
		gType=type;
	}
	
	if(!newdiv || newdiv.style.visibility=="hidden")
	{
		var menuHolder=document.getElementById("header");
		newdiv = document.createElement('div');
		newdiv.setAttribute('id', "menu");
		newdiv.setAttribute('class', "submenuClass");
		
		var t=setTimeout("openMenu()", 100);
		newdiv.style.height="0px";
			
		newstep = document.createElement('div');
		newstep.setAttribute('id', "step");
		newstep.style.height="20px";
		newstep.style.background="#e8e6e3";
		newstep.style.position="absolute";
		
		newstep.style.top=menuHolder.offsetTop + 44 + "px";
		newdiv.style.top=menuHolder.offsetTop + 64 + "px";
		
		if(type==1)
		{
			link=document.getElementById("link2");
			if(navigator.appName=="Microsoft Internet Explorer")
				newstep.style.width="95px";
			else
				newstep.style.width="95px";
				
			if(navigator.appName=="Netscape")
			{
				if(navigator.userAgent.search("Safari") > 0)
					newdiv.style.marginLeft= newstep.style.marginLeft=menuHolder.offsetLeft + 100 + "px";
				else
				{
					newstep.style.width="94px";
					newdiv.style.marginLeft= newstep.style.marginLeft=menuHolder.offsetLeft + 102 + "px";
				}
			}
			else
				newdiv.style.marginLeft= newstep.style.marginLeft=menuHolder.offsetLeft + 101 + "px";
		}
		else if(type==2)
		{
			link=document.getElementById("link3");
						
			if(navigator.appName=="Microsoft Internet Explorer")
			{
				newstep.style.width="93px";
				newdiv.style.marginLeft= newstep.style.marginLeft=menuHolder.offsetLeft + 203 + "px";
			}
			else if(navigator.appName=="Netscape")
			{
				if(navigator.userAgent.search("Safari") > 0)
				{
					newstep.style.width="92px";
					newdiv.style.marginLeft= newstep.style.marginLeft=menuHolder.offsetLeft + 202 + "px";
				}
				else
				{
					newstep.style.width="93px";
					newdiv.style.marginLeft= newstep.style.marginLeft=menuHolder.offsetLeft + 203 + "px";
				}
			}
		}
		else if(type==3)
		{
			link=document.getElementById("link4");
			newstep.style.width="93px";
			if(navigator.appName=="Microsoft Internet Explorer")
				newdiv.style.marginLeft= newstep.style.marginLeft=menuHolder.offsetLeft + 303 + "px";
			else if(navigator.appName=="Netscape")
			{
				if(navigator.userAgent.search("Safari") > 0)
					newdiv.style.marginLeft= newstep.style.marginLeft=menuHolder.offsetLeft + 301 + "px";
				else
				{
					newstep.style.width="93px";
					newdiv.style.marginLeft= newstep.style.marginLeft=menuHolder.offsetLeft + 303 + "px";
				}
			}
		}
		
		link.style.fontWeight="bold";
		link.style.color="#3b5998";
		
		newdiv.style.visibility="hidden";
		newdiv.style.zIndex="100";
		newstep.style.visibility="visible";
		document.body.appendChild(newstep);
		document.body.appendChild(newdiv);
	}
	else
	{
		var t=setTimeout("closeMenu()", 100);
	}
}

function closeMenu()
{
	if(newdiv)
	{
		newdiv.style.height = parseInt(newdiv.style.height) - 10 + "px"
	
		if(parseInt(newdiv.style.height) == 0)
		{
			link.style.fontWeight="bold";
			link.style.color="#333";
			newdiv.style.visibility="hidden";
			document.body.removeChild(newdiv);
			document.body.removeChild(newstep);
			if(gType!=gTypeOld)
			showMenu(gType,"other");
		}
		else
		{
			newdiv.innerHTML="";
			var s=setTimeout("closeMenu()", 15);
		}
	}
}

function openMenu()
{
	var w;
	newdiv.style.height = parseInt(newdiv.style.height) + 10 + "px"
	
	if(gType==1)
	{
		var menuContents="<a href='/newcastlegateshead.php'>Newcastle upon Tyne</a><br><a href='/edinburgh.php'>Edinburgh</a><br><a href='/glasgow.php'>Glasgow</a><br><a href='/london.php'>London</a><br><a href='/liverpool.php'>Liverpool</a><br><a href='/angelnorth.php'>Angel of the North</a><br><a href='/uk_landmarks.php'>UK Landmarks &amp; Castles</a><br><a href='/northumberland.php'>Northumberland</a><br><a href='/italy.php'>Rome &amp; Italy</a><br><a href='/germany.php'>Germany</a><br><a href='/brussels.php'>Brussels</a><br><a href='/ne_england.php'>North East England</a><br>";
		w=240;
	}
	else if(gType==2)
	{
		var menuContents="<a href='/about.php'>About Us</a><br><a href='/cameras.php'>Our Cameras</a><br><a href='/weather.php'>Weather Conditions</a><br><a href='/post_production.php'>Post Production</a><br><a href='/photographers.php'>Photographers </a>";
		w=110;
	}
	else if(gType==3)
	{
		var menuContents="<a href='/services.php'>General Services</a><br><a href='/print_technology.php'>Print Technology</a><br><a href='/print_quality.php'>Print Quality</a><br><a href='/papers_canvas.php'>Papers and Canvas</a><br><a href='/stockists.php'>Stockists</a>";
		w=110;
	}
	
	if(parseInt(newdiv.style.height) == w)
	{
		newdiv.innerHTML=menuContents;			
	}
	else
	{
		newdiv.style.visibility="visible";
		var s=setTimeout("openMenu()", 1);
	}
}

function repositionMenu()
{
	if(newdiv)
	{
		var ms=document.getElementById("header");
		if(gType==1)
		{
			if(navigator.appName=="Netscape")
			{
				if(navigator.userAgent.search("Safari") > 0)
					newdiv.style.marginLeft= newstep.style.marginLeft = ms.offsetLeft + 100 + "px";
				else
					newdiv.style.marginLeft= newstep.style.marginLeft = ms.offsetLeft + 102 + "px";
			}
			else
				newdiv.style.marginLeft= newstep.style.marginLeft = ms.offsetLeft + 101 + "px";
		}
		else if(gType==2)
		{
			if(navigator.appName=="Netscape")
			{
				if(navigator.userAgent.search("Safari") > 0)
					newdiv.style.marginLeft= newstep.style.marginLeft = ms.offsetLeft + 202 + "px";
				else
					newdiv.style.marginLeft= newstep.style.marginLeft = ms.offsetLeft + 203 + "px";
			}
			else
				newdiv.style.marginLeft= newstep.style.marginLeft=menuHolder.offsetLeft + 203 + "px";
		}
		else if(gType==3)
		{
			if(navigator.appName=="Netscape")
			{
				if(navigator.userAgent.search("Safari") > 0)
					newdiv.style.marginLeft= newstep.style.marginLeft = ms.offsetLeft + 301 + "px";
				else
					newdiv.style.marginLeft= newstep.style.marginLeft = ms.offsetLeft + 303 + "px";
			}
			else
				newdiv.style.marginLeft= newstep.style.marginLeft=menuHolder.offsetLeft + 303 + "px";
		}
	}
}
