﻿// JScript File
function changeLanguage(lang)
{
    // Construeix la nova adreça i li envia el paràmetre de l'idioma
    location = location.protocol + "//" + location.host + location.pathname + "?language=" + lang;
}

function SwitchLanguageDiv(){    if(document.getElementById('divLang').style.display == 'none' ||        document.getElementById('divLang').style.display == '')    {        document.getElementById('divLang').style.display = 'block';        return;    }    else     {        document.getElementById('divLang').style.display = 'none';    }}function CloseLanguageDiv(){       document.getElementById('divLang').style.display = 'none';}// GESTIÓ D'EVENTS DEL DROPDOWNLIST
function changePhoneCode(control, destinationId)
{
    var code = control.value;
    if(code != "")
    {
       document.getElementById(destinationId).value = countryArray[code];
       document.getElementById(destinationId).value = countryArray[code];
    }
    else
    {
        document.getElementById(destinationId).value = "";
        document.getElementById(destinationId).value = "";
    }     
}

// LIMITACIÓ DELS CARACTERS (TEXTBOX MULTILINE)
function doBeforePaste(control, maxLength)
{
   if(maxLength)
   {
       event.returnValue = false;
   }
}
function doPaste(control, maxLength)
{
   value = control.value;
   if(maxLength){
        event.returnValue = false;
        maxLength = parseInt(maxLength);
        var o = control.document.selection.createRange();
        var iInsertLength = maxLength - value.length + o.text.length;
        var sData = window.clipboardData.getData("Text").substr(0,iInsertLength);
        o.text = sData;
    }
}
function LimitInput(control, maxLength)
{
    if(control.value.length > maxLength)
    {
        control.value = control.value.substring(0,maxLength);
    }
}


// GESTIÓ DEL SECTION MENU
function SetSelectedSection(control, section)
{
alert(control);
alert(control.value);
alert(control.Id);
alert(control.id);
alert(control.name);
    switch(section)
    {
        case 'welcome':
            document.getElementById('tdSectionMenuWelcome').setAttribute("class", "HOC-tdMenuSelected");
            document.getElementById('linkMenuWelcome').setAttribute("class", "HOC-menulinkSelected");
            break;
            
        case 'registration':
            document.getElementById('tdSectionMenuRegistration').setAttribute("class", "HOC-tdMenuSelected");
            document.getElementById('linkMenuRegistration').setAttribute("class", "HOC-menulinkSelected");
            break;            
            
            
    }

}


// GESTIO DELS LINKS (PER IDIOMAES)
function LinkTo(language,url)
{
 if(language!='en' & language!='')
 {
    url = url.replace("http://www.fifa", "http://"+language+".fifa");
    url = url.replace("http://fifa", "http://"+language+".fifa");
 }
   document.location = url;

}



