//This file contains some functions that are useful for multiple purposes

//Returns the value of the parameter "name" in the URL of the page
function gup(name) {
    name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    var regexS = "[\\?&]"+name+"=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results==null) {
        return "";
    } else {
        return results[1];
    }
}

function dialogIE6(lang) {
	var dialog = document.createElement("div");
	dialog.setAttribute("id","dialog");
    if (lang=='es') {
        dialog.setAttribute("title","Compatibilidad con Internet Explorer 6");
    } else {
        dialog.setAttribute("title","Internet Explorer 6 compatibility");
    }
	var dContent = document.createElement("a");
	var nameSpan = document.createElement("span");
    if (lang=='es') {
        nameSpan.innerHTML ="<center><p>Esta p&aacute;gina est&aacute; dise&ntilde;ada para navegadores que acepten XHTML, JavaScript y CSS 2.0.</p><p>Su navegador no es compatible con estos est&aacute;ndares, as&iacute; que es posible que experimente problemas navegando por nuestro sitio web.</p><p>Le recomendamos actualizar a una versi&oacute;n m&aacute;s reciente de su navegador.</p></center>";
    } else {
        nameSpan.innerHTML ="<center><p>This web is designed for browsers with XHTML, JavaScript and CSS 2.0 support.</p><p>Your navigator does not support these standards, so it is possible that you experience some problems while you are in our website.</p><p>We encourage you to get an updated version of your browser.</p></center>";
    }
    dContent.appendChild(nameSpan);
    dialog.appendChild(dContent);
	document.body.appendChild(dialog);
    var context = this;
	$("#dialog").dialog({
		modal: true,
		width: 450,
		resizable: false,
		draggable: false,
		buttons: {},
        close: function(){$("#dialog").dialog('destroy');document.body.removeChild(document.getElementById("dialog"))}
	});
}

//Effects for the blocks

// sets the block to its green version
function greenOver(id,lang) {
    var oEvent = $("#"+id);
    if (!oEvent.hasClass("activeSectionBlock")) {
        switch (id) {
            case "blockHome":
                oEvent.attr("src","../images/elements/blockHomeOn_"+lang+".png");
                break;
            case "blockCompany":
                oEvent.attr("src","../images/elements/blockCompanyOn_"+lang+".png");
                break;
            case "blockSectors":
                oEvent.attr("src","../images/elements/blockSectorsOn_"+lang+".png");
                break;
            case "blockNews":
                oEvent.attr("src","../images/elements/blockNewsOn_"+lang+".png");
                break;
            case "blockContact":
                oEvent.attr("src","../images/elements/blockContactOn_"+lang+".png");
                break;
            default:
                oEvent.attr("src","../images/elements/blockClientAreaOn_"+lang+".png");
        }
    }
}

// sets the block to its inactive state in gray
function grayOut(id,lang) {
    var oEvent = $("#"+id);
    if (!oEvent.hasClass("activeSectionBlock")) {
        switch (id) {
            case "blockHome":
                oEvent.attr("src","../images/elements/blockHomeOff_"+lang+".png");
                break;
            case "blockCompany":
                oEvent.attr("src","../images/elements/blockCompanyOff_"+lang+".png");
                break;
            case "blockSectors":
                oEvent.attr("src","../images/elements/blockSectorsOff_"+lang+".png");
                break;
            case "blockNews":
                oEvent.attr("src","../images/elements/blockNewsOff_"+lang+".png");
                break;
            case "blockContact":
                oEvent.attr("src","../images/elements/blockContactOff_"+lang+".png");
                break;
            default:
                oEvent.attr("src","../images/elements/blockClientAreaOff_"+lang+".png");
        }
    }
}

function showFor (id, time) {
    $("#"+id).attr("style","display:block");
    setTimeout(function(){$("#"+id).attr("style","display:none")},time); 
}

