// enviar a un amig
function enviar1() 
{
mssg='';
var email=document.amigo.email.value;
var correoamigo=document.amigo.correoamigo.value;
document.amigo.email.value=email;
document.amigo.recipient.value=correoamigo;
if (document.amigo.email.value.length == 0) mssg=mssg+"No ha indicado su e-mail (como remitente) \n";
if (document.amigo.email.value.length != 0) {
   if ((email.indexOf('@') == -1) || (email.indexOf('.')== -1)) mssg= mssg+"Su e-mail (como remitente) no es válido\n"; }
//
if (document.amigo.correoamigo.value.length == 0) mssg=mssg+"No ha indicado el e-mail de su amigo \n";
if (document.amigo.correoamigo.value.length != 0) {
   if ((correoamigo.indexOf('@') == -1) || (correoamigo.indexOf('.')== -1)) mssg= mssg+"El e-mail de su amigo no es válido\n"; }
if (mssg.length == 0) {
  validar="";
  validar=confirm("Confirma el envío de su recomendación \n\n por correo electrónico a \n\n "+correoamigo+" ?"); 
  if (validar) { document.amigo.submit(); }
  }
  else { alert(mssg); }
}

// calcular metres habitacio
function calcular() 
{
mssg=""; errorennumeros="";
var longitud = document.calculmetres.longitud.value;
var anchura  = document.calculmetres.anchura.value;
var perimetro= document.calculmetres.perimetro.value;

if (longitud.length == 0)  mssg=mssg+"- no ha indicado los metros de longitud máxima de la habitación \n";
if (anchura.length == 0)   mssg=mssg+"- no ha indicado los metros de anchura máxima de la habitación \n";
if (perimetro.length == 0) mssg=mssg+"- no ha indicado los metros de perímetro de la habitación \n";
if (longitud<0  || isNaN(longitud))  { mssg=mssg+" - no ha indicado un número correcto en los metros de longitud. \n"  ; errorennumeros="si"; }
if (anchura<0   || isNaN(anchura))   { mssg=mssg+" - no ha indicado un número correcto en los metros de anchura. \n"   ; errorennumeros="si"; }
if (perimetro<0 || isNaN(perimetro)) { mssg=mssg+" - no ha indicado un número correcto en los metros del perímetro. \n"; errorennumeros="si"; }

if (mssg!="") {
	if (errorennumeros!="") { mssg=mssg + "\n\nRecuerde: el separador de decimales es el punto, no la coma"; }
	alert ("Aviso: \n\n" + mssg);
	}
	else {
		document.calculmetres.submit();
		}
}

// buscar des de qualsevol pàgina
//
function buscador()
  {
  var t=document.buscar.text.value;
  opcions="";
  if (t.length<=2)
    { alert("Aviso:\n\nDebe indicar un texto de más de 2 caracteres."); }
    else { document.buscar.submit(); }
    }

// gestió de capes/submenús
//
function mostrar(nomcapa) { document.getElementById(nomcapa).style.visibility="visible"; } 
function amagar(nomcapa)  { document.getElementById(nomcapa).style.visibility="hidden";  } 

//
// selecció full d'estils (mida de la font)
//
function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);
//
// botó dret
//
function dreta(e) { 
  if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2)){ 
    alert('mundoparquet.com') 
    return false; 
    } 
    else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2)){ 
      alert('mundoparquet.com') 
      } 
    } 
//document.onmousedown=dreta 
//
//
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
//
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
//
function canvititolpagina(tipus,titolpagina) {
	if (tipus=="0") { nomweb="mundoparquet.com / Tienda online de parquet para Particulares y Profesionales"; }
	if (tipus=="1") { nomweb="mundoparquet.com"; }
	titolpagina = titolpagina.replace(/<[^>]+>/g,''); // eliminar les etiquetes html (per si n'hi ha)
	document.title = nomweb + ": " + titolpagina;
}
//
