// Flash header Script
// Entrepot Marine theme

if(window.attachEvent) //IE
{
	window.attachEvent("onload", _initPageFunction);
}
else if(window.addEventListener) //DOM
{
	window.addEventListener("load", _initPageFunction, false);
}

// Function used to initialize all functions used in page
function _initPageFunction()
{
	_initLogo();
	_positionSearch();
	_checkIOS();
	
		if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){
		_checkTabPosition();
	}
}

// function that insert a link over the logo in the header of the page for SEO
function _initLogo()
{
	if(document.getElementById('contentLogo'))
	{
		var oDivLogo = document.getElementById('contentLogo');
		if(EcommercePageCulture == "fr-CA")
		{
			if(oDivLogo){oDivLogo.innerHTML = '<a id="EntrepotMarine" href="/" title="Entrepot Marine">Entrepot Marine</a>';}
		}
		else
		{
			if(oDivLogo){oDivLogo.innerHTML = '<a id="EntrepotMarine" href="/" title="Entrepot Marine">Entrepot Marine</a>';}
		}
	}
}

function _checkTabPosition()
{
	if(document.getElementById("oucProductDescription_oTabs"))
	{
		document.getElementById("oucProductDescription_oTabs").style.marginBottom = "-1px";
	}
}

function _positionSearch(){
	if(document.getElementById("flashdefault") && document.getElementById("contentSearchAvailable"))
	{
		var flashSize = document.getElementById("flashdefault").offsetHeight;
		document.getElementById("contentSearchAvailable").style.top = document.getElementById("contentSearchAvailable").offsetTop + flashSize + "px";
	}
	
	if(document.getElementById("oLayerSwitch") && document.getElementById("contentSearchAvailable"))
	{
		document.getElementById("contentSearchAvailable").style.display = "none";
	}
}


function _checkIOS()
{
	var deviceAgent = navigator.userAgent.toLowerCase();
	$iOS = deviceAgent.match(/(iphone|ipod|ipad)/);

	if ($iOS) {
		document.getElementById("pageAlign").style.backgroundColor = "#fff";
		document.body.style.background = "none";
	}
}



