// FUNCION PARA DETECTAR BROWSER
if(typeof jsExa=="undefined"){var jsExa=new Object();}
if(typeof jsExa.Browser=="undefined"){jsExa.Browser=new Object();}
jsExa.Browser = function() {
    var intIdx = 0;
    var strUA = navigator.userAgent.toLowerCase();
    strUA = strUA.toLowerCase();
    this.appVersion = navigator.appVersion;
    this.appProduct = navigator.product;
    this.appPlatform = navigator.platform;
    this.appName = navigator.appName;
    this.appCodeName = navigator.appCodeName;
    this.intVer = 0;
    this.sngVer = 0;
    this.strVer = "";
    this.bolIE = false;
    this.bolNav = false;
    this.bolFF = false;
    this.bolSaf = false;
    this.bolWin32 = false;
    this.bolWin16 = false;
    this.bolUnix = false;
    this.bolLinux = false;
    this.bolMac = false;
    this.bolWinCE = false;
    this.bolChrome = false;
    //---  080218  HMO  Browser y version 
    if (strUA.indexOf("msie") != -1) {
        this.bolIE = true;
        this.strNom = "Microsoft Internet Explorer";
        this.strVer = strUA.substring(intIdx = strUA.indexOf("msie") + 5, strUA.indexOf(";", intIdx));
    }
    else
        if (strUA.indexOf("netscape6/") != -1 || strUA.indexOf("netscape/") != -1) {
        this.bolNav = true;
        this.strNom = "NETSCAPE";
        this.strVer = strUA.indexOf("netscape6/") != -1 ? strUA.split(' netscape6/')[1] : strUA.split(' netscape/')[1];
    }
    else
        if (strUA.indexOf("firefox/") != -1) {
        this.bolFF = true;
        this.strNom = "MOZILLA FIREFOX";
        this.strVer = strUA.split(' firefox/')[1];
    }
    else
        if (strUA.indexOf("chrome") != -1) {
        this.bolChrome = true;
        this.strNom = "GOOGLE CHROME";
        this.strVer = strUA.split(' chrome/')[1].split(' ')[0];
    }
    else
        if (strUA.indexOf("safari/") != -1) {
        this.bolSaf = true;
        this.strNom = "APPLE SAFARI";
        this.strVer = strUA.split(' safari/')[1];
    }
    else
        if (strUA.indexOf("opera") != -1) {
        this.bolOpe = true;
        this.strNom = "OPERA";
        //---  090729  HMO  Se corrige un problema al obtener la version, se tomaba strUA.agent cuando strUA es tan solamente un string...
        this.strVer = strUA.split('opera')[1].substring(1).split(' (')[0];
    }

    //---  080218  HMO  Plataforma...
    if (strUA.indexOf("windows 95") > 0 || strUA.indexOf("win95") != -1 || strUA.indexOf("win98") != -1 || strUA.indexOf("windows 98") != -1 || strUA.indexOf("windows nt") != -1) { this.bolWin32 = true; }
    else if (strUA.indexOf("windows 3.1") != -1 || strUA.indexOf("win16") != -1) { this.bolWin16 = true; }
    else if (strUA.indexOf("mac") != -1) { this.bolMac = true; }
    else if (strUA.indexOf("linux") != -1) { this.bolLinux = true; }
    else if (!this.bolLinux && (strUA.indexOf("sunos") != -1 || strUA.indexOf("hp-ux") != -1 || strUA.indexOf("x11") != -1)) { this.bolUnix = true; }
    else if (strUA.indexOf("windows ce") != -1) { this.bolWinCE = true; }

    this.sngVer = parseFloat(this.strVer);
    this.intVer = Math.floor(this.sngVer);
};
var objBC = new jsExa.Browser();


function LimitAttach(tField,iType){
	file=tField.value;
	if (iType==1) { 
		extArray = new Array(".gif",".jpg",".png");
	}
	
	allowSubmit = false;
	if (!file) return;
	
	while (file.indexOf("\\") != -1) file = file.slice(file.indexOf("\\") + 1);
	ext = file.slice(file.indexOf(".")).toLowerCase();
	for (var i = 0; i < extArray.length; i++) {
		if (extArray[i] == ext) {
			allowSubmit = true;
			break;
		}
	} 
	if (!allowSubmit) {
		alert("Únicamente es posible subir archivos con extensiones " + (extArray.join(" ")) + "\nPor favor seleccione un nuevo archivo");
	}
}

function objNumericos(){
	var Forma = document.form1;
	Forma.txtCp.onkeypress = EventoNumericoEntero;
	Forma.txtNoCliente.onkeypress = EventoNumericoEntero;
	Forma.txtTel.onkeypress = EventoNumericoEntero;
	Forma.txtMovil.onkeypress = EventoNumericoEntero;
}

function EventoNumericoEntero() { ValidaNumerico(); }
function ValidaNumerico(strRangoAdc){
	// Rango entre 48 (0) y 57 (9)...
	if (!(event.keyCode>=48 && event.keyCode<=57))
		if (ValidaNumerico.arguments.length>0)
		{
			if (strRangoAdc.indexOf(String.fromCharCode(event.keyCode))==-1)
				event.returnValue=false;
			else
				if (event.srcElement.value.indexOf(String.fromCharCode(event.keyCode))>=0)
					event.returnValue=false;
		}else{
			event.returnValue=false;
		}
}
function ValidaDatos(){
	var Forma = document.form1;
	if (Forma.txtNombre1.value == ""){
		alert("Es necesario que ingreses tu Nombre");
		Forma.txtNombre1.focus();
		return false;
	}
	if ((Forma.txtEmail1.value.indexOf ('@', 0) == -1) || (Forma.txtEmail1.value.indexOf ('.', 0) == -1)){
		alert('Es necesario que ingrese un Correo electrónico válido (por ejemplo: usuario@jeep.com.mx)');
		Forma.txtEmail1.focus();
		return false;
	}
	if (Forma.txtNombre2.value == ""){
		alert("Es necesario que ingreses el Nombre de tu Amigo");
		Forma.txtNombre2.focus();
		return false;
	}
	if ((Forma.txtEmail2.value.indexOf ('@', 0) == -1) || (Forma.txtEmail2.value.indexOf ('.', 0) == -1)){
		alert('Es necesario que ingrese un Correo electrónico válido (por ejemplo: usuario@jeep.com.mx)');
		Forma.txtEmail2.focus();
		return false;
	}
}
function ValidaCaracteresEspeciales(objTxt) {
	var strCadena = objTxt.value;
	var ValidChars='$%*+@·"#|-_:;,!¡?¿&\/()1234567890';
	for(i=0; i<strCadena.length; i++){
		if (ValidChars.indexOf(strCadena.charAt(i),0)!=-1){
			alert("Unicamente se permiten caracteres alfanuméricos en este campo");
			objTxt.value="";
			objTxt.focus();
			return false;
		}
	}
}
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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
