/******************************************************************************
* web.js
*
* Scripts generals per la web
*
*	Albert Sunyer @ Soluciones Multimedia Tec (SMTec) 2009 | http://www.smtec.es
******************************************************************************/
var myWin;

var WEB={
	logout:function(){
		window.location='../index.php?acc=logout';
	},
	popup:function(url, id){
		if(!myWin || myWin.closed){
			myWin = window.open(''+url+'',''+id+'','width='+screen.width+',height='+screen.height+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=0,left=0');
		}else{
			myWin.focus();
		};
		
		void(0); 
	},
	popupWH:function(url, id, w, h){
		if(!myWin || myWin.closed){
			myWin = window.open(''+url+'',''+id+'','width='+w+',height='+h+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top='+((screen.height/2)-(w/2))+',left='+((screen.width/2) - (h/2)) + '');
		}else{
			myWin.focus();
		};
		
		void(0); 
	}
}

$(document).ready(function(){
	/** Enllaços generals *******************************/
	$('a[rel="external"]').click(function(){
		window.open(''+this.href+'');
		return false;
	});
	
	$('a[rel="popup"]').click(function(){
		WEB.popupWH(''+this.href+'', 'legal', 500, 600);
		return false;
	});
	
	/* RANKING */
	$('#desplegar').click(function(){
		var r=$('#ranking');
		var l=$(this);
		
		if(r.height()>200){
			r.animate({height:126, top:4, bottom:0}, 'normal', function(){ l.removeClass('down'); });
			$('#footer').animate({top:0}, 'normal');
		}else{
			r.animate({height:290, top:-160, bottom:0}, 'normal', function(){ l.addClass('down'); });
			$('#footer').animate({top:-160}, 'normal');
		}
		
		return false;
	});
});