﻿function GetPais(combo) {    
    var aux = window.location.href.split("/");
    var loc = aux[0] + "//" + aux[2] + "/sunenergy.aspx";

    var indice = loc.indexOf("?");
    if (indice != -1)
        loc = loc.substr(0, indice);

    var pais = $(".cb_paises").val();
    
    $.ajax({
        type: "POST",
        url: loc + "/GetPais",
        data: "{'pais': '" + pais + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        cache: false,
        success: function(msg) {
            var html = msg.d;
            $("." + combo).attr("href", html);
            externalLinks();
        }
    });
}


function externalLinks() {
    if (!document.getElementsByTagName) return;
    var anchors = document.getElementsByTagName("a");
    for (var i = 0; i < anchors.length; i++) {
        var anchor = anchors[i];
        if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
            anchor.target = "_blank";
    }
}

function Inicio() {
    externalLinks();
}

$(document).ready(function() {
    Inicio();
});
