﻿// JScript File
function zoomText(Accion,Elemento)
    {
        //inicializacion de variables y parámetros 
        var obj=document.getElementById('wrapper');
        //alert(obj);
        var max = 200 //tamaño máximo del fontSize
        var min = 70 //tamaño mínimo del fontSize
        if (obj.style.fontSize=="")
        {
            obj.style.fontSize="100%";
        }
        actual=parseInt(obj.style.fontSize); //valor actual del tamaño del texto 
        incremento=10;// el valor del incremento o decremento en el tamaño 
            
        //accion sobre el texto 
        if( Accion=="reestablecer" )
        {
            obj.style.fontSize="100%"
        }
        if( Accion=="aumentar" && ((actual+incremento) <= max ))
        {
            valor=actual+incremento;
            //alert(valor);
            obj.style.fontSize=valor+"%"          
        }
        if( Accion=="disminuir" && ((actual+incremento) >= min ))
        {
            valor=actual-incremento;
            obj.style.fontSize=valor+"%"
        }
    } 

function AgregaraFavoritos()
    {
         if (window.sidebar) 
         {
            window.sidebar.addPanel("Mundial", "http://www.mundial.com.co",'');
         } 
         else if( window.external ) 
         {
            window.external.AddFavorite("http://www.mundial.com.co","Mundial");
         } 
         else if( window.opera && window.print ) 
         {
            return true;
         }     
    }
    
    
    ///Aumentar o disminuir el tamaño del texto
    





function SystemPrintPreview(OLECMDID) 
{ 
 
//var OLECMDID = 10; 
 
/* OLECMDID values: 
 
* 6 - print 
 
* 7 - print preview 
 
* 8 - page setup (for printing) 
 
* 1 - open window 
 
* 4 - Save As 
 
* 10 - properties 
 
*/
    try
 
    {
         
        var PROMPT = 1; // 1 PROMPT & 2 DONT PROMPT USER 
         
        var oWebBrowser = document.getElementById("WebBrowser1");
         
        if(oWebBrowser == null)
         
        {
         
            var sWebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>'; 
             
            document.body.insertAdjacentHTML('beforeEnd', sWebBrowser); 
            //document.write(sWebBrowser);
             alert(document.getElementById("WebBrowser1"));
            oWebBrowser = document.getElementById("WebBrowser1");
             
            //WebBrowser1.outerHTML = ""; 
             
        }
         
        oWebBrowser.ExecWB(OLECMDID,PROMPT);
         
    }
         
    catch(e){alert("Printing failed! " + e.message);}
        
} 

/* Inicio - Funciones del toolbox */
var ToolBox = {};

ToolBox.Formulario = null;
ToolBox.FormularioError = true;

//*************************************************************************************************

ToolBox.Ayuda = function()
{
    window.open('http://www.mundial.com.co/web/Default.aspx?tabid=77',null,'height=600,width=800,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes');
}

//*************************************************************************************************

ToolBox.ReportarError = function()
{
    // Titulo y descripcion
    document.getElementById('toolboxFormulario').style.display='';
    document.getElementById('toolboxFormularioTitulo').innerHTML = 'Reportar un error';
    document.getElementById('toolboxFormularioDescripcion').innerHTML = 'Para Mundial las observaciones sobre su contenido son importantes, perm&iacute;tanos conocerlas para, si es el caso, tomar los correctivos necesarios, o darle trámite ante las instancias pertinentes dentro de Mundial<br />Por favor, incluya su nombre y correo electr&oacute;nico para informarle del seguimiento que le hemos dado a su observaci&oacute;n.';
    // Ocultar campos de amigo
    document.getElementById('toolboxFormularioNombreAmigo').style.display='none';
    document.getElementById('toolboxFormularioEmailAmigo').style.display='none';
    // Cambiar boton
    document.getElementById('toolboxFormularioEnviar').src = 'images/botones/bt_reportar.png';
    // Tipo de formulario
    ToolBox.FormularioError = true;
    // Mostrar
    ToolBox.Formulario.show();
    document.getElementById('toolboxFormulario_mask').style.zIndex='1000';
}

//*************************************************************************************************

ToolBox.RecomendarAmigo = function()
{
    // Titulo y descripcion
    document.getElementById('toolboxFormulario').style.display='';
    document.getElementById('toolboxFormularioTitulo').innerHTML = 'Recomendar a un amigo';
    document.getElementById('toolboxFormularioDescripcion').innerHTML = 'Para recomendar el sitio Web de Mundial, ingrese la siguiente informaci&oacute;n';
    // Ocultar campos de amigo
    document.getElementById('toolboxFormularioNombreAmigo').style.display='';
    document.getElementById('toolboxFormularioEmailAmigo').style.display='';
    // Cambiar boton
    document.getElementById('toolboxFormularioEnviar').src = 'http://images2.mundial.com.co/MundialB2B/images/botones/bt_recomendar.png';
    // Tipo de formulario
    ToolBox.FormularioError = false;
    // Mostrar
    ToolBox.Formulario.show();
    document.getElementById('toolboxFormulario_mask').style.zIndex='1000';
}

//*************************************************************************************************

ToolBox.AgregarFavoritos = function()
{
    if (window.sidebar)
    { // Mozilla Firefox Bookmark
        window.sidebar.addPanel(document.title, location.href,"");
    } else if( window.external ) 
    { // IE Favorite
           window.external.AddFavorite( location.href, document.title); 
    }
    else if(window.opera && window.print) 
    { // Opera Hotlist
           return true; 
    }
}

//*************************************************************************************************

ToolBox.EnviarFormulario = function()
{
    var nombre = document.getElementById('toolboxNombre').value.replace(/^\\s+|\\s+$/g,'');
    var email = document.getElementById('toolboxEmail').value.replace(/^\\s+|\\s+$/g,'');
    var nombreAmigo = document.getElementById('toolboxNombreAmigo').value.replace(/^\\s+|\\s+$/g,'');
    var emailAmigo = document.getElementById('toolboxEmailAmigo').value.replace(/^\\s+|\\s+$/g,'');
    var comentario = document.getElementById('toolboxComentario').value.replace(/^\\s+|\\s+$/g,'');
    var emailRegex = new RegExp(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+[a-zA-Z0-9]{2,4}$/);
    var ltrURL = location.href;
    
     
    if(ToolBox.FormularioError)
    {
        // Validar campos
       
            document.getElementById('spanNombre').style.display = ((nombre == '') ? "" : "none");              
            document.getElementById('spanEmail').style.display = ((email == '') ? "" : "none");
            document.getElementById('spanEmail').innerHTML = ((email == '') ? " Ingrese correo " : "");            
            if(email != '')
            {                
                document.getElementById('spanEmail').style.display = ((!emailRegex.test(email)) ? "" : "none");
                document.getElementById('spanEmail').innerHTML = ((!emailRegex.test(email)) ? " Correo inválido " : "");
            }                
            document.getElementById('spanComentario').style.display = ((comentario == '') ? "" : "none");
       
             
        if(nombre == '' || email == '' || comentario == '' || !emailRegex.test(email))
            return;
            
        // Enviar reporte de error
        var ReportarError_OnSuccess = function(args, e)
        {
            var respuesta = eval('(' + args + ')');
            if(!respuesta.resultado)
            {
                ModalDialog.Show('Error', respuesta.mensajeError, ModalDialog.OK);
                return;
            }
            ToolBox.Cancelar();
        }
        Sys.Net.WebServiceProxy.invoke('http://www.mundial.com.co/MundialB2B/ScriptServices.asmx', 
            'ToolBoxReportarError', false, 
            {'nombre':nombre, 'email':email, 'comentario':comentario, 'UrlReporte':ltrURL}, ReportarError_OnSuccess, function(error){}, null, 0);        
    }
    else
    {
        // Validar campos        
        
            document.getElementById('spanNombre').style.display = ((nombre == '') ? "" : "none");                  
            document.getElementById('spanEmail').style.display = ((email == '') ? "" : "none");
            document.getElementById('spanEmail').innerHTML = ((email == '') ? " Ingrese correo " : "");         
            document.getElementById('spanNombreAmigo').style.display = ((nombreAmigo == '') ? "" : "none");           
            document.getElementById('spanEmailAmigo').style.display = ((emailAmigo == '') ? "" : "none");
            document.getElementById('spanEmailAmigo').innerHTML = ((emailAmigo == '') ? " Ingrese correo amigo " : "");               
            if(email != '')
            {                
                document.getElementById('spanEmail').style.display = ((!emailRegex.test(email)) ? "" : "none");
                document.getElementById('spanEmail').innerHTML = ((!emailRegex.test(email)) ? " Correo inválido " : "");
            }
         
            if(emailAmigo != '')
            {  
                document.getElementById('spanEmailAmigo').style.display = ((!emailRegex.test(emailAmigo)) ? "" : "none");
                document.getElementById('spanEmailAmigo').innerHTML = ((!emailRegex.test(emailAmigo)) ? " Correo inválido " : "");
            }
        
        if(nombre == '' || email == '' || nombreAmigo == '' || emailAmigo == '' || !emailRegex.test(email) || !emailRegex.test(emailAmigo))
            return;
        
        // Enviar recomendar amigo
        var RecomendarAmigo_OnSuccess = function(args, e)
        {
            var respuesta = eval('(' + args + ')');
            if(!respuesta.resultado)
            {
                ModalDialog.Show('Error', respuesta.mensajeError, ModalDialog.OK);
                return;
            }
            ToolBox.Cancelar();
        }
        var a;
        Sys.Net.WebServiceProxy.invoke('http://www.mundial.com.co/MundialB2B/ScriptServices.asmx', 
            'ToolBoxRecomendarAmigo', false, 
            {'nombre':nombre, 'email':email, 'nombreAmigo':nombreAmigo, 'emailAmigo':emailAmigo, 'comentario':comentario,'ltrURL':ltrURL}, RecomendarAmigo_OnSuccess, function(error){}, null, 0);
            //Mundial.ScriptServices.ToolBoxRecomendarAmigo(nombre, email, nombreAmigo, emailAmigo, comentario,ltrURL, RecomendarAmigo_OnSuccess, function(args){}, function(args){});
    }
}

//*************************************************************************************************

ToolBox.Limpiar = function()
{
    document.getElementById('toolboxNombre').value = '';
    document.getElementById('toolboxEmail').value = '';
    document.getElementById('toolboxNombreAmigo').value = '';
    document.getElementById('toolboxEmailAmigo').value = '';
    document.getElementById('toolboxComentario').value = '';
    
    document.getElementById('spanNombre').style.display = "none";          
    document.getElementById('spanEmail').style.display = "none";
    document.getElementById('spanComentario').style.display = "none"; 
    if(!ToolBox.FormularioError)
    {
        document.getElementById('spanNombreAmigo').style.display = "none";   
        document.getElementById('spanEmailAmigo').style.display = "none";       
    }     
}

//*************************************************************************************************

ToolBox.Cancelar = function()
{
    ToolBox.Limpiar();
    ToolBox.Formulario.hide();
}


ToolBox.ValidarNombre = function()
{
     var nombre = document.getElementById('toolboxNombre').value.replace(/^\\s+|\\s+$/g,'');
    document.getElementById('spanNombre').style.display = ((nombre == '' && document.getElementById('spanNombre').style.display=='') ? "" : "none");
}

ToolBox.ValidarEmail = function()
{
     var email = document.getElementById('toolboxEmail').value.replace(/^\\s+|\\s+$/g,'');
      document.getElementById('spanEmail').style.display = ((email == '' && document.getElementById('spanEmail').style.display=='') ? "" : "none");
}

ToolBox.ValidarNombreAmigo = function()
{
     var nombreAmigo = document.getElementById('toolboxNombreAmigo').value.replace(/^\\s+|\\s+$/g,'');
     document.getElementById('spanNombreAmigo').style.display = ((nombreAmigo == ''&& document.getElementById('spanNombreAmigo').style.display=='') ? "" : "none");
}

ToolBox.ValidarEmailAmigo = function()
{
     var emailAmigo = document.getElementById('toolboxEmailAmigo').value.replace(/^\\s+|\\s+$/g,'');
     document.getElementById('spanEmailAmigo').style.display = ((emailAmigo == ''&& document.getElementById('spanEmailAmigo').style.display=='') ? "" : "none");
}

ToolBox.ValidarComentario = function()
{
     var comentario = document.getElementById('toolboxComentario').value.replace(/^\\s+|\\s+$/g,'');
     document.getElementById('spanComentario').style.display = ((comentario == ''&& document.getElementById('spanComentario').style.display=='') ? "" : "none");
}
/* Fin - Funciones del toolbox */
