bw=new checkBrowser();

function checkBrowser(){
 	this.ver=navigator.appVersion
 	this.dom=document.getElementById?1:0
 	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
 	this.ie4=(document.all && !this.dom)?1:0;
 	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
 	this.ns4=(document.layers && !this.dom)?1:0;
 	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
 	return this
}

function makeObj(obj){
	this.css=bw.dom? document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?document.layers[obj]:0;
	this.wref=bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?document.layers[obj].document:0;
	this.writeIt=b_writeIt;
	return this
}
function b_writeIt(text){if(bw.ns4){this.wref.write(text);this.wref.close()}
else this.wref.innerHTML=text}
//Capturing mousemove
var descx,descy;
function popmousemove(e){descx=bw.ns4?e.pageX:event.x; descy=bw.ns4?e.pageY:event.y}
//Initiates page
var isLoaded;

function init(){

oDesc=new makeObj('divDescription')
if(bw.ns4)document.captureEvents(Event.MOUSEMOVE)
document.onmousemove=popmousemove;
isLoaded=true;

}

function popup(texto,imagen){
 if(isLoaded){

 	oDesc.writeIt('<div class="clDescription">'+texto+'</div>')
 	if(bw.ie5) descy=descy+document.body.scrollTop
 	oDesc.css.left=getX(imagen)+4; oDesc.css.top=getY(imagen)+imagen.height+10;
 	oDesc.css.visibility='visible'
}
}

function popup2(texto,imagen){
 if(isLoaded){

	if (imagen==mapasud)
	{posx=0;
	} else
	{posx=-110;
	}

 	oDesc.writeIt('<div class="clDescription2">'+texto+'</div>')
 	if(bw.ie5) descy=descy+document.body.scrollTop
 	oDesc.css.left=event.clientX + document.body.scrollLeft + posx; oDesc.css.top=event.clientY + document.body.scrollTop+15;
 	oDesc.css.visibility='visible'
}
}

function popup3(texto){
 
 	oDesc.writeIt('<div class="clDescription">'+texto+'</div>')
 	if(bw.ie5) descy=descy+document.body.scrollTop
 	oDesc.css.left=5; oDesc.css.top=document.body.scrollTop+5;
 	oDesc.css.visibility='visible'
 	
 	setTimeout('popout2()',20000);
	
}

function popup4(texto){
 
 	oDesc.writeIt('<div class="clDescription">'+texto+'</div>')
 	if(bw.ie5) descy=descy+document.body.scrollTop
 	oDesc.css.left=5; oDesc.css.top=document.body.scrollTop+5;
 	oDesc.css.visibility='visible'
 	
 	setTimeout('popout2()',120000);
	
}

function popup5(texto,imagen){
 if(isLoaded){

 	oDesc.writeIt('<div class="clDescription">'+texto+'</div>')
 	if(bw.ie5) descy=descy+document.body.scrollTop
 	oDesc.css.left=getX(imagen)+1; oDesc.css.top=getY(imagen)+imagen.height+1;
 	oDesc.css.visibility='visible'
}
}

function popout(){
	if(isLoaded) 
	{
	oDesc.css.visibility='hidden';
	oDesc.writeIt('');
	oDesc.css.left=-500; oDesc.css.top=-500;
	}
}

function popout2(){
	if(isLoaded) 
	{
	oDesc.css.visibility='hidden';
	oDesc.writeIt('');
	oDesc.css.left=-500; oDesc.css.top=-500;
	alert('Posible falla de recepción, envíe nuevamente');
	}
}

function getY(a)
{
	var x=a.offsetTop;
	while(a.offsetParent!=null)
 {
 a=a.offsetParent;
 x+=a.offsetTop;
 };
	return x;
};

function getX(a)
{
	var x=a.offsetLeft;
	while(a.offsetParent!=null)
 {
 a=a.offsetParent;
 x+=a.offsetLeft;
 };
	return x;
};

function f0001(theTxt,txtLen)
       {
                       if(txtLen > 240)
                       {
                                       alert("No se permiten más que 240 caracteres para un mensaje.");
                                       formenvio.consulta.value = theTxt.substr(0,240);
                       }
                       return 240-formenvio.consulta.value.length;

       }

function verifico_nombre(){
	if(document.formenvio.realname.value==""){
		alert("Tienes que ingresar tu nombre");
		document.formenvio.realname.focus();
		return false;
	}else{
		return true;
	}
}

function verifico_correo() {
	Cadena=document.formenvio.email.value;
	if (Cadena!="") {
		Punto = Cadena.substring(Cadena.lastIndexOf('.') + 1, Cadena.length)
		Dominio = Cadena.substring(Cadena.lastIndexOf('@') + 1, Cadena.lastIndexOf('.'))
		Usuario = Cadena.substring(0, Cadena.lastIndexOf('@'))
		Reserv = "@/º\"\'+*{}\\<>?¿[]áéíóú#·¡!^*;,:"
		valido = true
		for (var Cont=0; Cont<Usuario.length; Cont++) {
			X = Usuario.substring(Cont,Cont+1)
			if (Reserv.indexOf(X)!=-1)
				valido = false
		}
		for (var Cont=0; Cont<Punto.length; Cont++) {
			X=Punto.substring(Cont,Cont+1)
			if (Reserv.indexOf(X)!=-1)
				valido = false
		}
		for (var Cont=0; Cont<Dominio.length; Cont++) {
			X=Dominio.substring(Cont,Cont+1)
			if (Reserv.indexOf(X)!=-1)
				valido = false
			}
		if (Punto.length<2 || Dominio <1 || Cadena.lastIndexOf('.')<0 || Cadena.lastIndexOf('@')<0 || Usuario<1) {
			valido = false
		}
		if (valido) {
			return true;
		} else {
			alert('Ingreso erroneamente su dirección de correo')
			document.formenvio.email.focus();
			return false;
		}
	} else {
		alert("Falta ingresar su dirección de correo");
		document.formenvio.email.focus();
		return false;
	}
}

function verifico_consulta(){
	if(document.formenvio.consulta.value==""){
		alert("Tienes que ingresar una consulta");
		document.formenvio.consulta.focus();
		return false;
	}else{
		return true;
	}
}

function back() {
   history.go(-1);
}

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 var expires = "";
	var ck = name+"="+value+expires+"; path=/";
	//if (days != -1) alert('Cookie\n' + ck + '\ncreated');
	document.cookie = ck;
}

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;
}

function sav() {
	
	createCookie('realname',document.formenvio.realname.value);
	createCookie('email',document.formenvio.email.value);
	createCookie('telefono',document.formenvio.telefono.value);
	createCookie('consulta',document.formenvio.consulta.value);
		
}


function pre() {

if (document.formenvio.realname.value == '')
{
vname=readCookie('realname');

if ((vname!='') && (vname!=null))
{
pregunta = confirm("¿ Quiere ecribir la consulta anterior ?");
if (pregunta == true)
{
	document.formenvio.realname.value = vname;
	document.formenvio.email.value = readCookie('email');
	document.formenvio.telefono.value = readCookie('telefono');
	document.formenvio.consulta.value = readCookie('consulta');
}
else
document.formenvio.realname.focus();
}
}
}

function sav2(pos) {

var vloc = window.location.href;
var vlocs = vloc.split("#");

createCookie('loc',vlocs[0]);
createCookie('pos',pos);

}

function setfocus()
{
   document.forms[0].t.select();
   document.forms[0].t.focus();
}

