var scroller_height = 0;
var BFI = 2;	// BFI => Base Frame Index
var search_focused = false;

var Menu_Reset_Timer = 0;
var Menu_Set_Timer = 0;
var current_menu = null;
var clrList = new Array();
clrList[0] = new Array("#990000", "#660000");
clrList[1] = new Array("#436BFF", "#1135BB");
var clrOld = "";
var argObject = null;

var Menu_Directory = location.href.substr(0, location.href.lastIndexOf('/'));
var Root_Directory = parent.location.href.substr(0, parent.location.href.lastIndexOf('/') + 1); //Menu_Directory.substr(0, Menu_Directory.lastIndexOf('/') + 1);
Menu_Directory += '/';

var imgTopLeft = new Image();		imgTopLeft.src = Menu_Directory + 'top_l.gif'
var imgTopRight = new Image();		imgTopRight.src = Menu_Directory + 'top_r.gif'
var imgBottomLeft = new Image();	imgBottomLeft.src = Menu_Directory + 'bottom_l.gif'
var imgBottomRight = new Image();	imgBottomRight.src = Menu_Directory + 'bottom_r.gif'
var imgSpacer = new Image();		imgSpacer.src = Root_Directory + 'images/spacer.gif'

var isIE = false;
var doc = "document.";
var st = ""; 

if(navigator.appName == "Microsoft Internet Explorer")	{ doc += "all."; st=".style"; isIE=true; }

var MenuText = new Array();
	MenuText[0] = new Array('Home', 'This page have some general information about me and my thinking. You can also' +
							' get my PGP Public Key &amp; "Geek Code" from here.');
	MenuText[1] = new Array('Curriculum Vitae', 'My Dynamic R&eacute;sum&eacute; is featured with different view' +
							' and edit modes. My r&eacute;sum&eacute; is also available in <a class="hint"' +
							' href="' + Root_Directory + 'ashutosh/cv/cv.pdf" target="_blank">PDF</a> and plain' +
							' <a class="hint" href="' + Root_Directory + 'ashutosh/cv/cv.txt" target="_blank">' +
							' text</a> formats.');
	MenuText[2] = new Array('Downloads', 'Some of the softwares I developed. If you already know them then you may' +
							' also download them directly from here <ul>' +
		'<li><a class="hint" href="' + Root_Directory +
		'guestbook.html#Anti-Redlof?./download/Anti-Redlof.zip" target="_blank">Anti-Redlof</a></li>' +
		'<li><a class="hint" href="' + Root_Directory +
		'guestbook.html#Hindi Editor?./download/hindi_editor.zip" target="_blank">Hindi Editor</a></li>' +
		'<li><a class="hint" href="' + Root_Directory +
		'guestbook.html#WMSelect?./download/WMSelect-1.00-1.i386.rpm" target="_blank">WMSelect</a></li>' +
		'<li><a class="hint" href="' + Root_Directory +
		'guestbook.html#Windows API for DOS?./download/api.zip" target="_blank">Windows Api for Dos</a></li>' +
		'<li><a class="hint" href="' + Root_Directory +
		'guestbook.html#Language Interprater?./download/lipi.zip" target="_blank">Lipi</a></li>' +
		'<li><a class="hint" href="' + Root_Directory +
		'guestbook.html#splash?./download/splash.zip" target="_blank">Splash</a></li></ul>');
	MenuText[3] = new Array('Articles', 'Some of my technical and philosophical articles.');
	MenuText[4] = new Array('Links', 'Some useful links that I got from friends and friendly search engines');
	MenuText[5] = new Array('Guest Book', 'Please sign my "Guest Book" with your valuable comments. You can also ' +
							'<a class="hint" href="http://guestbooks.pathfinder.gr/read/pragya" target="_blank">view</a> the ' +
							'comments of other visitors.');
	MenuText[6] = new Array('Reader', 'If you are running Windows ME/2000/XP or better then just give it a try. you might get some' +
							' rest for your eyes.');
	MenuText[7] = new Array('Raw TCP/IP', 'A low level TCP/IP client based on WinSock control. It is working but still under' +
							' development so please notify me about errors.');
	MenuText[8] = new Array('Secret', 'If you think you can crack passwords. Try this!');
	MenuText[9] = new Array('Shantikunj', 'The official site of Gayatri Pariwar, Shantikunj Haridwar.');
	MenuText[10] = new Array('Education', 'My educational biography.');
	MenuText[11] = new Array('Knowledge', 'Take a look at what I have fed to the Neural Nets of my brain.');
	MenuText[12] = new Array('Family Cube', 'A VRML world with the pictures of my family members. Your browser must support VRML(Virtual Reality' +
								' Markup Language).');
	MenuText[13] = new Array('My Computer', 'My computer\'s hardware and software configuration.');
	MenuText[14] = new Array('IGNOU - MCA', 'My activities at IGNOU. Here you can find the assignments and projects' +
								' of the MCA 1<sup>st</sup> Semester.');
	MenuText[15] = new Array('My Teachers','About the teachers who changed my life.');
	MenuText[16] = new Array('Hindi Editor','You can type Hindi efficiently with this editor.');
	MenuText[17] = new Array('Encrypter','A JavaScript Encrypter. It will hide your source code but it will still work as before.');
	MenuText[18] = new Array('Contact Info','The information about all pointers that points towards me. With this information you may contact me using any possible medium.');
	MenuText[19] = new Array('Sitemap','This will help you to navigate through the site easily.');
	MenuText[20] = new Array('Photo Album','Some of my memories in the form of images.');
	MenuText[21] = new Array('','');

function GetText(ListName, ItemName){
var i = 0;
	for(i = 0; i < ListName.length; i++) if(ListName[i][0] == ItemName) return ListName[i][1];
	return "";
}

function reset_menu(){
	if(current_menu)	current_menu.bgColor = clrOld;
	if(parent.frames.item(BFI).document.all.InterFrameMenu)	
		parent.frames.item(BFI).document.all.InterFrameMenu.style.visibility="hidden";
	if(parent.frames.item(BFI).document.all.InterFrameMenuBack)	
		parent.frames.item(BFI).document.all.InterFrameMenuBack.style.visibility="hidden";
}

function set_menu(pos_x, pos_y){
	reset_menu();
	current_menu = argObject;
var ht = 0, wd = 0;
var i = 0;
var delta = current_menu.offsetHeight;
var clrBorder = "#FF00FF";
var clrBack = GetText(clrList, current_menu.bgColor.toUpperCase());

	clrOld = current_menu.bgColor;
	current_menu.bgColor = clrBack;
	current_menu.style.color = "#FFFFFF";
	with(parent.frames.item(BFI).document){
		if(body && !all.InterFrameMenu){
			body.insertAdjacentHTML('AfterBegin','<div id="InterFrameMenu"" style="position:absolute;z-index:1000;padding:10px;"></div>');
			body.insertAdjacentHTML('AfterBegin','<div id="InterFrameMenuBack" style="position:absolute;z-index:1000;padding:0px;filter:alpha(Opacity=100,FinishOpacity=60,style=1);">' +
'<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%"><tr>' +
'	<td width="10" height="10" align="left" valign="top"><img src="' + imgTopLeft.src +'" border="0" width="10" height="10"></td>' +
'	<td width="100%" height="10" bgcolor="#660000"><img src="' + imgSpacer.src + '" border="0" width="1" height="1"></td>' +
'	<td width="10" height="10" align="right" valign="top"><img src="' + imgTopRight.src + '" border="0" width="10" height="10"></td>' +
'</tr>' +
'<tr height="100%">' +
'	<td bgcolor="#660000"><img src="' + imgSpacer.src + '" border="0" width="10" height="10"></td>' +
'	<td width="100%" height="100%" bgcolor="#660000">&nbsp;</td>' +
'	<td bgcolor="#660000"><img src="' + imgSpacer.src + '" border="0" width="10" height="10"></td>' +
'</tr>' +
'<tr>' +
'	<td width="10" height="10" align="left" valign="bottom"><img src="' + imgBottomLeft.src + '" border="0" width="10" height="10"></td>' +
'	<td width="100%" height="10" bgcolor="#660000"><img src="' + imgSpacer.src + '" border="0" width="10" height="10"></td>' +
'	<td width="10" height="10" align="right" valign="bottom"><img src="' + imgBottomRight.src + '" border="0" width="10" height="10"></td>' +
'</tr>' +
'</table>' +
'</div>');
			if(!all.InterFrameMenu)	 return null;
			else{
				body.onscroll = reset_menu;
				all.InterFrameMenu.style.left = -2;
				all.InterFrameMenuBack.style.left = 0;
				all.InterFrameMenu.onmouseover = mouseover;
				all.InterFrameMenu.onmouseout = mouseout;
				all.InterFrameMenuBack.onmouseover = mouseover;
				all.InterFrameMenuBack.onmouseout = mouseout;
			}
		} else if(!body)	return null;
		all.InterFrameMenu.innerHTML = '<div id="InterFrameMenuText" style="color:' + current_menu.style.color +
										';font-size:12pt;"><b>' + GetText(MenuText, current_menu.innerText) + '</b></div>';
		all.InterFrameMenu.style.height = ht = 0;
		all.InterFrameMenu.style.width = wd = 0;
		ht = all.InterFrameMenu.offsetHeight;
		wd = all.InterFrameMenu.offsetWidth;
		i = 10;
		while(Math.abs((wd * 2 / 3) - ht) > 10 && i > 0 ){
			all.InterFrameMenu.style.height = Math.sqrt(wd * ht * 2 / 3);
			all.InterFrameMenu.style.width = Math.sqrt(wd * ht * 3 / 2);
			ht = all.InterFrameMenu.offsetHeight;
			wd = all.InterFrameMenu.offsetWidth;
			--i;
		}
		all.InterFrameMenu.style.height = all.InterFrameMenuBack.style.height = ht+"px";
		all.InterFrameMenu.style.width = all.InterFrameMenuBack.style.width = wd+"px";

		if((pos_y + scroller_height + body.scrollTop + ht) < (body.scrollTop + body.clientHeight))
			all.InterFrameMenu.style.top = (pos_y + scroller_height + body.scrollTop);
		else
			if(ht < body.clientHeight)
				all.InterFrameMenu.style.top = (body.scrollTop + body.clientHeight - ht);
			else
				all.InterFrameMenu.style.top = body.scrollTop;
		all.InterFrameMenuBack.style.top = all.InterFrameMenu.style.top;

		all.InterFrameMenu.style.visibility = "visible";
		all.InterFrameMenuBack.style.visibility = "visible";
	}
}

function install_menu(){
	try{
		if(	parent.frames.item(BFI) &&
			parent.frames.item(BFI).document &&
			parent.frames.item(BFI).document.all.InterFrameMenu &&
			parent.frames.item(BFI).document.all.InterFrameMenuBack ){
				parent.frames.item(BFI).document.all.InterFrameMenu.outerHTML = "";
				parent.frames.item(BFI).document.all.InterFrameMenuBack.outerHTML = "";
			}
			set_menu(-500,-500);
			reset_menu();
	}
	catch(er){/*Do Nothing*/}
}

function mouseover(src){
	clearTimeout(Menu_Set_Timer);
	if(!src) { clearTimeout(Menu_Reset_Timer); return; }
	clearTimeout(Menu_Reset_Timer);
	argObject = src;
	Menu_Set_Timer = setTimeout('set_menu(' + (event.clientX - event.offsetX + src.offsetWidth) + ',' +
							(event.clientY - event.offsetY) + ');', 500);
}

function mouseout(){
	clearTimeout(Menu_Set_Timer);
	Menu_Reset_Timer = setTimeout("reset_menu()", 1000);
}

function mouseclick(){
	reset_menu();
}

function mousealert(){	if(event.button==2) alert('Please don\'t right click on this button.'); }
function keyalert(){	if(event.keyCode==93 || event.keyCode==121)	alert('Please don\'t try to open popup menu for this button.'); }

function menu_block_toggle(obj) {obj.style.display=(obj.style.display=='none') ? 'block' : 'none';}

function init(){
	document.all.q.style.filter = "Light(0);"
	document.all.q.filters.Light(0).addPoint(10,10,100,255,255,255,1000);
	document.all.q.filters.Light(0).addCone(-500,-500,100,300,200,100,0,0,50,90);

	if(!parent.frames.length) return;

	for(i = 0; i < parent.frames.length; i++){
		if(parent.frames.item(i).name == "pragya_base") BFI = i;
	}
	argObject = document.all.first_menu;
	install_menu();
}

document.onscroll=reset_menu;
