﻿function init() {
    $('#dvListProvincia').hide();

    var hash = getUrlVars();
    
    if (hash["c"] != undefined) {
        Cobertura = hash["c"];
        
        if (Cobertura == "1") {
            document.getElementById("txtInputAderir2").focus();
            $('#dvListProvincia').show();
        }
    }
}
function initCont() {

    var txtTitle = window.document.title;
    var txtUrl = window.location.href;

    if (txtTitle.indexOf("#TV") > 0)
        window.document.title = 'TV CABO';
    else if (txtUrl.indexOf("#TV") > 0)
        window.document.title = 'TV CABO';

    if (txtTitle.indexOf("#NET") > 0)
        window.document.title = 'TV CABO';
    else if (txtUrl.indexOf("#NET") > 0)
        window.document.title = 'TV CABO';

    if (txtTitle.indexOf("#TVNET") > 0)
        window.document.title = 'TV CABO';
    else if (txtUrl.indexOf("#TVNET") > 0)
        window.document.title = 'TV CABO';

}

function roll(img_name, img_src) { document[img_name].src = img_src; }

function resetTxtSearch() { document.getElementById("txtSearch").value = ""; }

function disableEnterKey(e)
{
     var key;

     if ( window.event ) { key = window.event.keyCode;  }
     else { key = e.which; }
     
     if ( key == 13 ) { document.strSearch.submit();  return false; }
     else { return true; }
  }

/* Rua & Provincia */
function resetTxtRua() { document.getElementById("txtInputAderir1").value = ""; }

function resetTxtProvincia() {
      $('#dvListProvincia').show('fast', function () {});
      document.getElementById("txtInputAderir2").value = "";
}

function SetProvincia(pNameProvincia) {
    $('#dvListProvincia').hide('fast', function () {});
    document.getElementById("txtInputAderir2").value = pNameProvincia;
}

function showInfo() { $.prettyPhoto.open('Info.html?iframe=true&width=450&height=300', '', ''); }
function showCobertura() {
    //if (document.getElementById("txtInputAderir2").value != "Província..." && document.getElementById("txtInputAderir1").value != "Rua..." && document.getElementById("txtInputAderir1").value != "") {
    if (document.getElementById("txtInputAderir2").value != "Cidade...") {
        $.prettyPhoto.open('Cobertura.aspx?pProvincia=' + document.getElementById("txtInputAderir2").value + '&iframe=true&width=600&height=420', '', '&nbsp;&nbsp;&nbsp;<img src="http://www.tvcabo.co.ao/images/iconCobertura.jpg"/>&nbsp;&nbsp;Zona de Cobertura assinalada');
    }
    else {
        alert('Por favor seleccionar a Cidade');
    }
}

function closeWarning() { $.prettyPhoto.close(); }

function EdicaoViva() { winRef = window.open('http://www.visabeiraglobal.com/tvcabomz/EdicaoViva.aspx', 'mywindow', 'width=800,height=600,scrollbars=0,resizable=0,status=0,toolbar=0'); }

function getStyle(el, styleProp) {
    var x = document.getElementById(el);
    if (x.currentStyle)
        var y = x.currentStyle[styleProp];
    else if (window.getComputedStyle)
        var y = document.defaultView.getComputedStyle(x, null).getPropertyValue(styleProp);
    return y;
}

// Read a page's GET URL variables and return them as an associative array.
function getUrlVars() {
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split("*");
    
    for (var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }

    return vars;
}


