﻿var transURL = location.href;
var PageLangCode="";

var targetLangCodes=new Array("deu");

var WSENG = "http://www.systemcollection.com";
var WSDEU = "http://www.emoda.de"; 

var strURLPath = location.pathname;
var strQS = "";


function createTranslutionFlagBar(strLangCode){

	PageLangCode = strLangCode;
	
	
	document.write("<div id='TranslutionLB'>");
	
	//This is Change Language Label	
	document.write("<span align='centre'>");
	document.write("<p style='font-size:11px;font-weight:bold'>" + getLabelText(PageLangCode) + "</p>");
	document.write("</span>");
	
	//HTML for Language DROP DOWN
	document.write("<span>");
	document.write("<select name='cmbTransLanguage' id='cmbTransLanguage'>");
	
	//This is for English - Source Language
	if ( PageLangCode.length == 0){
		document.write("<option value=''>" + getLanguageName("",PageLangCode) + "</option>");
	}
	else{
		document.write("<option value='' selected>" + getLanguageName("",PageLangCode) + "</option>");
	}
	
	//For Target Languages
	
	for (i=0;i<targetLangCodes.length;i++){
			//alert("strLangCode = " + strLangCode);
			//alert("Target Code = " + targetLangCodes[i]);
			if ( targetLangCodes[i].toUpperCase() == PageLangCode.toUpperCase() ){
		        document.write("<option value='" + targetLangCodes[i] + "'>" + getLanguageName(targetLangCodes[i],PageLangCode) + "</option>");
	        }
			else{
				document.write("<option value='" + targetLangCodes[i] + "' selected>" + getLanguageName(targetLangCodes[i],PageLangCode) + "</option>");
			}
	}
	
	document.write("</select>");
	document.write("</span>");
	
	document.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
	
	//THIS IS FOR BUTTON HTML
	document.write("<span>");
	document.write("<input type='button' name='btnLocalise' value='" + getButtonText() + "' onclick='ChangePageLanguage()'>");
	document.write("</span>");
	
	
	
	//document.write("</tr>");
	//document.write("</table>");
	document.write("</div>");
}

function getButtonText(){

	var strRet="GO";
	
	switch(PageLangCode.toUpperCase()){
		case "":
			strRet = "GO";
			break;
		case "DEU":
			strRet = "LOS";
			break;
	}
	return strRet;
	
}

function ChangePageLanguage(){

//showHTML();
try{
	//Get the Language Combo
	var objLang = document.getElementById("cmbTransLanguage");;

	
	
	if ( objLang != null){
		//Get the Selected option object
		var objSelOption = objLang.options[objLang.selectedIndex];
		if ( objSelOption != null){
			
			var SelValue= objSelOption.value.toUpperCase();
			if ( SelValue != PageLangCode.toUpperCase() ){
				
				strQS = location.search;
				
				var RedirectionURL = "";
				switch(SelValue){
					case "":
					//Navigate to Source Language Website
					RedirectionURL = WSENG + strURLPath + strQS;
					window.location = RedirectionURL;
					break;
					case "DEU":
					//Navigate to German Language Website
					RedirectionURL = WSDEU + strURLPath + strQS;
					window.location =RedirectionURL;
					break;
				}
			}
		}
	}
}
catch(err){

}
}



function getLanguageName(strLangCode,strPageLang){
    var strRet="";
    //alert("inside lang code = " + strLangCode.toUpper());
	if ( strPageLang.toUpperCase() == "" ){
		switch(strLangCode.toUpperCase()){
			case "":
				strRet = "English";
				break;
			case "DEU":
				strRet = "German";
				break;
		}
	}
	if ( strPageLang.toUpperCase() == "DEU" ){
		switch(strLangCode.toUpperCase()){
			case "":
				strRet = "Englisch";
				break;
			case "DEU":
				strRet = "Deutsch";
				break;
		}
	}
	
    return strRet;
}

function getLabelText(strLangCode){
	var strRet="";
    //alert("inside lang code = " + strLangCode.toUpper());
    switch(strLangCode.toUpperCase()){
        case "":
            strRet = "Change Language";
            break;
        case "DEU":
			strRet = "Sprache ändern";
            break;
       
    }
    return strRet;
}



function showHTML(){
    var oEle = document.getElementById("TranslutionLB");
    if ( oEle != null){
        alert("Inner HTML = " + oEle.innerHTML);
    }
}

/*function setWindowStatus(pStatusId)
{
	switch(pStatusId)
	{
		case 0://error
			window.status="";
			break;
		case 1://started
		    if (transSourceLang == "fra")
		    {
    			window.status="Svp attente. La page courante est traduite..";
    		}
    		else
    		{
    			window.status="Please wait. The current page is being translated..";    			
    		}
			break;
		case 2://success
			window.status="";
			break;
	}
}





//----------MARINA FUNCTION - SORRY PLEASE DO NOT TAKE OUT!!!

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
try {
var pageTracker = _gat._getTracker("UA-1278302-7");
pageTracker._trackPageview();
} catch(err) {}







*/
