$(document).ready(function(){	
	if ($('.slider').length>0) {
		$('.slider UL').cycle({
			fx: 'scrollLeft',
			timeout: 0,
			prev:   '#prevBtn', 
    		next:   '#nextBtn', 
			after: onAfter,
			sync: true 
		});
	}
	function onAfter(curr,next,opts) {
		var caption = (opts.currSlide + 1) + ' van ' + opts.slideCount;
		$('#caption').html(caption);
	} 
	if ($('.slider-news').length>0) {
		$('.slider-news UL').cycle({
			fx: 'scrollLeft',
			timeout: 0,
			prev:   '#prevNews', 
    		next:   '#nextNews', 
			after: onAfterNews,
			sync: true 
		});
	}
	 function onAfterNews (curr,next,opts) {
	 	var cnt_news = $('.slider-news UL LI .news').addClass('active').length;
		var caption = (opts.currSlide * 3 + 3) + ' van ' + cnt_news;
		if ((opts.currSlide * 3 + 3) > cnt_news) {caption = cnt_news + ' van '+ cnt_news;}
		$('#caption').html(caption);
	} 
	
	
	
	$('#content .navigation LI.parent A').click(function(){
		window.location = this.href;
		
		if ($(this).parent().hasClass('open')) {
			$(this).parent().children('UL').css('display','none');
			$(this).parent().removeClass('open');
			
		}
		else {
			$(this).parent().children('UL').css('display','block');
			$(this).parent().addClass('open');
		}
		if ($(this).parent().hasClass('parent') && ($(this).parent().children('UL').length > 0)) {
			return false;
		}
	});
	
	$('.area').click (function(){
		if (($(this).children().children().children('.top').children('.text').length) > 0) {
			var area_cur = $(this);
			if ($(this).hasClass('open')) {
				$(this).children().children().children('.top').animate({height: 111},1000,function(){
					area_cur.removeClass('open');
				});
			}
			else {
				if ($('.area.open').length > 0) {
					var area_open = $('.area.open');
					area_open.children().children().children('.top').animate({height: 111},1000,function(){
						area_open.removeClass('open');
					});
				}
				var height_text = area_cur.children().children().children('.top').children('.text').height();
				var pos = area_cur.children().children().children('.top').children('.text').position();
				area_cur.addClass('open').children().children().children('.top').animate({height: pos.top+height_text+20},1000);
			}
		}
	});
	 
	 $('INPUT').click(function(){
		if ($(this).attr('value') == $(this).attr('title')) $(this).attr('value', '');
	});
	$('INPUT').blur(function(){
		if ($(this).attr('value') == '') $(this).attr('value', $(this).attr('title'));
	});
	 $('TEXTAREA').click(function(){
		if ($(this).attr('value') == $(this).attr('title')) $(this).attr('value', '');
	});
	$('TEXTAREA').blur(function(){
		if ($(this).attr('value') == '') $(this).attr('value', $(this).attr('title'));
	});
	
	// PJ: Open link in new window to avoid target="_blank" which causes invalid xhtml strict
	$(function(){    
		$('a.new-window').click(function(){
			window.open(this.href);        
	   		return false;    
	   	});
	});
});
