/*
 * Tooltip script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 


this.tooltip = function(){	
	/* CONFIG */		
		xOffset = 10;
		yOffset = 20;		
		active = 0;
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$("a.tooltip").mouseover(function(e){											  
	active = 1;
		this.t = this.rel;
		this.title = "";									  
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");
    },
	function(){
//		this.rel = this.t;		
		$("#tooltip").remove();
		active = 0;
    });	

	$("a.tooltip").mouseout(function(e){											  
		$("#tooltip").remove();
		active = 0;

});


	$("a.tooltip").mousemove(function(e){
if(!active) {
//alert(this.rel);
		this.t = this.rel;
		this.title = "";									  
		$("#tooltip").remove();
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
/*			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px") */
			.fadeIn("fast");		
}

		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};


// starting the script on page load
$(document).ready(function(){

/*$("img").each(function(i) {
this.title = 'your new alt text';
} ); */

tooltip();
});



function hidediv(id) {
    if(document.getElementById(id) != null) {
    	document.getElementById(id).style.display = 'none';
    }
}

function showdiv(id) {
    if(document.getElementById(id) != null) {
    	document.getElementById(id).style.display = 'block';
    }
}


function togglediv(id) {
    if(document.getElementById(id).style.display == 'none') {
        document.getElementById(id).style.display = 'block';
    } else {
        document.getElementById(id).style.display = 'none';
    }
}


//Change state

function overstate(nombreCapa){
    if(document.getElementById(nombreCapa) != null) {
    	document.getElementById(nombreCapa).className="overstat";
    }
}

function offstate(nombreCapa){
	document.getElementById(nombreCapa).className="offstat";
}


function overstatedouble(nombreCapa, nombreEnlace){
	document.getElementById(nombreCapa).className="overstat";
	document.getElementById(nombreEnlace).className="overlink";
}

function offstatedouble(nombreCapa, nombreEnlace){
	document.getElementById(nombreCapa).className="offstat";
	document.getElementById(nombreEnlace).className="offlink";
}


$(document).ready(function() {		
if(document.getElementById("")) slideShow();
});

$(document).ready(function() {
$('').submit(function() {

var te = encodeURIComponent(document.newsletter_subscribe.newsletter_email_address.value);

var u = "" + te + "";
var t = "";
var g = null;


//alert(u);
tb_show(t, u, g);
return false;
});
});

function slideShow() {

	//Set the opacity of all images to 0
	$('#gallery a').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('#gallery a:first').css({opacity: 1.0});
	
	//Set the caption background to semi-transparent
	$('#gallery .caption').css({opacity: 0.8});

	//Resize the width of the caption according to the image width
	$('#gallery .caption').css({width: $('#gallery a').find('img').css('width')});
	
	//Get the caption of the first image from REL attribute and display it
	$('#gallery .content').html($('#gallery a:first').find('img').attr('rel'))
	.animate({opacity: 0.8}, 400);
	
	//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('gallery()',8000);
	
}

function gallery() {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#gallery a.show')?  $('#gallery a.show') : $('#gallery a:first'));

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery a:first') :current.next()) : 
$('#gallery a:first'));	
	
	//Get next image caption
	var caption = next.find('img').attr('rel');	
	
	//Set the fade in effect for the next image, show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
	$('#gallery .content').html(caption);
}

function wyloguj() {

$.ajax({ url: "",  async: false });

var html = $.ajax({
  url: "ajax_topbar.php",
  async: false
 }).responseText;

if((window.location.href.indexOf("")!=-1) || (window.location.href.indexOf("")!=-1))
{
window.location.reload();
return false;
}

   $('#topbar').slideUp("normal",function() { $('#topbar').html(html); } );
   $('#topbar').slideDown("normanl", function() { tb_init('#topbar a.thickbox'); } );

}
