﻿
 // Core Tecnologia
 // Sitio: podergrafico.com
 //
 // Libreria de funciones JS
 //
 // Autor: Tonino Yannarella
 //
 // Creacion: 11-04-2010
 //
 // Ultima actualizacion: 12-08-2010






// Funciones para el manejo AJAX con ASP.net
// ....................................................................................................


function EstadoAjax(sender, args)  {
   
   
} // FIN function EstadoAjax()





function CancelarAjax() {

 Sys.WebForms.PageRequestManager.getInstance().abortPostBack();

} // FIN function CancelarAjax() 





  function initializeRequestHandler(sender, args) {
                
    // Se provoca antes de que se inicie el procesamiento de la solicitud asincrónica.
    // Puede utilizar este evento para cancelar una devolución de datos.


            
  }  // FIN function initializeRequestHandler()





  function BeginRequestHandler(sender, args) {

    // Se provoca antes de que empiece el procesamiento de una devolución de datos asincrónica
    // y se envíe la devolución de datos al servidor. Puede utilizar este evento para establecer
    // los encabezados de la solicitud o para iniciar una animación que indique que la página
    // se está procesando.

     $('body').css('cursor', 'wait');   // colocar el cursor en modo de espera
      
     var elem = args.get_postBackElement();
     // alert (elem.id);
     selem = elem.id      // guardar botom que llamó

switch (elem.id){      // Seleccionar botom que llama

case "ctl00_ContentPlaceHolder1_Button_Enviar":       // Formulario de contacto

// muestra el DIV de espera desde la pagina: Default.aspx

 $(document).ready(function(){

    div = document.getElementById('Home');
    div.style.display='none';

    div = document.getElementById('Contacto');
    div.style.display='none';

    div = document.getElementById('Vinfo');
    div.style.display='none';

    $(TvMensaje).fadeIn("slow"); 

    //div = document.getElementById('TvMensaje');
    //div.style.display = 'block';
 
 });

break;





case "ctl00_ContentPlaceHolder1_Botom_Guardar_Pedido":       // Formulario TV.aspx : Guardar pedido

// muestra el DIV de espera

 $(document).ready(function(){


    div = document.getElementById('TvFinalizar');
    div.style.display='none';

    div = document.getElementById('TVPrevio');
    div.style.display='none';

    div = document.getElementById('TvPedido');
    div.style.display='none';

    $(TvMensaje).fadeIn("slow"); 

    //div = document.getElementById('TvMensaje');
    //div.style.display = 'block';
 
 });

break;



case "ctl00_ContentPlaceHolder1_Botom_micuenta_opciones_guardar" :         // formulario micuenta.aspx


// muestra el DIV de espera

 $(document).ready(function(){

// ocultar el div actual

    div = document.getElementById('Opciones');
    div.style.display='none';

// mostrar el div mensaje

   $(TvMensaje).fadeIn("slow"); 


 });

break;



case "ctl00_ContentPlaceHolder1_Botom_micuenta_pagar_guardar" :         // formulario pagar.aspx


// muestra el DIV de espera

 $(document).ready(function(){

// ocultar el div actual

    div = document.getElementById('Pagar');
    div.style.display='none';

// mostrar el div mensaje

   $(TvMensaje).fadeIn("slow"); 


 });

break;






default :    // elemento no identificado

  //  alert ("Procesar: " + elem.id);




}  // FIN switch (ID)


}    // FIN function BeginRequestHandler()



   
  function pageLoadingHandler(sender, args) {

    // Se provoca después de recibir la respuesta del servidor a una devolución de datos asincrónica,
    // pero antes de actualizar el contenido de la página.
    // Puede utilizar este evento para proporcionar un efecto de transición personalizado para el
    // contenido actualizado.

     
     
  }   // FIN function pageLoadingHandler()
                



  function pageLoadedHandler(sender, args) {
    
    // Se provoca una vez actualizado todo el contenido de la página,
    // como resultado de una devolución de datos sincrónica o asincrónica.
    // Puede utilizar este evento para proporcionar un efecto de transición personalizado
    // para el contenido actualizado.
                
       
  }  // FIN function pageLoadedHandler()




  function EndRequestHandler(sender, args) {
  
   // Se provoca después de que finalice una devolución de datos asincrónica y se haya devuelto
   // el control al explorador. 
   // Puede utilizar este evento para proporcionar una notificación a los usuarios o 
   // para registrar los errores.

  
   $('body').css('cursor', 'default');     // normalizar el cursor


  switch (selem){      // Seleccionar botom que llamó

    case "ctl00_ContentPlaceHolder1_Button_Enviar":       // Formulario de contacto  

      vresul = document.getElementById("ctl00_ContentPlaceHolder1_Contacto_Resul").value 


if(vresul=="SI") {

    div = document.getElementById('TvMensaje');
    div.style.display='none';

    $(Home).fadeIn("400"); 

    //div = document.getElementById('Home');
    //div.style.display = 'block';
    
  vmensaje =  ' <br /> ' +
              ' <br /> ' +
              ' <br /> ' +
              ' <div style="width:303px; height:auto; "> ' +
              '   <div style=" text-align:center; " > ' +
              '     <h4> ' +
              '       ! Información enviada Correctamente !  ' +
              '     </h4> ' +
              '   </div> ' +        
              '   <div style="   margin-top:15px; text-align:justify  ;  line-height:16px; " > ' +
              '      Pronto nuestros ejecutivos se comunicaran con usted' +
              '   </div> ' + 
              ' </div> '
    
    
    setTimeout("MensajeInfo(vmensaje)", 400);


}else{

  // no se pudo enviar la informacion
   
  div = document.getElementById('TvMensaje');
  div.style.display='none';

  $(Contacto).fadeIn(400); 

  //div = document.getElementById('Contacto');
  //div.style.display = 'block';


  vmensaje =  ' <br /> ' +
              ' <br /> ' +
              ' <br /> ' +
              ' <div style="width:303px; height:auto; "> ' +
              '   <div style=" text-align:center; " > ' +
              '     <h4> ' +
              '       ! Problema de Conexión !  ' +
              '     </h4> ' +
              '   </div> ' +        
              '   <div style="   margin-top:15px; text-align:justify  ;  line-height:16px; " > ' +
              '      No se pudo enviar la Información ' +
              '      <br /> ' +
              '      <br /> ' +             
              '      Intente nuevamente ' +
              '   </div> ' + 
              ' </div> '


  setTimeout("MensajeAlerta(vmensaje)", 400);

   
}  // Fin if

   
    break;


    case "ctl00_ContentPlaceHolder1_TreeView_Carrito":       // Formulario TV.aspx : Quitar Items

     // DEBUG
     //alert("ok:  " + SIDa )
     //alert("ok:  " + SIDn )

 
 
    break;



    case "ctl00_ContentPlaceHolder1_P0_Agregar":       // Formulario TV.aspx agregar: Personalizado P0

       SIDa = "P0";     // Servicio actual en edicion (para ocultar el DIV al mostrar otro)
       SIDn = "P0";     // Servicio nuevo a editar (para mostrar el DIV)
       Compra('P0'); 

       // mostrar mensaje de error si se produjo algun error
       vresul = document.getElementById("ctl00_ContentPlaceHolder1_tvs_agregar_resul").value 
        if (vresul != "OK") {
          alert(vresul)
         }  // Fin if
 
    break;



    case "ctl00_ContentPlaceHolder1_S1_Agregar":       // Formulario TV.aspx agregar: Impresion Digital S1

       SIDa = "P0";    // Servicio actual en edicion (para ocultar el DIV al mostrar otro)
       SIDn = "S1";    // Servicio nuevo a editar (para mostrar el DIV)
       Compra('S1');

       // mostrar mensaje de error si se produjo algun error
       vresul = document.getElementById("ctl00_ContentPlaceHolder1_tvs_agregar_resul").value 
        if (vresul != "OK") {
          alert(vresul)
         }  // Fin if

      break;



    case "ctl00_ContentPlaceHolder1_S3_Agregar":       // Formulario TV.aspx agregar: Impresion Transfer S3

       SIDa = "P0";    // Servicio actual en edicion (para ocultar el DIV al mostrar otro)
       SIDn = "S3";    // Servicio nuevo a editar (para mostrar el DIV)
       Compra('S3');

       // mostrar mensaje de error si se produjo algun error
       vresul = document.getElementById("ctl00_ContentPlaceHolder1_tvs_agregar_resul").value 
        if (vresul != "OK") {
          alert(vresul)
         }  // Fin if

      break;



    case "ctl00_ContentPlaceHolder1_S4_Agregar":       // Formulario TV.aspx agregar: Ploteo Artes Gráficas S4

       SIDa = "P0";    // Servicio actual en edicion (para ocultar el DIV al mostrar otro)
       SIDn = "S4";    // Servicio nuevo a editar (para mostrar el DIV)
       Compra('S4');

       // mostrar mensaje de error si se produjo algun error
       vresul = document.getElementById("ctl00_ContentPlaceHolder1_tvs_agregar_resul").value 
        if (vresul != "OK") {
          alert(vresul)
         }  // Fin if

      break;



    case "ctl00_ContentPlaceHolder1_S6_Agregar":       // Formulario TV.aspx agregar: Carnet S6

       SIDa = "P0";    // Servicio actual en edicion (para ocultar el DIV al mostrar otro)
       SIDn = "S6";    // Servicio nuevo a editar (para mostrar el DIV)
       Compra('S6');

       // mostrar mensaje de error si se produjo algun error
       vresul = document.getElementById("ctl00_ContentPlaceHolder1_tvs_agregar_resul").value 
        if (vresul != "OK") {
          alert(vresul)
         }  // Fin if

      break;



    case "ctl00_ContentPlaceHolder1_S7_Agregar":       // Formulario TV.aspx agregar: Fotografía Digital S7

       SIDa = "P0";    // Servicio actual en edicion (para ocultar el DIV al mostrar otro)
       SIDn = "S7";    // Servicio nuevo a editar (para mostrar el DIV)
       Compra('S7');

       // mostrar mensaje de error si se produjo algun error
       vresul = document.getElementById("ctl00_ContentPlaceHolder1_tvs_agregar_resul").value 
        if (vresul != "OK") {
          alert(vresul)
         }  // Fin if

      break;






    case "ctl00_ContentPlaceHolder1_Botom_Guardar_Pedido":       // Formulario TV.aspx : TVFinalizar
    
    vresul = document.getElementById("ctl00_ContentPlaceHolder1_TVS_finalizar_guardar_Resul").value 
   
    // DEBUG
    // alert("valor de vresul: " + vresul)


        // activar el DIV "TvFinalizar"

        // ocultar las otras ventanas

        div = document.getElementById('TvMensaje');
        div.style.display='none';

        div = document.getElementById('TvPedido');
        div.style.display='none';

        div = document.getElementById('TVPrevio');
        div.style.display='none';

        // mostrar el DIV TvFinalizar ( tienda virtual )

        $(TvFinalizar).fadeIn("slow"); 

//        div = document.getElementById('TvFinalizar');
//        div.style.display = 'block';


          if ( vresul != "OK" ) {     // no se pudo guardar el pedido

              setTimeout ('alert(vresul)', 100);              // mostrar el mensaje regresado durante el proceso de guardar el pedido
  
          }  // Fin if


        return; 
    

    break;



   case "ctl00_ContentPlaceHolder1_Botom_micuenta_opciones_guardar":       // Formulario micuenta.aspx :  Opciones
  
    vresul = document.getElementById("ctl00_ContentPlaceHolder1_micuenta_opciones_resul").value 
   
    // DEBUG
    // alert("valor de vresul: " + vresul)


    // ocultar el div del mensaje de espera

    div = document.getElementById('TvMensaje');
    div.style.display='none';


    // mostrar el div del modulo

    $(Opciones).fadeIn("slow");


        if ( vresul != "OK" ) {     // no se pudo actualizar la informacion

             setTimeout ('alert(vresul)', 1000);              // mostrar el mensaje regresado durante el proceso de guardar el pedido
  
             break;

        }  // Fin if


   location.href="Default.aspx" ;

    break;
    
    

   case "ctl00_ContentPlaceHolder1_GridView1":       // Formulario micuenta.aspx :  mi pedido / griwied
   
    // volver a colocar el cursor en modo de mano
    
      $('body').css('cursor', 'hand');     // establecer el cursor tipo mano
   
    
   break;
    



   case "ctl00_ContentPlaceHolder1_Botom_micuenta_pagar_guardar" :         // formulario pagar.aspx


    vresul = document.getElementById("ctl00_ContentPlaceHolder1_pagar_resul").value 
   
    // DEBUG
    // alert("valor de vresul: " + vresul)


    // ocultar el div del mensaje de espera

    div = document.getElementById('TvMensaje');
    div.style.display='none';


        if ( vresul != "OK" ) {     // no se pudo actualizar la informacion

           // mostrar el div del modulo
           $(Pagar).fadeIn("slow");

  
             setTimeout ('alert(vresul)', 1000);            // mostrar el mensaje regresado durante el proceso de guardar el pedido
  
             break;

        }  // Fin if


   location.href="micuenta.aspx?ID=Pedidos" ;


   break;





  default :    // elemento no identificado
    
    // DEBUG
    // alert ("Procesado: " + selem);



}  // FIN switch (ID)
     
       
}  // FIN function EndRequestHandler()
 







// ....................................................................................................




// Funciones para el manejo de la tienda virtual
// ....................................................................................................



function Compra(ID) {

$(document).ready(function(){

// Seleccionar servicio
switch (ID) {


case "S1":       // Impresión Digital
    SIDn = "S1"                    // Servicio nuevo a editar (para mostrar el DIV)
    fileid = "Media/Copias_Inf.png"   // Archivo de imagen para mostrar()
    
break;


case "S3":       // Impresión Transfer
    SIDn = "S3"                    // Servicio nuevo a editar (para mostrar el DIV)
    fileid = "Media/Transfer_Inf.png"   // Archivo de imagen para mostrar()
    
break;


case "S4":       // Ploteo Artes Gráficas
    SIDn = "S4"                    // Servicio nuevo a editar (para mostrar el DIV)
    fileid = "Media/GrandesFormatos_Inf.png"   // Archivo de imagen para mostrar()
    
break;


case "S6":       // Carnet PVC
    SIDn = "S6"                    // Servicio nuevo a editar (para mostrar el DIV)
    fileid = "Media/Carnet_Inf.png"   // Archivo de imagen para mostrar()
    
break;


case "S7":       // Fotografía Digital
    SIDn = "S7"                    // Servicio nuevo a editar (para mostrar el DIV)
    fileid = "Media/FotografiaDigital_Inf.png"   // Archivo de imagen para mostrar()
    
break;


case "P0":       // Servicio a medida
    SIDn = "P0"                    // Servicio nuevo a editar (para mostrar el DIV)
    fileid = "Media/personalizado_Inf.png"   // Archivo de imagen para mostrar()
    
break;



default :    // Personalizado

    SIDn = "P0"                     // Servicio actual en edicion (para ocultar el DIV al mostrar otro)
    fileid = "Media/personalizado_Inf.png"   // Archivo de imagen para mostrar()


  vmensaje =  ' <br /> ' +
              ' <br /> ' +
              ' <br /> ' +  
              ' <div style="width:303px; height:auto; "> ' +
              '   <div style=" text-align:center; " > ' +
              '     <h4> ' +
              '       ! Solo por Tienda !  ' +
              '     </h4> ' +
              '   </div> ' +        
              '   <div style="   margin-top:15px; text-align:justify  ;  line-height:16px; " > ' +
              '      Este servicio no esta disponible aun para ser adquirido ' +
              '      a travez de la tienda virtual. ' +
              '      <br /> ' +
              '      <br /> ' +             
              '      Puede ingresar su requerimiento como un servicio personalizado ' +
              '      o contactenos para mayor información. ' +
              '   </div> ' + 
              ' </div> '



         MensajeAlerta(vmensaje);


    return; 


}  // FIN switch (ID)



pagina = document.getElementById("ctl00_ContentPlaceHolder1_General_Pagina").value

if(pagina=="Tv.aspx") {
  
  // ya esta en la tienda virtual (Tv.aspx) 
  
// ocultar las otras ventanas

    div = document.getElementById('TvEpagos');
    div.style.display='none';

    div = document.getElementById('TVPrevio');
    div.style.display='none';

    div = document.getElementById('TvFinalizar');
    div.style.display='none';

    div = document.getElementById('TvMensaje');
    div.style.display='none';


// mostrar el DIV segun el servicio seleccionado

    //DEBUG
    // alert("SIDa: " + SIDa);
    // alert("SIDn: " + SIDn );


 // Ocultar DIV anterior
 div = document.getElementById(SIDa);
 div.style.display='none';


// $('#' + SIDn).fadeIn("slow"); 

 div = document.getElementById(SIDn);
 div.style.display = 'block';

 SIDa = SIDn 


// mostrar el DIV TVPedido ( tienda virtual )

    $(TvPedido).fadeIn(400); 

    //div = document.getElementById('TvPedido');
    //div.style.display = 'block';


}else{

  // no esta en la tienda virtual (Tv.aspx) 


   location.href="Tv.aspx?ID="+ SIDn ;

}  // Fin if


});

}   // fin Compra()




function botomM()  {
   
   // invocar

  // DEBUG
  //    alert("botom")
            
 vid3 = document.getElementById("ctl00_ContentPlaceHolder1_TVS_HstringH").value 
 vid2 = document.getElementById("ctl00_ContentPlaceHolder1_TVS_Hstring2H").value 
 vid1 = document.getElementById("ctl00_ContentPlaceHolder1_TVS_Hstring3H").value 

  // DEBUG
  //   alert(vid1);
  //   alert(vid2);
  //   alert(vid3);

 vajax = "eMercantil.aspx?id1=" + vid1 + "&id2=" + vid2  + "&id3=" + vid3  

 div = document.getElementById('TvFinalizar');
 div.style.display='none';
 
 $(TvEpagos).fadeIn(1000); 

 $("#TvEpagos").load(vajax); 
   
} // FIN function botomM()





function VolverPago()  {

  // muestra indicaciones sobre como pagar el pedido luego
  
  vmensaje =  ' <br /> ' +
              ' <br /> ' +
              ' <br /> ' +              
              ' <div style="width:343px; height:auto; "> ' +
              '   <div style=" text-align:center; " > ' +
              '     <h3> ' +
              '        ! Importante !  ' +
              '     </h3> ' +
              '   </div>  ' +      
              '   <div style="   margin-top:15px; text-align:center ;  line-height:16px; " > ' +     
              '      Para pagar el pedido mas tarde vaya a < Pedidos Pendientes > ' +
              '      seleccione el pedido y haga click en < Pagar > ' +
              '   </div>  ' +
              ' </div> ' 
  
  MensajeInfo(vmensaje);


  setTimeout("NuevoPedido()", 5000);   // iniciar nuevo pedido


  // NuevoPedido()    // iniciar nuevo pedido

return true;
 
   
} // FIN function VolverPago()







function NuevoPedido()  {

  // iniciar un nuevo pedido

  items = 0

   //  Verificar si hay items actualmente en el carrito si existe el campo html    

   if($("#ctl00_ContentPlaceHolder1_tvs_ctr_items").length > 0)   {
     items = parseInt(document.getElementById("ctl00_ContentPlaceHolder1_tvs_ctr_items").value);
   }


  if (items>0) { 

     if ( confirm("¿Seguro que desea cancelar el pédido actual?") )  {
        
        location.href='Tv.aspx?Pedido=nuevo'
     
     }

    return; 
 
  }
  

 location.href='Tv.aspx?Pedido=nuevo'

} // FIN function NuevoPedido()







function CancelarPedido() {

// no utilizado por ahora

// muestra un mensaje de alerta si hay items y sale del pedido


 //  Verificar si hay items actualmente en el carritto 

  items = parseInt(document.getElementById("ctl00_ContentPlaceHolder1_tvs_ctr_items").value);

  if (items>0) { 
   
     MensajeAlerta('Para volver al pédido haga click en la opción "Editar Pedido"')
       
  }


  CargaHome();

    return; 

}   // fin CancelarPedido()






function mostrar() {	

// DEBUG
// alert( "fileid es igual: " + fileid ) 

$(document).ready(function(){


// asignar la imagen correspondiente al DIV a mostrar
   $("#mdimag").attr( "src" , fileid ); 


 //Get the screen height and width
 var maskHeight = $(document).height();
 var maskWidth = $(window).width();
	
 //Set heigth and width to mask to fill up the whole screen
 $('#mask').css({'width':maskWidth,'height':maskHeight});


 //transition effect		
 $('#mask').fadeIn(1000);	
 $('#mask').fadeTo("slow",0.8);


 //Get the window height and width
 var winH = $(window).height();
 var winW = $(window).width();


 //Set the popup window to center
 $(dialog).css('top',  winH/2-$(dialog).height()/2);
 $(dialog).css('left', winW/2-$(dialog).width()/2);


 //transition effect
 $(dialog).fadeIn(2000); 



 //if close button is clicked
 $('.window .close').click(function (e) {
	//Cancel the link behavior
	e.preventDefault();
		
	$('#mask').fadeOut(1000);
	$('.window').fadeOut(1000);

				
 });		



 //if mask is clicked
	$('#mask').click(function () {
		$(this).fadeOut(1000);
		$('.window').fadeOut(1000);
		
	});	


 // Salir si presiona <ESC>
 $(document).keydown( function( e ) {
  
   if( e.which == 27) {  // escape, close box 
   
 	$('#mask').fadeOut(1000);
 	$('.window').fadeOut(1000);

   } 
   
 }); 


});
	
}  // Fin funcion mostrar()



function MostrarPedido()  {
   
 vdetalle = document.getElementById("ctl00_ContentPlaceHolder1_TVS_pedido").value
   
// alert(vdetalle)
  
  
       if ( ! ValidarVacio(vdetalle) ) {     // chequear que tenga informacion

        return;
  
      }   // fin pedido no seleccionado
  
  

  // Escribir en el DIV el contenido a mostrar

  $("#Ver").html(vdetalle);


 // mostrar el DIV

   $(function(){
 // Evento del dialogo 
 $("#Ver").dialog({
   modal: true,
   title: "Ver Pedido",
   width: 650,
   height: 450,
   minWidth: 650,
   maxWidth: 650,
   show:500,
   hide:500,
   buttons: { 
   "Cerrar": function() {  
     $(this).dialog("close"); 
   } 
   }
  });
  
});

   
} // FIN function MostrarPedido()





function ImprimirPedido()  {
   
 vdetalle = document.getElementById("ctl00_ContentPlaceHolder1_TVS_pedido").value

// alert(vdetalle)
  
       if ( ! ValidarVacio(vdetalle) ) {     // chequear que tenga informacion

        return;
  
      }   // fin pedido no seleccionado
  
  
  // Escribir en el DIV el contenido a mostrar

  $("#Ver").html(vdetalle);


  // imprimir el contenido del DIV
   
  var ficha = document.getElementById('Ver');
  var ventimp = window.open(' ', 'popimpr');
  ventimp.document.write( ficha.innerHTML );
  ventimp.document.close();
  ventimp.print( );
  ventimp.close();

   
} // FIN function ImprimirPedido()




function MostrarEstado()  {
   
 vdetalle = document.getElementById("ctl00_ContentPlaceHolder1_TVS_estado_info").value
   
// alert(vdetalle)
  
       if ( ! ValidarVacio(vdetalle) ) {     // chequear que tenga informacion

        return;
  
      }   // fin pedido no seleccionado
  

  // Escribir en el DIV el contenido a mostrar

  $("#Ver").html(vdetalle);


 // mostrar el DIV

   $(function(){
 // Evento del dialogo 
 $("#Ver").dialog({
   modal: true,
   title: "Ver Estado del Pedido",
   width: 400,
   height: 450,
   minWidth: 400,
   maxWidth: 400,
   show:500,
   hide:500,
   buttons: { 
   "Cerrar": function() {  
     $(this).dialog("close"); 
   } 
   }
  });
  
});

   
} // FIN function MostrarEstado()







function MostrarInfo(mdiv,mtitulo) {
   
   $(function(){
 // Evento del dialogo 
 $(mdiv).dialog({
   modal: false,
   title: mtitulo,
   minWidth: 300,
   maxWidth: 600,
   show:500,
   hide:500,
   buttons: { 
   "Cerrar": function() {  
     $(this).dialog("close"); 
   } 
   }
  });
  
});


}   // fin MostrarInfo()




function CargarArchivos()  {

// funcion para cargar archivos al servidor a traves de: "FileUP.aspx"


// obtener valores

vnumero_pedido = document.getElementById("ctl00_ContentPlaceHolder1_TVS_Npedido").value  // numero de pedido

vitemtext = document.getElementById("ctl00_ContentPlaceHolder1_tvs_ctr_items").value        // proximo item a registrar

vitem = Number(vitemtext) + 1

// cargar pagina en el iframe y mostrar el Div


// "eMercantil.aspx?id1=" + vid1 + "&id2=" + vid2  + "&id3=" + vid3


 $('#IframeSA').attr('src','FileUP.aspx?v1=' + vnumero_pedido + '&v2=' + vitem   );

 $(DivSA).fadeIn(400); 


}   // fin CargarArchivos()









function ChequearFin()  {

  // Validar cantidad de items 

  cant_item = parseInt(document.getElementById("ctl00_ContentPlaceHolder1_tvs_ctr_items").value);


// DEBUG
//alert(cant_item) 


  if ( isNaN(cant_item)  || (cant_item<=0) )   {      // no se ha agregado ningun item
        
        
  vmensaje =  ' <br /> ' +
              ' <br /> ' +
              ' <br /> ' +
              ' <div style="width:303px; height:auto; "> ' +
              '   <div style=" text-align:center; " > ' +
              '     <h4> ' +
              '       ! El Carrito esta vacio !  ' +
              '     </h4> ' +
              '   </div> ' +        
              ' </div> '
   
        
    MensajeAlerta(vmensaje);
    
    return; 
    
  }





if (usuario=="Invitado" || usuario=="") {     // no hay usuario activo

// activar el DIV "TVPrevio"
// para permitir iniciar session o registrar un usuario nuevo

// ocultar las otras ventanas

    div = document.getElementById('TvEpagos');
    div.style.display='none';

    div = document.getElementById('TvFinalizar');
    div.style.display='none';

    div = document.getElementById('TvPedido');
    div.style.display='none';

    div = document.getElementById('TvMensaje');
    div.style.display='none';


// mostrar el DIV TVPrevio ( tienda virtual )

    $(TVPrevio).fadeIn(400); 

    //div = document.getElementById('TVPrevio');
    //div.style.display = 'block';

    return; 


}else{     // usuario activo - proseguir con la opcion de guardar

// activar el DIV "TvFinalizar"

// ocultar las otras ventanas

    div = document.getElementById('TvEpagos');
    div.style.display='none';

    div = document.getElementById('TvPedido');
    div.style.display='none';

    div = document.getElementById('TVPrevio');
    div.style.display='none';

    div = document.getElementById('TvMensaje');
    div.style.display='none';

// mostrar el DIV TvFinalizar ( tienda virtual )

    $(TvFinalizar).fadeIn(400); 

    //div = document.getElementById('TvFinalizar');
    //div.style.display = 'block';

    return; 

}  // fin Usuario



} // FIN function ChequearFin()





function ChequearItems(fmensaje,fcantidad,farchivo,fespecificaciones,fval,fvaltipo,fmin,fmax)  {

 /*  definicion de parametros parametros

     fmensaje               ->  campo html para mostrar mensaje de error tipo texto  
     
     fcantidad              ->  campo para validar cantidad
     
     farchivo               ->  campo para validar el archivo a subir
     
     fespecificaciones      ->  campo para validar que se indiquen las epecificaciones
                                un valor vacio, significa que no es obligatorio  
     
     fval                   ->  campo para validar hojas o medida
                                un valor vacio significa que no aplica  
     
     fvaltipo               ->  tipo de valor de "fval" a validar
                                 "" ninguno para cuando no aplique validar hojas o medida
                                 "H" validar hojas
                                 "M" validar medida
    
     fmin                   -> valor minimo del rango de hojas o medida 
                               "0" no aplica 
     
     fmax                   -> valor maximo del rango de hojas o medida 
                               "0" no aplica 

*/



  // Validar cantidad de items - Maximo 30

  max_item = parseInt(document.getElementById("ctl00_ContentPlaceHolder1_tvs_ctr_items").value);


  if (max_item>=30) { 

  vmensaje =  ' <br /> ' +
              ' <br /> ' +
              ' <br /> ' +
              ' <div style="width:303px; height:auto; "> ' +
              '   <div style=" text-align:center; " > ' +
              '     <h4> ' +
              '       ! Máximo 30 Items por pedido !  ' +
              '     </h4> ' +
              '   </div> ' +        
              ' </div> '
   
    
    MensajeAlerta(vmensaje);
    
    return false; 
    
  }



// validar cantidad

campo = "ctl00$ContentPlaceHolder1$" + fcantidad
valor = document.getElementById(campo).value

 if (valor<=0) {
      
   $(fmensaje).val('Debe especificarse la cantidad');
   return false;
 }
 


// validar hojas o medida

if (fval.length>1) {

  // Validar solo si se indico el valor del campo de control


   log_error = false     // "true" indica error de validacion 

   campo = "ctl00$ContentPlaceHolder1$" + fval
   valor = document.getElementById(campo).value

     if (valor<fmin) {
        log_error = true 
      }

     if (valor>fmax) {
        log_error = true 
      }


  if (log_error) {
   
    if (fvaltipo == "H") {
      $(fmensaje).val('Debe indicarse la cantidad de Páginas');
    }

    if (fvaltipo == "M") {
      $(fmensaje).val('Debe indicarse el largo en metros');
    }

   return false; 
  
  }    // fin if (log_error)

}   // fin if (fval.length>1)




/*


 // validar archivo
      
   valor = document.getElementById(farchivo).value
   log_error = false     // "true" indica error de validacion 
      
   // Debug
   // alert("valor: " + valor );
     
   if ( ValidarVacio(valor) ) {     // chequear que el campo no este vacio 
                 
     // el campo no esta vacio   
  
      
      if (ChequearExtension(valor)) {  // archivo ok
      
        log_error = false;
      
      }else{       // archivo no permitido
      
        log_error = true;
      
      }  // fin chequear extension
                 
   
   }else{

     // campo vacio
  
      log_error = true                 
       
    }  // fin si campo vacio
   
        
  
  if (log_error) {
   
   $(fmensaje).val('El archivo no es valido');
   return false; 
  
  }


*/





// Validar especificaciones
  

if (fespecificaciones.length>1) {

  // Validar especificaciones solo si se indico el valor del campo de control

   campo = "ctl00$ContentPlaceHolder1$" + fespecificaciones
   valor = document.getElementById(campo).value

     if (valor.length<1) {

        $(fmensaje).val('Debe indicarse las especificaciones');
        return false;
      
      }
}


// validacion completa
 

/*

   // guardar el archivo a subir en el campo oculto compartido con asp.net   
   valor = document.getElementById(farchivo).value
   document.getElementById("ctl00_ContentPlaceHolder1_tvs_File").value = valor;
   
   $(fmensaje).val('');
   
*/   
   
   
   
   
   return true;
      
} // FIN function ChequearItems()





function ValidarVacio(q) {   

// valida que el campo no este vacio y no tenga solo espacios en blanco   
// regresa True si no esta vacio   

       if ( q == null ) {
         return false;
        }

        for ( i = 0; i < q.length; i++ ) {   
                if ( q.charAt(i) != " " ) {   
                        return true;   
                }   
        }   

        return false;   

} // FIN function ValidarVacio() 



// ....................................................................................................






// Funciones para mostrar el DIV segun el formulario seleccionado
// ....................................................................................................


function CargaHome() {

 $(document).ready(function(){

pagina = document.getElementById("ctl00_ContentPlaceHolder1_General_Pagina").value

if(pagina=="Default.aspx") {

 // ya esta en la pagina Default.aspx

    div = document.getElementById('Contacto');
    div.style.display='none';

    div = document.getElementById('Vinfo');
    div.style.display='none';

    div = document.getElementById('TvMensaje');
    div.style.display='none';

    $(Home).fadeIn("slow"); 

}else{

  // no esta en la pagina Default.aspx


   location.href="Default.aspx?modulo=home";

   
}  // Fin if


 
 });

}   // FIN CargaHome()





function CargaContacto() {

 $(document).ready(function(){

pagina = document.getElementById("ctl00_ContentPlaceHolder1_General_Pagina").value

if(pagina=="Default.aspx") {

 // ya esta en la pagina Default.aspx

    div = document.getElementById('Home');
    div.style.display='none';

    div = document.getElementById('Vinfo');
    div.style.display='none';

    div = document.getElementById('TvMensaje');
    div.style.display='none';

    $(Contacto).fadeIn("slow"); 


}else{

  // no esta en la pagina Default.aspx

   location.href="Default.aspx?modulo=contacto";
     
}  // Fin if

 
 });

}   // fin CargaContacto()



function CargaVinfo() {

 $(document).ready(function(){

pagina = document.getElementById("ctl00_ContentPlaceHolder1_General_Pagina").value

if(pagina=="Default.aspx") {

 // ya esta en la pagina Default.aspx

    div = document.getElementById('Home');
    div.style.display='none';

    div = document.getElementById('Contacto');
    div.style.display='none';

    div = document.getElementById('TvMensaje');
    div.style.display='none';

    $(Vinfo).fadeIn("slow"); 

}else{

  // no esta en la pagina Default.aspx

   location.href="Default.aspx?modulo=vinfo";
   
}  // Fin if

 
 });

}   // fin Vinfo()





function CargaTvPedido() {

 $(document).ready(function(){

pagina = document.getElementById("ctl00_ContentPlaceHolder1_General_Pagina").value

if(pagina=="Tv.aspx") {
  
  // ya esta en la tienda virtual (Tv.aspx) 

    div = document.getElementById('TvEpagos');
    div.style.display='none';

    div = document.getElementById('TvFinalizar');
    div.style.display='none';

    div = document.getElementById('TVPrevio');
    div.style.display='none';

    div = document.getElementById('TvMensaje');
    div.style.display='none';

    $(TvPedido).fadeIn("slow"); 

 }else{

  // no esta en la tienda virtual (Tv.aspx) 

   location.href="Tv.aspx";
   
}  // Fin if

 
 });

}   // fin CargaTvPedido()





function MicuentaSelect(ID) {

// Seleccionar DIV a mostrar de la pagina micuenta.aspx

$(document).ready(function(){

switch (ID) {


case "Pedidos":       // Div pedidos - Pedidos pendiendes

// ocultar las otras ventanas

    div = document.getElementById('Opciones');
    div.style.display='none';

    div = document.getElementById('Compras');
    div.style.display='none';

    div = document.getElementById('TvMensaje');
    div.style.display='none';

// mostrar el DIV seleccionado

    $(Pedidos).fadeIn("slow"); 
    
break;






case "Compras":       // Div compras - Mis compras

// ocultar las otras ventanas

    div = document.getElementById('Opciones');
    div.style.display='none';
    
    div = document.getElementById('Pedidos');
    div.style.display='none';

    div = document.getElementById('TvMensaje');
    div.style.display='none';

// mostrar el DIV seleccionado

    $(Compras).fadeIn("slow"); 

    
break;



default :    // Div Opciones - Opciones ( default div )
  
// ocultar las otras ventanas

    div = document.getElementById('Pedidos');
    div.style.display='none';
    
    div = document.getElementById('Compras');
    div.style.display='none';

    div = document.getElementById('TvMensaje');
    div.style.display='none';

// mostrar el DIV seleccionado

    $(Opciones).fadeIn("slow"); 


}  // FIN switch (ID)



});

}   // fin function MicuentaSelect()





// ....................................................................................................








// Funciones para el "jqDock"
// ....................................................................................................



function mostrardiv() {

 // $(document).ready(function(){

   div = document.getElementById('FlotanteMenu');
   div.style.display = 'block';
 
   div = document.getElementById('FlotanteMenu2');
   div.style.display = 'block';
 
   div = document.getElementById('flotante1');
   div.style.display = 'block';

 // });

}



function de1a2() {

 // $(document).ready(function(){

div = document.getElementById('flotante1');
div.style.display='none';

div = document.getElementById('flotante2');
div.style.display = 'block';

 // });

}



function de2a1() {

 // $(document).ready(function(){

div = document.getElementById('flotante2');
div.style.display='none';

div = document.getElementById('flotante1');
div.style.display = 'block';

 //  });

}



// ....................................................................................................







// Funciones para mostrar mensajes, cuadro de dialogos, otras
// ....................................................................................................


function CerrarDiv(vdiv)  {

// oculta el DIV pasado por parametro

$(vdiv).css("display", "none"); 

return false;

}   // fin CerrarDiv()





function Mespera() {

// muestra el DIV de espera desde la pagina: Default.aspx

 $(document).ready(function(){

    div = document.getElementById('Home');
    div.style.display='none';

    div = document.getElementById('Contacto');
    div.style.display='none';

    div = document.getElementById('Vinfo');
    div.style.display='none';

    $(TvMensaje).fadeIn("slow"); 

    //div = document.getElementById('TvMensaje');
    //div.style.display = 'block';
   
  return true;

 });

}   // fin Mespera()



function MesperaLogin() {

// muestra el DIV de espera desde la pagina: login.aspx

 $(document).ready(function(){

    div = document.getElementById('Sesion');
    div.style.display='none';

    $(TvMensaje).fadeIn("slow"); 

    //div = document.getElementById('TvMensaje');
    //div.style.display = 'block';
  
  return;

});

}   // fin MesperaLogin()




function MesperaRegistro() {

// muestra el DIV de espera desde la pagina: Registro.aspx

 $(document).ready(function(){

    div = document.getElementById('Registro');
    div.style.display='none';

    $(TvMensaje).fadeIn("slow"); 

    //div = document.getElementById('TvMensaje');
    //div.style.display = 'block';
  
  return;

});

}   // fin MesperaRegistro()




function MesperaTv() {

// muestra el DIV de espera desde la pagina: Tv.aspx

 $(document).ready(function(){

    div = document.getElementById('TvEpagos');
    div.style.display='none';

    div = document.getElementById('TvFinalizar');
    div.style.display='none';

    div = document.getElementById('TvPedido');
    div.style.display='none';

    div = document.getElementById('TVPrevio');
    div.style.display='none';

    $(TvMensaje).fadeIn("slow"); 

    //div = document.getElementById('TvMensaje');
    //div.style.display = 'block';
  
  return;

});

}   // fin MesperaTv()





function MensajeInfo(texto) {

// muestra un mensaje de informacion con la información pasada en la variable texto
// la cual debe pasarse en formato html, esta basada en Sexy Alert Box 1.2 ( jquery pluing )

Sexy.info(texto);

return false;

} // FIN function MensajeInfo(texto)



function MensajeAlerta(texto) {

// muestra un mensaje de alerta con la información pasada en la variable texto
// la cual debe pasarse en formato html, esta basada en Sexy Alert Box 1.2 ( jquery pluing )

Sexy.alert(texto);

return false;

} // FIN function Mensajealerta(texto)



function MensajeError(texto) {

// muestra un mensaje de error con la información pasada en la variable texto
// la cual debe pasarse en formato html, esta basada en Sexy Alert Box 1.2 ( jquery pluing )

Sexy.error(texto);

return false;

} // FIN function MensajeError(texto)





function MensajeBarra() {
 
 $(document).ready(function(){

current = 0
x = 0
vel = 80
vel2 = 2000

typ = new initArray(7)
typ[0]="  podergrafico.com"
typ[1]="  Tu tienda virtual, 24 horas en linea"
typ[2]="  Envianos tu trabajo via internet, directamente a nuestro servidor"
typ[3]="  Descuento del 20% para estudiantes, presentando tu carnet"
typ[4]="  Descuento especial por volumen en todos los servicios"
typ[5]="  Impresión por demanda, tu verdadera imprenta digital"
typ[6]="  © 2010 Copicentro, C.A. - Caracas / Venezuela"

typewrite()

   });

}  // FIN function MensajeBarra()




function initArray(n) {

  this.length = n;
  for (var i =1; i <= n; i++) {this[i] = ' '}

}



function typewrite()  {

var m = typ[current]
window.status = m.substring(0, x++) + " "
if (x == m.length + 1) {
x = 0
current++
if (current > typ.length - 1) {
current = 0
}
setTimeout("typewrite()", vel2)
}
else {
setTimeout("typewrite()", vel)
}

}



// ....................................................................................................







/*

********************************************************************************************************
*****************************  funciones no utilizadas y ejemplos ***************************************
********************************************************************************************************


function miPrueba() {

// otras opciones de dialog de jquery UI

$(document).ready(function(){
   
// increase the default animation speed to exaggerate the effect
$.fx.speeds._default = 1000;
   
   $(function(){
 // Evento del dialogo 
 $('#dialogo').dialog({
   modal: false,
   title: "Especificaciones ?",
   //width: 550,
   //minWidth: 400,
   //maxWidth: 650,
   //show: "highlight" ,
   //show:500,
   //hide: "explode",
   hide:500,

			show:{
				effect:"highlight",
				speed: "Slow"
			},

   buttons: {
   "Cerrar": function() { 
     $(this).dialog("close"); 
   } 
   }
  });
  
});

      
});

}   // fin miPrueba()






function Cerrar() {

  $(document).ready(function(){


	$('#mask').fadeOut(1000);
 	$('.window').fadeOut(1000);


 });

 }  Fin funcion cerrar


// Funciones para ejecutar codigo en el servidor mediante AJAX
// ....................................................................................................



function Enviar() {

 // enviar la informacion del formulario de contacto

Mespera();
 

// var x = jQuery("ctl00_ContentPlaceHolder1_nombre").value;  


jQuery.post("coreapps.aspx", {modulo: "contacto"},   

  function(data, textStatus, XMLHttpRequest){   


   alert("Han devuelto: " + data);
   alert("textStatus: " + textStatus);


CargaHome();


  });   
  


}    // FIN funcion Enviar()




function ExeContacto() {


 // enviar la informacion del formulario de contacto

Mespera();
 

jQuery.post("coreapps.aspx", {modulo: "contacto"},   

  function(data, textStatus, XMLHttpRequest){   


   alert("Han devuelto: " + data);
   alert("textStatus: " + textStatus);


CargaHome();


  });   


}    // FIN funcion ExeContacto()


// ....................................................................................................



ojo callbak de funciones con jquery

miFuncion ("parametros de la funcion", function(){
   funcionCallback();
});


Mespera("", function(){ExeContacto();});

Mespera ("", ExeContacto); 


// __doPostBack();   // forzar actualizacion de la pagina completa


// Gets the session state value.
function GetSessionValue(key) 
{
    PageMethods.GetSessionValue(key, 
        OnSucceeded, OnFailed);
}

//Sets the session state value.
function SetSessionValue(key, value) 
{
    PageMethods.SetSessionValue(key, value, 
        OnSucceeded, OnFailed);
}




function generateRandom()  { 

 // generar valores aleatorios

var g = ""; 

for(var i = 0; i < 32; i++) 

g += Math.floor(Math.random() * 0xF).toString(0xF) 

return g; 

}




// jquery
// $('#foo').fadeIn(200).delay(5000).fadeOut(200).remove(); 



********************************************************************************************************
********************************************************************************************************
********************************************************************************************************

*/

