$(document).ready(function() {

	Cufon.replace('.cz #intro li strong,.en #intro li strong',{ fontFamily: 'Eurostile CE',textShadow: '#ab4c05 1px 2px'});
	Cufon.replace('.cz #intro li .caption,.en #intro li .caption',{ fontFamily: 'Eurostile CE Demi',textShadow: '#ff8732 1px 1px'});
	Cufon.replace('.cz #nav .cufon,.en #nav .cufon,#aside .title', {fontFamily: 'Eurostile CE Demi',hover:true});

/* target blank */
$("a[rel=external]").attr("target","_blank");

/* infield labels */
$("#newsletter label").inFieldLabels({ fadeOpacity: 0.4 });


/* hover state for top menu */
	$('#nav td').hover(
		function(){$(this).addClass("hover");},
		function(){$(this).removeClass("hover");}
	);

	$('#nav .level2 li').hover(
		function(){$(this).addClass("hover");},
		function(){$(this).removeClass("hover");}
	);

	$('#nav').mouseleave(function(){
		Cufon.refresh();
	});


/* hover state for intro block */
	$('#intro li').hover(
		function(){$('#intro ul').addClass($(this).attr("class"));$(this).addClass("hover");},
		function(){$('#intro ul').removeClass();$(this).removeClass("hover");}
	);

	$('#intro li').click(function(){
		var link = $(this).children("p").children("a").attr("href");
		location.href=link;
	});

/* parsing rss feed - wrap pairs and make columns */
	$("#rssfeed h4").each(function(){
		el1 = $(this);
		el2 = $(this).next("p");
		el = $("<div class='rss' />");
		el.append(el1);
		el.append(el2);
		$("#rssoutput").append(el);
	});

/* zebra tables */
	$(".article .table tr").filter(":even").addClass("even");
	$(".list tr").hover(
   		function(){$(this).addClass("hover");},
		function(){$(this).removeClass("hover");}
	);

/* forms */
	$(".form .text input").focus(function(){
		$(this).parent("td").addClass("inputfocus");
	});

	$(".form .text input").focusout(function(){
		$(this).parent("td").removeClass("inputfocus");
	});

	$(".form textarea").focus(function(){
		$(this).parent("td").addClass("textareafocus");
	});

	$(".form textarea").focusout(function(){
		$(this).parent("td").removeClass("textareafocus");
	});

	$("#customformElement4").parent("td").removeClass("text").addClass('textarea');

	$("#newsletter .text input").focus(function(){
		$(this).parent("span").addClass("inputfocus");
	});

	$("#newsletter .text input").focusout(function(){
		$(this).parent("span").removeClass("inputfocus");
	});

/* lightbox */
	$('a.lightbox').nyroModal();

	/* back button in gallery */
	$('.gallerydetail .back a').click(function(){
		history.go(-1);
		return false;
	});
	
	/* send button in table in student/results page */
	$('a.send_exam').click(function(){
		$('.classification_form').show("slow");
		$('#moduleId').val($(this).attr('id'));
		return false;
	});
	
/* send button in table in student/classification page */
	$('a.send_classification').click(function(){
		$('.classification_form').show("slow");
		$('#examId').val($(this).attr('id'));
		return false;
	});
	
	if(!$('.error').size())
	{
		$('.classification_form').hide();
	}

});
