var n4,ie,n6;

var doc, doc2,doc3, sty;

if (document.layers){
 doc="document." ;
 doc2=".document.";
 doc3="";
 sty="";
 n4=true;
}
else if (document.all){
 doc="document.all.";
 doc2="";
 doc3="";
 sty=".style";
 ie=true;

}

else if (document.getElementById){
 doc="document.getElementById('";
 doc2="')";
 doc3="')";
 sty="').style";
 n6="true";
}

//the variables for the window dimensions
var win_width, win_height;
var centerhor, centerever;

// Get the dimension of the window


function dimensions()
{
      if (n4||n6){
      win_width=window.innerWidth;
      win_height=window.innerHeight;
      }
      else if(ie)
      {
       win_width=document.body.clientWidth;
       win_height=document.body.clientHeight; 

      }

   centerhor=win_width/2;
   centerver=win_height/2;
}// function end

// place the element relative to the page

 function placeIt(elem, leftPos, topPos){
      docObj=eval(doc + elem + sty);
      if (n4||n6){
        docObj.left=leftPos;
        docObj.top=topPos;
      }
      else if(ie){
        docObj.pixelLeft=leftPos;
        docObj.pixelTop=topPos;
      
      }

}  // End Function


// preload navigation images

var loaded=false;
var navdir="images/nav/";



function preload(){

// Home
 
 top_home_off=new Image;
 top_home_off.src=navdir+ "home.gif";

 top_home_on=new Image;
 top_home_on.src=navdir+ "homeover.gif";

// about
 top_about_off=new Image;
 top_about_off.src=navdir+ "about.gif";
 
 top_about_on=new Image;
 top_about_on.src=navdir+ "aboutover.gif";


//services Center
 top_service_off=new Image;
 top_service_off.src=navdir+ "services.gif";

 top_service_on=new Image;
 top_service_on.src=navdir+ "servicesover.gif";


//calculation
 top_calc_off=new Image;
 top_calc_off.src=navdir+ "calc.gif";

 top_calc_on=new Image;
 top_calc_on.src=navdir+ "calcover.gif";

// Legal Forms
 top_legal_off=new Image;
 top_legal_off.src=navdir+ "legal.gif";

 top_legal_on=new Image;
 top_legal_on.src=navdir+ "legalover.gif";



// Contact
 top_contact_off=new Image;
 top_contact_off.src=navdir+ "contact.gif";

 top_contact_on=new Image;
 top_contact_on.src=navdir+ "contactover.gif";

// News Link
 top_newslink_off=new Image;
 top_newslink_off.src=navdir+ "newslink.gif";

 top_newslink_on=new Image;
 top_newslink_on.src=navdir+ "newslinkover.gif";

// Site Map
top_sitemap_off=new Image;
top_sitemap_off.src=navdir+ "site.gif";

top_sitemap_on=new Image;
top_sitemap_on.src=navdir+ "siteover.gif";


 loaded =true;


}// end preload

// image swapping

function onoff(elemparent,elem,state)
   {
    if(loaded){
      newstate=eval(elem +"_"+ state);
      if(n4){
             
         menuObj=eval(doc + elemparent+ doc2 + elem);   }
      else if (ie || n6){
         menuObj=eval(doc + elem + doc2); 
              } 
 menuObj.src=newstate.src; 


      }

}// end function onoff


//mouse over

var oncolor="#B5CFB5";

//var offcolor="#6699CC";

//var oncolor="#C1E1FF";
//var offcolor="#FFD7AD";
var offcolor="#ffffff";

function changecolor(divname,colorname){
 stopall();
 if(!n4){
   menuObj=eval(doc + divname + sty);
   menuObj.backgroundColor=colorname;

   }

}// end function changecolor



// show or hide


function showhide(elem,state){

 if (elem!=null)
    
	if (elem=='test3')
	 {	  
	   if (eval('document.all.test3')==null)
          return false;
     else{
		  docObj=eval(doc+elem+sty);
	      docObj.visibility=state;
		  }
	  }
	  if (elem=='test2')
	 {	  
	   if (eval('document.all.test2')==null)
          return false;
     else{
		  docObj=eval(doc+elem+sty);
	      docObj.visibility=state;
		  }
	  }
	
	  
	  else{
		  docObj=eval(doc+elem+sty);
	      docObj.visibility=state;
		  }
	   	
     
}//End Function

// variable that hold the value of the currently active open menu

var active_submenu1=null;
var active_submenu2=null;
var active_menuelem=null;
var active_topelem=null;


// function closes all active menus and turns back to off state

function closeallmenus(){
   
   if (active_submenu1 != null)
        showhide(active_submenu1,'hidden');
        

   if (active_submenu2 != null)
        showhide(active_submenu2,'hidden');
        

   if (active_menuelem != null)
        changecolor(active_menuelem,offcolor);
        
        

   if (active_topelem != null)
        onoff('mainmenu',active_topelem,'off');
        
        showhide('test2','visible');
        showhide('test3','visible');


}// end function





// the menu close timeout variable

var menu_close_timeout = 0;
var delay = 500;

function closeall(){

menu_close_timeout = setTimeout('closeallmenus()',delay);


}// end function



function stopall(){

clearTimeout(menu_close_timeout);

}//end function




function controlsubmenu(submenu1, submenu2, menuelem,topelem)

{
 stopall();
 closeallmenus();

 if (submenu1 != null){
   showhide(submenu1,'visible');
   active_submenu1=submenu1;
  }


 if (submenu2!=null){
   showhide(submenu2,'visible');
   active_submenu2=submenu2;
  }
  showhide('test2','hidden');
  showhide('test3','hidden');

 if (menuelem!=null){
   changecolor(menuelem,oncolor);
   active_menuelem=menuelem;
  }

 if (topelem!=null){
   onoff('mainmenu',topelem,'on');
   active_topelem=topelem;
  }



}// end function



function initialize()
{
 
 preload();
 
 closeallmenus();
 
 stopall();
 
 dimensions();
 
 if (win_width < 800){
    var mainmenuleft=centerhor - 340;
	var offset1=50;
	var offset2=120;//about us
	var offset3=200;//services
	var offset4=275;//calculations
	var offset5=359;//legal
	var offset6=535;// Newslink
	var offsetX=440;
    var offsetY=107;
	
	}
    
 if (win_width > 800){ 
     mainmenuleft=centerhor - 300;
	// alert (centerhor);
// added 100 
	var offset1=50;
	var offset2=270;//about us
	var offset3=350;//services
	var offset4=425;//calculations
	var offset5=510;//legal
	var offset6=685;// Newslink

	var offsetX=440;
    var offsetY=107;
	}
    placeIt('mainmenu',mainmenuleft,85);// images
  //  placeIt('home',offset1,offsetY+12); //home
	//placeIt('about',offset2,offsetY); // about us
 //	placeIt('service',offset3,offsetY); //services
    placeIt('calc', offset4,offsetY);// calculations
	placeIt('legal', offset5,offsetY);// legal Forms
	placeIt('newslink', offset6,offsetY); // Newslink
	placeIt('order', offset5-55,offsetY+26); // order
   
	
}
