
﻿
var selectionLanguage=getLanguage();var selectionCountry=getCountry();var ddlOnScreen=false;var onShowLangListActive=false;var selectionLanguage='EN';var selectionCountry='ROW';function getUrlLanguage()
{var url=location.href.replace("#","");var re=/\/(EN|DE|FR|IT|ES)\//i;var arr=re.exec(url);return((arr!=null)&&(arr[1]!=null))?arr[1].toUpperCase():'';}
function validateUrlLanguage(language)
{var urlLanguage=getUrlLanguage();if(language&&urlLanguage&&(language!=urlLanguage))
{redirectToLanguage(language);}
createCookie(cookieLanguageName,pageLanguage,365);createCookie("Country",pageCountry,365);}
function redirectToLanguage(language)
{var url=location.href.replace("#","");var re=/\/(EN|DE|FR|IT|ES)\//i;location.href=url.replace(re,'/'+language+'/');}
function getCookieLanguage()
{return readCookie(cookieLanguageName);}
function getCookieCountry()
{return readCookie("Country");}
function getLanguage(){return(typeof(pageLanguage)!='undefined')?pageLanguage:'EN';}
function getCountry(){return(typeof(pageCountry)!='undefined')?pageCountry:'ROW';}
function maintainDropDowns(val)
{if(typeof(HideDropDowns)!='undefined')
{if(val&&ddlOnScreen)
{maintainDropDowns(false);}
HideDropDowns(val);ddlOnScreen=true;}}
function showLanguageLayer()
{maintainDropDowns(true);ddlOnScreen=true;if(document.getElementById('languagelayer').className=='shown'){hideLanguageLayer();}
else{document.getElementById('languagelayer').className='shown';document.getElementById('langbutton').className="hi";}
onShowLangListActive=false;languageActivation();}
function hideLanguageLayer()
{maintainDropDowns(false);hideCountryList(null,0);hideLangList(null);document.getElementById('languagelayer').className='';document.getElementById('langbutton').className="";}
function showCountryList(){hideLangList(null);if(document.getElementById('countrytitle').className=='langlink hi'){hideCountryList(null);}
else{document.getElementById('countrylist').className='shown';document.getElementById('countrytitle').className='langlink hi';}}
function hideCountryList(elm,country,shrt,lang){if(elm!=null){document.getElementById('langlist').innerHTML=document.getElementById('langlist_'+country).innerHTML;hideLangList(document.getElementById('langlist_'+country).firstChild.firstChild.firstChild,null);document.getElementById('countrytitle').innerHTML=elm.innerHTML;}
document.getElementById('countrytitle').className='langlink';document.getElementById('countrylist').className='';if(shrt){selectionCountry=shrt;}
if(lang){selectionLanguage=lang;}
onShowLangListActive=false;languageActivation();}
function showLangList(){hideCountryList(null,0);languageActivation();if(document.getElementById('langtitle').className=='langlink hi'){hideLangList(null);}
else{document.getElementById('langlist').className='shown';document.getElementById('langtitle').className='langlink hi';}}
function hideLangList(elm,lang,shrt){languageActivation();if(elm!=null){document.getElementById('langtitle').innerHTML=elm.innerHTML;}
document.getElementById('langtitle').className='langlink';document.getElementById('langlist').className='';if(shrt){selectionCountry=shrt;}
if(lang){selectionLanguage=lang;}}
function SetLanguage(){var oldLang=readCookie(cookieLanguageName);var oldCountry=readCookie("Country");createCookie(cookieLanguageName,selectionLanguage,365);createCookie("Country",selectionCountry,365);hideLanguageLayer();var locact=location.href;var ahref=urlHandler(locact,selectionLanguage,selectionCountry,oldLang,oldCountry);var loc=locact.indexOf("#",0);if(loc>0)
{locact=locact.substring(0,loc);}
if(locact==ahref)
{location.reload();}
else
{location.href=ahref;}
return false;}
function languageActivation()
{var count=document.getElementById('langlist').childNodes[0].childNodes.length==0?document.getElementById('langlist').childNodes[1].childNodes.length==2:document.getElementById('langlist').childNodes[0].childNodes.length==1;if(count)
{document.getElementById('selectfakeLanguage').style.background='#dfdfdf';document.getElementById('langtitle').onclick=function(){void(0);};if(document.getElementById('langtitle').style)
{document.getElementById('langtitle').style.textDecoration='none';document.getElementById('langtitle').style.color='gray';document.getElementById('langtitle').style.cursor='default';}
onShowLangListActive=false;}
else
{if(onShowLangListActive)
{document.getElementById('langtitle').setAttribute('onClick',"hideLangList(null);");document.getElementById('langtitle').onclick=function(){hideLangList(null);};onShowLangListActive=false;}
else
{document.getElementById('langtitle').setAttribute('onClick',"showLangList();");document.getElementById('langtitle').onclick=function(){showLangList();};onShowLangListActive=true;}
document.getElementById('langtitle').style.cursor='pointer';document.getElementById('langtitle').className='langlink';document.getElementById('selectfakeLanguage').className='selectfake';if(document.getElementById('selectfakeLanguage').style)
{document.getElementById('selectfakeLanguage').style.background="transparent url("+serverProtocol+"://"+homeDomain+"/Style%20Library/images/language/bg_select.gif) no-repeat scroll right center";document.getElementById('selectfakeLanguage').style.border="1px solid #999999";document.getElementById('selectfakeLanguage').style.padding="2px 0pt 2px 5px";}}}