var special=1;
var disablemenu=false;

function MM_swapImgRestore()
{
	var i,x,a=document.MM_sr;
	for(i=0; a && i < a.length && (x = a[i]) && x.oSrc; i++)
		x.src=x.oSrc;
}

function MM_preloadImages()
{
	var d=document;
	if(d.images)
	{
		if(!d.MM_p)
			d.MM_p=new Array();
		var i, j = d.MM_p.length, a = MM_preloadImages.arguments;
		for(i=0; i < a.length; i++)
		{
			if (a[i].indexOf("#")!=0)
			{
				d.MM_p[j] = new Image;
				d.MM_p[j++].src=a[i];
			}
		}
	}
}

function MM_findObj(n, d)
{
	var p,i,x;
	if(!d)
		d=document;
	if((p=n.indexOf("?")) > 0 && parent.frames.length)
	{
		d=parent.frames[n.substring(p+1)].document;
		n=n.substring(0,p);
	}
	if(!(x=d[n]) && d.all)
		x=d.all[n];
	for(i=0; !x && i < d.forms.length; i++)
		x=d.forms[i][n];
	for(i=0; !x && d.layers && i < d.layers.length; i++)
		x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById)
		x=d.getElementById(n);
	return x;
}

function MM_swapImage() {
	var i, j = 0, x, a = MM_swapImage.arguments;
	document.MM_sr = new Array;
	for(i=0; i < (a.length - 2); i += 3)
	{
		if ((x = MM_findObj(a[i])) != null)
		{
			document.MM_sr[j++]=x;
			if(!x.oSrc)
				x.oSrc=x.src;
			x.src=a[i+2];
		}
	}
}

function GetMsg()
{
	var wisdom="True wisdom comes from above.";
	Window2=open("","quote","scrollbars=no,width=300,height=150,left=200,top=100");
	Window2.document.open();
	Window2.document.write("<HEAD><TITLE>Wisdom Quote of the Day!</TITLE></HEAD>");
	Window2.document.write("<CENTER><BIG><B>"+wisdom+"</B></BIG>");
	Window2.document.write("</CENTER>");
	Window2.document.close();
}
function CloseMsg()
{
	Window2=open("","quote");
	Window2.close();
}

function Buttons(page,section){ 
	var i, txt;
	var xlink = new Array("", "about.asp", "serv_over.asp", "showcase.asp", "faq.asp", "news_over.asp", 
		"projmgmt.asp", "showcase.asp", "talent.asp", "subscribe.asp", "help_and_support.asp", "projmgmt.asp", 
		"contact2.asp");
	x = (((section-1)*4)+1);
	xpage = (page*1)+x-1;
	for (i=x; i < x+6 ; i++)
	{
		//for each nav left button
		if (i==xpage)
		{
			//if the current view is i page - menu always displayed (disable the DOM for menu)
			txt='<img src="images/nav' + i;
			txt += '_in.gif" name="Image' + (20+i) + '" width="198" height="35" border="0">';
			switch (i) //special rules for special buttons (i) : put a case if the button needs a menu
			{
				case 2:
		    		txt = Write_Menu (false,131,'<a href="'+xlink[i]+'">'+txt+'</a>','','sitebuilding1.asp',
						'Website Services','services.asp','Custom Software','hosting.asp','Hosting Services',
						'network.asp','Network Services','hardware.asp','Hardware Configurations','help_and_support.asp',
						'Help and Support','products.asp','WebServ Products','MakePayment.asp','Pay WebServ Invoice');
					break;
				case 5:
					txt = Write_Menu(false,65,'<a href="' + xlink[i] + '">' + txt + '</a>','','news.asp','News',
						'links.asp','Useful Links','resources.asp','Resources','jobs.asp','Jobs');
					break;
				default:
					txt = '<img src="images/nav' + i;
					txt += '_in.gif" name="Image' + (20+i) + '" width="198" height="35" border="0">';
			}
      	}
		else //if the current view is not page i (all other buttons)
		{
			var Link_Code='<a class="navImage" id="img' + (20+i) + '" href="' + xlink[i] + '">';
			Link_Code += '<img src="images/transparent.gif" width="198" height="34" border="0"></a>';

			switch (i) //special rules for special buttons (i) put a case if the button needs a menu
			{
				case 2 :			
					if (disablemenu)
						txt=Link_Code+'<br>';
					else
						txt += Write_Menu (true, 131, Link_Code,'','sitebuilding1.asp','Website Services',
							'services.asp','Custom Software','hosting.asp','Hosting Services','network.asp',
							'Network Services','hardware.asp','Hardware Configurations','help_and_support.asp','Help and Support'
							,'products.asp','WebServ Products','MakePayment.asp','Pay WebServ Invoice');
					break;
				case 5:
					if (disablemenu)
						txt = Link_Code+'<br>';
					else
						txt += Write_Menu (true, 65,Link_Code,'','news.asp','News','links.asp','Useful Links',
							'resources.asp','Resources','jobs.asp','Jobs');
					break;
				default:
					txt = Link_Code;
					break;
			}
		}
		document.write(txt);
		txt="";
	}
}

function BodyPreLoad(section)
{ 
	x = ((section-1)*4)+1;
	txt = '<body bgcolor="#f0f0f0" ';
	txt += 'onLoad="MM_preloadImages(';
	for(i=x; i < x+6 ; i++)
		txt += "'images/nav"+i+"_ovr.gif',";	
	txt += "'images/top_email-ovr.gif',";
	txt += "'images/top_contact--ovr.gif',";
	txt += "'images/nav_left_logo-ovr.gif')";
	txt += '">';
	document.write(txt);
	txt = "";
}

var PIX_SLIDE = 10; //this is the amount of slide/DELAY_SLIDE
var DELAY_SLIDE = 30;
var timers = new Array();
var closeMenu = new Array();

function OpenMenu(obj, divHeight, index)
{
	var slide = obj.getElementsByTagName("div").item(1);

	var doOpen = function() {
		var newHeight = parseInt(slide.style.height);
		if(!newHeight)
			newHeight = 0;
		newHeight += PIX_SLIDE;
		
		if(newHeight > divHeight)
		{
			clearInterval(timers[index]);
			timers[index] = null;
			slide.style.height = divHeight;
		}
		else
			slide.style.height = newHeight;
		slide.style.display = "block";
	}

	var cancelClose = function() {
		closeMenu[index] = false;
	}
	
	var waitClose = function() {
		closeMenu[index] = true;
		setTimeout(tryClose, 350);
	}
	
	var tryClose = function() {
		if(closeMenu[index] && !timers[index])
			timers[index] = setInterval(doClose, DELAY_SLIDE);
	}
	
	var doClose = function() {
		var newHeight = parseInt(slide.style.height);
		if(!newHeight)
			newHeight = 0;
		newHeight -= PIX_SLIDE;
		
		if(newHeight < 0)
		{
			clearInterval(timers[index]);
			timers[index] = null;
			slide.style.height = 0;
			slide.style.display = "none";
		}
		else
		{
			slide.style.height = newHeight;
			slide.style.display = "block";
		}
	}

	closeMenu[index] = false;
	if(!timers[index])
	{
		obj.onmouseout = waitClose;
		slide.onmouseover = cancelClose;
		slide.onmouseout = waitClose;
		timers[index] = setInterval(doOpen, DELAY_SLIDE);
	}
}

var indexHolder = 0;

function Write_Menu () {
	//writes folding menu script
	//usage Write_Menu (boolean (true=enable init false=disable init), height, HTML (put link if wanted), functions for 
	//					mousovers (HTML), (for main menu),URL , HTML (for submenus),URL2, HTML2...)
	//example:  txt += Write_Menu (true,'<img src="images/nav'+i+'_in.gif" name="Image'+(20+i)+'"
	//				border = "0">','','about.asp','about');

	//can combine the navigator sensitive commands sometime for optimized code
	var x=0, txt;
	var enabled = Write_Menu.arguments[0];
	var height = Write_Menu.arguments[1];

	txt = '<div class="mainDiv" onmouseover="OpenMenu(this,' + height + ',' + indexHolder + ');">';
	txt += '<div class="topItem" ' +Write_Menu.arguments[3] + '>'+Write_Menu.arguments[2]+
		'</div><div class="dropMenu">';

	for (x=4; x<Write_Menu.arguments.length; x+=2) //for each argument after the first 3, make a submenuitem for it
	{
		txt += '<a class="subItem" href="' + Write_Menu.arguments[x] + '">' + Write_Menu.arguments[x+1] + '</a><br/>';
	}
	txt += '</div></div>';
	indexHolder++;
	return txt;
}

document.write ('<link href="style/webserv.css" rel="stylesheet" type="text/css">');
document.write ('<link href="style/sddm.css" rel="stylesheet" type="text/css">');