var message = "...::: Trinity Software :::...^^...::: Si los Aztecas pudieron nosotros porque no? :::...^^";
var scrollSpeed = 50;
var lineDelay   = 1500;
var txt = "";
var iAceptar = new Image();
var ioAceptar = new Image();
var iEnviar = new Image();
var ioEnviar = new Image();
var sResult;
jQuery.noConflict();
document.onmousedown = function (){};

function init()
{
jQuery("#header").hide();
jQuery("#menu").hide();
jQuery("#page").hide();
jQuery("#footer").hide();
var dlgLoad = new Ext.BasicDialog("Loading", {
    height: 105,
    width: 180,
    modal: true,
    proxyDrag: true,
    shadow: true,
    closable: false,
    collapsible: false,
    draggable: true,
    resizable: false
});
dlgLoad.show();
setTimeout(
    function(){
        dlgLoad.hide();
		jQuery("#header").show("slow");
		jQuery("#content").load("trinity.htm");
        setTimeout(
            function(){
				jQuery("#menu").show("slow");
				setTimeout(
					function(){
						jQuery("#page").show("slow");
						setTimeout(
							function(){
								jQuery("#footer").show("slow");
						},750);
				},750);
            },750);
    }, 3000);
}	
function opciones(nOpcion)
{
	//jQuery("#content").hide("slow");
	switch(nOpcion)
	{
		case 1:
			jQuery("#content").load("trinity.htm");
			break;
		case 2:
			jQuery("#content").load("desarrollo.htm");
			break;
		case 21:
			jQuery("#content").load("desarrollo1.htm");
			break;
		case 3:
			jQuery("#content").load("redes.htm");
			break;
		case 4:
			jQuery("#content").load("equipamiento.htm");
			break;
		case 5:
			jQuery("#content").load("experiencia.htm");
			break;
		case 6:
			jQuery("#content").load("contacto.htm");
			break;
		default:
			jQuery("#content").load("trinity.htm");
			break;
	}
	//jQuery("#content").show("slow");
}	
function validaCorreo(eCorreo){
    regx = /^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/;
    return !regx.test(eCorreo);
}
function validaTelefono(eTelefono){
    regx = /^([0-9s+-])+$/;
    return !regx.test(eTelefono);
}
function pause(millisecondi){
	var now = new Date();
	var exitTime = now.getTime() + millisecondi;

	while(true)
	{
		now = new Date();
		if(now.getTime() > exitTime) return;
	}
}
function trim(str){
	s = str.replace(/^(\s)*/, '');
	s = s.replace(/(\s)*$/, '');
	return s;
}
function scrollText(pos) {
   if (message.charAt(pos) != '^') 
   {
      txt = txt + message.charAt(pos);
      status = txt;
      pauze  = scrollSpeed;
   }
   else 
   {
      pauze = lineDelay;
      txt = "";
      if (pos == message.length-1) pos = -1;
   }
   pos++;
   setTimeout("scrollText('"+pos+"')",pauze);
}
function Limpia()
{
	if (jQuery("#username").val() != "")	{
		jQuery("#username").val("");
		jQuery("#password").val("");
		jQuery("#cliente").val("");
		jQuery("#passcliente").val("");
	}
	if (jQuery("#cliente").val() != "")	{
		jQuery("#username").val("");
		jQuery("#password").val("");
		jQuery("#cliente").val("");
		jQuery("#passcliente").val("");
	}
}
function AbreDemo(nDemo){
    var sUrl = "";
    switch (nDemo)
    {
        case 1:
            sUrl = "http://demo.openbravo.com/";
            break;
        case 2:
            sUrl = "";
            break;
        case 3:
            sUrl = "";
            break;
    }
    window.open(sUrl,"_blank");
}
function EnviarCorreo() {
	var dlgEnviando = new Ext.BasicDialog("Enviar", {
		height: 105,
		width: 180,
		modal: true,
		proxyDrag: true,
		shadow: true,
		closable: false,
		collapsible: false,
		draggable: true,
		resizable: false
	});
	var sEnvio = true;
	if (trim(jQuery("#Nombre").val()) == "") {
        msgbox("Error","Proporcione un nombre de contracto");
		sEnvio = false; 
		return;
	}
	if (trim(jQuery("#Telefono").val()) == "") {
		msgbox("Error","Proporcione un telefono de contacto");
		sEnvio = false;
		return;
	}
	if (validaTelefono(jQuery("#Telefono").val())) {
        msgbox("Error","El teléfono solo debe contener numeros y guiones");
		sEnvio = false;
		return;
	}
	if (validaTelefono(jQuery("#Celular").val()) && jQuery("#Celular").val() != "") {
		msgbox("Error","El celular solo debe contener numeros y guiones");
		sEnvio = false;
		return;
	}
	if (validaTelefono(jQuery("#Fax").val()) && jQuery("#Fax").val() !="") {
		msgbox("Error","El fax solo debe contener numeros y guiones");
		sEnvio = false;
		return;
	}
	if (trim(jQuery("#Correo").val()) == "") {
		msgbox("Error","Proporcione un correo electronico de contacto");
		sEnvio = false;
		return;
	}
	if (validaCorreo(jQuery("#Correo").val())) {
		msgbox("Error","La cuenta de correo no es valida");
		sEnvio = false;
		return;
	}
	if (trim(jQuery("#Comentarios").val()) == "") {
		msgbox("Error","Proporcione la información que desea obtener");
		sEnvio = false;
		return;
	}
	if (sEnvio) {
		sUrl = "js/Contacto.aspx?Nombre="+jQuery("#Nombre").val()+"&Telefono="+jQuery("#Telefono").val()+"&eMail="+jQuery("#Correo").val()+"&Celular="+jQuery("#Celular").val()+"&Fax="+jQuery("#Fax").val()+"&Comentarios="+jQuery("#Comentarios").val();
		// Antes de realizar la operacion
		jQuery("#Loading").ajaxStart(function(){
			dlgEnviando.show();
		});
		// Cuando termina la accion
		jQuery('#Loading').ajaxComplete(function(request, settings){
			dlgEnviando.hide();
			jQuery("#content").load("correo.htm");
		});
   		// La accion que debe realizar
		jQuery.ajax({
			url: sUrl, 
			async: true,
			success: function(msg){sResult = msg;}
		});
	}
}

