var cursid=0
var imgtype    = ".gif";
divOn = new Array (1,1,1,1,0,0,0,0,0,0,0,0,0,0,0);
imagesNames  = new Array("services", "portfolio", "aboutus", "contact", "webdesign", "programming", "support", "news", "webteam", "keypoint", "requestprop", "projsupport", "web_design", "flash", "customers");

ns4=(document.layers)?true:false;
ie4=(document.all)?true:false;



function getRealLeft(el) {
    xPos = el.offsetLeft;
    tempEl = el.offsetParent;
    while (tempEl != null) {
        xPos += tempEl.offsetLeft;
        tempEl = tempEl.offsetParent;
    }
    return xPos;
}

function getRealTop(el) {
    yPos = el.offsetTop;
    tempEl = el.offsetParent;
    while (tempEl != null) {
        yPos += tempEl.offsetTop;
        tempEl = tempEl.offsetParent;
    }
    return yPos;
}


function hidemenu(e) {
 if (cursid != 0) {	

	if (ns4) {
		if  (divOn[cursid-1] != 0) {
		img = document.images["i" + cursid];
		menu = document["a" + cursid];
		
		//img x & y
			imgX = img.x;
			imgY = img.y;
			imgH = img.height;			
			imgW = img.width;

		//menu width and height
			menuX = menu.left;
			menuY = menu.top;	
			menuW = menu.clip.right;        
        	menuH = menu.clip.bottom;

		//e.pageY and e.pageX are the current mouse location
      if (!((e.pageX <= menuX + menuW) && (e.pageY >= menuY) && (e.pageY <= (menuY + menuH)) && (e.pageX >= menuX)) &&
	      !((e.pageX <= imgX + imgW) && (e.pageY >= imgY) && (e.pageY <= (imgY + imgH)) && (e.pageX >= imgX))) {
	    	hidediv(cursid);
	}
	}


	} 
	else {
		hidediv(cursid);
	}

}  
}

function showdiv(sid){
	
if ((sid >= 0) && (sid < 16)) {
		if (cursid != 0) {
			hidediv(cursid);		
		}
	    cursid = sid;
	  if (currentsection != sid) {
		eval("document.images['i' + sid].src = " + imagesNames[sid-1] + "2.src");
	}
	    		if (divOn[cursid-1] != 0) {
			if (ns4) {
				 var divsid=eval("document.a"+sid);
			  	 divsid.visibility="show";
				 windowwidth = window.innerWidth;
				 imageloc = document.images["i" + sid].x;
				 imagewidth = document.images["i" + sid].width;
				 imageheight = document.images["i" + sid].height;
				 imagetop = document.images["i" + sid].y;
				 
				 //imagetop = document.images["i1"].y;
			}
			if (ie4) {
				divsid=eval("a"+sid+".style");
				divsid.visibility="visible";
				windowwidth = document.body.clientWidth;
				imageloc = getRealLeft(document.all["s" + sid]);
				imagewidth = document.all["s" + sid].width;
				imageheight = document.all["s" + sid].height;
			    imagetop =  getRealTop(document.all["s" + sid]);
				
				//imagetop =  getRealTop(document.all["s1"]);
			}
			
				// load the menu to upper-right of the current navigation image
				// -----------------------------------------------------------
				//divsid.left= (imagewidth+imageloc);
				//divsid.top= (imagetop);
			
				
				// load the menu bottom-left of the current navigation image
				// ---------------------------------------------------------
				divsid.left= (imageloc);
		        divsid.top= (imagetop + imageheight);
		}
	}	
	if (!ns4) window.event.cancelBubble = true;
}       

function subover(subrow) {
	subrow.style.backgroundColor = "";
	subrow.style.cursor = 'hand';
}

function subout(subrow) {
	subrow.style.backgroundColor = "";
}


function imgoff(sid) {

	if (divOn[sid-1] == 0) {
	if (currentsection != sid) {
	  eval("document.images['i' + sid].src = " + imagesNames[sid-1] + "1.src");		
	 }
	}

}        

function hidediv(sid){
if (currentsection != sid) {
	  eval("document.images['i' + sid].src = " + imagesNames[sid-1] + "1.src");
}

if ((sid >= 0) && (sid < 16)) {  	    
	if (ns4) divsid=eval("document.a"+ sid);
	if (ie4) divsid=eval("a"+sid+".style");
	if (ns4) divsid.visibility="hide";
	if (ie4) divsid.visibility="hidden";
	cursid = 0;
}

}

if (document.images) {
        for (i = 0; i < imagesNames.length; i++) {
         imageObj1 = imagesNames[i] + "1";
         temp = eval(imageObj1 + " = new Image()");
         temp.src = imgDir + imageObj1 + ".gif";

          imageObj2 = imagesNames[i] + "2";
          temp = eval(imageObj2 + " = new Image()");
          temp.src = imgDir +  imageObj2 + ".gif";
        }
}


function go2(urlstr) {
	location.href = urlstr;
}			 


if (ns4) { 
  	document.captureEvents(Event.MOUSEMOVE); 
    document.onmousemove = hidemenu;
} else {
	document.onmouseover = hidemenu;
}
             
			 


