// JavaScript Document
if ((screen.width == 640) && (screen.height == 480)) 
alert ("ATENCIÓN!!\r\rLa resolución de pantalla que Ud. utiliza actualmente no le permitirá ver bien este sitio.\r\rPor favor, cambie la resolución a 800x600 o más.\r\r\rGracias.")

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;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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 limpia(campo){
if (campo=="user"){
	if(document.clientes.user.value=="usuario"){
		document.clientes.user.value="";
	}
}else if(campo=="password"){
	if(document.clientes.password.value=="password"){
		document.clientes.password.value="";
	}
}
}

function coloca(campo){
if (campo=="user"){
	if(document.clientes.user.value==""){
		document.clientes.user.value="usuario"
	}
}else if(campo=="password"){
	if(document.clientes.password.value==""){
		document.clientes.password.value="password"
	}
}
}

function verifica(){
	if(document.clientes.user=="usuario"){
		alert("Por favor ingrese NOMBRE DE USUARIO");
		return false;
	}else if(document.clientes.user=="password"){
		alert("Por favor ingrese PASSWORD");
		return false;
	}else{
	return true;
	document.clientes.submit();
	}	
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function checkdata(){
	if(document.cotizacion.nombre==""){
		alert("Debe incluir su nombre por favor.");
		
	}
	return false;
}

function popUp(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
if(myWidth=="" || myHeight==""){
		myWidth=680;
		myHeight=509;
	}
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}


function TRACKlink(CounterScript) {
  if (!document.createElement) { return true };
  var TRACKfrDoc;
  if (!TRACKfrObj && document.createElement) {
    try {
      var TRACKfrtemp=document.createElement('iframe');
      TRACKfrtemp.setAttribute('id','TRACKframe');
      TRACKfrtemp.style.border='0px';
      TRACKfrtemp.style.width='0px';
      TRACKfrtemp.style.height='0px';
      TRACKfrObj = document.body.appendChild(TRACKfrtemp);
      if (document.frames) {TRACKfrObj = document.frames['TRACKframe']; }
    }
    catch(exception) {
      TRACKhf='\<iframe id=" TRACKframe" style="';
      TRACKhf+='border:0px;';
      TRACKhf+='width:0px;';
      TRACKhf+='height:0px;';
      TRACKhf+='"><\/iframe>';
      document.body.innerHTML+= TRACKhf;
      TRACKfrObj = new Object();
      TRACKfrObj.document = new Object();
      TRACKfrObj.document.location = new Object();
      TRACKfrObj.document.location.iframe = document.getElementById('TRACKframe');
      TRACKfrObj.document.location.replace = function(location)
        { this.iframe.src = location; }
    }
  }
  if (navigator.userAgent.indexOf('Gecko') !=-1 && ! TRACKfrObj.contentDocument)
    {setTimeout(' TRACKtrack()',10); return false;}
  // Browser tipo/version NS6
  if (TRACKfrObj.contentDocument) {TRACKfrDoc = TRACKfrObj.contentDocument;}
  // Browser tipo/version IE5.5 & IE6
  else if (TRACKfrObj.contentWindow) {TRACKfrDoc = TRACKfrObj.contentWindow.document;}
  // Browser tipo/version IE5
  else if (TRACKfrObj.document) {TRACKfrDoc = TRACKfrObj.document;}
  else { return true; }
  TRACKfrDoc.location.replace(CounterScript);
  return false;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' debe ser un email válido.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' Debe ser un número.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' se requiere.\n'; }
  } if (errors) alert('Ocurrieron los siguientes errores:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function fuerzadisplay(ID,estado) {
		if(navigator.appVersion.indexOf("Win") != -1){
		cual = document.getElementById(ID).style;
		if (estado=="no") {
			cual.display = "none";
			cual.visibility = "hidden"
		}else {
			cual.display = "block";
			cual.visibility = "visible"
		}
		return false;		
	}
}

function chktipo(tipo){
	if (tipo=="Posicionamiento en Buscadores"){
		fuerzadisplay('url_sitio','si')
	}else{
		fuerzadisplay('url_sitio','no')
	}
}

function popUp(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
if(myWidth=="" || myHeight==""){
		myWidth=625;
		myHeight=420;
	}
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}

function saltoBlank(selObj){ 
 open(selObj);
}

function channel(pagina){

	window.open(pagina,"","channelmode")

}

function status(cliente,directorio,status) {
	var answer = confirm("Esta seguro que desea modificar el status de este directorio?")
	if (answer){
		window.location = "midif_directorio.asp?operacion=status&cliente="+cliente+"&directorio="+directorio+"&status="+status;
	}
	else{
		
	}
}

function pendiente(cliente,directorio) {
	var answer = confirm("Esta seguro que desea dejar este directorio en lista de pendientes?")
	if (answer){
		window.location = "midif_directorio.asp?operacion=pendiente&cliente="+cliente+"&directorio="+directorio;
	}
	else{
		
	}
}

function agregar(cliente,directorio) {
	var answer = confirm("Esta seguro que desea agregar este directorio en lista de trabajados?")
	if (answer){
		window.location = "midif_directorio.asp?operacion=agregar&cliente="+cliente+"&directorio="+directorio;
	}
	else{
		
	}
}

function ClipBoard(cual) 
{
holdtext.innerText = cual.innerText;
Copied = holdtext.createTextRange();
Copied.execCommand("Copy");
alert("Texto copiado: "+cual.innerText);
}

function checkaddurl(){
	if(document.addurlform.url=="http://"){
		alert("Debe incluir la URL de su sitio");	
		return false;
	}
	if(document.addurlform.url_reciproca!=""){
		var urlreciproca=document.addurlform.url_reciproca;
		var url_upper=urlreciproca.toUpperCase(); 
			if (url_upper=="HTTP://WWW.MEDIATOOLS.CL" || url_upper=="WWW.MEDIATOOLS.CL"){
				alert("La URL reciproca no puede ser "+urlreciproca);
				return false;
			}

	}else{
		alert("Debe incluir una URL reciproca");
		return false;
	}
}

function validawidget(){
	
	if (document.widget.url.value==""){
		alert("Se requiere la URL en donde deseas instalar el Widget");
		document.widget.url.focus();
		return false;
	}
	if (document.widget.Como_Supo.value=="0"){
		alert("Como supiste de nosotros?");
		document.widget.Como_Supo.focus();
		return false;
	}	
}

function cargaGENERICA(url,valor,div) {
	//  Primero vamos a ver si la URL es una URL :)
	eldiv=div;
    //  Usuario inteligente...
    if (window.XMLHttpRequest) {
        reqgenerico = new XMLHttpRequest();
        reqgenerico.onreadystatechange = processReqGenerico;
        reqgenerico.open("GET", url+"?valor="+ valor, true);
        reqgenerico.send(null);
		//alert(window.XMLHttpRequest)
    //  ...y usuario de Internet Explorer Windows
    } else if (window.ActiveXObject) {
        isIE = true;
        reqgenerico = new ActiveXObject("Microsoft.XMLHTTP");
        if (reqgenerico) {
            reqgenerico.onreadystatechange = processReqGenerico;
            reqgenerico.open("GET", url+"?valor="+ valor, true);
            reqgenerico.send();
        }
    }
}


function processReqGenerico(){
// Referencia a nuestro DIV con ID unica:

var detalles = document.getElementById(eldiv); 
// Si se ha completado la carga de datos, los mostramos en el DIV...
if(reqgenerico.readyState == 4){
	cadena=unescape(reqgenerico.responseText);
	cadenafinal=cadena.replace(/\+/gi," ");
detalles.innerHTML = cadenafinal;
} else {
// ...en caso contrario, le diremos al usuario que los estamos cargando:
detalles.innerHTML = "<img src='img/loading.gif'/><b>Cargando...</b>";
}
}

function ajaxInsertPagerankScript(indice) {
    //  Usuario inteligente...
div="insertScript"+indice;
    if (window.XMLHttpRequest) {
        reqInsertScript = new XMLHttpRequest();
        reqInsertScript.onreadystatechange = processAjaxInsertScript;
        reqInsertScript.open("GET", "http://www.mediatools.cl/insert_pagerank_script.php?valor="+indice, true);
        reqInsertScript.send(null);
		//alert(window.XMLHttpRequest)
    //  ...y usuario de Internet Explorer Windows
    } else if (window.ActiveXObject) {
        isIE = true;
        reqInsertScript = new ActiveXObject("Microsoft.XMLHTTP");
        if (reqInsertScript) {
            reqInsertScript.onreadystatechange = processAjaxInsertScript;
            reqInsertScript.open("GET","http://www.mediatools.cl/insert_pagerank_script.php?valor="+indice, true);
            reqInsertScript.send();
        }
    }
}


function processAjaxInsertScript(){
	//alert("Gracias");

var detalles = document.getElementById(div); 
// Si se ha completado la carga de datos, los mostramos en el DIV...
if(reqInsertScript.readyState == 4){
detalles.innerHTML = reqInsertScript.responseText;
} else {
// ...en caso contrario, le diremos al usuario que los estamos cargando:
detalles.innerHTML = "Grabando";
}
}

function informa_url_medidor(ultimo,url) {
    //  Usuario inteligente...
    if (window.XMLHttpRequest) {
        reqInsertScript = new XMLHttpRequest();
        reqInsertScript.onreadystatechange = processAjaxInforma;
        reqInsertScript.open("GET", "http://www.mediatools.cl/informa_url_medidor.php?valor="+ultimo+"&url="+url, true);
        reqInsertScript.send(null);
		//alert(window.XMLHttpRequest)
    //  ...y usuario de Internet Explorer Windows
    } else if (window.ActiveXObject) {
        isIE = true;
        reqInsertScript = new ActiveXObject("Microsoft.XMLHTTP");
        if (reqInsertScript) {
            reqInsertScript.onreadystatechange = processAjaxInforma;
            reqInsertScript.open("GET","http://www.mediatools.cl/informa_url_medidor.php?valor="+ultimo+"&url="+url, true);
            reqInsertScript.send();
        }
    }
}


function processAjaxInforma(){
	//alert("Gracias");

var detalles = document.getElementById("informa_url"); 
// Si se ha completado la carga de datos, los mostramos en el DIV...
if(reqInsertScript.readyState == 4){
detalles.innerHTML = reqInsertScript.responseText;
} else {
// ...en caso contrario, le diremos al usuario que los estamos cargando:
detalles.innerHTML = "Grabando";
}
}
