RegisterForm = {
	init : function () {
		if ($('#UserNationBritain').size() > 0 && $('#UserNationIreland').size() > 0) {
			RegisterForm.updateForm();
			RegisterForm.addEvent();
		}
	},
	addEvent : function() {
		$('input:radio[name="data[User][nation]"]').change(function () {
			RegisterForm.updateForm();
		});
	},
	updateForm : function() {
		if ($('input:radio[name="data[User][nation]"]:checked').val() == 'Ireland') {
			$('#js_postcode-field').hide();
		} else {
			$('#js_postcode-field').show();
		}
	}
};

jQuery(document).ready(function($){	
	if($('#homepage_carousel').size() > 0){
		var embed = {
			src: 'homepage',
			width: 977,
			height: 313
		}
		
	}else if($('#explore_carousel').size() > 0){
		var embed = {
			src: 'explore',
			width: 977,
			height: 548
		}
	}
	
	if(embed){
		swfobject.embedSWF(
			'/swf/' + embed.src + '.swf', 
			embed.src + '_carousel', 
			embed.width, 
			embed.height, 
			'9.0.0',
			null,
			{
				xmlSource: '/explore.xml'
			},
			{
				wmode: 'transparent'
			}
		);
	}
	
	
	if($('#advert_container_inner').size() > 0){
		swfobject.embedSWF('/swf/PhileasFoggTVAd.swf', 'advert_container_inner', 634, 390, '9.0.0',null, {}, {wmode: 'transparent'});
	}
	
	if($('#about_globe_inner').size() > 0){
		swfobject.embedSWF('/swf/globe.swf', 'about_globe_inner', 164, 212, '9.0.0', null, {}, {wmode: 'transparent'});
	}
	
	
	/* set body js-only class */
	$('body').attr('id','jsOnly');
	
	/*  list border  */
	$('#rewards_nav ul li:last').addClass('noRightBorder');
	$('#rewards_list ul li:last').addClass('noRightBorder');
	
	/* random formatting */
	$('#rewards_left p:first').css('font-weight', 'bold');
	
	/* fade images */ 
	$('#promo_image_fade').innerfade({ speed: 'slow',
		timeout: 2500,
		type: 'sequence',
		containerheight: '302px' 
	}); 
	
	/* time batch code */
	/* $('#time_code').mouseover(function(e) {
		e.preventDefault();
		$('#time_code_content').css('display', 'block');
	});
	*/
	$("#time_code[title]").tooltip();
	$("#batch_code[title]").tooltip();
	
	/* batch and time code explanatory links */
	/* $('#time_code').click(function() { 
        $.blockUI({ 
            message: $('#time_code_content'), 
            css: { top: '20%' } 
        });  
        setTimeout($.unblockUI, 2000); 
    });
 */

	RegisterForm.init();
	
});

function getQuery() {
	retstr = "";
	fullURL = parent.document.URL;
	if (fullURL.indexOf('#') > 0) {
		retstr = fullURL.substring(fullURL.indexOf('#')+1, fullURL.length);
		retstr = unescape(retstr);
	}
	return (retstr);
}

