﻿document.write('<div id="dhtmltooltip"></div>') //write out tooltip DIV
document.write('<img id="dhtmlpointer" class="imgPointer" >') //write out pointer image
/***********************************************
* Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var offsetxpoint = -60 //Customize x offset of tooltip
var offsetypoint = 20 //Customize y offset of tooltip
var ie = document.all
var ns6 = document.getElementById && !document.all
var enabletip = false


if (ie || ns6)
    var tipobj = document.all ? document.all["dhtmltooltip"] : document.getElementById ? document.getElementById("dhtmltooltip") : ""

function ietruebody() {
    return (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth) {
    if (ns6 || ie) {
        if (typeof thewidth != "undefined") tipobj.style.width = thewidth + "px"
        if (typeof thecolor != "undefined" && thecolor != "") tipobj.style.backgroundColor = thecolor
        tipobj.innerHTML = thetext
        enabletip = true
        return false
    }
}

function positiontip(e) {
    if (enabletip) {
        var curX = (ns6) ? e.pageX : event.clientX + ietruebody().scrollLeft;
        var curY = (ns6) ? e.pageY : event.clientY + ietruebody().scrollTop;
        //Find out how close the mouse is to the corner of the window
        var rightedge = ie && !window.opera ? ietruebody().clientWidth - event.clientX - offsetxpoint : window.innerWidth - e.clientX - offsetxpoint - 20
        var bottomedge = ie && !window.opera ? ietruebody().clientHeight - event.clientY - offsetypoint : window.innerHeight - e.clientY - offsetypoint - 20

        var leftedge = (offsetxpoint < 0) ? offsetxpoint * (-1) : -1000

        //if the horizontal distance isn't enough to accomodate the width of the context menu
        if (rightedge < tipobj.offsetWidth)
        //move the horizontal position of the menu to the left by it's width
            tipobj.style.left = ie ? ietruebody().scrollLeft + event.clientX - tipobj.offsetWidth + "px" : window.pageXOffset + e.clientX - tipobj.offsetWidth + "px"
        else if (curX < leftedge)
            tipobj.style.left = "5px"
        else
        //position the horizontal position of the menu where the mouse is positioned
            tipobj.style.left = curX + offsetxpoint + "px"

        //same concept with the vertical position
        if (bottomedge < tipobj.offsetHeight)
            tipobj.style.top = ie ? ietruebody().scrollTop + event.clientY - tipobj.offsetHeight - offsetypoint + "px" : window.pageYOffset + e.clientY - tipobj.offsetHeight - offsetypoint + "px"
        else
            tipobj.style.top = curY + offsetypoint + "px"
        tipobj.style.visibility = "visible"
    }
}

function hideddrivetip() {
    if (ns6 || ie) {
        enabletip = false
        tipobj.style.visibility = "hidden"
        tipobj.style.left = "-1000px"
        tipobj.style.backgroundColor = ''
        tipobj.style.width = ''
    }
}

document.onmousemove = positiontip



function ponerTooltipsAreas(nombreMapa, tooltips) { 
    var imageMap = document.getElementsByName(nombreMapa)[0];
    var areas = imageMap.getElementsByTagName("area");
    for (var i = 0; i < areas.length; i++) {
        var a = tooltips[i];
        areas[i].onmouseover = new Function("ddrivetip('" + a + "');");
        areas[i].onmouseout = function() {
            hideddrivetip();

        }
    }
}

function LoadUserDataByNif(nif) {
    Newshore.Modules.Abonos.Abonos.getDataUser(nif, succesAbonosCallback);
}


function LoadUserDataByEmail(email) {
    Newshore.Modules.Abonos.Abonos.getDataUserEmail(email, succesAbonosCallback);
}

function succesAbonosCallback(result) {

    if (result != null) {
        $("#<%= dllTxtNombre.ClientID %>")[0].value = (result.NOM != null) ? result.NOM : "";
        $("#<%= dllTxtCorreo.ClientID %>")[0].value = (result.Email != null) ? result.Email : "";
        $("#<%= dllTxtPrimerApellido.ClientID %>")[0].value = (result.COGNOM1 != null) ? result.COGNOM1 : "";
        $("#<%= dllTxtSegundoApellido.ClientID %>")[0].value = (result.COGNOM2 != null) ? result.COGNOM2 : "";
        $("#<%= txtnomvia.ClientID %>")[0].value = (result.NAMEVIA != null) ? result.NAMEVIA : "";
        $("#<%= txtnumvia.ClientID %>")[0].value = (result.NUMVIA != null) ? result.NUMVIA : "";
        $("#<%= txtaltervia.ClientID %>")[0].value = (result.ALTERVIA != null) ? result.ALTERVIA : "";
        $("#<%= txtpostal.ClientID %>")[0].value = (result.Cod_pos != null) ? result.Cod_pos : "";
        $("#<%= TxtTelF.ClientID %>")[0].value = (result.Telef_Fx1 != null) ? result.Telef_Fx1 : "";
        $("#<%= TxtTelM.ClientID %>")[0].value = (result.Telef_Mb != null) ? result.Telef_Mb : "";
        $("#<%= dllTxtNif.ClientID %>")[0].value = (result.NIF != null) ? result.NIF : "";
        $("#<%= txtpostal.ClientID %>")[0].value = (result.Cod_pos != null) ? result.Cod_pos : "";
        valor = 2; //(result.CTPpago != null) ? selectedValue($("#<%= dllDrownFormasPago.ClientID %>")[0], result.CTPpago) : 0; //traer de bd NewshoreC

        if (valor == 1) {
            $("#<%= dllTxtNumTarjeta.ClientID %>")[0].value = (result.NUM_ID != null) ? result.NUM_ID : "";
            $("#<%= dllTxtCaducidadMes.ClientID %>")[0].value = (result.CCaducidad) ? result.CCaducidad : "";
            $("#<%= TextBox4.ClientID %>")[0].value = (result.NumSeg) ? result.NumSeg : "";
            $("#<%= dllTxtTitular.ClientID %>")[0].value = (result.CTitular != null) ? result.CTitular : "";

        }
        /*if (valor == 2) {
            $("#<%= dllTxtBeneficiario.ClientID %>")[0].value = (result.CBeneficiario != null) ? result.CBeneficiario : "";
            $("#<%= dllTxtNumerocuenta.ClientID %>")[0].value = (result.CNumcuenta != null) ? result.CNumcuenta : "";
        }*/

        (result.NACIONALITAT != null) ? selectedValue($("#<%= dllCmbNacionalidad.ClientID %>")[0], result.NACIONALITAT) : 0;

        if ($("#<%= ddcomarca.ClientID %>").lenght > 0) {
            (result.Comarca != null) ? selectedValue($("#<%= ddcomarca.ClientID %>")[0], result.Comarca) : 0;
        }

        if ($("#<%= txtCorreoEnvio.ClientID %>").lenght > 0) {
            $("#<%= txtCorreoEnvio.ClientID %>")[0].value = result.Telef_Fx1;
        }

        (result.IDIOMA != null) ? selectedValue($("#<%= dllCmbIdioma.ClientID %>")[0], result.IDIOMA) : 0;
        (result.Provincia != null) ? selectedValue($("#<%= ddprovincia.ClientID %>")[0], result.Provincia) : 0;
        (result.Poblacio != null) ? selectedValue($("#<%= ddpoblacion.ClientID %>")[0], result.Poblacio) : 0;
        (result.Tip_vp != null) ? selectedValue($("#<%= ddtipovia.ClientID %>")[0], result.Tip_vp) : 0;
        $("#<%= dllRadioGenero.ClientID %>")[0].selectedIndex = (result.SEXE != null) ? result.SEXE : 0;
        $("#<%= dllRadioAceptaEnvios.ClientID %>")[0].selectedIndex = 0; //  (result.NUMVIA != null) ? result.NUMVIA : 0; //traer de bd NewshoreC
        $("#<%= rbLTipoEnvio.ClientID %>")[0].selectedIndex = 0; //  (result.NUMVIA != null) ? result.NUMVIA : 0; //traer de bd NewshoreC

        hora = new Date(result.DATA_NAIX);
        nuevo = hora.format("ddd mmm dd yyyy HH:MM:ss");

        mes = hora.getMonth();
        dia = hora.getDay();
        year = hora.getYear();
    }

}

function LoadUbicacionPostal(codPostal) {
    Newshore.Modules.Abonos.Abonos.LoadUbicacionPostal(codPostal, succesUbicacionCallback);
}

function getFilasByBloque(bloque) {
    alert("entro");
    Newshore.Modules.Abonos.Abonos.rbOpcAsientos_CheckedChanged(bloque);
}

function selectedValue(control, value) {
    for (var i = 0; i < control.options.length; i++) {
        if (control.options[i].value == value) {
            control.options[i].selected = true;
            return;
        }
    }
}

function load_poblacionAj(codProv) {
    alert("sidd");
    Newshore.Modules.Abonos.Abonos.LoadUbicacionPostal.load_poblacionAj(codProv, succesPoblacionCallback);
}

function popSubmit(vinner, url) {
    var form1 = document.createElement('form');
    form1.name = "form1";
    form1.id = "form1";
    form1.method = "post";
    var inner = vinner;
    form1.innerHTML = inner;
    //var popName = "formPopUp";
    //var popStyle = "width=300,height=300,location=yes,resizable=yes";
    form1.action = url;
    //form1.target = "_Self";

    document.body.appendChild(form1);
    //window.open("about:blank", popName, popStyle);
    form1.submit();
}
        

