Cufon.replace('#lang', { hover: true } );
Cufon.replace('#nav a', { hover: true } );
Cufon.replace('h1,h2,h3,h4');


$(document).ready( function() {
	
	$("input[type=text], input[type=password], textarea").focus( function() {
		if ( $(this).val() == $(this).attr("title") ) {
			$(this).val("")
		}
	}).blur( function() {
		if ( $(this).val() == '' ) {
			$(this).val( $(this).attr("title") );
		}
	});
	
	// fotogaleria
	$("#nextFoto").click( function() {
		showPreviev( $(this).attr("rel"), $(this).attr("href") );
		return false;
	});
	
	$("#prevFoto").click( function() {
		showPreviev( $(this).attr("rel"), $(this).attr("href") );
		return false;
	});
	
	$("#nl_email").focus( function() {
		if ( $(this).val() == $(this).attr("title") ) {
			$(this).val("")
		}
	}).blur( function() {
		if ( $(this).val() == '' ) {
			$(this).val( $(this).attr("title") );
		}
	});
	
	
	$(".lista").click( function() {
		var id = $(this).attr("rel");
		$("#stos_"+id).hide();
		$("#lista_"+id).show();
		return false;
	});
	
	$(".stos").click( function() {
		var id = $(this).attr("rel");
		$("#stos_"+id).show();
		$("#lista_"+id).hide();
		return false;
	});
	
	
	$("a.fancyimage").fancybox({
		'hideOnContentClick': true,
		'zoomSpeedIn': 300,
		'zoomSpeedOut':	300,
		'overlayOpacity':0.7,
		'overlayColor':'#000'
	});
	
	
	$("a.fancyframe").fancybox({
		'zoomSpeedIn':0,
		'zoomSpeedOut':	0,		
		'overlayOpacity':0.7,
		'overlayColor':'#111',
		'frameWidth':600,
		'frameHeight':450,
		'showCloseButton': true,
		'hideOnOverlayClick': false,
		'hideOnContentClick': false,
		'callbackOnClose':function()
		{
			location.reload();
		}
	});
	
});


function showPreviev( gal,cur ) {
	var prev = parseInt(cur)-1;
	var next = parseInt(cur)+1;
	
	if ( fotki[gal][cur] != '' ) {
		$("#foto_"+gal+" a img").attr( 'src', $("#thumb_"+fotki[gal][cur]).attr("src").replace(/thumb0_/, "thumb1_") );
	}
	
	$("#nextFoto").attr("href",next);
	$("#prevFoto").attr("href",prev);
	
	if ( typeof fotki[gal][next] == 'undefined' ) {
		$("#nextFoto").hide();
	} else {
		$("#nextFoto").show();
	}
	if ( typeof fotki[gal][prev] == 'undefined' ) {
		$("#prevFoto").hide();
	} else {
		$("#prevFoto").show();
	}
	return false;
}

function getPoll( poll, what ) {
	$.ajax({
		url: "/_ajax/poll.php?method=get&poll="+poll+"&what="+( what=='result' ? 'result' : 'form' ),
		type: "GET",
		cache: false,
		success: function( data ) {
			$("#poll_"+poll).html(data);
		}
	});
}

function setPoll( poll ) {
	var answer = $("#poll_"+poll+" form").find("input[type=radio][checked]").val();
	if ( typeof answer != 'undefined' ) {
		$.ajax({
			url: "/_ajax/poll.php?method=set&poll="+poll+"&answer="+answer,
			type: "GET",
			cache: false,
			success: function( data ) {
				$("#poll_"+poll).html(data);
			}
		});
	}
}
