/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: ScriptBreaker :: http://www.scriptbreaker.com/ */

var height = 25; // height of the menu headers
var iheight = 22; // height of the menu_items

var bgc = "" // background color of the item
var tc = "#30465B" // text color of the item

var over_bgc = "";
var over_tc = "#30465B";


<!-- New Variables 02/10/2007 Start-->
var bg = "" // background color of the item
var bc = "#336699" // text color of the item

var over_bg = "";
var over_bc = "#7D0100";
<!-- End 02/10/2007 -->

var speed = 0;
var timerID = "";
var N = (document.all) ? 0 : 1;
var width = 190
var self_menu = new Array();

function write_menu() {
  smc = 0; // count the position of the self_menu
  document.write("<div style='position:relative' id='maindiv'>");
  mn = 0;
  mni = 1;
  start = -1;

  for(i=0;i<Link.length;i++) {
   la = Link[i].split("|");
   if (la[0] == "0") {
    if(start == 0) {
      document.write("</div>");
      h =  csmc * iheight;
      tmn = mn; //-h
      self_menu[smc] = new Array(tmn,h,0,-2);
      smc++;
      mn--;
     }
     csmc = 0;
	 if (la[2] == "0" || la[2] == "X") {
	 	if (la[1] == "") {
			document.write("<div class='menu' style='top:"+mn+";height:"+height+"' id='down"+smc+"'onmouseover='colour(this.id)' onmouseout='uncolour(this.id)'> &nbsp;");
			mni++;
			mn+=height;
		}else{	
		 	document.write("<div class='menu' style='top:"+mn+";height:"+height+"' id='down"+smc+"' onclick='redirect_page("+la[4]+")'onmouseover='colour(this.id)' onmouseout='uncolour(this.id)'>&nbsp;&nbsp;<img src='images/arrow.gif' name='"+la[3]+"' border='0' id='"+la[3]+"'> &nbsp;&nbsp;"+ la[1] + "");
			mni++;
			mn+=height;
		}
	 }else{
		//document.write("<div class='menu' style='top:"+mn+";height:"+height+"' id='down"+smc+"' onclick='pull_down("+smc+","+mni+")'>&nbsp;&nbsp;<img src='images/arrow.gif' name='"+la[3]+"' border='0' id='"+la[3]+"'> &nbsp;&nbsp;"+ la[1] + "</div>");
		document.write("<div class='menu' style='top:"+mn+";height:"+height+"' id='down"+smc+"' onclick='redirect_page("+la[2]+")'onmouseover='colour(this.id)' onmouseout='uncolour(this.id)'>&nbsp;&nbsp;<img src='images/arrow.gif' name='"+la[3]+"' border='0' id='"+la[3]+"'> &nbsp;&nbsp;"+ la[1] + "</div>");
		self_menu[smc] = new Array(mn,height,0,mni);
		smc++;
		mni++;
		mn+=height;
		start = 1;
	}
   } else {
    if(start == 1) {
      if(N)mn+=2;
       document.write("<div class='item_panel' id='down"+smc+"' style='top:"+mn+"'>");
       start = 0;
     }

    document.write("<a href='javascript:redirect_page("+la[2]+")'");
    if (la[3] != "") document.write(" target='" + la[3] + "' ");
    document.write("><div class='item' id='d"+i+"' style='height:"+iheight);
    if (N) document.write(";width:190");
    document.write("' onmouseover='color(this.id)' onmouseout='uncolor(this.id)' onclick='redirect_page("+la[2]+")'>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src='images/dot_bu.gif' height=8 width=8 name='"+la[4]+"' border='0' id='"+la[4]+"'>&nbsp;"+ la[1] + "</div></a>");
    csmc++;
   }
  }
  if (start == 0) {
     document.write("</div>");
     h =  csmc * iheight;
     tmn = mn + 5; //-h
     self_menu[smc] = new Array(tmn,h,0);
     name = "down" + (self_menu.length-1);
     obj = document.getElementById(name);
     obj.style.borderBottomColor = "darkblue";
     obj.style.borderBottomWidth = 0;
     obj.style.borderBottomStyle = "solid";
   }
  document.write("</div>");
}

function color(obj) {
 document.getElementById(obj).style.backgroundColor = over_bg;
 document.getElementById(obj).style.color = over_bc
  
 
}

function uncolor(obj) {
 document.getElementById(obj).style.backgroundColor = bgc;
 document.getElementById(obj).style.color = tc
}

<!-- New Function  On 02/10/2007 Start -->
function colour(obj) {
 document.getElementById(obj).style.backgroundColor = over_bg;
 document.getElementById(obj).style.color = over_bc

}

function uncolour(obj) {
 document.getElementById(obj).style.backgroundColor = bg;
 document.getElementById(obj).style.color = bc
}
<!-- New Function  On 02/10/2007 End -->

function pull_down(nr,c,sh) {
 if (timerID == "") {
	 to = self_menu[nr+1][1]
	 begin = nr + 2;
	 if (timerID != "") clearTimeout(timerID);
	 if (self_menu[nr+1][2] == 0) {
	  self_menu[nr+1][2] = 1;
	  if(nr == self_menu.length-2) {to++;}
	  if (sh==0)
	  {
	  	epull_down(begin,to,0);
	  }
	  else if(sh==1)
	  {
	  	epull_down_full(begin,to,to);
	  }
	 } else {
	  to = 0;
	  self_menu[nr+1][2] = 0;
	  name = "down"+(nr+2);
	  open_item = 0;
	  for(i=0;i<nr;i++) {
	   if(self_menu[i][2] == 1)
		{open_item += self_menu[i][1];
		}
	  }
	  if (N == false) {open_item-= (c*1)};
	  if (nr== self_menu.length-2) {val = self_menu[self_menu.length-1][1];to=-1;}
	  else  val = parseInt(document.getElementById(name).style.top) -(open_item)-(c*height);
		  //if (sh==0)
		  //{
			epull_up(begin,to,val);
		 /* }
		  else
		  {
		  	alert()
			epull_up_full(begin,to,to);
		  }*/
	  
	 }
  }
}

function epull_down(nr,to,nowv) {
 name = "down" + (nr-1);
 obj = document.getElementById(name).style.clip = "rect(0,"+width+","+(nowv+1)+",0)";
 for (i=nr;i<self_menu.length;i++) {
  name = "down" + i;
  obj = document.getElementById(name);
  obj.style.top = parseInt(obj.style.top)+1;
 }
 nowv++;
 if(nowv < to) timerID = setTimeout("epull_down("+nr+","+to+","+nowv+")",speed);
 else timerID = ""; 
}

function epull_down_full(nr,to,nowv) {
 name = "down" + (nr-1);
 obj = document.getElementById(name).style.clip = "rect(0,"+width+","+(nowv+1)+",0)";
 for (i=nr;i<self_menu.length;i++) {
  name = "down" + i;
  obj = document.getElementById(name);
  obj.style.top = parseInt(obj.style.top)+to;
 }
 nowv++;
 if(nowv < to) timerID = setTimeout("epull_down_full("+nr+","+to+","+nowv+")",speed);
 else timerID = ""; 
}

function epull_up(nr,to,nowv) {
 name = "down" + (nr-1);
 obj = document.getElementById(name).style.clip = "rect(0,"+width+","+nowv+",0)";
 for (i=nr;i<self_menu.length;i++) {
  name = "down" + i;
  obj = document.getElementById(name);
  obj.style.top = parseInt(obj.style.top)-1;
 }
 nowv--;
 if(nowv > to) timerID = setTimeout("epull_up("+nr+","+to+","+nowv+")",speed);
 else timerID = "";
}

function epull_up_full(nr,to,nowv) {
 name = "down" + (nr-1);
 obj = document.getElementById(name).style.clip = "rect(0,"+width+","+nowv+",0)";
 for (i=nr;i<self_menu.length;i++) {
  name = "down" + i;
  obj = document.getElementById(name);
  obj.style.top = parseInt(obj.style.top)-to;
 }
 nowv--;
 if(nowv > to) timerID = setTimeout("epull_up("+nr+","+to+","+nowv+")",speed);
 else timerID = "";
}

function startup(nr) {
 write_menu();
 changeimg();
 var str_page;
 var subshow
 str_page=window.location.href;
 if(str_page.indexOf('?p=')>0)
 {
		subshow=str_page.substr(str_page.indexOf('?p=')+3,str_page.indexOf('?p=')+4)
		if (subshow != 0) {
		  for(i=0;i<self_menu.length;i++)
		  {
				if (subshow==11 || subshow==12|| subshow==13)
				{
					if(self_menu[i][3] == 1) pull_down(i,1,1)
					i==self_menu.length;
				}
				if (subshow==31 || subshow==32 || subshow==33 || subshow==34 || subshow==35 || subshow==36 || subshow==37 || subshow==38|| subshow==39)
				{
					 if(self_menu[i][3] == 5) pull_down(i,5,1)
				 	 i==self_menu.length;
				}
				if (subshow==1 || subshow==2 || subshow==5)
				{
				 if(self_menu[i][3] == subshow) pull_down(i,subshow,0)
				 i==self_menu.length;
				}
		  }
		 }
 }
 /*if (nr != 0) {
 for(i=0;i<self_menu.length;i++)
 {
 // if(self_menu[i][3] == nr) pull_down(i,nr)
  //i==self_menu.length;
 }
 }*/
}

function redirect_page(strpage)
{
	var sub_show
	var str_page1=window.location.href;
	var imgname;
	if(strpage==1)	//aboutus
	{
		window.location.href="aboutksw.html?p=1"
	}
	if(strpage==11)	//aboutus
	{
		window.location.href="valueeng.html?p=11"
	}
	if(strpage==12)	//aboutus
	{
		window.location.href="trademanagement.html?p=12"
	}
	if(strpage==2)	//corporate
	{
		window.open("http://finance.yahoo.com/q/ks?s=KSW")
		window.location.href="listofexe.html?p=2"
	}

	if(strpage==200)	//index
	{
		window.location.href="PDFs/2006_audit_committee_charter.pdf"
	}
	if(strpage==201)	//index
	{
		window.location.href="PDFs/KSW_Inc_Compensation_Committee_Charter.pdf"
	}


	if(strpage==3)	//completed
	{
		window.location.href="completedproj.html?p=5"
	}
	if(strpage==31)	//hospital
	{
		window.location.href="hospital.html?p=31"
	}
	if(strpage==32)	//hotels
	{
		window.location.href="hotels.html?p=32"
	}
	if(strpage==33)	//apartments
	{
		window.location.href="apartments.html?p=33"
	}
	if(strpage==34)	//commercial
	{
		window.location.href="commercial.html?p=34"
	}
	if(strpage==35)	//transport
	{
		window.location.href="transport.html?p=35"
	}
	if(strpage==36)	//speciality
	{
		window.location.href="speciality.html?p=36"
	}
	if(strpage==37)	//education
	{
		window.location.href="education.html?p=37"
	}
	if(strpage==38)	//courthouse
	{
		window.location.href="courthouse.html?p=38"
	}
	if(strpage==39)	//Chiller Plants
	{
		window.location.href="chillerplants.html?p=39"
		//window.location.href="courthouse.html?p=38"
	}
	if(strpage==101)	//current
	{
		window.location.href="currentkswproject.html"
	}
	if(strpage==102)	//sec
	{
		if(str_page1.indexOf('?p=')>0)
 		{
			sub_show=str_page1.substr(str_page1.indexOf('?p=')+3,str_page1.indexOf('?p=')+4)
			if (sub_show != 0) {
				for(i=0;i<self_menu.length;i++)
		  		{
					if (sub_show==11 || sub_show==12)
					{
						if(self_menu[i][3] == 1) pull_down(i,1,2)
						i==self_menu.length;
					}
					if (sub_show==31 || sub_show==32 || sub_show==33 || sub_show==34 || sub_show==35 || sub_show==36 || sub_show==37 || sub_show==38|| sub_show==39)
					{
						 if(self_menu[i][3] == 5) pull_down(i,5,2)
						 i==self_menu.length;
					}
					if (sub_show==1 || sub_show==2 || sub_show==5)
					{
					 if(self_menu[i][3] == sub_show) pull_down(i,sub_show,2)
					 i==self_menu.length;
					}
		  		}
			}
		}
		
		 for(var i=0;i<=7;i++)
		 {
		 	imgname='img'+ (parseInt(i)+1);
		 	if(document.getElementById(imgname))
			{
				document.getElementById(imgname).setAttribute("src","images/arrow.gif");
			}
		 }
		 
		 document.getElementById('img5').setAttribute("src","images/redicon.gif");
		 window.open("http://www.sec.gov/cgi-bin/browse-edgar?company=&CIK=ksw&filenum=&State=&SIC=&owner=include&action=getcompany ");
		
	}
	if(strpage==103)	//news
	{
		if(str_page1.indexOf('?p=')>0)
 		{
			sub_show=str_page1.substr(str_page1.indexOf('?p=')+3,str_page1.indexOf('?p=')+4)
			if (sub_show != 0) {
				for(i=0;i<self_menu.length;i++)
		  		{
					if (sub_show==11 || sub_show==12)
					{
						if(self_menu[i][3] == 1) pull_down(i,1,2)
						i==self_menu.length;
					}
					if (sub_show==31 || sub_show==32 || sub_show==33 || sub_show==34 || sub_show==35 || sub_show==36 || sub_show==37 || sub_show==38|| sub_show==39)
					{
						 if(self_menu[i][3] == 5) pull_down(i,5,2)
						 i==self_menu.length;
					}
					if (sub_show==1 || sub_show==2 || sub_show==5)
					{
					 if(self_menu[i][3] == sub_show) pull_down(i,sub_show,2)
					 i==self_menu.length;
					}
		  		}
			}
		}
		for(var i=0;i<=7;i++)
		 {
		 	imgname='img'+ (parseInt(i)+1);
		 	if(document.getElementById(imgname))
			{
				document.getElementById(imgname).setAttribute("src","images/arrow.gif");
			}
		 }
		document.getElementById('img6').setAttribute("src","images/redicon.gif");
		window.open("http://finance.yahoo.com/q/h?s=KSW")
	}
	if(strpage==104)	//contactus
	{
		window.location.href="contactus.html"
	}
	if(strpage==105)	//index
	{
		window.location.href="index.html"
	}
	
}

