function URLDecode( s )
{
   // Replace + with ' '
   // Replace %xx with equivalent character
   // Put [ERROR] in output if %xx is invalid.
   var HEXCHARS = "0123456789ABCDEFabcdef"; 
   var encoded = s;
   var plaintext = "";
   var i = 0;
   while (i < encoded.length) {
       var ch = encoded.charAt(i);
	   if (ch == "+") {
	       plaintext += " ";
		   i++;
	   } else if (ch == "%") {
			if (i < (encoded.length-2) 
					&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
					&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
				plaintext += unescape( encoded.substr(i,3) );
				i += 3;
			} else {
				alert( 'Bad escape combination near ...' + encoded.substr(i) );
				plaintext += "%[ERROR]";
				i++;
			}
		} else {
		   plaintext += ch;
		   i++;
		}
	} // while
	return plaintext;
};

function enviarContacto(){
	//alert("Correo enviado");
        $.post("http://www.pacificsoft.com.mx/contacto/procesarsolicitud.asp")	
}

/*
function MoveArea(x,y){ 
    this.x=x;this.y=y 
    this.css.left=this.x 
    this.css.top=this.y 
} */
 
function down(){ 
alert( $("#fileTreeDemo_1").css("top") );
	$("#fileTreeDemo_1").css("top", $("#fileTreeDemo_1").css("top")-5 );
	/*if(this.y>-this.scrollHeight+objContainer.clipHeight){ 
    this.MoveArea(0,this.y-move) 
    if(loop) setTimeout(this.obj+".down("+move+")",speed) 
	} */
} 
function up(){ 
	$("#fileTreeDemo_1").css("top", $("#fileTreeDemo_1").css("top")+5 );
	/*if(this.y<0){ 
    this.MoveArea(0,this.y-move) 
    if(loop) setTimeout(this.obj+".up("+move+")",speed) 
	} */
} 


function Producto( p ){
	//alert("Producto : " +p);	
	$.post("pacific.aspx",{ prod : 1 },function(result){												 	
			if(result){
				$("#main").html(result);
				$("#menu14 li a").click(function(){
										
						//alert( $(this).html() );
						$("#tituloDescripcion").html( $(this).html() );
						
						var st;
						if ( $(this).attr("rel") == 2 )
							st = "Cada equipo que opere como Punto de Venta debe mantener conectada la llave USB que contiene la licencia que le corresponde como caja."						
						if ($(this).attr("rel") == 1)
							st = "<ul><li>Facturaci&oacute;n directa de la venta o por seleccion de notas.</li><li>Permite poner y recuperar una venta en espera.</li><li>Recepcion de pago en monedas y formas de pago definidas por la empresa.</li><li>Opcion de redondeo del importe de la venta.</li><li>Modalidad Mostradores &shy; Caja.</li><li>	Corte y arqueo de caja, con comprobante. </li><li>Control de inventario por distintas unidades.</li><li>Clasificacion de catalogos definible por el usuario, sin limite.</li><li>Opcion de puntos acumulables por producto a clientes frecuentes.</li><li>Cambio masivo de precios.</li><li>Definicion de listas de precios por rango o clasificacion.</li><li>Precios por volumen.</li><li>Ofertas programables en periodo y horario, por clasificacion de articulos.</li><li>Accesos a menu definibles por equipo y usuario.</li><li>Busquedas en cada pantalla.</li><li>Consultas de catalogos y movimientos, por diversos filtros.</li><li>Dise&ntilde;o de documentos cachichurris.</li><li>Ayuda en cada pantalla.</li></ul>"
						if ($(this).attr("rel") == 3)
						    st = "El sistema es compatible con impresoras, Scanners, Touchscreen, b&aacute;sculas Corre en Windows 9x, NT, 2000, XP Trabaja con Bases de Datos en Access y MySQL."
						if ($(this).attr("rel") == 4)
						    st = "Llave de licencia f&iacute;sica, instalable en cualquier equipo de la red. Un equipo que opere caja de ventas no debe tener ninguna otra llave de licencias conectada a otro puerto USB, s&oacute;lo la que contiene la licencia que le corresponde.";
						
						$("#contenidoProducto").html( st );
						return false;
				});
				$("#descrProducto").corner();/*$("#descrProducto").corner({
			  tl: { radius: 16 },
			  tr: false,
			  bl: false,
			  br: { radius: 16 },
			  antiAlias: true,
			  autoPad: true,
			  validTags: ["div"] });//corner();
				/*$("#descrProducto").corner();
				$("#myfield").corner();
				$("#mylegend").corner();*/
			}else
				alert("Hubo un problema con la peticion");
	});
}

function linkear(){
	$(".blockContent:first .links a").click(function(){	
		var s = $(this).attr("rel");											 
		if( $(this).attr("rel")	== "PV")
			Producto(1);		
		else
			$.post("pacific.aspx",{ sec : $(this).attr("rel") },function(result){												 	
				$("#main").html(result);					
				if( s == "S1")
					$(".pf").corner();			
				
			});
		return false;
	});	
};




$(document).ready(function() {
			var wh = $(window).height();
			var hh = $("#header").outerHeight();
			var mh = $("#menu").outerHeight();
			var fh = $("#footer").outerHeight();
			
			//$(".blockContent .links").hide();
			//$(".blockContent").hide();


//$(".blockContent .links").show("slow");
//$(".blockContent").show("slow");
			var mainh = wh - hh - mh - fh - 12;
			/*var s = "window.width: " + $(window).width() + 
					"<br>document.width: "+ $(document).width() +
					"<br>document.height: "+ $(document).height() +
					"<br><br>window.height: " + wh +					
					"-<br>header.outerheight: " +  hh+
					"-<br>menu.outerheight: "+ mh +
					"-<br>footer.outerheight: " + fh +
					"-<br>_____________________________<br>total: " + mainh;
			
			$("#main").html(s);	*/
			//desliz
			
			//$("#yeah").corner({  tl: { radius: 5 },  tr: { radius: 5 }, bl: { radius: 5 },  br: { radius: 5 } });
			//$("#center").corner({  tl: { radius: 16 },  tr: { radius: 16 }, bl: { radius: 0 },  br: { radius: 0 } });
			
			slider.init(); 
			$("#center").dropShadow();
			$("#parent3").wslide({
					width: 250,
					height: 300,
					col: 3,
					autolink: 'menu3'
				});
			

			$("#tabs10 ul li a").click(function(){
				var sec = $(this).attr("rel");
				
				
				$.post("pacific.aspx",{ p: sec },function(result)
					{								
						$("#main").html(result);
						$(".ticker").hide();						
						
						if(sec == 3){slider.init(); $("#center").dropShadow();}
						if(sec == 8){ //tree							
								$('#fileTreeDemo_1').fileTree({ root: 1, script: 'Tree.aspx' }, function(file) { /*alert(file);*/ });
						}
						
						$.getJSON("menu.aspx",{ menu : sec }, function(json)
						{
							if(!json) return;
							//$(".nifty:first").hide();
							//$(".nifty").hide();
							$(".blockContent:first .links").hide();
							$(".blockContent:first .blockTitle").html(json.titulo);
							
							var s = "";
							$.each(json.menu,function(i,item) {
								s += "<li><a href='PacificSoft' rel='"+item.rel+"'>"+item.texto+"</a></li>";
							});
							
							$(".blockContent:first .links").html(s);
							$(".blockContent:first .links").show("slow");
							//$(".nifty:first").show("slow");
							//$(".nifty").show("slow");
							
							linkear();	
						});									
					});	//post
				return false;				
			});
			
			
			 $("#content h2").click(function() {
				if ( $(this).next().css("display") == "none") $(this).next().show("slow"); 
				else $(this).next().hide("slow");
			  });
			
			
			
			if (parseInt(navigator.appVersion)>3) { 
			 if (navigator.appName=="Netscape") {
			  $("#main, #loading").css("height",mainh+"px");
			 }
			 if (navigator.appName.indexOf("Microsoft")!=-1) { //$.browser.msie
			  $("#main, #loading").css("height","100%");
			  $(".botn").css("margin-bottom","-28px");
			  $(".topn").css("margin-top","-13px");
			 }
			}
					
			//$(".blockContent").show(3000);
			$('#misClientes').cycle({ 
				fx:    'fade',
				sync:   0, 
				delay: -3000 				
			 });
			 
			 //$(".dano").corner();
			 $(".blockTitle").click(function() {
				if ( $(this).next().css("display") == "none"){
					 $(".blockTitle").next().hide();
					 $(this).next().show("slow"); 
				}else{					 
					 $(this).next().hide("slow");
				}
			    //$(this).next('ul:hidden').slideDown('fast').siblings('ul:visible').slideUp('fast');/
			  });
			  
			 //$(".blockContent").corner();
			  linkear();
			  
		});


/*$.getJSON("json.aspx",{ seccion : $(this).attr("rel") },function(json){		
					var lsRegExp = /\+/g;

					var txt = unescape( json.contenido );
					var txt2=txt.replace(/\+/gi," ");

					//$("#main").html( unescape(String( json.contenido ).replace(lsRegExp, " ") ) ) ;	
					$("#main").html( URLDecode( txt2 ) ) ;	
					$(".blockContent:first .blockTitle").html( URLDecode( json.titulo ) );
					//$(".blockContent:first .links").html( URLDecode( json.menu ) );
					//alert( unescape(json.menu ) ); 
					//alert( URLDecode( json.menu ) );
					//alert( json.link );
					//alert( json.menu.menu );					
					//alert( json.contenido );
					//alert( json.menu );
				});
				return false;
				*/