var url = document.location.href;
function switchLanguage() {
	
	var str = document.location.href;

	if(str.indexOf("/en/") >= 0){
		url = url.replace("/en/", "/fr/");
		document.location = url;
	}
	else if(str.indexOf("lang=en") >= 0){
		url = url.replace("lang=en", "lang=fr");
		document.location = url;
	}
	else if(str.indexOf("/fr/") >= 0){
		url = url.replace("/fr/", "/en/");
		document.location = url;
	}
	else if(str.indexOf("lang=fr") >= 0){
		url = url.replace("lang=fr", "lang=en");
		document.location = url;
	}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  var selURL = selObj.options[selObj.selectedIndex].value;
  
  if (selURL == '')
  {
	// nothing need to do
  }
  else if (selURL.indexOf('~') == 0)
  {
  	window.open(selURL.substr(1, selURL.length), "_blank");
  }
  else
  {
   eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  }
  if (restore) selObj.selectedIndex=0;
}
function checkPageSecurity() {
    var currentUrl = document.location.href;
    var secured = currentUrl.indexOf("https://") == 0;
    if (typeof(_page_need_secure_) != 'undefined' && _page_need_secure_) {
        if (!secured) {
            document.location.href = "https://" + currentUrl.substr(7);
        }
    } else {
        if (secured) {
            document.location.href = "http://" + currentUrl.substr(8);
        }
    }
}

// check security before any other scripts
var oldonload = window.onload;
if (typeof window.onload != 'function'){
    window.onload = checkPageSecurity;
} else {
    window.onload = function(){
        checkPageSecurity();
        oldonload();
    };
}

