// Switch website language
function switchLanguage()
{
	var myFQDN = 'http://www.orengine.com';
	var option = '';
	var languageOptions = prompt("Please select:\n[1] English  [2] Spanish  [3] Italian", "");
	if (languageOptions !== "" && languageOptions !== null) {
		if (languageOptions == 1) {
			option += '/en/';
		} else if (languageOptions == 2) {
			option += '/es/';
		}  else if (languageOptions == 3) {
			option += '/it/';
		} else {
			languageOptions;
		}
		document.location.href=myFQDN+option;
	}
}
// Update status bar copyright accordingly to current and first copyright year
defaultStatus	= "Orengine International Ltd. 2008, 2012. All Rights Reserved.";
// Brake external frames 	
if (top.frames.length != 0) {
	top.location = self.document.location;
}
// Import external js
function $import(src){
	var scriptElem = document.createElement('script');
	scriptElem.setAttribute('src',src);
	scriptElem.setAttribute('type','text/javascript');
	document.getElementsByTagName('head')[0].appendChild(scriptElem);
}
// Import external js avaoiding cache
function $noCacheImport(src){
	var ms = new Date().getTime().toString();
	var seed = "?" + ms; 
	$import(src + seed);
}
// cssMenu
cssMenu = function()
{
	var cssRule;
	var newSelector;
	for (var i=0;i<document.styleSheets.length;i++) {
		for (var x=0;x<document.styleSheets[i].rules.length;x++) {
			cssRule = document.styleSheets[i].rules[x];
			if (cssRule.selectorText.indexOf("LI:hover") != -1) {
				newSelector = cssRule.selectorText.replace(/LI:hover/gi, "LI.iehover");
				document.styleSheets[i].addRule(newSelector , cssRule.style.cssText);
			}
		}
	}
	var getElm = document.getElementById("cssMenu").getElementsByTagName("LI");
	for (var i=0;i<getElm.length;i++) {
		getElm[i].onmouseover=function() {
			this.className+=" iehover";
		}
		getElm[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"),"");
		}
	}
}
// Initialize cssMenu
if (window.attachEvent) {
	window.attachEvent("onload",cssMenu);
}
// Allow both Microsoft IE and FireFox users to bookmark this website
function addToFavorites()
{
    if (document.all) {
        window.external.AddFavorite("http://www.orengine.com","Orengine International");
    } else if (window.sidebar) {
        window.sidebar.addPanel("Orengine International","http://www.orengine.com","");
    }
}	
// Spot hiding
function hideSplashScreen()
{
	document.getElementById('flash-splash-screen').style.display='none';
}

function $import(src)
{
	var scriptElem = document.createElement('script');
	scriptElem.setAttribute('src',src);
	scriptElem.setAttribute('type','text/javascript');
	document.getElementsByTagName('head')[0].appendChild(scriptElem);
}

// import with a random query parameter to avoid caching
function $importNoCache(src)
{
  var ms = new Date().getTime().toString();
  var seed = "?" + ms; 
  $import(src + seed);
}


