function nuevoAjax(){
	var xmlhttp=false;

 	try {
 		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 	} catch (e) {
 		try {
 			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
 		} catch (E) {
 			xmlhttp = false;
 		}
  	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}
function rescatar_script(texto){ 
var p1=texto.split("<scrip",2); 
if (p1[1]) { 
    var p2=p1[1].split(">",2); 
    var p3=p2[1].split("</script",2) 
    if (p3[0] && p3[0]!='') eval(p3[0]);
    texto=p1[0]+p3[1]; 
    texto=rescatar_script(texto); 
} 
return texto; 
} 
function cargar(cont){
	var contenedor;
	contenedor = document.getElementById('contenedor');
	//alert(contenedor);
	ajax=nuevoAjax();
	ajax.open("GET", cont,true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==1){
			contenedor.innerHTML = "<br><br><img src='../images/loader.gif'><br><span class='textcontenedor'>Carregando...</span>"
		}

		else if (ajax.readyState==4) {
			if (ajax.status==200){
				var texto = ajax.responseText;
				texto = texto.replace(/\+/g," ");
				texto = unescape(texto);	
//			alert(texto);
//				texto=rescatar_script(ajax.responseText);
//			alert(texto);				
				contenedor.innerHTML = texto;
//			alert(texto);
			//var tx=texto.substr(500,texto.length);
			}else if(
				ajax.status==404){
                contenedor.innerHTML = "<span style='color:#cccccc; font-weight:bold'>P&aacute;gina no encontrada.</span>";
                }else{
                //mostramos el posible error
                contenedor.innerHTML = "Error:".ajax.status; 
            }
		}
	}
	 ajax.send(null)
}
function cargaim(cont){
	var contenedor;
	contenedor = document.getElementById('foto');
	ajax=nuevoAjax();
	ajax.open("GET", cont,true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			contenedor.innerHTML = ajax.responseText;
		}
		if (ajax.readyState==1){
			contenedor.innerHTML = "<br><br><img src='../images/loader.gif'><br>Carregando..."
		}
	}
	 ajax.send(null)
}
function todos(){
texto = document.getElementById('txbusca');
selec = document.getElementById('secciones');
cargar("productos.php?proc=1");
}
function buscar(){
texto = document.getElementById('txbusca');
//selec = document.getElementById('secciones');
//cargar("productos.php?proc=2&txsea="+texto.value+"&selsec="+selec.value);
cargar("productos.php?proc=2&txsea="+texto.value);
}
function menu(sec){
texto = document.getElementById('txbusca');
//selec = document.getElementById('secciones');
cargar("productos.php?proc=3&secc="+sec);
}
function getuRl(ref){
window.location.href=ref
}
function prod(pro){
cargar("showprod.php?prod="+pro);
}
function hidediv(){
document.getElementById('foto').style.top=0;
document.getElementById('foto').style.visibility="hidden";
}
function showdiv(event,fot,w,h,l){
eldiv=document.getElementById('foto');
eldiv.style.visibility="hidden";
if (document.getElementById && !document.all){
eldiv.style.top=event.clientY + window.pageYOffset+"px";
eldiv.style.left=event.clientX + window.pageXOffset+"px";
}else{
eldiv.style.top=event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
eldiv.style.left=event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
}
eldiv.style.width=w+"px";
eldiv.style.height=h+"px";
cargaim("viewer.php?fot="+fot);
eldiv.style.visibility="visible";
}
function resizediv(){
pict=document.getElementById('pic')
eldiv=document.getElementById('foto')
eldiv.style.width=pict.width;
eldiv.style.height=pict.height + 22;
}
//function paginicio(){
//obj_pagina_inicio.style.behavior='url(#default#homepage)';
//obj_pagina_inicio.setHomePage("http://www.freeshoplaser.com"); // pongan aqui su direción	
//oHomePage.setHomePage("http://www.freeshoplaser.com");
//event.returnValue = false;
//}
function favoritos(){
var url="http://www.freeshoplaser.com" 
var titulo="Laser Free Shop"
if (document.all)
window.external.AddFavorite(url,titulo)
}

//Tratamiento del formulario
   var http_request = false;
   function makePOSTRequest(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = alertContents;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8");
//      http_request.setRequestHeader("Content-type", "charset=utf-8");	  
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

   function alertContents() {
      if (http_request.readyState == 4) {
//alert(http_request.status);
//alert(document.location);
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('myspan').innerHTML = result;            
         } else {
            alert('There was a problem with the request.');
         }
      }
   }
   
   function get(obj) {
      var poststr = "nombre=" + encodeURI( document.getElementById("nombre").value ) + 
	  "&email=" + encodeURI( document.getElementById("email").value ) + 
	  "&comentarios=" + encodeURI( document.getElementById("comentarios").value ) + 
	  "&ciudad=" + encodeURI( document.getElementById("ciudad").value ) + 	  
	  "&subject=" + encodeURI( document.getElementById("subject").value );
//	  alert(poststr);
      makePOSTRequest('contacto/post.php', poststr);
	  var contact=document.getElementById("formu");
	  contact.style.visibility="hidden";
   }
   function showcontact(){
	  var contact=document.getElementById("formu");
	  contact.style.visibility="visible";
	  var container=document.getElementById("myspan");
	  container.innerHTML="";
   }