/* 
--------------------------------------------
	Northern Gas Networks Javascript
	Last Updated:  02/04/2006
--------------------------------------------
*/

	function searchDefault()
	{
		var s =  document.getElementById('search-input');

		s.onfocus = function()
		{
			s.value = (s.value=='search here') ? '' : s.value;
		}

		s.onblur = function()
		{
			s.value=(s.value == '') ? 'search here' : s.value;
		}


		var b = document.getElementById('search-button');

		b.onclick = function ()
		{
			s.value = (s.value=='search here') ? '' : s.value;
		}
	}
	
	//-------------------------------------------
	// Flash related functions
	//-------------------------------------------

	function findPosX(obj)
	{
		var curleft = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curleft += obj.offsetLeft
				obj = obj.offsetParent;
			}
		}
		else if (obj.x)
			curleft += obj.x;
		return curleft;
	}

	function findPosY(obj)
	{
		var curtop = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curtop += obj.offsetTop
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)
			curtop += obj.y;
		return curtop;
	}

	function resizeDiv(w,h,divId)
	{
		if (!document.getElementById) return;
		if ( w == null || h == null || divId == null ) return;

		var w = w;
		var h = h;
		var el = document.getElementById(divId);
		
		if (w) el.style.width = w + 'px';
		if (h) el.style.height = h + 'px';

		resizeFlash(w,h,'ngnmap');
	}
	
	function resizeFlash(w,h,id)
	{
      	var el = document.getElementById(id);
		if (w) el.style.width = w + 'px';
		if (h) el.style.height = h + 'px';
	}
	
	function positionFlashMap()
	{
//alert('1');
		var reference = document.getElementById("hdr");
		var moveObj = document.getElementById("flashmap");
//alert('2');
		moveObj.style.display = "none";
 	    if ( moveObj == null ) return;
//alert('3');
		moveObj.style.left = (findPosX(reference) + reference.offsetWidth) - 550 + "px";
		moveObj.style.top = "130px";
 		moveObj.style.display = "block";
///alert('4');
	}

	function showMap() {
//		var hdrDiv = document.getElementById("pagecontainer");
//		var pos = hdrDiv.offsetLeft;
//		if (pos > 0) {
//		 	pos = (pos + 620);	
			document.write("<div id=\"star\" style=\"position:absolute; top:15px; left:"+pos+"px;\">");
			document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" width=\"550\" height=\"100\">");
			document.write("<param name=\"movie\" value=\"/images/map.swf\">");
			document.write("<param name=\"menu\" value=\"false\">");
			document.write("<param name=\"wmode\" value=\"transparent\">");		
			document.write("<param name=\"quality\" value=\"high\">");
			document.write("<embed src=\"/images/map.swf\" quality=\"high\" wmode=\"transparent\" menu=\"false\" width=\"550\" height=\"100\" name=\"star\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"></embed>");
			document.write("</object>");
			document.write("</div>");
//		}
	}

