/**
* Date		:	Friday,July 19,2002.
* Author	:	Yogesh Sarang.
* Company	:	Infoseek India Pvt. Ltd.
*/
function CheckBrowserEx()
{
	this.NS=false;
	this.IE=false;
	this.ver=0;
	if(navigator.appCodeName=="Mozilla")
	{
		var ver=navigator.appVersion;
		if(navigator.appName=="Microsoft Internet Explorer")
		{
			this.IE=true;
			if(ver.indexOf("MSIE 4")>-1)
				this.ver=4;
			else if(ver.indexOf("MSIE 5")>-1)
				this.ver=5;
			else if(ver.indexOf("MSIE 6")>-1)
				this.ver=6;
			else if(ver.indexOf("MSIE 3")>-1)
				this.ver=3;
		}
		else if(navigator.appName=="Netscape")
		{
			this.NS=true;
			this.ver=parseInt(ver);
		}
	}
}

var bw=new CheckBrowserEx();

function Location()
{
	this.X=0;
	this.Y=0;
}

function MenuItem(parent)
{
	this.parent=parent;
	this.height=25;
	this.width=60;
	this.bgcolorOn='magenta';
	this.bgcolorOff='lightyellow';
	this.fontSize=15;
	this.fontFamily='verdana';
	this.fontColor='#aaaaaa';
	this.mOverImg='onarrow.jpg';
	this.mOutImg='offarrow.jpg';
	this.showImg=false;
	this.imgPos="left";
	this.createObject=createMenuItem;
}

function createMenuItem(name,loc,content,refStr,mOver,mOut)
{
	var imgOver="",imgOut="";
	var text="";


	if(bw.IE)
	{
		if((refStr!=this.parent.NULL)&&((refStr.indexOf("htm")!=-1)||(refStr.indexOf("html")!=-1)||(refStr.indexOf("asp")!=-1)))
			refStr="javascript:location.href='"+refStr+"'";

		if((this.showImg)&&(mOver==this.parent.NULL)&&(this.imgPos=="left"))
		{
			imgOver="images."+name+"_arrow.src='"+this.mOverImg+"';";
			imgOut="images."+name+"_arrow.src='"+this.mOutImg+"';";
		}
		
		text="<DIV name="+name+" id="+name+" style=visibility:hidden;position:absolute;"+((refStr!=this.parent.NULL)?"cursor:hand;":"")+"background-color:"+this.bgcolorOff+";width:"+this.width+";height:"+this.height+";left:"+loc.X+";top:"+loc.Y+";z-index:4; onmouseover=\""+mOver+";this.style.backgroundColor='"+this.bgcolorOn+"';this.style.zIndex=15;"+imgOver+"\" onmouseout=\""+mOut+";this.style.backgroundColor='"+this.bgcolorOff+"';this.style.zIndex=4;"+imgOut+"\" onclick="+refStr+"><table width=100% height=100% cellspacing=0 cellpadding=2 border=0><tr>";

		if((this.showImg)&&(this.imgPos=="left"))
				text+="<td><img name='"+name+"_arrow' id='"+name+"_arrow' src="+this.mOutImg+"></td>";
		text+="<td width="+this.width+" valign='middle' style='font-size:"+this.fontSize+";font-family:"+this.fontFamily+";color:"+this.fontColor+"'>"+content+"</td>";
		if((this.showImg)&&(this.imgPos=="right")&&(mOver!=this.parent.NULL))
				text+="<td><img name='"+name+"_arrow' id='"+name+"_arrow' src="+this.mOutImg+"></td>";
		text+="</tr></table></DIV>";
	}
	else if((bw.NS) && (bw.ver == 4))
	{
		if((this.showImg)&&(mOver==this.parent.NULL)&&(this.imgPos=="left"))
		{
			imgOver="this.document.images."+name+"_arrow.src='"+this.mOverImg+"';";
			imgOut="this.document.images."+name+"_arrow.src='"+this.mOutImg+"';";
		}

		text="<LAYER name="+name+" id="+name+" top="+loc.Y+" left="+loc.X+" width="+this.width+" height="+this.height+" visibility=hidden z-index=4 "+((this.bgcolorOff!=null)? "bgColor="+this.bgcolorOff : "")+" onmouseover=\"this.bgColor="+((this.bgcolorOn!=null)? "'"+this.bgcolorOn+"'" : "null")+";"+mOver+";"+imgOver+"\" onmouseout=\"this.bgColor="+((this.bgcolorOff!=null)? "'"+this.bgcolorOff+"'" : "null")+";"+mOut+";"+imgOut+"\"><table width=100% height=100% cellspacing=0 cellpadding=2 border=0><tr>";

		if((this.showImg)&&(this.imgPos=="left"))
				text+="<td><img name='"+name+"_arrow' id='"+name+"_arrow' src="+this.mOutImg+"></td>";
		if(refStr==this.parent.NULL)
			refStr="javascript:void()";
			text+="<td width=100% valign='middle'><A href='"+refStr+"' style='text-decoration:none;font-size:"+this.fontSize+"px;font-family:"+this.fontFamily+";color:"+this.fontColor+"'>"+content+"</A></td>";
		if((this.showImg)&&(this.imgPos=="right")&&(mOver!=this.parent.NULL))
				text+="<td><img name='"+name+"_arrow' id='"+name+"_arrow' src="+this.mOutImg+"></td>";
		text+="</tr></table></LAYER>";
	}
	this.parent.filler+=text;
}

function MenuItemCollection(parent)
{
	this.parent=parent;
	this.direction=parent.VERTICAL;
	this.placement=3;
	this.createObject=createMenuItemCollection;
}

function createMenuItemCollection(i,name,loc,mitems,mlinks)
{
	this.parent.mainMenuItem.createObject(this.parent.name+"_mainMenu_"+i,loc,name,this.parent.NULL,this.parent.name+".showSub("+i+")",this.parent.name+".hideSub("+i+")");

	if(this.direction==this.parent.HORIZONTAL)
	{
		loc.X+=this.parent.mainMenuItem.width;
		loc.Y+=this.placement;
	}
	else if(this.direction==this.parent.VERTICAL)
	{
		loc.X+=this.placement;
		loc.Y+=this.parent.mainMenuItem.height;
	}


	if(bw.IE)
		this.parent.filler+="<div name="+this.parent.name+"_subMenu_"+i+" id="+this.parent.name+"_subMenu_"+i+" style=visibility:hidden;position:absolute;left:"+loc.X+";top:"+loc.Y+"; onmouseover="+this.parent.name+".showSub("+i+") onmouseout="+this.parent.name+".hideSub("+i+")>";
	else if((bw.NS) && (bw.ver == 4))
		this.parent.filler+="<layer name="+this.parent.name+"_subMenu_"+i+" id="+this.parent.name+"_subMenu_"+i+" visibility=hidden left="+loc.X+" top="+loc.Y+" z-index=15 onmouseover="+this.parent.name+".showSub("+i+") onmouseout="+this.parent.name+".hideSub("+i+")>";

	for(j=0; j<mitems.length; j++)
	{
		sloc=new Location();

		if(this.direction==this.parent.HORIZONTAL)
		{
			sloc.X=0;
			sloc.Y=this.parent.subMenuItem.height*j;
		}
		else if(this.direction==this.parent.VERTICAL)
		{
			sloc.X=0;
			sloc.Y=this.parent.subMenuItem.height*j;
		}

		if((typeof(mlinks)=="object")
		&&(typeof(mlinks[j])=="string"))
			this.parent.subMenuItem.createObject(this.parent.name+"_subMenu_"+i+"_"+j,sloc,mitems[j],mlinks[j],this.parent.NULL,this.parent.NULL);
		else
			this.parent.subMenuItem.createObject(this.parent.name+"_subMenu_"+i+"_"+j,sloc,mitems[j],this.parent.NULL,this.parent.NULL,this.parent.NULL);
	}

	if(bw.IE)
		this.parent.filler+="</div>";
	else if((bw.NS) && (bw.ver == 4))
		this.parent.filler+="</layer>";
}

function YSMenu(name)
{
	this.HORIZONTAL=0,this.VERTICAL=1,this.UNORDERED=2,this.NULL=0;

	this.name=name;

	this.MainMenuItems=new Array();
	this.SubMenuItems=new Array();
	
	this.MainMenuLinks=new Array();
	this.SubMenuLinks=new Array();
	
	this.mainMenuLocations=new Array();

	this.mainMenuItem=new MenuItem(this);
	this.subMenuItem=new MenuItem(this);
	this.subMenuItemCollection=new MenuItemCollection(this);
	
	this.showMain=showMain;

	this.showSub=showSub;
	this.hideSub=hideSub;

	this.CreateMenu=create;

	this.filler="";
	this.direction=this.HORIZONTAL;
	this.placement=0;
}

function create(x,y)
{
	if(this.direction==this.UNORDERED)
		if(this.mainMenuLocations.length<this.MainMenuItems.length)
			this.direction=this.HORIZONTAL;

	if(this.direction==this.HORIZONTAL)
	{
		for(i=0; i<this.MainMenuItems.length; i++)
		{
			this.mainMenuLocations[i]=new Location();
			this.mainMenuLocations[i].X=x+i*(this.mainMenuItem.width+this.placement);
			this.mainMenuLocations[i].Y=y;
		}
	}
	else if(this.direction==this.VERTICAL)
	{
		for(i=0; i<this.MainMenuItems.length; i++)
		{
			this.mainMenuLocations[i]=new Location();
			this.mainMenuLocations[i].X=x;
			this.mainMenuLocations[i].Y=y+i*(this.mainMenuItem.height+this.placement);
		}
	}
	
	if((bw.NS) && (bw.ver == 4))
	{
		if(this.mainMenuItem.bgcolorOn.length==0)
			this.mainMenuItem.bgcolorOn=null;
		if(this.mainMenuItem.bgcolorOff.length==0)
			this.mainMenuItem.bgcolorOff=null;
		if(this.subMenuItem.bgcolorOn.length==0)
			this.subMenuItem.bgcolorOn=null;
		if(this.subMenuItem.bgcolorOff.length==0)
			this.subMenuItem.bgcolorOff=null;
	}

	for(i=0; i<this.MainMenuItems.length; i++)
	{
		if(typeof(this.SubMenuItems[i])=="object")
			this.subMenuItemCollection.createObject(i,this.MainMenuItems[i],this.mainMenuLocations[i],this.SubMenuItems[i],this.SubMenuLinks[i]);
		else if(typeof(this.MainMenuLinks[i])=="string")
			this.mainMenuItem.createObject(this.name+"_mainMenu_"+i,this.mainMenuLocations[i],this.MainMenuItems[i],this.MainMenuLinks[i],this.NULL,this.NULL);
		else
			this.mainMenuItem.createObject(this.name+"_mainMenu_"+i,this.mainMenuLocations[i],this.MainMenuItems[i],this.NULL,this.NULL,this.NULL);
	}

	document.write(this.filler);
}

function showMain()
 {
	for(i=0; i<this.MainMenuItems.length; i++)
	{
		if(bw.IE)
		{
			obj=eval(this.name+"_mainMenu_"+i);
			obj.style.clip="rect(0, "+this.mainMenuItem.width+", "+this.mainMenuItem.height+", 0)";
			obj.style.visibility="visible";
		}
		else if((bw.NS) && (bw.ver == 4))
		{
			obj=eval("document."+this.name+"_mainMenu_"+i);
			obj.visibility="visible";
		}
	}
}

function showSub(main)
{
	if(bw.IE)
	{
		obj=eval(this.name+"_mainMenu_"+main);
		obj.style.backgroundColor=this.mainMenuItem.bgcolorOn;

		if(this.mainMenuItem.showImg)
		{
			imge=eval("document.images."+this.name+"_mainMenu_"+main+"_arrow");
			imge.src=this.mainMenuItem.mOverImg;
		}

		obj=eval(this.name+"_subMenu_"+main);
		obj.style.visibility="visible";
		obj.style.width=this.mainMenuItem.width;
		obj.style.zIndex=15;

		for(i=0; i<this.SubMenuItems[main].length; i++)
		{
			obj=eval(this.name+"_subMenu_"+main+"_"+i);
			obj.style.visibility="visible";
		}
	}
	else if((bw.NS) && (bw.ver == 4))
	{
		obj=eval("document."+this.name+"_mainMenu_"+main);
		obj.bgColor=this.mainMenuItem.bgcolorOn;
		
		if(this.mainMenuItem.showImg)
		{
			imge=eval("document."+this.name+"_mainMenu_"+main+".document.images."+this.name+"_mainMenu_"+main+"_arrow");
			imge.src=this.mainMenuItem.mOverImg;
		}

		obj=eval("document."+this.name+"_subMenu_"+main);
		obj.visibility="visible";
		obj.width=this.mainMenuItem.width;
		
		for(i=0; i<this.SubMenuItems[main].length; i++)
		{
			obj=eval("document."+this.name+"_subMenu_"+main+".document."+this.name+"_subMenu_"+main+"_"+i);
			obj.visibility="visible";
		}
	}
}

function hideSub(main)
{
	if(bw.IE)
	{
		obj=eval(this.name+"_mainMenu_"+main);
		obj.style.backgroundColor=this.mainMenuItem.bgcolorOff;

		if(this.mainMenuItem.showImg)
		{
			imge=eval("document.images."+this.name+"_mainMenu_"+main+"_arrow");
			imge.src=this.mainMenuItem.mOutImg;
		}

		obj=eval(this.name+"_subMenu_"+main);
		obj.style.visibility="hidden";
		obj.style.zIndex=4;

		for(i=0; i< this.SubMenuItems[main].length; i++)
		{
			obj=eval(this.name+"_subMenu_"+main+"_"+i);
			obj.style.visibility="hidden";
		}
	}
	else if((bw.NS) && (bw.ver == 4))
	{
		obj=eval("document."+this.name+"_mainMenu_"+main);
		obj.bgColor=this.mainMenuItem.bgcolorOff;

		if(this.mainMenuItem.showImg)
		{
			imge=eval("document."+this.name+"_mainMenu_"+main+".document.images."+this.name+"_mainMenu_"+main+"_arrow");
			imge.src=this.mainMenuItem.mOutImg;
		}

		obj=eval("document."+this.name+"_subMenu_"+main);
		obj.visibility="hidden";

		for(i=0; i< this.SubMenuItems[main].length; i++)
		{
			obj=eval("document."+this.name+"_subMenu_"+main+".document."+this.name+"_subMenu_"+main+"_"+i);
			obj.visibility="hidden";
		}
	}
}
