if (window!= top)
top.location.href=location.href

$(document).ready(function(){
	$('label#label_email').css({display: 'block'});
	$('label#label_password').css({display: 'block'});
	
	$('input.email').focus(function(){
		$('label#label_email').css({display: 'none'});
	});
	
	$('input.password').focus(function(){
		$('label#label_password').css({display: 'none'});
	});
	
	$('label#label_email').click(function(){
		$(this).css({display: 'none'});
		$('input.email').focus();
	});
	
	$('label#label_password').click(function(){
		$(this).css({display: 'none'});
		$('input.password').focus();
	});
	
	$('input.email').blur(function(){
		if($(this).val().trim() == ''){
			$('label#label_email').css({display: 'block'});
		}
	});
	
	$('input.password').blur(function(){
		if($(this).val().trim() == ''){
			$('label#label_password').css({display: 'block'});
		}
	});
	
	$('div.testimonials').cycle({
		fx: 'scrollUp',
		timeout: 0,
		speed: 1000,
		next: '#moretestimonials',
		clearTypeFix: false
	});
	
	/* Join page */
	
	$('.optionButtons.radio input').click(function(){
		$(this).parent().addClass('checked').siblings().removeClass('checked');
	});
	
	$('.optionButtons.checkbox input').click(function(){
		var checked = $(this).parent().hasClass('checked');
		switch(checked){
			case true:
				$(this).parent().removeClass('checked');
			break;
			default:
				$(this).parent().addClass('checked');
			break;
		}
	});
	
	// set them on page load
	$('.optionButtons.radio input').each(function(){
		switch($(this).attr('checked')){
			case true:
				$(this).parent().addClass('checked');
			break;
		}
	});
	
	$('.optionButtons.checkbox input').each(function(){
		switch($(this).attr('checked')){
			case true:
				$(this).parent().addClass('checked');
			break;
		}
	});
	
	$('#dob').DatePicker({
		format: 'd/m/Y',
		date: $('#dob').val(),
		current: $('#dob').val(), 
		starts: 1,
		position: 'r',
		onBeforeShow: function(){
			$('#dob').DatePickerSetDate($('#dob').val(), true);
		},
		onChange: function(formatted, dates){
			$('#dob').val(formatted);
			$('#dob').DatePickerHide();
		}
	})
	
	/* Adverts page */
	$('ul.category_list li ul').hide();
	$('ul.category_list li ul').removeClass('visible');
	$('ul.category_list>li>a').click(function(){
		$('ul.category_list li ul').slideUp('slow');
		switch($(this).parent().find('ul').hasClass('visible')){
			case true:
				$(this).parent().find('ul').removeClass('visible');
			break;
			case false:
				$(this).parent().find('ul').slideDown('slow');
				$(this).parent().find('ul').addClass('visible');
			break;
		}
	});
	
	/* Logged in home page */
	$('ul.localCats li ul').hide();
	$('ul.localCats>li>a').click(function(){
		$('ul.localCats li ul').slideUp('slow');
		switch($(this).parent().find('ul').hasClass('visible')){
			case true:
				$(this).parent().find('ul').removeClass('visible');
			break;
			case false:
				$(this).parent().find('ul').slideDown('slow');
				$(this).parent().find('ul').addClass('visible');
			break;
		}
	});
	
	$(document).bind('contextmenu', function(e){
		e.preventDefault();
	});
});
