/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
var intervalup;
var width=-200;
var heights = new Array();
	heights["about"] = 13;
	heights["trip"] = 13;
	heights["cwn"] = 13;
	heights["himalaya"] = 13;
var intervaldown;
var interval;
var expanded = "";
var ids = -1;
var searchsize = 30;
var mouseX=0;
var mouseY=0;
var fixedDivs = new Array();
var fixedDivsPosx = new Array();
var fixedDivsPosy = new Array();
var IE = document.all?true:false;
//if (!IE) document.captureEvents(Event.MOUSEMOVE)
window.onMouseMove = getMouseXY;

window.onscroll = temp;
    function temp(e)
    {
	if(document.all)
            for(var i=0;i<fixedDivs.length;i++)
            {
		document.getElementById(fixedDivs[i]).style.top = (document.body.scrollTop + fixedDivsPosy[fixedDivs[i]]) + "px";
       	        document.getElementById(fixedDivs[i]).style.left = (document.body.scrollLeft + fixedDivsPosx[fixedDivs[i]]) + "px";
            }
    }
    function keepFixed(idname,left,top)
    {
	if(document.all)
	{
		document.getElementById(idname).style.position = "absolute";
		document.getElementById(idname).style.top = top + "px";
		document.getElementById(idname).style.left = left + "px";
	}
	else
	{
		document.getElementById(idname).style.left = left + "px";
		document.getElementById(idname).style.top = top + "px";
		document.getElementById(idname).style.position = "fixed";
	}
        fixedDivs.push(idname);
        fixedDivsPosx[idname] = left;
        fixedDivsPosy[idname] = top;
    }
    function adjustText(left,top,width)
    {
        document.getElementById("maincontent").style.left = left + "px";
        document.getElementById("maincontent").style.top = top + "px";
        document.getElementById("maincontent").style.width = width + "px";
    }
function showCaption(str)
{
    document.getElementById("caption").innerHTML = str;
    document.getElementById("caption").style.visibility = "visible";
    if(document.all)
    {
    	if((mouseX + 10 + document.getElementById("caption").offsetWidth) < 297)
        {
	    document.getElementById("caption").style.left = (mouseX + 10) + "px";
        }
    }
    else
	{
	document.getElementById("caption").style.left = (mouseX + 10) + "px";
    	if((parseInt(document.getElementById("caption").style.left) + parseInt(document.getElementById("caption").offsetWidth)) >= 297)
        {
		
	    document.getElementById("caption").style.left = (297 - parseInt(document.getElementById("caption").offsetWidth))  + "px";
        }}
        document.getElementById("caption").style.top = (mouseY + 10) + "px";
    return true;
}
function hideCaption()
{
    document.getElementById("caption").style.visibility = "hidden";
}
function getMouseXY(e) {
if(!e) return true;

if (IE) { // grab the x-y pos.s if browser is IE
mouseX = e.clientX + document.body.scrollLeft;
mouseY = e.clientY + document.body.scrollTop;
}
else {  // grab the x-y pos.s if browser is NS
mouseX = e.pageX;
mouseY = e.pageY;
}
if (mouseX < 0){mouseX = 0;}
if (mouseY < 0){mouseY = 0;}
return true;
}
function searchSlide()
    {
        searchsize += 5;
        document.getElementById("searchbarmiddle").style.height = searchsize + "px";
        if(searchsize > 45)
            {
                clearInterval(ids);
                ids = -1;
            }            
    }
function transit()
{
	if(interval!=-1)
		clearInterval(interval);

    interval = setInterval("expand()", 50);
}
function expand()
{
    width += 10;
    if(width<10)
    {
        document.getElementById("slidemenu-menu").style.marginLeft = width + "px";
    }
    else
        {
        clearInterval(interval);
	interval = -1;
        }
}
function transitback()
{
	if(interval!=-1)
		clearInterval(interval);

    interval = setInterval("contract()", 50);
}
function contract()
{
    width -= 10;
    if(width>-200)
    {
        document.getElementById("slidemenu-menu").style.marginLeft = width + "px";
    }
    else
        {
        clearInterval(interval);
	interval = -1;
        }
}

function wipedown(str)
{
    if(expanded!=str)
    {
        expanded = str;
	if(!document.all)
	{
  //      document.getElementById("abouttext").style.height = "5px";
        document.getElementById("aboutmenu").style.height = "13px";
	heights["about"] = 13;

        document.getElementById("tripmenu").style.height = "13px";
    //    document.getElementById("triptext").style.height = "5px";
	heights["trip"] = 13;

        document.getElementById("cwnmenu").style.height = "13px";
      //  document.getElementById("cwntext").style.height = "5px";
	heights["cwn"] = 13;
        
        document.getElementById("himalayamenu").style.height = "13px";
      //  document.getElementById("himalayatext").style.height = "5px";
	heights["himalaya"] = 13;
	}
	else
	{
	document.getElementById("aboutmenu").style.height = "28px";
	heights["about"] = 8;
http://content.cricinfo.com/rsavaus2009/engine/current/match/350473.html
        document.getElementById("tripmenu").style.height = "28px";
    //    document.getElementById("triptext").style.height = "5px";
	heights["trip"] = 8;

        document.getElementById("cwnmenu").style.height = "28px";
      //  document.getElementById("cwntext").style.height = "5px";
	heights["cwn"] = 8;
        
        document.getElementById("himalayamenu").style.height = "28px";
      //  document.getElementById("himalayatext").style.height = "5px";
	heights["himalaya"] = 8;
	}
        if(intervaldown!=-1)
            clearInterval(intervaldown);

        intervaldown = setInterval("expanddown('" + str + "')", 50);
    }
}
function wipeup()
{
    if(expanded!="")
    {
        height=40;
        
        intevalup = setInterval("compressup('" + expanded + "')", 50);
    }
}
function expanddown(str)
{
    heights[str] += 5;
    if(heights[str]<30)
    {
       // document.getElementById(str + "text").style.height = heights[str] + "px";
        document.getElementById(str + "menu").style.height = heights[str] + "px";
    }
    else
    {
       // document.getElementById(str + "text").style.height = "auto";
        document.getElementById(str + "menu").style.height = "auto";
        clearInterval(intervaldown);
        intervaldown = -1;
    }
}
function compressup(str)
{
    height -= 5;
    if(height>5)
    {
        document.getElementById(str + "text").style.height = height + "px";
        document.getElementById(str + "menu").style.height = height + "px";
    }
    else
    {
        document.getElementById(str + "text").style.height = "7px";
        document.getElementById(str + "menu").style.height = "7px";
        expanded = "";
        clearInterval(intervalup);
    }
}
function makemenuitem(str)
{
	document.write("<table cellspacing=0 cellpadding=0 border=0><tr><Td>" + str + "</td></tr><tr><td class=\"underline\"></td></tr></table>");
}
function showSearch()
{
	document.getElementById("advisor").style.visibility = "hidden";
	document.getElementById('searchbar').style.left = document.getElementById("advisor").offsetLeft + document.getElementById("bodifier").offsetLeft + document.getElementById("headerright").offsetLeft - 33 + "px";
	document.getElementById('searchbar').style.top = document.getElementById("advisor").offsetTop - 16  + "px";
	document.getElementById('searchbar').style.visibility='visible';
}
function hideSearch()
{
	document.getElementById("advisor").style.visibility = "visible";
	document.getElementById('searchbar').style.visibility='hidden';
}
