SIV.addHandlers({	

	castVote : function(success, data) {
		
		if(success){
			
			$('#vote-html-container').html(data.html);
			
		}else{
			$('.sivform-loading').hide();
			$('.form-buttons').show();
			$('.sivform-error').html(data.error);
			$('.sivform-error').show()
		}
	}
});

$(function() {
	
	$('.top-links a').hover(function(ev){
		$(this).gx({'top': '+=25'}, 500, 'Linear'); 
	},function(){$(this).gx({'top': '-=25'},300, 'Linear')});
	
	$('#twitter').hover(function(ev){
		hover(this);
	})
	
	function hover(obj){
		$(obj).gx({'top':'-=25px'},600).gx({'top':'+=25px'},500,'Linear');
	}
	
	$('.more').click(function(ev){
		ev.target.blur();
		$('#links-container').gx({'top': -60}, 1000, 'Bounce:Out');
		$('#links-container').addClass('out');
	});
	
	$('#links-container').mouseleave(function(ev){
		if($('#links-container').hasClass('out')){
			$('#links-container').gx({'top': -310}, 1000, 'Bounce:Out');
			$('#links-container').removeClass('out')
		}
	})
	
	$('.poll-submit').click(function(ev){
		if($(this).hasClass('inactive')){
			return false;
		}
		if($(this).hasClass('voting')) return false;
		Set_Cookie('voted',true,2,'/','www.summer-holiday-sheffield.com');
		$('.poll-submit').addClass('voting');
		$('.poll-submit').html('<img src="/open/img/poll-load.gif" border="0"/>')
		SIV.ajaxCall({
			url: '/ajax/poll/castVote/',
			handler: 'castVote',
			form: 'poll-form'
		});
		return false;
		
	});
	
	$('.vote-radio').click(function(ev){
		$('.poll-submit').removeClass('inactive');
	});
	
	$('.timetable').click(function(ev){
		if ($(ev.target).hasClass('day-link')) {
			day = $(ev.target).attr('href');
			$(".timetable-day-container").hide();
			if(day != 'all'){
				$(".timetable-for-" + day).show()
			}else{
				$(".timetable-day-container").show();
			}
		}
		return false;
	});
	
	$('.cluetip').cluetip({
		  splitTitle: '|', 
		  arrows: true, 
		  dropShadow: false, 
		  cluetipClass: 'jtip'}
	);
	
})

function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}
