jQuery.noConflict();
(function($) { 
$(function() {



(jQuery)(document).ready( function() {
	
	(jQuery)("#imagenes a").append("<span></span>");
            (jQuery)("#imagenes a").hover(function(){
                (jQuery)(this).children("span").stop(true,true).fadeIn(600);
            },function(){
                (jQuery)(this).children("span").stop(true,true).fadeOut(200);
            });

	    
	    $(".buttonimportant").hover(function(){
        $(".buttonimportant img")
            // first jump  
            .animate({top:"-10px"}, 200).animate({top:"-4px"}, 200)
            // second jump
            .animate({top:"-7px"}, 100).animate({top:"-4px"}, 100)
            // the last jump
            .animate({top:"-6px"}, 100).animate({top:"-4px"}, 100);
    });
	    

(jQuery)('.indexfour').not('#ultimas').fadeTo("slow",0.4);


(jQuery)('.indexfour').click( function() {

 (jQuery)('.indexfour').not(this).fadeTo("slow",0.4);
 
 (jQuery)(this).fadeTo("slow",1.0);
 
 
});

	(jQuery)('input').focus( function() { 
	
(jQuery)(this).css('background-color','#F0F8FF');
	
}); 

(jQuery)('input').blur( function() { 
	
(jQuery)(this).css('background-color','#FFFFFF');
	
}); 

(jQuery)('textarea').focus( function() { 
	
(jQuery)(this).css('background-color','#F0F8FF');
	
}); 

(jQuery)('textarea').blur( function() { 
	
(jQuery)(this).css('background-color','#FFFFFF');
	
}); 






});

});

})(jQuery);


function nuevoAjax(){
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 time(){
		var misesion = document.getElementById("misesion");
		var r;
		ajax=nuevoAjax();
		ajax.open("GET", "notif.php",true);
		ajax.onreadystatechange=function() {
		if (misesion) {
		if (ajax.readyState==4) {
		r = Number(ajax.responseText);
		if (r > 0) { document.getElementById("misesion").style.color = "red";
		document.getElementById("misesion").firstChild.firstChild.data = "Mi Sesión " + "(" + r + ")"; }
		else
		document.getElementById("misesion").firstChild.firstChild.data = "Mi Sesión";
		} 
		else { document.getElementById("misesion").firstChild.firstChild.data = "..."; }
		}
		}
		ajax.send(null)
setTimeout('time();',60000);
}

function changeDesc(url) {
ajax=nuevoAjax();
ajax.open("GET", "description.php"+"?url="+url ,true);
ajax.onreadystatechange=function() {
  if ((ajax.readyState==4) && (ajax.status==200)) {
    var x = ajax.responseXML.getElementsByTagName("desc");
    txt = x[0].firstChild.nodeValue;
    toggleshow(txt);
    }
    else { document.getElementById("descripcion").innerHTML = "..."; }
  
  }

ajax.send();
}


function pinta(){
	tabla=document.getElementById("tablaindex").rows;

	for(a=0;a<tabla.length;a++){
		color(a);
	}

	tabla=document.getElementById("tablaindex2").rows;
	
	for(a=0;a<tabla.length;a++){
		color2(a);
	}

}
function color2(b){
	if(b%2==0)
		tabla[b].style.backgroundColor="#E6E6FA";
	else
		tabla[b].style.backgroundColor="#FFFFFF";
}

function color(b){
	if(b%2==0)
		tabla[b].style.backgroundColor="#ADD8E6";
	else
		tabla[b].style.backgroundColor="#F0F8FF";
}


function cargarportada(boldelement) {
jQuery.noConflict();
(function($) { 
$(function() {
// more code using $ as alias to jQuery

ajax=nuevoAjax();
ajax.open("GET", "thumb.php"+"?tipo="+boldelement ,true);
ajax.onreadystatechange=function() {
  if ((ajax.readyState==4) && (ajax.status==200)) {
    urls = ajax.responseXML.getElementsByTagName("url");
    users = ajax.responseXML.getElementsByTagName("user");
    (jQuery)('#img1').hide();
    (jQuery)('#img1').attr("src",urls[0].firstChild.nodeValue + ".th");
    (jQuery)('#link1').attr("href","show.php?name=" + urls[0].firstChild.nodeValue);
    (jQuery)('#p1').text(users[0].firstChild.nodeValue);
    (jQuery)('#img1').show("slow");
    (jQuery)('#img2').hide();
    (jQuery)('#img2').attr("src", urls[1].firstChild.nodeValue + ".th");
    (jQuery)('#link2').attr("href", "show.php?name=" + urls[1].firstChild.nodeValue);
    (jQuery)('#p2').text(users[1].firstChild.nodeValue);
    (jQuery)('#img2').show("slow");
    (jQuery)('#img3').hide();
    (jQuery)('#img3').attr("src", urls[2].firstChild.nodeValue + ".th");
    (jQuery)('#link3').attr("href", "show.php?name=" + urls[2].firstChild.nodeValue);
    (jQuery)('#p3').text(users[2].firstChild.nodeValue);
    (jQuery)('#img3').show("slow");
    (jQuery)('#img4').hide();
    (jQuery)('#img4').attr("src",urls[3].firstChild.nodeValue + ".th");
    (jQuery)('#link4').attr("href", "show.php?name=" + urls[3].firstChild.nodeValue);
    (jQuery)('#p4').text(users[3].firstChild.nodeValue);
    (jQuery)('#img4').show("slow");
    
    }
    else {  }
  
  }

ajax.send();
});
})(jQuery);
// other code using $ as an alias to the other library

if (boldelement != 'masvisitados') { document.getElementById("ultimas").style.fontWeight="Bold"; document.getElementById("masvisitados").style.fontWeight=""; }
else { document.getElementById("masvisitados").style.fontWeight="Bold"; document.getElementById("ultimas").style.fontWeight=""; }
}

function echoregistrarse()
{
document.getElementById("welcome").innerHTML="¿De que sirve registrarse? Podrás subir y comentar las imágenes que desees sin limitación. Tambien recibir puntaje por tus aportes y personalizar tus comentarios!";
}
function echobienvenido()
{
document.getElementById("welcome").innerHTML="Bienvenidos a <strong>ScreenTube</strong>, aqui podrás por ahora, compartir los <strong>screenshots</strong> de tu Desktop (Escritorio), tus Juegos y tu Computadora. <strong>(¿No sabes cómo? <a href=\"howto.php\">entrá</a>)</strong> Aclaración: Eviten subir imágenes fuera de la tematica de la pagina, o stats de sus partidas en los juegos.";
}

function login_box() {

jQuery.noConflict();
(function($) { 
$(function() {
// more code using $ as alias to jQuery

(jQuery)("#loginbox").slideToggle("slow");
setTimeout("document.getElementById('login_input').focus();",800);
});
})(jQuery);

// other code using $ as an alias to the other library
//var lg=document.getElementById("loginbox");
//alert("a");
//if (lg.style.visibility != 'visible') { lg.style.visibility = "visible"; document.getElementById("login_input").focus(); }
//else { lg.style.visibility = 'hidden'; } 
}

function toggleshow(txt){

var editar = document.getElementById("newdesc");
if (editar.style.visibility == "hidden") { 
editar.style.visibility = "visible";
editar.style.display = "";
document.getElementById("newdesctextarea").value = txt.replace(/<br>/gi,'\r');
document.getElementById("descripcion").innerHTML = "";
 }
else {
editar.style.visibility = "hidden";
editar.style.display = "none";
document.getElementById("descripcion").innerHTML = document.getElementById("newdesctextarea").value.replace(/\n/gi,"<br>");
document.getElementById("newdesctextarea").value = "";
 }
 }

function writesmiley(smiley,caja) {
var cajatmp = document.getElementById(caja);
cajatmp.focus();
cajatmp.value = cajatmp.value + smiley + " ";
}

function tags(text,caja){
var texto= prompt("Texto?","");
document.getElementById(caja).value = document.getElementById(caja).value + '[b]' + texto + '[/b]';
}

function insertimg(caja){
var texto= window.prompt("Dirección URL de la imagen?","http://");
if (texto)
document.getElementById(caja).value = document.getElementById(caja).value + '[img]' + texto + '[/img]';
}
function insertyt(caja){
var texto= window.prompt("Ingrese el ID del video de YouTube: \rEjemplo: \rSi la URL de su video es:\rhttp://www.youtube.com/watch?v=AbCdE54321&screen \rEl ID es: AbCdE54321","Solo el ID del video YouTube");
if (texto)
document.getElementById(caja).value = document.getElementById(caja).value + '[youtube]' + texto + '[/youtube]';
}



