$(document).ready(function(){
	imagen_ale();
	if($('a.galeria').length > 0){
		$('a.galeria').showLightbox({speed:800});
	}
	if($('.qtips').length > 0){
	    $('.qtips').each(function(){
			if($(this).attr('rel')){
				//$(this).qtip({content:{text:'<img class="throbber" src="/projects/qtip/images/throbber.gif" alt="Loading..." />',ajax:{url:$(this).attr('rel')},title:{text:'Wikipedia - ' + $(this).text(),button:true}},position:{at:'bottom center',my:'top center',viewport:$(window),effect:false},show:{event:'click',solo:true},hide:'unfocus',style:{classes:'ui-tooltip-wiki ui-tooltip-light ui-tooltip-shadow'}}).click(function(event){event.preventDefault();}); 
			}else{
				$(this).qtip({style:{name:'cream',tip:true,border:{width:3,radius:8,color:'#6699CC'}},position:{adjust:{screen: true}},corner:{target:'topRight',tooltip:'bottomLeft'}});
			}
		});
	}
	
	/*if($('input:checkbox').length > 0){
		$('input:checkbox').checkbox({'cls':'jquery-safari-checkbox'});
	}
	
	if($('input:radio').length > 0){
		$('input:radio').checkbox({cls:'jquery-safari-checkbox'});
	}*/
	
	/*user_bar flotante*/
	if($('#user_bar_submenu').length > 0){
		$('#user_bar_submenu').mouseenter(function(){
			$(this).children().eq(1).show();
		}).mouseleave(function(){
			$(this).children().eq(1).hide();
		});
	}
	
	if($('#navigation a').length > 0){
		$(function() {
			var d=300;
			$('#navigation a').each(function(){
				$(this).stop().animate({
					'marginTop':'-80px'
				},d+=150);
			});
		
			$('#navigation > li').hover(
				function () {
					$('a',$(this)).stop().animate({
						'marginTop':'-2px'
					},200);
				},
				function () {
					$('a',$(this)).stop().animate({
						'marginTop':'-80px'
					},200);
				}
			);
		});
	}
});


function imagen_ale(){
	var img = Array('header1','header2');
	var header_aleatorio = Math.floor(Math.random()*(img.length))
	$('div.header1').removeClass()./*css('background','url("/images/'+img[header_aleatorio]+'") no-repeat scroll left top #579EC7').*/addClass(img[header_aleatorio]);
	return false;
}

function walert(message, title){

	$("#wpopup").remove();

	$("body").append("<div id='wpopup' title='" + title + "' style='display:none'><br />"+ message +"</div>");

	$('#wpopup').dialog({
		autoOpen: true,
		width: 500,
		buttons: {
			"Ok": function() { 
				$(this).dialog("close");
				$("#wpopup").remove();							
			}
		}
	});
};

function wconfirm(message, title, callback){

	var b = {};

	b["NO"] = function() { 
					$(this).dialog("close");
					$("#wpopup").remove();						
			    };

	b["SI"] = function() { 
					$(this).dialog("close");
					$("#wpopup").remove();
					if(callback) callback();					
				};

	$("#wpopup").remove();

	$("body").append("<div id='wpopup' title='" + title + "' style='display:none'><br />"+ message +"</div>");

	$('#wpopup').dialog({
		autoOpen: true,
		width: 500,
		buttons: b
	});
};

