//Working Javascript file for L-3 CS East web site
//All scripting done by Andy West
//ext 3009
//
//*************
//* IMPORTANT *
//*************
//DO not make any changes to this file without first checking with Andy West

//Preload Image Section
//
//All Jpegs and gifs are to be preloaded from this section. 
//Format below must be used
//Andy West 6/20/03

//08/05 - removed sub19 and 20
//09/05 - added talon, stevoip, unitycp
//11/06 - added talonnsacertificate
//02/07 - added star jpgs
//06/07 - added unitycpnsacertificate
//08/07 - added kg245x certificate
//06/08 - added taloncertificate2
//07/08 - added cogswell award
//11/08 - added press photo 48
//02/09 - added press photo 50

//Load JPGs


//End Image Preload


//Image Map Hover Work
//Controls IM hover boxes on opening page
function menu(which){

document.getElementById(which).style.visibility="visible";
}

function sub_close(which){
document.getElementById(which).style.visibility="hidden";
}

//Image Map Hover Work
//Controls IM hover boxes on mrapp
function menu_mrapp(which){
document.all.sub1.style.visibility="hidden";

document.all[which].style.visibility="visible";
}

//Image Map Hover Work
//Controls IM hover boxes on mrapp
function menu_nssapp(which){
document.all.sub1.style.visibility="hidden";

document.all[which].style.visibility="visible";
}

//Image Map Hover Work
//Controls IM hover boxes on mrapp
function menu_fssapp(which){
document.all.sub1.style.visibility="hidden";

document.all[which].style.visibility="visible";
}


//Links in New Window Section

//Any links located in the content of a page should open up in a new window 
//The static section is where single functions with varying dimensions will be added
//The dynamic section is where functions with passed parameters will be added



//Jobs
function job_open(which){
window.open(which,"","width=600,height=600,menubar=0,toolbar=0,status=0,address=0,resizable=0");
}

//Sale Info
function sale_open(which){
sale = window.open(which,"","width=610,height=300,menubar=0,toolbar=0,status=0,address=0,resizable=0");
}

function sale_open_bigger(which){
sale = window.open(which,"","width=610,height=600,menubar=0,toolbar=0,status=0,address=0,resizable=0");
}

function sale_open_1(which){
sale = window.open(which,"","width=610,height=350,menubar=0,toolbar=0,status=0,address=0,resizable=0");
}

function sale_open_re(which){
sale = window.open(which,"","width=610,height=300,menubar=0,toolbar=0,status=0,address=0,resizable=0");
}

function sale_open_omni(which){
sale = window.open(which,"","width=610,height=200,menubar=0,toolbar=0,status=0,address=0,resizable=0");
}

function sale_open_omni_first(which){
sale = window.open(which,"","width=610,height=475,menubar=0,toolbar=0,status=0,address=0,resizable=0");
}
//dynamic
//
//Press releases
function link_open(which){
window.open(which);
}

function pr_release_open(which){
window.open(which,"","width=800,height=500,menubar=1,toolbar=1,status=0,address=1,resizable=1,scrollbars=1");
}

//Omni Sales Open
function omni_sales_open(which){
window.open(which,"","width=610,height=500,menubar=0,toolbar=0,status=0,address=0,resizable=1,scrollbars=1");
}

//Talon info Open
function info_open(which){
info = window.open(which,"","width=610,height=500,menubar=0,toolbar=0,status=0,address=0,resizable=0");
}

//PDFs
function pdf_open(which){
window.open(which,"","menubar=1,toolbar=1,status=1,address=1,resizable=1");
}

function sale_close(which){
window.close(which);
}

function info_close(which){
window.close(which);
}
//End Links in New Window Section


//Banner Sections
//Scrolling S/TAR Status Bar Banner
function scrollit(seed)
{
        var m1="CS-E awarded F-16 Solid State Recorder Poland Peace Sky Contract.         ";
        var m2="Click on latest news button for more details.  ";
        var m3="  ";
           var msg=m1+m2+m3;     var out=" ";
        var c=0;
    
        if (seed>100)
            {
             seed--;
             var cmd="scrollit(" + seed + ")";
             timerTwo=window.setTimeout(cmd,100);
            }
        else
            if (seed<=100 && seed >0)
                {
                for (c=0; c<seed; c++)
                   {
                   out+=" ";
                   }
                out+=msg;
                seed--;
                var cmd="scrollit(" + seed + ")";
                window.status=out;
                timerTwo=window.setTimeout(cmd,100);
                }
            else if (seed<=0)
                {
                if (-seed < msg.length)
                   {
                   out+=msg.substring(-seed,msg.length);
                   seed--;
                   var cmd="scrollit(" + seed + ")";
                   window.status=out
                   timerTwo=window.setTimeout(cmd,100);
                   }
                else
                   {
                   window.status=" ";
                   timerTwo=window.setTimeout("scrollit(100)",75);
                   }
                }
}

//Scrolling Index Status Bar Banner
function index_scroll(seed)
{
        var m1="      Click on an image above to get a brief description.      ";
        var m2="      Click on an image above to get a brief description.      ";
        var m3="  ";
	    var msg=m1+m2+m3;     var out=" ";
        var c=0;
    
        if (seed>100)
            {
             seed--;
             var cmd="index_scroll(" + seed + ")";
             timerTwo=window.setTimeout(cmd,100);
            }
        else
            if (seed<=100 && seed >0)
                {
                for (c=0; c<seed; c++)
                   {
                   out+=" ";
                   }
                out+=msg;
                seed--;
                var cmd="index_scroll(" + seed + ")";
                window.status=out;
                timerTwo=window.setTimeout(cmd,100);
                }
            else if (seed<=0)
                {
                if (-seed < msg.length)
                   {
                   out+=msg.substring(-seed,msg.length);
                   seed--;
                   var cmd="index_scroll(" + seed + ")";
                   window.status=out
                   timerTwo=window.setTimeout(cmd,100);
                   }
                else
                   {
                   window.status=" ";
                   timerTwo=window.setTimeout("index_scroll(100)",50);
                   }
                }
}
//End Banner Sections

//Drop Down Menu Section
//** DO NOT CHANGE WITHOUT CONTACTING Andy West


//Menu Delay
function delay (){
setTimeout("HideMenu(menuBar)",10000);
}

function delaysubmenu (){
setTimeout("HideMenu(menuBar)",15000);
}



//Main Menu AnimationWork
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); 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 InitMenu()
   {
     var bar = menuBar.children     

     for(var i=0;i < bar.length;i++) 
        {
          var menu=eval(bar[i].menu)
          menu.style.visibility = "hidden"
          bar[i].onmouseover = new Function("ShowMenu("+bar[i].id+")")
          var Items = menu.children
          for(var j=0; j<Items.length; j++)
            {
              var menuItem = eval(Items[j].id)
                
                if(menuItem.menu != null)
                   { 
                    menuItem.innerHTML += "<Span Id="+menuItem.id+"_Arrow class='Arrow'>4</Span>"
                    //var tmp = eval(menuItem.id+"_Arrow")
                    // tmp.style.pixelLeft = menu.getBoundingClientRect().Right //- tmp.offsetWidth - 15
                    FindSubMenu(menuItem.menu)}
               
                 if(menuItem.cmd != null) 
                   {
                   menuItem.onclick = new Function("Do("+menuItem.id+")") } 
                   
              menuItem.onmouseover = new Function("highlight("+Items[j].id+")")
            
            }    
        
        }  
   }
   function FindSubMenu(subMenu)
   {
         var menu=eval(subMenu)
         var Items = menu.children
          for(var j=0; j<Items.length; j++)
            {
              menu.style.visibility = "hidden"
              var menuItem = eval(Items[j].id)
              
              
              if(menuItem.menu!= null)
                 {
                    menuItem.innerHTML += "<Span Id="+menuItem.id+"_Arrow class='Arrow'>4</Span>"
                    // var tmp = eval(menuItem.id+"_Arrow")
                    //tmp.style.pixelLeft = 35 //menuItem.getBoundingClientRect().right - tmp.offsetWidth - 15
                    FindSubMenu(menuItem.menu)
                 }

                 if(menuItem.cmd != null) 
                   {
                   menuItem.onclick = new Function("Do("+menuItem.id+")") } 
                  
              menuItem.onmouseover = new Function("highlight("+Items[j].id+")")
                 
            }  
   } 
   function ShowMenu(obj)
   {
     HideMenu(menuBar)
     var menu = eval(obj.menu)
     var bar = eval(obj.id)
     bar.className="barOver"
     menu.style.visibility = "visible"
     menu.style.pixelTop =  obj.getBoundingClientRect().top + obj.offsetHeight + Bdy.scrollTop
     menu.style.pixelLeft = obj.getBoundingClientRect().left + Bdy.scrollLeft
   }
   
   function highlight(obj)
   {
     var PElement = eval(obj.parentElement.id)
     if(PElement.hasChildNodes() == true)
     {  var Elements = PElement.children
       for(var i=0;i<Elements.length;i++)
       {
          TE = eval(Elements[i].id)
          TE.className = "menuItem"
       }
      } 
     obj.className="ItemMouseOver"
     window.defaultStatus = obj.title
     ShowSubMenu(obj)
   }
   
   function Do(obj)
   {
    var cmd = eval(obj).cmd	
    window.navigate(cmd)
     
   }
   
   function HideMenu(obj)
   {
          if(obj.hasChildNodes()==true)
              {  
                 var child = obj.children     
                 
                 for(var j =0;j<child.length;j++)
                  {
                     if (child[j].className=="barOver")
                     {var bar = eval(child[j].id)
                      bar.className="Bar"}
                      
                     if(child[j].menu != null)
                       {
                          var childMenu = eval(child[j].menu)
                          if(childMenu.hasChildNodes()==true) 
                               HideMenu(childMenu)
                          
                           childMenu.style.visibility = "hidden" 
                         }
                  }
              
              }
   }
  function ShowSubMenu(obj)
  {
     PMenu = eval(obj.parentElement.id)
      HideMenu(PMenu)
     if(obj.menu != null)
     {
     var menu = eval(obj.menu)
     menu.style.visibility = "visible"
     menu.style.pixelTop =  obj.getBoundingClientRect().top + Bdy.scrollTop
     menu.style.pixelLeft = obj.getBoundingClientRect().right + Bdy.scrollLeft
     if(menu.getBoundingClientRect().right > window.screen.availWidth )
       menu.style.pixelLeft = obj.getBoundingClientRect().left - menu.offsetWidth
    }
  }


//S/TAR Banner
function scrollit(seed)
{
        var m1="CS-E awarded F-16 Solid State Recorder Poland Peace Sky Contract.         ";
        var m2="Click on latest news button for more details.  ";
        var m3="  ";
           var msg=m1+m2+m3;     var out=" ";
        var c=0;
    
        if (seed>100)
            {
             seed--;
             var cmd="scrollit(" + seed + ")";
             timerTwo=window.setTimeout(cmd,100);
            }
        else
            if (seed<=100 && seed >0)
                {
                for (c=0; c<seed; c++)
                   {
                   out+=" ";
                   }
                out+=msg;
                seed--;
                var cmd="scrollit(" + seed + ")";
                window.status=out;
                timerTwo=window.setTimeout(cmd,100);
                }
            else if (seed<=0)
                {
                if (-seed < msg.length)
                   {
                   out+=msg.substring(-seed,msg.length);
                   seed--;
                   var cmd="scrollit(" + seed + ")";
                   window.status=out
                   timerTwo=window.setTimeout(cmd,100);
                   }
                else
                   {
                   window.status=" ";
                   timerTwo=window.setTimeout("scrollit(100)",75);
                   }
                }
} 
//End Drop Down Menu Section
