function getUrlParam(name, url) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    if (url == null) {url = window.location.href.toLowerCase();}else{url=url.toLowerCase();}
    var results = regex.exec(url);
    if (results == null)
        return null;
    else
        return results[1];
}
function initFlashView(){
	var videoAction = getUrlParam('videoaction');
	var videoGroup = unescape(getUrlParam('videogroup'));
	if(videoAction == 'launch'&&videoGroup != null){
		jQuery(document).ready(function(){if(ShowModal){ShowModal(videoGroup);}});
	}
}
function hideSideWithNoConent()
{

	var left=document.getElementById("divleftColumnThumbbottom_left");
	var right=document.getElementById("divleftColumnThumbbottom_right");
	var childCount=0;
	if(left!=null||right!=null)
	{
		if (window.navigator.userAgent.toLowerCase().indexOf("msie")<0)
		{
			childCount=1;
		}
		var leftdivs=left.getElementsByTagName('div');
		var rightdivs=right.getElementsByTagName('div');
		
		if(right.childNodes.length==childCount&&left!=null)
		{	
			left.style.width="588px";right.style.display="none";
		}
		if(left.childNodes.length==childCount&&right!=null)
		{
			right.style.width="588px";	left.style.display="none";	
		}
		if(leftdivs.length==1)
		{
			right.style.width="588px";left.style.display="none";
		}
		if(rightdivs.length==1)
		{
			left.style.width="588px";right.style.display="none";
			if(jQuery('#divleftColumnThumbbottom_left .leftColumnThumbbottomCol2').size()>0)
			{
				jQuery('.leftColumnThumbbottomCol2').css('width','480px');
			}
		}
	}  
	var bottomContent=document.getElementById('divSubpagebottomContent');
	if(bottomContent!=null)
	{
		childCount=0;
		if (window.navigator.userAgent.toLowerCase().indexOf("msie")<0)
		{
			childCount=1;
		}
		if(bottomContent.childNodes.length==childCount)
		{	
			bottomContent.style.display="none";
		}
	}
	initFlashView();
}
function slideShowImages(section,divshow)
{
	var flashsetting=section;
	var flashheight='340';
	switch(section.toLowerCase())
	{
		case 'project':flashsetting='bannar_fluor_project';flashheight='260';break;
		case 'career':flashsetting='bannar_fluor_careers';flashheight='260';break;
		case 'professional':flashsetting='bannar_fluor_careers';flashheight='260';break;
		case 'college':flashsetting='bannar_fluor_careers';flashheight='260';break;
		case 'craft':flashsetting='bannar_fluor_careers';flashheight='260';break;
		case 'sustainability':flashsetting="photos";flashheight='260';break;
		default:flashsetting=section;flashheight='340';break;
	}
	flashsetting=flashsetting.toLowerCase();
	if(checkFlashPlushIn()==true){
	if (AC_FL_RunContent == 0) {
		alert("This page requires AC_RunActiveContent.js.");
	} else {
		AC_FL_RunContent(
			'FlashVars','xml_path=/_layouts/css/SlideShowsDataSource.aspx?section='+section,			
			'codebase', 'https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', '100%',
			'height',flashheight ,
			'src', '/SiteCollectionImages/swf/'+flashsetting,
			'quality', 'high',
			'pluginspage', 'https://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'transparent',
			'devicefont', 'false',
			'id', flashsetting,
			'bgcolor', '#070709',
			'name', flashsetting,
			'menu', 'true',
			'allowFullScreen', 'false',
			'allowScriptAccess','sameDomain',
			'movie', '/SiteCollectionImages/swf/'+flashsetting,
			'salign', ''
			); //end AC code
		}
    //document.getElementById(divshow).style.width=window.screen.width-20;
    }
    else{
    		document.getElementById(divshow).style['backgroundImage']='url('+checkFluorSection(section.toLowerCase())+')';
       	}
    if(section=="Home"){
    document.getElementById('centerbannercontent').style.width=window.screen.width-20+'px';}
}
function checkFlashPlushIn()
{
    if (navigator.plugins) {
        for (var i=0; i < navigator.plugins.length; i++) {
            if (navigator.plugins[i].name.toLowerCase().indexOf("shockwave flash") >= 0) {
               return true||FLUORCLIENTSITESEUPFLASH; 
            }
        }
        return false||FLUORCLIENTSITESEUPFLASH;
    }
    else
    {
     return false||FLUORCLIENTSITESEUPFLASH;
    }
}


function checkFluorSection(section)
{
	var sections=['home','career','craft','college','professional','project','sustainability'];
	var images=['/publishingimages/homepage/1600x340_homepage.jpg','/PublishingImages/Careers/1380x260_career.jpg',
				'/PublishingImages/Careers/Craft/1380x260_craft.jpg','/PublishingImages/Careers/College/1380x260_college.jpg',
				'/PublishingImages/Careers/Professional/1380x260_professional.jpg','/FluorProjectPhotos/1380x260_project.jpg',
				'/SiteCollectionImages/Sustainability/fluor_report_banner.jpg'];
	for(var index=0; index<sections.length;index++)
	{
		if(sections[index]==section)
		return images[index];
	}
	return '';
}
function showTopNav()
{
	var so = new SWFObject("/SiteCollectionImages/swf/top_nav.swf", "topnav", "785", "320", "8", "#2F5691");
	so.addParam("scale", "noscale");
	so.addParam("quality", "high");
	so.addParam("wmode", "Transparent");
	so.addParam("menu", "false");
	so.addParam("salign", "lt");
	so.addParam("loop", "false");	
	so.addParam("flashvars", "id="+window.location	);			
	so.write("topNavigationContent");
	var topnavContent = document.getElementById("topNavigationContent");
	if(topnavContent!=null)
	{
		topnavContent.style.height="65px";
		document.getElementById("topNavigationContent").overflow = "";							
	}
}
//The "Project Finder" function is not working properly for users within the Fluor firewall
function WebForm_PostBackOptions(eventTarget, eventArgument, validation, validationGroup, actionUrl, trackFocus, clientSubmit) {
    this.eventTarget = eventTarget;
    this.eventArgument = eventArgument;
    this.validation = validation;
    this.validationGroup = validationGroup;
    this.actionUrl = actionUrl;
    this.trackFocus = trackFocus;
    this.clientSubmit = clientSubmit;
}
function renderTopNav()
{
	var menufile = getMenuFile();
	var nav = null;
	if(menufile.isOnloaded == true)
	{
		var windowonload = window.onload;
		jQuery(document).ready(function(){
			if(windowonload)windowonload.apply();
			nav = new mcoJSMenu(menufile.xmlfile,"jsTopNavigationContent",window.screen.width-20);
		});
		return;
	}
	nav = new mcoJSMenu(menufile.xmlfile,"jsTopNavigationContent",window.screen.width-20);
}
//This function is to make the masterpage be compatible with different sites
function  compatibleAllSites()
{
	var settings = changeSettings();
	//Change the http://www.fluor.com to http://www.fluor.com/australia
	//jQuery("#fluorheaderlogoId a").attr("href",settings.logoLink+jQuery("#fluorheaderlogoId a").attr("href"));
	//Add the logon title
	//jQuery("#fluorcountry").html(jQuery("#divCountryTraslation").html());
	//Translate the "Print this page" text to the local.
	if(jQuery.trim(jQuery("#divPrintthispageTraslation").html())!="")
		jQuery(".rightcontent .printpage a").html(jQuery("#divPrintthispageTraslation").html());
	//Remove the Home title in the sitemap
	if(settings.editSitemap == true){
		jQuery("#centrecontent .siteMap #ctl00_cphContent_siteMapPath span").each(function(index){
				if(index < settings.hideIndex){
					jQuery(this).hide();	
				}
				if(index == settings.hideIndex && settings.changeTitle == true){
					jQuery(this).find("a").html(jQuery("#divCountryTraslation").html());
				}	
			});
	}
}
function getMenuFile()
{
	// need to edit when adding the new international site.
	var countries=["/australia/","/spain/en/","/spain/","/canada/","/southafrica/","/netherlands/en/","/netherlands/","/uk/"];
	//-------------------end----------------------/
	var fluorLogoLink = jQuery("#fluorlogoimageid a").attr("href");
	if(typeof fluorLogoLink !='undefined'){
		fluorLogoLink = jQuery.trim(fluorLogoLink.toLowerCase());
		for(var country in countries)
		{
			if(fluorLogoLink.indexOf(countries[country])>=0){
				return {xmlfile:"the file no need",isOnloaded:true};
			}
		}
	}
	return {xmlfile:"No File Needed",isOnloaded:false};
}
function changeSettings()
{
	// need to edit when adding the new international site.
	var countries = ["/australia/","/spain/en/","/spain/","/canada/","/southafrica/","/netherlands/en/","/netherlands/","/uk/"];
	var logoLinks = ["/australia","/spain/en","/spain","/canada","/southafrica","/netherlands/en","/netherlands","/uk"];
	var  hideIndexes = [2,4,2,2,2,4,2,2];
	var  changeTitles = [false,true,false,false,false,false,false,false];
	//-------------------end----------------------/
	for(var country in countries)
	{
		if(jQuery.trim(window.location.href.toLowerCase()).indexOf(countries[country])>=0){
			return {logoLink:logoLinks[country],editSitemap:true,
						hideIndex:hideIndexes[country],changeTitle:changeTitles[country]};
		}
	}
	return {logoLink:"",editSitemap:false,hideIndex:-1,changeTitle:""};
}
function switchCoutrySite(settings)
{
	if(settings != null){
		if(settings.isLocal==true) return;
		var currentpageurl = jQuery.trim(window.location.href.toLowerCase());
		if(currentpageurl.indexOf(settings.urlreplaced)>=0){
			window.location.href = currentpageurl.replace(settings.urlreplaced,settings.urlreplace);
		}
	}
}
var blank = new Image();
blank.src = '/sitecollectionimages/blank.gif';
function fixPngForIE6(png) {
	if(jQuery.browser.msie&&jQuery.browser.version<=6){
	   // get src
	   var src = png.src;
	   // set width and height
	   if (!png.style.width) { png.style.width = jQuery(png).width(); }
	   if (!png.style.height) { png.style.height = jQuery(png).height(); }
	   // replace by blank image
	   png.onload = function() { };
	   png.src = blank.src;
	   // set filter (display original image)
	   png.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
 	}
 }