(function($){
	/* hoverIntent by Brian Cherne */
	$.fn.hoverIntent = function(f,g) {
		// default configuration options
		var cfg = {
			sensitivity: 7,
			interval: 100,
			timeout: 0
		};
		// override configuration options with user supplied object
		cfg = $.extend(cfg, g ? { over: f, out: g } : f );

		// instantiate variables
		// cX, cY = current X and Y position of mouse, updated by mousemove event
		// pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
		var cX, cY, pX, pY;

		// A private function for getting mouse position
		var track = function(ev) {
			cX = ev.pageX;
			cY = ev.pageY;
		};

		// A private function for comparing current and previous mouse position
		var compare = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			// compare mouse positions to see if they've crossed the threshold
			if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
				$(ob).unbind("mousemove",track);
				// set hoverIntent state to true (so mouseOut can be called)
				ob.hoverIntent_s = 1;
				return cfg.over.apply(ob,[ev]);
			} else {
				// set previous coordinates for next time
				pX = cX; pY = cY;
				// use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
				ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval );
			}
		};

		// A private function for delaying the mouseOut function
		var delay = function(ev,ob) {
		
		    
		    
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			ob.hoverIntent_s = 0;
			
			var rtr = cfg.out.apply(ob,[ev]);
			
			
			return rtr;
		};

		// A private function for handling mouse 'hovering'
		var handleHover = function(e) {
			// next three lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut
			var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
			while ( p && p != this ) { try { p = p.parentNode; } catch(e) { p = this; } }
			if ( p == this ) { return false; }

			// copy objects to be passed into t (required for event object to be passed in IE)
			var ev = jQuery.extend({},e);
			var ob = this;

			// cancel hoverIntent timer if it exists
			if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }

			// else e.type == "onmouseover"
			if (e.type == "mouseover") {
				// set "previous" X and Y position based on initial entry point
				pX = ev.pageX; pY = ev.pageY;
				// update "current" X and Y position based on mousemove
				$(ob).bind("mousemove",track);
				// start polling interval (self-calling timeout) to compare mouse coordinates over time
				if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}

			// else e.type == "onmouseout"
			} else {
			    if( ob.style.borderTopWidth == "1px" )
		        {
		            //alert('aa');
		            ob.style.borderTop = "1px solid #192E59";
                    ob.style.borderRight = "1px solid #192E59";
                    ob.style.borderLeft = "1px solid #192E59";
                    if(window.navigator.userAgent.indexOf("MSIE")>=1)
                    {
                    }
                    else
                    {
                        if( ob.style.paddingTop == "2px")
                        {
                            ob.style.paddingTop = "0px";
                        }
                    }
                    
                    //modify at 20080910 15:07
//                    ob.style.background="none";
//                    ob.getElementsByTagName('a')[0].style.background="none";
                    //
                    var img = ob.getElementsByTagName('img')[0];
                    if(img.src.indexOf("/SiteCollectionImages/moreinfo_arrow_down.gif")!=-1)
                    {    
                        img.src = "http://www.fluor.com/SiteCollectionImages/topmoreinfo_arrow.gif";
                    }
		        }
				// unbind expensive mousemove event
				$(ob).unbind("mousemove",track);
				// if hoverIntent state is true, then call the mouseOut function after the specified delay
				if (ob.hoverIntent_s == 1) 
				{ 
				    ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );
				    
				    
				}
			}
		};

		// bind the function to the two event listeners
		return this.mouseover(handleHover).mouseout(handleHover);
	};
	
})(jQuery);



if(window.navigator.userAgent.indexOf("MSIE")>=1)
{
    var browser=navigator.appName;
    var b_version=navigator.appVersion;
    //var version=parseFloat(b_version);
   //alert( "test by cola : it will be remove this debug msg soon,thx!" + b_version ); 
   if( b_version.indexOf("6.0") >0 ) 
   {
        var obj = document.getElementById("topNavigation_outer");
        if( obj != null )
         obj.style.marginBottom = "-34px";
   }
}

function hide(imgid)
{
    
    if (document.getElementById( imgid ).style.visibility=="visible")
	{
	    //alert(imgid + "hidden 1");
	    document.getElementById( imgid ).style.visibility="hidden";
	}
	else
	{
	    // alert(imgid + "visible 2");
	    document.getElementById( imgid ).style.visibility="visible";
	}
}

function RemoveBackColor(li2_id){
//     setTimeOut("document.getElementById( '"+li2_id+"' ).style.backgroundColor='#192E59'",0);
//     alert(li2_id);
     
}

function hide(imgid,obj)
{
// if (imgid.indexOf("b_")>-1)
//   alert(imgid);

var flag = true;
if (obj!=null)
{
	var uls = obj.getElementsByTagName("ul");
	if (uls !=null)
	{
		var ul = uls[0];		
		if (ul != null)
		{
		    if (ul.style.visibility!="hidden")
		    {
			    flag = false;
		    }	
	    }
	}
} 
// alert(imgid + "unhide");
if (flag)
{
    if (document.getElementById( imgid ).style.visibility=="visible")
	{
	    // alert(imgid + "hidden 2");
	    document.getElementById( imgid ).style.visibility="hidden";
	}
	else
	{
	    // alert(imgid + "visible 2");
	    document.getElementById( imgid ).style.visibility="visible";
	}
}
// document.getElementById( imgid ).style.visibility="hidden";

}

function initline()
{
var obj = document.getElementById("FluorDemoMenu");
var imgs = obj.getElementsByTagName("img");
for (var i=0;i<imgs.length;i++)
{
    imgs[i].style.visibility="visible";
}

}

function unhide(imgid,obj)
{
var flag = true;
if (obj!=null)
{
	var uls = obj.getElementsByTagName("ul");
	if (uls !=null)
	{
		var ul = uls[0];		
		if (ul != null)
		{
		    if (ul.style.visibility!="hidden")
		    {
			    flag = false;
		    }	
	    }
	}
} 
// alert(imgid + "unhide");
if (flag)
    // alert(imgid + "unhide 2");
	document.getElementById( imgid ).style.visibility="visible";
}

function changeText(liid, imgid )
{
   // alert(1); 
   
   var img = document.getElementById( imgid );
   ///firefox
   if(window.navigator.userAgent.indexOf("MSIE")>=1)
   {
        liid.getElementsByTagName('a')[0].style.overflow="hidden"; 
        //liid.getElementsByTagName('a')[0].style.backgroundColor = "#0B1836";
        liid.getElementsByTagName('a')[0].style.zIndex = 2222;
        liid.getElementsByTagName('ul')[0].style.top= "29px";
        liid.getElementsByTagName('a')[0].style.height="15px";
        
        var ua = navigator.userAgent;
        var opera = /opera [56789]|opera\/[56789]/i.test(ua);
        var webkit = /webkit/i.test(ua);
        var ie = !opera && /MSIE/.test(ua);
        var ie6 = ie && /MSIE [6789]/.test(ua);
        var ie7 = ie && /MSIE [789]/.test(ua);
        
         if (jQuery.browser.msie && jQuery.browser.version == "6.0") {
        
            //alert("ttt");
            liid.getElementsByTagName('a')[0].style.height="12px";
            liid.getElementsByTagName('ul')[0].style.top= "25px";
        }
        

   }
   else
   {
        //liid.getElementsByTagName('a')[0].style.overflow="inherit";
        //liid.style.backgroundColor = "#192E59";
        //liid.style.paddingTop = "1px";
        liid.getElementsByTagName('a')[0].style.overflow="hidden";  

        //liid.getElementsByTagName('a')[0].style.backgroundColor = "#0B1836";

        liid.getElementsByTagName('a')[0].style.height="15px";
        liid.getElementsByTagName('a')[0].style.zIndex = 2222;
        liid.getElementsByTagName('ul')[0].style.top= "29px";

        
        
        //liid.getElementsByTagName('ul')[0].style.
   }
    //alert(textspan.innerText);
    if(img.src.indexOf("topmoreinfo_arrow.gif")!=-1)
    {
        
        
        if( liid != null )
        {
            //alert("changetext");
            //liid.getElementsByTagName('a')[0].style.backgroundColor = "#192E59";
            liid.style.borderTop = "1px solid #597ea8";
            liid.style.borderRight = "1px solid #597ea8";
            liid.style.borderLeft = "1px solid #597ea8";
            
        }
        img.src = "http://www.fluor.com/SiteCollectionImages/moreinfo_arrow_down.gif";
    }
    
    
}
function changeText2(liid, imgid)
 { 
     
     if( liid != null ) 
     { // liid.style.borderTop = "1px solid #192E59"; // liid.style.borderRight = "1px solid #192E59"; // liid.style.borderLeft = "1px solid #192E59"; 
        //alert('tttt');
        //alert("changetext2");
       // liid.style.backgroundColor = "red";
        //alert('tttt22');
     } 
 }
function changeBackGroup( liid, isOver)
{
    if(isOver){
         liid.style.backgroundColor = "#0B1836";
         liid.parentNode.style.backgroundColor = "#0B1836";
   }
   else
   {
        liid.style.backgroundColor = "#192E59";
         liid.parentNode.style.backgroundColor = "#192E59";
   }
    liid.style.zIndex = 2222;
}


function highlight()
{
	if(document.getElementById('currentitem')!=null)
    		document.getElementById('currentitem').className = "current";
}

//var currentMenuImage = new Image("/SiteCollectionImages/navtab_darkblue_40.png");

function MouseOutChangeBackgroup(obj) {
    //alert("mouse out");
    if(document.getElementById('currentliid')!=null)
   { 
        document.getElementById('currentliid').style.backgroundImage = "";
   } 
}

function MouseOverChangeBackgroup(obj) {
    //alert("mouse over");
    if (obj.id != "currentliid") {
             if(document.getElementById('currentliid')!=null)
            { 
                document.getElementById('currentliid').style.backgroundImage = "url(http://www.fluor.com//SiteCollectionImages/navtab_darkblue_40.png)";
            }
        }
}
