(function($){
$(document).ready(function() {
	/* CUFON */
	//Cufon.replace('#menu a, #warea h2,', {hover: {color: '-linear-gradient(#ff9933, #ff3399 )'}});
	//Cufon.replace('#page .post h2, #page .page h2, #page h2', {color: '-linear-gradient(#ff9933, #ff3399 )',hover:{color:'#ff3399'}});
	//Cufon.replace('.gal_list a', {hover: {color: '-linear-gradient(#ff9933, #ff3399 )'}});
	//$('#topnav #menu a').animate({opacity:'1'},100);
	
	
	/* MAIN MENU */
	$('#menu>ul>li').hover(function(){
		$(this).addClass('on');
		$('ul',this).slideDown(200);
		
	},function(){		
		$('ul',this).slideUp(100);
		$(this).removeClass('on');
	});
	
	
	/* BOOKING FORM */
	$('a.cfbtn').toggle(function(){
		$('.wpcf7').fadeIn();return false;
	},function(){
		$('.wpcf7').fadeOut();return false;
	});
	
	/* BOOKING LINK */
	view = window.location.hash;
	if (view=="#cfbtn")	{
		$('a.cfbtn').click();
		$(window).scrollTop($('a.cfbtn').offset().top)
	}		
	
	
	/* PHOTO */
	if($('.gal').width()>0){
	$(".gal .mainpic .galp,").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	false
        });
	$('.post p a').click(function(){
		if( $(this).attr('href').substr(-4)=='.jpg' )
		{
		$.fancybox({
			'href'			: 	this.href,
			'transitionIn'	:	'elastic',
			'transitionOut'	:	'elastic',
			'speedIn'		:	600, 
			'speedOut'		:	200, 
			'overlayShow'	:	false
        });
		return false;
		}
	});
	$('.gal .thumbs img').click(function(){
		$('.gal .mainpic img').attr('src',$(this).attr('rel'));
		$('.gal .mainpic a').attr('href',$(this).attr('rel'));
		return false;
	});
	$('.gal .prev:not(.off)').live('click',function(){
		$('.gal .next').removeClass('off')
		ml=$('.gal .thumbs div').css('margin-top');
		ml=parseInt(ml)+102;
		if (ml<1) $('.gal .thumbs div').filter(':not(:animated)').animate({'marginTop':ml},600,function(){
			if (parseInt($('.gal .thumbs div').css('margin-top')) > -1 ) $('.gal .prev').hide();
			if ($('.gal .thumbs div').height() > 102) $('.gal .next').fadeIn('slow');
		});
		
	})
	$('.gal .next:not(.off)').live('click',function(){
		ml=$('.gal .thumbs div').css('margin-top');
		ml=parseInt(ml)-102;
		$('.gal .thumbs div').filter(':not(:animated)').animate({'marginTop':ml},600,function(){
			$('.gal .prev').fadeIn();
			if (parseInt($('.gal .thumbs div').height())+parseInt($('.gal .thumbs div').css('margin-top')) < 103) $('.gal .next').addClass('off').hide();
		});
		return false;
		
	});
	if (parseInt($('.gal .thumbs div img').size()) > 2) $('.gal .next').fadeIn('slow');
	}
	
	
	/* CLEAR INPUT */
	$('input:text, textarea').each(function(){
		var default_value = $(this).val();
		$(this).focus(function(){
			if ($(this).val() == default_value) $(this).val("");
		});
		$(this).blur(function(){
			if ($(this).val() == "") $(this).val(default_value);
		});
	});
	
	
	/* TARGET BLANK */
	$("a").filter(function() { return this.hostname && this.hostname !== location.hostname;}).attr('target', '_blank');
	
	
	
	/* NEWS TICKER */
	ntw=$('#social .news').width()-$('#social .news span').width();
	window.setInterval(function() {
		$('#social .news label .mq1').animate({'marginLeft':-$('#social .news .mq1').width()},6000);
		$('#social .news label .mq1').appendTo('#social .news label').css({'margin':'0'});
	}, 10000);
	
	
	/* SLIDER */
	$('#topslider').cycle({
		speed:  	1500,  
		pause:		0,
		timeout:	10000
	});
	if ($('#latestnews').width()>0){
	$('#latestnews div').cycle({
		fx:     'scrollLeft',
		speed:  20000,
		pause:	0,
		continuous:          1,
		timeout:       1,
		fit:           1
	});}
	
	/* HOVER BOX YSLIDER */
	$('#yslider .thumbs div img').click(function(){
		video=$(this).attr('rel');
		$('#yslider .video').html('<object class="flashvideo" type="application/x-shockwave-flash" data="http://www.youtube.com/v/'+video+'?color1=888888&amp;color2=888888"><param name="wmode" value="transparent"><param name="movie" value="http://www.youtube.com/'+video+'/<?php echo $video ?>?color1=696969&amp;color2=696969" /></object>');
		$('#yslider .thumbs div').removeClass('active');
		$(this).parent().parent().addClass('active');
	})
	$('#yslider .thumbs div .img').click(function(){return false;});
	
});

})(jQuery);;




