function createRequestObject(){
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}
var http = createRequestObject();

function replace(string,text,by) {
	// Replaces text with by in string
	var strLength = string.length, txtLength = text.length;
	if ((strLength == 0) || (txtLength == 0)) return string;

	var i = string.indexOf(text);
	if ((!i) && (text != string.substring(0,txtLength))) return string;
	if (i == -1) return string;

	var newstr = string.substring(0,i) + by;

	if (i+txtLength < strLength)
	newstr += replace(string.substring(i+txtLength,strLength),text,by);

	return newstr;
}

function objetoAjax(){
	var xmlhttp=false;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		
		
	} catch (e) {
		try {
		   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
  		}
	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function setFocus(){
		document.getElementById('usrname').select();
		document.getElementById('usrname').focus();
}
	
function Trim(String)
{
	if(String == null) {
		return (false);
	}
	return String.replace(/(^\s+)|(\s+$)/g,"");
}

var carga='<br><br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="images/loading.gif" align="middle">';
var carga1='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="images/loading.gif" align="middle">';
var letters=' ABCÇDEFGHIJKLMNÑOPQRSTUVWXYZabcçdefghijklmnñopqrstuvwxyzàáÀÁéèÈÉíìÍÌïÏóòÓÒúùÚÙüÜ'
var numbers='1234567890'
var signs=',.:;@-\''
var mathsigns='+-=()*/'
var custom='<>#$%&?¿'

function alpha(e,allow) {
var k;
k=document.all?parseInt(e.keyCode): parseInt(e.which);
return (allow.indexOf(String.fromCharCode(k))!=-1);
}



///********* PARA BLOQQUERA EL BOTON DERECHO DEL MOUSE ****/////////
/*   document.oncontextmenu = function() {
      return false
   }
   function right(e) {
      var msg = "VIPROSEG S.A ! \n Derechos Reservados";
	  //var input ="<input name=usrname id=usrname type=text class=inputbox1 size=20 />"
      if (navigator.appName == 'Netscape' && e.which == 3) {
         alert(msg); //- Si no quieres asustar a tu usuario entonces quita esta linea...
         return false;
      }
      else if (navigator.appName == 'Microsoft Internet Explorer' && event.button==2) {
         alert(msg); //- Si no quieres asustar al usuario que utiliza IE,  entonces quita esta linea...
                        //- Aunque realmente se lo merezca...
      return false;
      }
   return true;
}
document.onmousedown = right;*/


function color1(who,color) {
who.bgColor = color;
}
function color2(who,color) {
who.bgColor = color;
}


function descarga()
{
	var content=document.getElementById("mostrar");
	ajax=objetoAjax();
		ajax.open("POST",'tpl/descargas.php', true);	
			ajax.onreadystatechange=function()
		{
		 	 if (ajax.readyState==1)
			 {
		         content.innerHTML='';
				 
		     }
		         else if (ajax.readyState==4)
			 {
				content.innerHTML = ajax.responseText;
		  	 }
		}
		ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		ajax.send(null);
}






/***********************************************
* Image w/ description tooltip- By Dynamic Web Coding (www.retranet.com)
* Copyright 2002-2007 by Sharon Paine
* Visit Dynamic Drive at http://www.retranet.com/ for full source code
***********************************************/

/* IMPORTANT: Put script after tooltip div or 
	 put tooltip div just before </BODY>. */

		var dom = (document.getElementById) ? true : false;
		var ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
		var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
		var ns4 = (document.layers && !dom) ? true : false;
		var ie4 = (document.all && !dom) ? true : false;
		var nodyn = (!ns5 && !ns4 && !ie4 && !ie5) ? true : false;
		
		// resize fix for ns4
		var origWidth, origHeight;
		if (ns4) {
			origWidth = window.innerWidth; origHeight = window.innerHeight;
			window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
		}
		
		// avoid error of passing event object in older browsers
		if (nodyn) { event = "nope" }
		
		///////////////////////  CUSTOMIZE HERE   ////////////////////
		// settings for tooltip
		// Do you want tip to move when mouse moves over link?
		var tipFollowMouse= true;
		// Be sure to set tipWidth wide enough for widest image
		var tipWidth= 0;
		var offX= 20;	// how far from mouse to show tip
		var offY= 12;
		var tipFontFamily= "Verdana, arial, helvetica, sans-serif";
		var tipFontSize= "8pt";
		// set default text color and background color for tooltip here
		// individual tooltips can have their own (set in messages arrays)
		// but don't have to
		var tipFontColor= "#000000";
		var tipBgColor= "";
		var tipBorderColor= "";
		var tipBorderWidth= 0;
		var tipBorderStyle= "none";
		var tipPadding= 0;

// tooltip content goes here (image, description, optional bgColor, optional textcolor)

		var messages = new Array();

// multi-dimensional arrays containing: 
// image and text for tooltip
// optional: bgColor and color to be sent to tooltip

		if (document.images) {
			var theImgs = new Array();
			for (var i=0; i<messages.length; i++) {
			theImgs[i] = new Image();
				theImgs[i].src = messages[i][0];
		  }
		}

// to layout image and text, 2-row table, image centered in top cell
// these go in var tip in doTooltip function
// startStr goes before image, midStr goes between image and text
		var startStr = '<table width="' + tipWidth + '"><tr><td align="center" width="100%"><img src="';
		var midStr = '" border="1"></td></tr><tr><td valign="top">';
		var endStr = '</td></tr></table>';

////////////////////////////////////////////////////////////
//  initTip	- initialization for tooltip.
//		Global variables for tooltip. 
//		Set styles
//		Set up mousemove capture if tipFollowMouse set true.
////////////////////////////////////////////////////////////
		var tooltip, tipcss;
		function initTip() {
			if (nodyn) return;
			tooltip = (ns4)? document.tipDiv.document: (ie4)? document.all['tipDiv']: (ie5||ns5)? document.getElementById('tipDiv'): null;
			tipcss = (ns4)? document.tipDiv: tooltip.style;
			if (ie4||ie5||ns5) {	// ns4 would lose all this on rewrites
				tipcss.width = tipWidth+"px";
				tipcss.fontFamily = tipFontFamily;
				tipcss.fontSize = tipFontSize;
				tipcss.color = tipFontColor;
				tipcss.backgroundColor = tipBgColor;
				tipcss.borderColor = tipBorderColor;
				tipcss.borderWidth = tipBorderWidth+"px";
				tipcss.padding = tipPadding+"px";
				tipcss.borderStyle = tipBorderStyle;
			}
			if (tooltip&&tipFollowMouse) {
				if (ns4) document.captureEvents(Event.MOUSEMOVE);
				document.onmousemove = trackMouse;
			}
		}
		
		window.onload = initTip;

/////////////////////////////////////////////////
//  doTooltip function
//			Assembles content for tooltip and writes 
//			it to tipDiv
/////////////////////////////////////////////////
var t1,t2;	// for setTimeouts
var tipOn = false;	// check if over tooltip link
function doTooltip(evt,messages) {
	if (!tooltip) return;
	if (t1) clearTimeout(t1);	if (t2) clearTimeout(t2);
	tipOn = true;
	// set colors if included in messages array
curBgColor = tipBgColor;
curFontColor = tipFontColor;
	if (ie4||ie5||ns5) {
		var tip = startStr + messages + midStr + '<span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + curFontColor + ';">' + '' + '</span>' + endStr;
		tipcss.backgroundColor = curBgColor;
	 	tooltip.innerHTML = tip;
	}
	if (!tipFollowMouse) positionTip(evt);
	else t1=setTimeout("tipcss.visibility='visible'",100);
}

var mouseX, mouseY;
function trackMouse(evt) {
	standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
	mouseX = (ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft;
	mouseY = (ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop;
	if (tipOn) positionTip(evt);
}


/////////////////////////////////////////////////////////////
//  positionTip function
//		If tipFollowMouse set false, so trackMouse function
//		not being used, get position of mouseover event.
//		Calculations use mouseover event position, 
//		offset amounts and tooltip width to position
//		tooltip within window.
/////////////////////////////////////////////////////////////
		function positionTip(evt) {
			if (!tipFollowMouse) {
				mouseX = (ns4||ns5)? evt.pageX: window.event.clientX + document.body.scrollLeft;
				mouseY = (ns4||ns5)? evt.pageY: window.event.clientY + document.body.scrollTop;
			}
			// tooltip width and height
			var tpWd = (ns4)? tooltip.width: (ie4||ie5)? tooltip.clientWidth: tooltip.offsetWidth;
			var tpHt = (ns4)? tooltip.height: (ie4||ie5)? tooltip.clientHeight: tooltip.offsetHeight;
			// document area in view (subtract scrollbar width for ns)
			var winWd = (ns4||ns5)? window.innerWidth-20+window.pageXOffset: document.body.clientWidth+document.body.scrollLeft;
			var winHt = (ns4||ns5)? window.innerHeight-20+window.pageYOffset: document.body.clientHeight+document.body.scrollTop;
			// check mouse position against tip and window dimensions
			// and position the tooltip
			if ((mouseX+offX+tpWd)>winWd)
				tipcss.left = (ns4)? mouseX-(tpWd+offX): mouseX-(tpWd+offX)+"px";
			else tipcss.left = (ns4)? mouseX+offX: mouseX+offX+"px";
			if ((mouseY+offY+tpHt)>winHt)
				tipcss.top = (ns4)? winHt-(tpHt+offY): winHt-(tpHt+offY)+"px";
			else tipcss.top = (ns4)? mouseY+offY: mouseY+offY+"px";
			if (!tipFollowMouse) t1=setTimeout("tipcss.visibility='visible'",100);
		}
		
		function hideTip() {
			if (!tooltip) return;
			t2=setTimeout("tipcss.visibility='hidden'",100);
			tipOn = false;
		}
document.write('<div id="tipDiv" style="position:absolute; visibility:hidden; z-index:100"></div>')


///********* PARA BLOQQUERA EL BOTON DERECHO DEL MOUSE ****/////////

document.oncontextmenu = function() {
      return false
   }
   function right(e) {
      var msg = "NEtComp Soluciones Integrales IT\n         Derechos Reservados";
	  //var input ="<input name=usrname id=usrname type=text class=inputbox1 size=20 />"
      if (navigator.appName == 'Netscape' && e.which == 3) {
         alert(msg); //- Si no quieres asustar a tu usuario entonces quita esta linea...
         return false;
      }
      else if (navigator.appName == 'Microsoft Internet Explorer' && event.button==2) {
         alert(msg); //- Si no quieres asustar al usuario que utiliza IE,  entonces quita esta linea...
                        //- Aunque realmente se lo merezca...
      return false;
      }
   return true;
}
document.onmousedown = right;




/*********************************************************************************/
/******** Validar Formulario de Comentario ******************/

function comentario(){

   if(Trim($F('contacto'))==''){
	alert('Ingresar Nombre y Apellido del Contacto');
		document.getElementById('contacto').focus();
		return false;		
		 }
	if(Trim($F('empresa'))==''){
	alert('Ingresar Nombre de la Empresa');
		document.getElementById('empresa').focus();
		return false;		
		 }

    if(Trim($F('correo'))==''){
		alert('Ingresar Cuenta de Correo');
		document.getElementById('correo').focus();
		return false;		
	 }
	txt=document.getElementById('correo').value;
	if (txt.indexOf("@")<=2){
		alert("Lo siento, la cuenta de correo parece errónea. Por favor, "
		+" comprueba el prefijo y el signo '@'.");
		document.getElementById('correo').focus();
		return false;
	}
	if ((txt.indexOf(".com")<5)&&(txt.indexOf(".org")<5)
		&&(txt.indexOf(".gov")<5)&&(txt.indexOf(".net")<5)
		&&(txt.indexOf(".mil")<5)&&(txt.indexOf(".edu")<5)){
		alert("Lo siento. Pero esa cuenta de correo parece errónea. Por favor,"
		+" comprueba el sufijo (que debe incluir alguna terminación como: "
		+".com, .edu, .net, .org, .gov o .mil)");
		document.getElementById('correo').focus();
		return false;
	 }	
	if(Trim($F('consult'))=='0'){
			alert('Seleccionar Consulta');
			document.getElementById('consult').focus();
			return false;		
     }
	if(Trim($F('mensaje'))==''){
	alert('Ingresar Mensaje');
		document.getElementById('mensaje').focus();
		return false;		
	 }
 var info_emp ='';
        info_emp  = '&nombremail=' + $F('contacto')+ 
				    '&empresa='    + $F('empresa')+ 
					'&telf1='      + $F('telf1')+
					'&telf2='      + $F('telf2')+
					'&mails='      + $F('correo')+
				    '&descrip='    + $F('mensaje')+  
					'&consulta='   + $F('consult')+  
 				    '&insert=1' 
				
	/////////////////////////
	
	var PerDiv=document.getElementById("correo_emp");
	
		ajax=objetoAjax();
		ajax.open("POST","tpl/correo2.php", true);	
	//	alert(codigo);
		ajax.onreadystatechange=function()
		{
		 	 if (ajax.readyState==1)
			 {
		         PerDiv.innerHTML='';
		     }
		         else if (ajax.readyState==4)
			 {
		   		//divSug.innerHTML = null
				PerDiv.innerHTML = ajax.responseText;
		  	 }
		}
		ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		ajax.send(info_emp);
 /** Limpioar Formulario **/
 document.getElementById('contacto').value="";
 document.getElementById('empresa').value="";
 document.getElementById('telf1').value="";
 document.getElementById('telf2').value="";
 document.getElementById('correo').value="";
 document.getElementById('consult').value="0";
 document.getElementById('mensaje').value="";
 
 } 
 
 function ShowDiv(id){
 if($(id).style.display=='none'){
     $(id).style.display='';
}else{
   $(id).style.display='none';
    }
}

