// JavaScript Document
function extractPageName(hrefString)
{
	var arr = hrefString.split('/');
	return  (arr.length<2) ? hrefString : arr[arr.length-2].toLowerCase() + arr[arr.length-1].toLowerCase();		
}

function setActiveMenu(arr, crtPage)
{
	crtPage = crtPage.replace("cme/careers","");
	for (var i=0; i<arr.length; i++)
	{
		comp = extractPageName(arr[i].href);
		comp = comp.replace("cme/careers","");
		if(comp == crtPage)
		{
			//if (arr[i].parentNode.tagName != "div")
			//{
				arr[i].className = "current";
			//	arr[i].parentNode.className = "current";
			//}
		}
	}
}

function setPage()
{
	hrefString = document.location.href ? document.location.href : document.location;
	if (document.getElementById("headingsNavigation")!=null) 
	{
		setActiveMenu(document.getElementById("headingsNavigation").getElementsByTagName("a"), extractPageName(hrefString));
	}
}
function customPopup(url, features) 
{
	window.open(url, '', features);
}
function siteMain(myURL) 
{
    window.opener.parent.location=myURL;
}

function get_random()
{
    var ranNum= Math.floor(Math.random()*10);
	//alert(ranNum);
	if(ranNum < 2)
	return "../assets/hi1.jpg";
	if(ranNum < 5 && ranNum >= 2)
	return "../assets/hi2.jpg";
	if(ranNum < 7 && ranNum >= 5)
	return "../assets/hi3.jpg";
}

function showLangURL()
{
	var compURL = document.URL;
	var indFileNameLast = compURL.lastIndexOf("/");
	var fileName = compURL.slice(indFileNameLast);
	
	
	//compURL = compURL.substr(indFileNameLast);
	//alert(indFileName + " - " + indFileNameLast);
	//alert(compURL + "/bmocareersfr"+fileName);
	
	var indFileName = compURL.lastIndexOf("/chip/");
	compURL = compURL.replace("/chip"+fileName, "");
	location.href= compURL + "/puce" + fileName;
}
