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 $(el) {
  return document.getElementById(el);
}

var x = 0; 
var Tiempo; 
function aparecer(e){
x++;
if(x < 101){
$(e).style.opacity = (x/100);
$(e).style.filter = 'alpha(opacity=' + x + ')';
(x >= 10) ? $(e).style.display = 'block' : '';
Tiempo = setTimeout("aparecer('"+e+"')",10); 
} else {clearTimeout(Tiempo); }
}

var x = 100;
function desaparecer(e){
x = x-1;
if(x <= 100 && x > 0){
$(e).style.opacity = x/100;
$(e).style.filter = 'alpha(opacity=' + x+ ')';
Tiempo = setTimeout("desaparecer('"+e+"')",10); 
(x <= 5) ? $(e).style.display = 'none' : '';
} else {clearTimeout(Tiempo); }
}


function efecto_aparece(i){ 
x = 5; 
setTimeout("aparecer('"+i+"')",1);
}

function efecto_desaparce(i){ 
x = 95; 
setTimeout("desaparecer('"+i+"')",1);
}



var x = 2500;
function desaparecer_dos(e){
x = x-1;
if(x <= 2500 && x > 0){
Tiempo = setTimeout("desaparecer_dos('"+e+"')",2); 
	if(x <= 5){
	$(e).style.display = 'none';
	$('contenido_ver').style.display = 'block';
	}
} else {clearTimeout(Tiempo); }
}


function efecto_desaparce_dos(i){ 
x = 2500; 
setTimeout("desaparecer_dos('"+i+"')",1);
}


function verRap(e){
	$(e).style.display = 'none';
	$('contenido_ver').style.display = 'block';
	}

function VerMasC(capa,value) {
  $(capa).innerHTML = '<center><br /><br /><img src="./imagenes/loading.gif" /><br /><br /></center>';
  MiAjax=objetoAjax();
var url = "./pro.ajax.php" + value;
MiAjax.open("GET", url, true);
MiAjax.onreadystatechange = function() {
  if (MiAjax.readyState == 4) {
	  if (MiAjax.status == 200) {
		var Respuesta = MiAjax.responseText;
		$(capa).innerHTML = Respuesta;
		efecto_aparece(capa);
	  }
  }
}
MiAjax.send(null);
}


function Buscar(capa,value,id) {
var q = $(id).value;
  MiAjax=objetoAjax();
var url = "./pro.ajax.php" + value + q;
MiAjax.open("GET", url, true);
MiAjax.onreadystatechange = function() {
  if (MiAjax.readyState == 4) {
	  if (MiAjax.status == 200) {
		var Respuesta = MiAjax.responseText;
		$(capa).innerHTML = Respuesta;
		efecto_aparece(capa);
	  }
  }
}
MiAjax.send(null);
}



function enviar_comentario(){
var c_id = $('id_cont').value; var c_nombre = $('Nombre').value; var c_correo = $('Correo').value; var c_contenido = $('Contenido').value;
if(c_nombre != ''){
  MiAjax=objetoAjax();
MiAjax.open("POST", "./pro.ajax.php", true);
MiAjax.onreadystatechange = function() {
  if (MiAjax.readyState == 4) {
	  if (MiAjax.status == 200) {
		var Respuesta = MiAjax.responseText;
		$('Nuevo_Comentario').innerHTML = Respuesta;
		$('id_cont').value = ''; $('Nombre').value = ''; $('Correo').value = ''; $('Contenido').value = '';
		efecto_aparece('Nuevo_Comentario');
	  }
  }
}
MiAjax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
MiAjax.send("c_id=" + c_id + "&c_nombre=" + c_nombre + "&correo=" + c_correo+ "&c_comentatario=" + c_contenido);
}
}



function antiboot() {
if($('seguridad').value == ''){
fuente = $('seguridad').value = 'seguridad';
MiAjax=objetoAjax();
var url = "./pro.ajax.php?7a5a7a5a7a=Seguridad";
MiAjax.open("GET", url, true);
MiAjax.onreadystatechange = function() {
  if (MiAjax.readyState == 4) {
	  if (MiAjax.status == 200) {
		var Respuesta = MiAjax.responseText;
		$('seguridad').value = Respuesta;
	  }
  }
}

MiAjax.send(null);
}}

function fbs_click(){
u=location.href;
t=document.title;
window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
return false;
}

function twi(){
u=location.href;
t=document.title;
window.open('http://twitter.com/home?status='+encodeURIComponent(t+" ( "+u+" )"),'sharer','toolbar=0,status=0,width=840,height=500');
return false;
}

function AlertM(server,seguro){
	VerMasC("contenido_ver","?server="+ server + "&width=653&height=422&afirmar=" + seguro)
	efecto_desaparce('mensaje_alert');
	efecto_aparece('contenido_ver');
}

function check(browser){
  document.getElementById("img_url").value=browser;
  }


function ComtFB(){
	$('commFB').style.display = 'block';
	$('Nuevo_Comentario').style.display = 'none';
	$('treFB').style.display = 'none';
	}

var Inicio = true;
function HomePage(e){
		if(Inicio){
            if (document.all) {
                e.style.behavior='url(#default#homepage)';
                e.setHomePage('http://www.goinicio.info');
            } 
        return true;
	} else {return true;}
}


function crear_pag(total,pag){
var code = "";
var num = ((pag+4) > total  ? total : pag+4)
for(var i = (pag-4); i <=  num  ; i++){
		if(i > 0){
	if(pag == i){
	code += '<li class="active" ><a onClick="return false;" href="">Parte ' + i +'</a></li>';
	}else{
	code += '<li><a href="" onClick="crear_pag('+total+',' + i + '); return false;">Parte ' + i + '</a></li>';
	}
		}
}
$('paginacion').innerHTML = code;
cambioDIV('part_',null,pag,total);
}

function cambioDIV(div,op,id,total){
for(var i = 1; i <=  total ; i++){
	if(id==i){
	$( div + id ).style.display="block";
	(op != null) ? $( op + i ).className="select" : "";
	} else { 
	$( div + i ).style.display="none";
	(op != null) ? $( op + i ).className="" : "";
	}
}
}


function statusCopy(){
  FB.ui(
   {
     method: 'stream.publish',
     message: 'Me Gusta esta pelicula dale click aqui -> ' + location.href
   }
  );
}


var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf(" chrome/") >= 0 || ua.indexOf(" firefox/") >= 0 || ua.indexOf(' gecko/') >= 0) {
	var StringMaker = function () {
		this.str = "";
		this.length = 0;
		this.append = function (s) {
			this.str += s;
			this.length += s.length;
		}
		this.prepend = function (s) {
			this.str = s + this.str;
			this.length += s.length;
		}
		this.toString = function () {
			return this.str;
		}
	}
} else {
	var StringMaker = function () {
		this.parts = [];
		this.length = 0;
		this.append = function (s) {
			this.parts.push(s);
			this.length += s.length;
		}
		this.prepend = function (s) {
			this.parts.unshift(s);
			this.length += s.length;
		}
		this.toString = function () {
			return this.parts.join('');
		}
	}
}


var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

function decode64(input) {
	var output = new StringMaker();
	var chr1, chr2, chr3;
	var enc1, enc2, enc3, enc4;
	var i = 0;

	// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
	input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

	while (i < input.length) {
		enc1 = keyStr.indexOf(input.charAt(i++));
		enc2 = keyStr.indexOf(input.charAt(i++));
		enc3 = keyStr.indexOf(input.charAt(i++));
		enc4 = keyStr.indexOf(input.charAt(i++));

		chr1 = (enc1 << 2) | (enc2 >> 4);
		chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
		chr3 = ((enc3 & 3) << 6) | enc4;

		output.append(String.fromCharCode(chr1));

		if (enc3 != 64) {
			output.append(String.fromCharCode(chr2));
		}
		if (enc4 != 64) {
			output.append(String.fromCharCode(chr3));
		}
	}

	return output.toString();
}
