// JavaScript Document
var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 
// -->

function showVideo(){
	var viewport = document.viewport.getDimensions();
	var height = viewport.height;
	var width = viewport.width;
	var vleft = Math.floor((width-480)/2);
	var vtop = Math.floor((height-390)/2);
	$('homeVideo').style.display = 'block';
	$('homeVideo').style.left = vleft+'px';
	$('homeVideo').style.top = vtop+'px';
	ifrm = document.createElement('iframe');
	ifrm.setAttribute('src','http://www.youtube.com/embed/I1Trxd4dh7Q?rel=0&autoplay=1');
	ifrm.style.height = 390+'px';
	ifrm.style.width = 480+'px';
	ifrm.setAttribute('title','YouTube video player');
	ifrm.setAttribute('frameborder',0);
	ifrm.setAttribute('id','iframeVideo');
	$('homeVideo').appendChild(ifrm);
	Event.observe('homeVideoClose','click',function(){
		$('iframeVideo').remove();
		$('homeVideo').style.display = 'none';
	});
}

function changeIt(objName)
{
	//The image object accessed through its id we mentioned in the DIV block which is going to be visible currently
	var obj = document.getElementById(objName);
	
	//An array that hold the IDs of images that we mentioned in their DIV blocks
	var objId = new Array();
	
	//Storing the image IDs into the array starts here
	objId[0] = "image1";
	objId[1] = "image2";
	objId[2] = "image3";
	objId[3] = "image4";
	objId[4] = "image5";
	//Storing the image IDs into the array ends here
	
	//A counter variable going to use for iteration
	var i;
	
	//A variable that can hold all the other object references other than the object which is going to be visible
	var tempObj;
	
	//The following loop does the display of a single image based on its ID. The image whose ID we passed into this function will be the
	//only image that is displayed rest of the images will be hidden based on their IDs and that part has been handled by the else part
	//of the if statement within this loop.
	for(i=0;i<objId.length;i++)
	{
		if(objName == objId[i])
		{
			obj.style.display = "block";
		}
		else
		{
			tempObj = document.getElementById(objId[i]);
			tempObj.style.display = "none";	
		}
	}
	return;	
}

