/* ccortes 
/********************************/
//carlos.cortes@kapitaldigital.com
/********************************/




var peticion = false;
 try {
  peticion = new XMLHttpRequest();
  } catch (trymicrosoft) {
  try {
		peticion = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (othermicrosoft) {
  try {
		peticion = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (failed) {
		peticion = false;
} 
}
}

if (!peticion)
  alert("ERROR AL INICIALIZAR!");

function cargar(fragment_url, element_id) 
{ 	var element = document.getElementById(element_id); 
	element.innerHTML = '<table width="470" height="250" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td align="center">&nbsp;</td></tr><tr><td height="20" align="center"><table width="100" border="0" cellpadding="0" cellspacing="0"><tr><td align="center"><img src="images/cargando.gif" width="20" height="20"/></td></tr><tr><td align="center" class="txt_bold">cargando</td></tr></table></td></tr><tr><td align="center">&nbsp;</td></tr></table>'; 
	peticion.open("GET", fragment_url); 
	peticion.onreadystatechange = function() { 
	if (peticion.readyState == 4) { 
		element.innerHTML = peticion.responseText; 
		
		
	} 
	} 
	peticion.send(null); 
}


//metodo post
function enviarFormulario(url,formid,element_id)
{
	var Formulario = document.getElementById(formid);
	var longitudFormulario = Formulario.elements.length;
	var cadenaFormulario = ""
	var sepCampos
	sepCampos = ""
	for (var i=0; i <= Formulario.elements.length-1;i++)
	{
	cadenaFormulario += sepCampos+Formulario.elements[i].name+'='+encodeURI(Formulario.elements[i].value);
	sepCampos="&";
	}
	//alert(cadenaFormulario);
	var element = document.getElementById(element_id);
	element.innerHTML = '<table width="100" border="0" cellpadding="0" cellspacing="0"><tr><td align="center"><img src="../images/cargando.gif" width="20" height="20"/></td></tr><tr><td align="center" class="texto">cargando</td></tr></table>'; 
	peticion.open("POST", url, true);
	peticion.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=ISO-8859-1');
	peticion.onreadystatechange = function () {
	if (peticion.readyState == 4) {
	element.innerHTML = peticion.responseText
	//document.getElementById('texto').innerHTML = "Los datos han sido enviados correctamente";
	}
	}
	peticion.send(cadenaFormulario);
}
var asistente="/ContacteAsistente/ContactoAsistente.aspx";
var contacto_web="/Contacto/Contacto.aspx";

function contacto(data) //creacion iframe dinamico 
{
var element = document.getElementById('camara');
element.innerHTML='<iframe frameborder="no"  src="'+data+'" height="600" width="100%" title="" name="" scrolling="no"></iframe>';

}


function ccs_block(dir,obj) //organigrama mostrar imagenes
{
	var elem = document.getElementById('ccs_img');
	var IE = document.all?true:false
	//alert(document.body.scrollTop);
	elem.style.top=document.body.scrollTop+100;
	//elem.style.top=y/5;
	elem.style.display='block';
	cargar(dir,obj);
	
}

function ccs_none()
{
	var elem = document.getElementById('ccs_img');
	elem.style.display='none';
}

function isEmail (s)
			{
				var i = 1;
				var sLength = s.length;
				while ((i < sLength) && (s.charAt(i) != "@"))
				{ i++
				}

				if ((i >= sLength) || (s.charAt(i) != "@")) return false;
				else i += 2;

				while ((i < sLength) && (s.charAt(i) != "."))
				{ i++
				}

				if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
				else return true;
			}
		
			function Valida ()
			{	
				if (document.Form1.Txt_Rut.value.length == 0){
					alert("Debe Ingresar Rut");
					document.Form1.Txt_Rut.focus();
					return false;
				}
				
				if (document.Form1.Txt_Nombre.value.length == 0){
					alert("Debe Ingresar Nombre");
					document.Form1.Txt_Nombre.focus();
					return false;
				}
				else if (document.Form1.Txt_Empresa.value.length == 0){
					alert("Debe Ingresar Empresa");
					document.Form1.Txt_Empresa.focus();
					return false;
				}
				/*else if (document.Form1.Txt_RutEmpresa.value.length == 0){
					alert("Debe Ingresar Rut Empresa");
					document.Form1.Txt_RutEmpresa.focus();
					return false;
				}*/
				else if (document.Form1.Txt_Telefono.value.length == 0){
					alert("Debe Ingresar Telefono");
					document.Form1.Txt_Telefono.focus();
					return false;
				}
				else if (document.Form1.producto.value == 0){
					alert("Seleccionar area de interes");
					document.Form1.producto.focus();
					return false;
				}
				else if ((document.Form1.Txt_Email.value.length != 0) && (! isEmail(document.Form1.Txt_Email.value))) {
					alert("Email Incorrecto");
					document.Form1.Txt_Email.focus();
					return false;
				}
				
				select_prod();// funcion rellena campo Txt_Fax se realiza de esta por no tener fuentes de la dll
				return true;
				
			}
			
			function clear_form ()
			{
			var Formulario = document.getElementById("Form1");
				for (var i=0; i <= Formulario.elements.length-1;i++)
				{
				Formulario.elements[i].value="";
				}
			}
			
function fal_pop()
{
	
}


var op_celda='';
function mouse_1(celda)
{
tab_div='tabla_'+op_celda;
tab_div2='tabla_'+celda;
if(celda != op_celda)
	{
	document.getElementById(celda).style.backgroundColor='#0176C6';
	document.getElementById(celda).style.color='#FFFFFF';
	if(op_celda!='')
	{
		document.getElementById(op_celda).style.backgroundColor='#FFFFFF';
		document.getElementById(op_celda).style.color='#666666';
		document.getElementById(tab_div).style.display='none';
	}
	document.getElementById(tab_div2).style.display='block';
	op_celda=celda;
	}
else
	{
	document.getElementById(celda).style.backgroundColor='#FFFFFF';	
	document.getElementById(celda).style.color='#666666';
	document.getElementById(tab_div2).style.display='none';
	op_celda="";
	}
}
			
			
var op_celda2='';

function mouse_2(celda)
{
tab_div='tabla_'+op_celda2;
tab_div2='tabla_'+celda;
if(celda != op_celda2)
	{
		
	document.getElementById(celda).style.backgroundColor='#0176C6';
	document.getElementById(celda).style.color='#FFFFFF';
	if(op_celda2!='')
	{
		
		document.getElementById(op_celda2).style.backgroundColor='#FFFFFF';
		document.getElementById(op_celda2).style.color='#666666';
		document.getElementById(tab_div).style.display='none';
	}
	document.getElementById(tab_div2).style.display='block';
	op_celda2=celda;
	}
else
	{
	document.getElementById(celda).style.backgroundColor='#FFFFFF';	
	document.getElementById(celda).style.color='#666666';
	document.getElementById(tab_div2).style.display='none';
	op_celda2="";
	}
}
			
function select_prod()
{
	valor1=document.getElementById('Txt_Fax').value;
	document.getElementById('Txt_Fax').value= valor1 + " - Producto : " + document.getElementById('producto').value;
			
	valor1="";
	valor1=document.getElementById('Txt_RutEmpresa').value;
	document.getElementById('Txt_RutEmpresa').value= valor1 + " - Rut Cliente : " + document.getElementById('Txt_Rut').value;
	
	valor1="";
	valor1=document.getElementById('Txt_Telefono').value;
	document.getElementById('Txt_Telefono').value= valor1 + " - Serial : " + document.getElementById('Txt_Serial').value;
	
	valor1="";
	valor1=document.getElementById('Txt_Ciudad').value;
	document.getElementById('Txt_Ciudad').value= valor1 + " - (CN) Nombre Certificado: " + document.getElementById('Txt_CN').value;
		
}
			
			
			//ccortes
