$.fn.openWindow = function(){
	var href = this.attr('href');
	href+='_p';
	newwindow=window.open(href,'name','height=600,width=600,scrollbars=1');
	if (window.focus) {newwindow.focus()}

}

$.fn.rotateContent = function(){
	var currentVisible = $(this).children("h4").not("h4:hidden");
	var nextToShow = currentVisible.next('h4');
	if ( nextToShow.length <= 0 )
	{
		nextToShow = $(this).children("h4:first");
	}
	currentVisible.hide();
	nextToShow.show();
	setTimeout("$('.h4_rotate').rotateContent();",4000);

}

$(document).ready( function(){
	$('.puwin').click(function(){
		$(this).openWindow();
		return false;
	});

	$('#UserRegisterForm div.submit input[type=submit]').click(function(){
		if ( $('#UserTandcAccepted:checked').length < 1 )
		{
			alert('You must tick to accept the Terms & Conditions');
			return false;
		}
	});

	if ( $('#OfferClaimPaymentTypeCheque:checked').length>0)
	{
		$('div.paypal_data').hide();
	}
	else if ( $('#OfferClaimPaymentTypePaypal:checked').length>0)
	{
		$('div.cheque_data').hide();
	}

	$('#OfferClaimPaymentTypeCheque').click(function(){
		$('div.paypal_data').hide();
		$('div.cheque_data').show();
	});
	$('#OfferClaimPaymentTypePaypal').click(function(){
		$('div.cheque_data').hide();
		$('div.paypal_data').show();
	});

	/*$('.magazines form .radio input').click(function(){
		$(this).attr('checked','checked');
		$(this).parents('form').submit();
	});*/
	$('.magazines form .radio input').change(function(){
		$(this).click();
	});
	$('a[rel=external], .tips .existing_content a').click(function(){
		$(this).attr('target', '_blank');
	});

	$('.h4_rotate').rotateContent();

});