//Browsercheck (needed) ***************
this.ver=navigator.appVersion
this.agent=navigator.userAgent
this.dom=document.getElementById?1:0
this.opera5=this.agent.indexOf("Opera 5")>-1
this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
this.ie=this.ie4||this.ie5||this.ie6
this.mac=this.agent.indexOf("Mac")>-1
this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
this.ns4=(document.layers && !this.dom)?1:0;
this.bw=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5)


/*****************************************FUNCTION REFRESH**********************************/

function refresh()
  {
   if(navigator.appName == "Netscape")
     {
	  if (innerWidth != origWidth || innerHeight != origHeight)
	  	  {
           origWidth = innerWidth;
           origHeight = innerHeight;
		   window.location.reload();
          }
     }
  }	



/******************************************************************************************/
/************************************* FUNCTION no-right-click ****************************/
var message = "&copy; by Casa Carmelina";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false")



//**********************************     Checkt eine übergebene Email Adresse     **************
function isEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) return (str.indexOf(".") > 3) && (str.indexOf("@") > 0);
  
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}


// *************************************************************************************************
function formCheck() {
	
	document.formContact.nombre.style.backgroundColor = "#ffffff";
	document.formContact.tel.style.backgroundColor = "#ffffff";
	document.formContact.email.style.backgroundColor = "#ffffff";
	document.formContact.descripcion.style.backgroundColor = "#ffffff";
	
	
	if(document.formContact.nombre.value == "") {
		alert("Introduzca su nombre por favor !");
		document.formContact.nombre.style.backgroundColor = "#e8e8e8";	
		document.formContact.nombre.focus();	
		return false;
	}
	
	// Tel - Email
	if (document.formContact.tel.value == "" && document.formContact.email.value == "") {
		alert("Introduzca su numero de telefono o su email por favor !");
	    document.formContact.tel.style.backgroundColor = "#e8e8e8";	
		document.formContact.email.style.backgroundColor = "#e8e8e8";	
		document.formContact.tel.focus();	
	    return false;
	}
	if(document.formContact.email.value != "" && !isEmail(document.formContact.email.value)) {
		alert("Introduzca un email correcto por favor !");
		document.formContact.email.style.backgroundColor = "#e8e8e8";	
		document.formContact.email.focus();	
		return false;
	}
	
	if(document.formContact.descripcion.value == "") {
		alert("Introduzca un texto por favor !");
		document.formContact.descripcion.style.backgroundColor = "#e8e8e8";	
		document.formContact.descripcion.focus();	
		return false;
	}
	
	
	
}


//*******************************************************************************************************************

// *************************************************************************************************
function libroCheck() {
	
	document.formGuest.name.style.backgroundColor = "#ffffff";
	document.formGuest.email.style.backgroundColor = "#ffffff";
	document.formGuest.comment.style.backgroundColor = "#ffffff";
	document.formGuest.security_code.style.backgroundColor = "#ffffff";
	
	
	if(document.formGuest.name.value == "") {
		alert("Introduzca su nombre por favor !");
		document.formGuest.name.style.backgroundColor = "#c0c0c0";	
		document.formGuest.name.focus();	
		return false;
	}
	
	if(document.formGuest.email.value != "" && !isEmail(document.formGuest.email.value)) {
		alert("Introduzca un email correcto por favor !");
		document.formGuest.email.style.backgroundColor = "#c0c0c0";	
		document.formGuest.email.focus();	
		return false;
	}
	
	if(document.formGuest.comment.value == "") {
		alert("Introduzca un texto por favor !");
		document.formGuest.comment.style.backgroundColor = "#c0c0c0";	
		document.formGuest.comment.focus();	
		return false;
	}
	if(document.formGuest.security_code.value == "") {
		alert("COPIAR el CODIGO DE SEGURIDAD por favor !");
		document.formGuest.security_code.style.backgroundColor = "#c0c0c0";	
		document.formGuest.security_code.focus();	
		return false;
	}
	
	
}

