jQuery(document).ready(
function() {
	
	if (jQuery('.BannerMain').html() == "" || jQuery('.BannerMain').html() === undefined || jQuery('.BannerMain').html() === null)
	{
		jQuery('.BannerFullEXP').css("display", "none");
	}

	jQuery('.Header_MenuWrapperMega ul#PfNavMega li').click(
		function() {
				jQuery(this).children('div[class="shadow"]').toggle();
		}
	);
	
	jQuery('.Header_MenuWrapperMega ul#PfNavMega li').hover(
		function() {
		},
		function() {
				jQuery(this).children('div[class="shadow"]').css("display", "none");
		}
	);
	
	jQuery('.Header_Home_FlagDD').click(
		function() {
				jQuery('div[class="LanguageDropDown_Shadow"]').toggle();
		}
	);
	
	jQuery('.Header_Home_FlagDD').hover(
		function() {
		},
		function() {
				jQuery('div[class="LanguageDropDown_Shadow"]').css("display", "none");
		}
	);
	
	
	var liPosition = 0;
	var liWidth = 0;
	var liAdjust = 0;
	var riAdjust = 0;
	var TopNavMainPos = 0;
	
	
	jQuery(".MenuWrapperMega ul#PfNavMega > li").hover(
		function() {
				liPosition = jQuery(this).position().left;
				liWidth = jQuery(this).width();
				TopNavMainPos = jQuery(".TopNavMain").position().left;
				
				liAdjust = (liPosition - TopNavMainPos) + (liWidth / 2);	
				riAdjust = (liPosition + (liWidth / 2) + 428) - (TopNavMainPos + 999);	
				
				if ((214 - (liWidth / 2)) > (liPosition - TopNavMainPos))
				{
					jQuery(this).children('div[class="shadow"]').css("margin-left", -liAdjust + "px");
				}
				if ((liPosition + (liWidth / 2) + 214) > (TopNavMainPos + 999)) 
				{
					jQuery(this).children('div[class="shadow"]').css("margin-left", -riAdjust + "px");
				}
		}
		,
		function() {
				liPosition = 0;
				liWidth = 0;
				liAdjust = 0;
				TopNavMainPos = 0;
		}
	);
	
	var agent=navigator.userAgent.toLowerCase();
	var is_mobile = agent.indexOf('mobile');
	
	if (is_mobile != -1)
	{
		jQuery('.BannerMainShadow').css({'width': '999px', 'overflow': 'hidden'});
		jQuery('.ContentFullEXP').css({'width': '999px', 'overflow': 'hidden'});
		jQuery('.ContentMainShadow').css({'width': '999px', 'overflow': 'hidden'});
		jQuery('.ContentMain').css({'width': '940px', 'overflow': 'hidden'});
		jQuery('.HeaderFullEXP').css({'width': '999px', 'overflow': 'hidden'});
		jQuery('.BlockSepOneFullEXP').css({'width': '999px', 'overflow': 'hidden'});
		jQuery('.BlockSepTwoFullEXP').css({'width': '999px', 'overflow': 'hidden'});
		jQuery('.ContentMainPatos').css({'width': '999px', 'overflow': 'hidden'});
		jQuery('.TopNavFullEXP').css({'width': '999px'});
		jQuery('.w1039px').css({'width': '999px'});
	}
	
	var HudsonSearchMainLIArr;
	var HudsonSearchMainLIHtml;
	var HudsonSearchMainLIArrCount = 0;
	
	HudsonSearchMainLIArr = jQuery('.HudsonSearchMain li').get();
	
	for (HudsonSearchMainLIArrCount = 0; HudsonSearchMainLIArrCount < HudsonSearchMainLIArr.length; HudsonSearchMainLIArrCount++)
	{
		HudsonSearchMainLIHtml = jQuery(HudsonSearchMainLIArr[HudsonSearchMainLIArrCount]).text();
		HudsonSearchMainLIHtml = HudsonSearchMainLIHtml.replace(/ /g, "");
		
		if (HudsonSearchMainLIHtml == "" || HudsonSearchMainLIHtml === null || HudsonSearchMainLIHtml === undefined)
		{
			jQuery(HudsonSearchMainLIArr[HudsonSearchMainLIArrCount]).remove();
		}
	}
	
	var LanguageDropDown_MainArr;
	var LanguageDropDown_MainHtml;
	var LanguageDropDown_MainArrCount = 0;
	
	LanguageDropDown_MainArr = jQuery('.LanguageDropDown_Main a').get();
	
	for (LanguageDropDown_MainArrCount = 0; LanguageDropDown_MainArrCount < LanguageDropDown_MainArr.length; LanguageDropDown_MainArrCount++)
	{
		LanguageDropDown_MainHtml = jQuery(LanguageDropDown_MainArr[LanguageDropDown_MainArrCount]).html();
		LanguageDropDown_MainHtml = LanguageDropDown_MainHtml.replace("??????????", "???????");
		LanguageDropDown_MainHtml = LanguageDropDown_MainHtml.replace("??????????", "???????");
		jQuery(LanguageDropDown_MainArr[LanguageDropDown_MainArrCount]).html(LanguageDropDown_MainHtml);
	}
	
	if (LanguageDropDown_MainArr.length <= 1)
	{
		jQuery('.LanguageDropDown_Main').remove();
	}
	
	var HudsonSearchID;
	var HudsonSearchSelect;
	var HudsonSearchSelectVal;
	var HudsonSearchAlert;
	var HudsonSearchPassValidation = true;
	var saywha;
	
	jQuery('.HudsonSearch_btn input').click(
		function (e)
		{
			HudsonSearchID = jQuery(this).attr("id");
			HudsonSearchID = HudsonSearchID.replace("btn_Search", "pnlSearch");
			HudsonSearchSelect = jQuery('#' + HudsonSearchID + ' select').get();
			HudsonSearchAlert = "";
			HudsonSearchPassValidation = true;
			
			for (i = 0; i < HudsonSearchSelect.length; i++)
			{
				HudsonSearchSelectVal = jQuery(HudsonSearchSelect[i]).children('option:selected').val();
				if (HudsonSearchSelectVal == "" || HudsonSearchSelectVal === null || HudsonSearchSelectVal === undefined)
				{
					HudsonSearchAlert = HudsonSearchAlert + "Please select a " + jQuery(HudsonSearchSelect[i]).children('option[value=""]').text().replace(/ \/ /gi, "/") + "\n";
					HudsonSearchPassValidation = false;
				}
			}
			
			if (HudsonSearchPassValidation)
			{
				return true;
			}
			else
			{
				alert(HudsonSearchAlert);
				return false;
			}
		}
	);
	
	//var thisLocationHost;
	//var thisLocationHostPortal;
	//
	//thisLocationHost = window.location.host;
	//thisLocationHost = thisLocationHost.toLowerCase();
	//thisLocationHostPortal = thisLocationHost.split(".");
	//
	//if (thisLocationHostPortal[0] == "be")
	//{
	//	jQuery('.Header_Home_FlagDD').find('img').attr("src", "/images/Flags/fr-BE.gif");
	//}
}
);


	function SetEasyXdm(divcontainer, domain, requestedURL, waitcontainer)
	{

		myvar= encodeURIComponent(requestedURL);
		var transport = new easyXDM.Socket(/** The configuration */
			{
			url: "http://google.com",
	                remote: domain + "/easyXDM/resize_intermediate.htm?url="+myvar,
			remoteHelper: domain + "/easyXDM/name.htm",
        	        swf: domain + "/easyXDM/easyxdm.swf",
			swfNoThrottle: "true",
                	container: divcontainer,
	                onMessage: function(message, origin)
				{
					if (waitcontainer != null)
					{
						mywaitDIV= document.getElementById(waitcontainer);
						if (mywaitDIV != null)
						{
							mywaitDIV.style.display= "none";
						}
					}
					this.container.style.visibility= "visible";
					sizeARR= message.split("|");
					this.container.getElementsByTagName("iframe")[0].style.height = (sizeARR[0]*1)+20 + "px";
					//this.container.getElementsByTagName("iframe")[0].style.width = (sizeARR[4]*1)+200 + "px";
					this.container.getElementsByTagName("iframe")[0].style.width = "1000px";
					this.container.getElementsByTagName("iframe")[0].style.overflow = "hidden";
					this.container.getElementsByTagName("iframe")[0].style.scrollbars= "none";
	                	}
			});
	}



	function TESTSetEasyXdm(divcontainer, domain, requestedURL, waitcontainer)
	{
		myvar= encodeURIComponent(requestedURL);
		var transport = new easyXDM.Socket(/** The configuration */
			{
			url: "http://google.com",
	                remote: domain + "/easyXDM/resize_intermediate.htm?url="+myvar,
			remoteHelper: domain + "/easyXDM/name.htm",
        	        swf: domain + "/easyXDM/easyxdm.swf",
			swfNoThrottle: "true",
                	container: divcontainer,
	                onMessage: function(message, origin)
				{
					if (waitcontainer != null)
					{
						mywaitDIV= document.getElementById(waitcontainer);
						if (mywaitDIV != null)
						{
							mywaitDIV.style.display= "none";
						}
					}

					this.container.style.visibility= "visible";
					sizeARR= message.split("|");
					contentIframe= this.container.getElementsByTagName("iframe")[0];

newheight= (sizeARR[0]*1)+20;
oldheight= this.container.style.height.replace("px","");
if (newheight < oldheight)
{
	newheight= oldheight;
}

newwidth= (sizeARR[4]*1)+200;
oldwidth= this.container.style.width.replace("px","");
if (newwidth < oldwidth)
{
	newwidth= oldwidth;
}




					contentIframe.style.height = newheight + "px";
					contentIframe.style.width = newwidth + "px";
					//contentIframe.style.width = "1000px";
					contentIframe.style.overflow = "hidden";
					contentIframe.style.scrollbars= "none";

					this.container.style.height = newheight + "px";
					this.container.style.width = newwidth + "px";
	                	}
			});
	}


	function SameDomainResize(myiframe)
	{
		myframe= document.getElementById(myiframe);
		myframe.style.height= myframe.contentWindow.document.body.scrollHeight + "px";
		myframe.style.width= myframe.contentWindow.document.body.scrollWidth + "px";
	}



//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
//var iframeids=["HudsonIFrame"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="no"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 3 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller(iframeids) {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
resizeIframe(iframeids)
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids] : document.getElementById(iframeids)
tempobj.style.display="block"
}
}
}

function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
currentfr.style.display="block"
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; 
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent){
currentfr.detachEvent("onload", readjustIframe) // Bug fix line
currentfr.attachEvent("onload", readjustIframe)
}
}
}

function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}

//if (window.addEventListener)
//window.addEventListener("load", resizeCaller, false)
//else if (window.attachEvent)
//window.attachEvent("onload", resizeCaller)
//else
//window.onload=resizeCaller

