/* -- ImgChangeAction function -- */ 
function ImgChangeAction(sObjectId, sImgPath) {
    document.getElementById(sObjectId).src = sImgPath;
} // End of ImgChangeAction function

// LimitTextArea function
function LimitTextArea(oTextArea, iMaxChar) {
    if(oTextArea.value.length >= iMaxChar) {
        oTextArea.value = oTextArea.value.substring(0, iMaxChar);
        //alert("Has sobrepasado el límite de " + iMaxChar + " caracteres.");
    }
} // End of LimitTextArea function

function SelectSpainNacionality(oCountrySelect) {         
    oCheckBox1 = document.getElementById("work-perm");
    oCheckBox2 = document.getElementById("res-perm");
    if(oCountrySelect.value != "España") {
        oCheckBox1.checked = 0;
        oCheckBox2.checked = 0;        
        oCheckBox1.disabled = false;
        oCheckBox2.disabled = false;    
    } else {
        oCheckBox1.checked = 1;
        oCheckBox2.checked = 1;  
        oCheckBox1.disabled = true;
        oCheckBox2.disabled = true;
    }
}

/* -- Tab selection function -- */
function SelectTab(sMenuId, sTabId, iId) {
    var oMenu = document.getElementById(sMenuId);
    var oTab = document.getElementById(sTabId);
    ResetTabSelection(iId);
    oMenu.className = "show";
    oTab.className = "show";
} // End of SelectTab function

/* -- Reset tab selection function -- */
function ResetTabSelection(iId) {    
    var i = 1;
    while( document.getElementById("menu" + i + iId) ) {
        document.getElementById("menu" + i + iId).className="hide";
        document.getElementById("tab" + i + iId).className = "hide";
        i++;
    }
/*    
    // Menu list elements are reset
    document.getElementById("menu1" + iId).className="hide";
    document.getElementById("menu2" + iId).className="hide";
    document.getElementById("menu3" + iId).className="hide";
    document.getElementById("menu4" + iId).className="hide";
    document.getElementById("menu5" + iId).className="hide";
    
    // Containers are reset
    document.getElementById("tab1" + iId).className = "hide";
    document.getElementById("tab2" + iId).className = "hide";
    document.getElementById("tab3" + iId).className = "hide";
    document.getElementById("tab4" + iId).className = "hide";
    document.getElementById("tab5" + iId).className = "hide";
*/
} // End of ResetTabSelection function

// AlternateObjects function 
function AlternateObjects(sObjId1, sObjId2) {
    var oObjId1 = document.getElementById(sObjId1);
    var oObjId2 = document.getElementById(sObjId2);
    oObjId1.style.display = "none";
    oObjId2.style.display = "inline";
} // End of AlternateObjects function

// OpenWindow function
function OpenWindow(sURL, sTitle) {
    x = (screen.height - 550)/2;
    y = (screen.width - 700)/2;
    sFeatures = "height=550,width=700,top=" + x + ",left=" + y + ",toolbar=No,location=No,scrollbars=Yes,status=No,resizable=No";
    window.open(sURL, sTitle, sFeatures);
} // End of OpenWindow function

// ShowFootText function
function ShowFootText(sHeadId, sTextId) {
    var oHead = document.getElementById(sHeadId);
    var oText = document.getElementById(sTextId);
    HideAllFootTexts();
    oHead.style.display = "block";
    oText.style.display = "block";
} // End of ShoFootText function

// HideAllFootTexts function
function HideAllFootTexts() {
    document.getElementById("dom-hd").style.display = "none";
    document.getElementById("how-hd").style.display = "none";
    document.getElementById("account-hd").style.display = "none";
    document.getElementById("comp-hd").style.display = "none";
    document.getElementById("ind-hd").style.display = "none";
    document.getElementById("photo-hd").style.display = "none";
    document.getElementById("dom-txt").style.display = "none";
    document.getElementById("how-txt").style.display = "none";
    document.getElementById("account-txt").style.display = "none";
    document.getElementById("comp-txt").style.display = "none";
    document.getElementById("ind-txt").style.display = "none";
    document.getElementById("photo-txt").style.display = "none";
}

// DeletePhoto function
function DeletePhoto(sCheckboxId, sPhotoId, sPhoto) {
    var oCheckbox = document.getElementById(sCheckboxId);
    var oPhoto = document.getElementById(sPhotoId);
    if(oCheckbox.checked == 1) {
        oPhoto.src = "../img/individuals/delete_photo.png";
    } else {
        oPhoto.src = "../img/individuals/" + sPhoto;
    }
}

// DeleteLogo function
function DeleteLogo(sCheckboxId, sLogoId, sLogo) {
    var oCheckbox = document.getElementById(sCheckboxId);
    var oLogo = document.getElementById(sLogoId);
    if(oCheckbox.checked == 1) {
        oLogo.src = "../img/companies/delete_logo.png";
    } else {
        oLogo.src = "../img/companies/" + sLogo;
    }
}

// CheckInputs function
function CheckInputs(oForm) {
    if((oForm.Activity.value == "") || (oForm.Province.value == "")) {
        alert("Tienes que indicar una actividad y una localidad");
        return false;
    } else {
        return true;
    }
}

function seccionShow(B, max){
    if(B!=''){        
        //$("listaSectores").show();
        $("#sector"+B).show();
        for(var A=1;A<=max;++A){
            if(A==B){
                $("#sector"+B).show()
            }
            else{
                $("#sector"+A).hide()
            }
        }
    }
    return false
}


function hideMain(){
    $("#overlay").show();
}

function showMain(){
    $("#overlay").hide()
}


function hideLayer(layer){
    $('#'+layer).hide();
    showMain();
    return false
}

function showLayer(layer){
    $('#'+layer).show();   
    hideMain();
    return false
}
