// JavaScript Document

(function($) {
	$.fn.customFadeIn = function(speed, callback) {
		$(this).fadeIn(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	$.fn.customFadeOut = function(speed, callback) {
		$(this).fadeOut(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
})(jQuery);

$(document).ready(function(){

$(".main_nav img.nav").hover(function(){
	$(this).css({'border-bottom' : '1px solid #6e480c'}); },
	function() { $(this).css({'border-bottom' : 'none'}); }
 );

$("#cross img").hover( function() {
	this.src = this.src.replace("_cross","_cross_rollover_2"); },
	function() {
		this.src = this.src.replace("_cross_rollover_2","_cross"); 
	});

$("#cross").click(function(){
	$("#contact_div").hide();
});

$("#contact_div").click(function(){
	$("#contact_div").hide();
});

$("#logo").click(function(){
	$(".content").hide();
	$(".main_nav img.nav").css({'border-bottom' : 'none'}); 
	$(".background").animate({backgroundPosition: '0px 0px'}, 1500, function(){
		$("#welcome_page").customFadeIn('slow');
		$("#welcome").css({'border-bottom' : '1px solid #6e480c'});
    });
	$("#slider_bar_right").animate({marginLeft: "53px"}, 500, function(){
	$("#slider_bar_left").animate({marginLeft: "0px"});
	});
	$("#slider_bar_left").fadeOut(100, function(){
	$("#slider_bar_right").fadeIn(100);
	});
});

$("#welcome").click(function(){
	$(".content").hide();
	$(".main_nav img.nav").css({'border-bottom' : 'none'}); 
	$(".background").animate({backgroundPosition: '0px 0px'}, 1500, function(){
		$("#welcome_page").customFadeIn('slow');
		$("#welcome").css({'border-bottom' : '1px solid #6e480c'});
    });
	$("#slider_bar_right").animate({marginLeft: "53px"}, 500, function(){
	$("#slider_bar_left").animate({marginLeft: "0px"});
	});
	$("#slider_bar_left").fadeOut(100, function(){
	$("#slider_bar_right").fadeIn(100);
	});
});

$("#bars").click(function(){
	$(".content").hide();
	$(".main_nav img.nav").css({'border-bottom' : 'none'}); 
	$(".background").animate({backgroundPosition: '-1024px 0px'}, 1500, function(){
		$("div.bars_page").html('<iframe width="637" height="500" scrolling="no" allowtransparency="true" id="bars_page" src="/Bars/611/n/3/0/0/" class="content"></iframe>');
		$(".bars_page").customFadeIn('slow');
		$("#bars_page").customFadeIn('slow');
		$("#bars").css({'border-bottom' : '1px solid #6e480c'});
	});
	$("#slider_bar_right").animate({marginLeft: "53px"}, 500, function(){
	$("#slider_bar_left").animate({marginLeft: "0px"});
	});
	$("#slider_bar_left").fadeOut(100, function(){
	$("#slider_bar_right").fadeIn(100);
	});
});

$(".bars").click(function(){
	$(".content").hide();
	$(".main_nav img.nav").css({'border-bottom' : 'none'}); 
	$(".background").animate({backgroundPosition: '-1024px 0px'}, 1500, function(){
		$("div.bars_page").html('<iframe width="637" height="500" scrolling="no" allowtransparency="true" id="bars_page" src="/Bars/611/n/3/0/0/" class="content"></iframe>');
		$(".bars_page").customFadeIn('slow');
		$("#bars_page").customFadeIn('slow');
		$("#bars").css({'border-bottom' : '1px solid #6e480c'});
	});
	$("#slider_bar_right").animate({marginLeft: "53px"}, 500, function(){
	$("#slider_bar_left").animate({marginLeft: "0px"});
	});
	$("#slider_bar_left").fadeOut(100, function(){
	$("#slider_bar_right").fadeIn(100);
	});
});

$("#functions").click(function(){
	$(".content").hide();
	$(".main_nav img.nav").css({'border-bottom' : 'none'}); 
	$(".background").animate({backgroundPosition: '-2048px 0px'}, 1500, function(){
	$("div.functions_page").html('<iframe width="501" height="540" scrolling="no" class="content" src="/Functions/616/n/3/0/0/" id="functions_page" allowtransparency="true"></iframe>');
		$(".functions_page").customFadeIn('slow');
		$("#functions_page").customFadeIn('slow');
		$("#functions").css({'border-bottom' : '1px solid #6e480c'});
    });
	$("#slider_bar_right").animate({marginLeft: "53px"}, 500, function(){
	$("#slider_bar_left").animate({marginLeft: "0px"});
	});
	$("#slider_bar_left").fadeOut(100, function(){
	$("#slider_bar_right").fadeIn(100);
	});
});

$(".whatson_link").click(function(){
	
	$(".content").hide();
	$(".main_nav img.nav").css({'border-bottom' : 'none'}); 
	$(".background").animate({backgroundPosition: '-3072px 0px'}, 1500, function(){
	$("div.whatson_page").html('<iframe width="714" height="484" scrolling="no" class="content" src="/WhatsOn/613/n/3/0/0/" id="whatson_page" allowtransparency="true"></iframe>');
		$(".whatson_page").customFadeIn('slow');
		$("#whatson_page").customFadeIn('slow');
		$("#whatson").css({'border-bottom' : '1px solid #6e480c'});
    });
	$("#slider_bar_right").animate({marginLeft: "53px"}, 500, function(){
	$("#slider_bar_left").animate({marginLeft: "0px"});
	});
	$("#slider_bar_left").fadeOut(100, function(){
	$("#slider_bar_right").fadeIn(100);
	});
});

function whatsonlink() {
	$(".content").hide();
	$(".main_nav img.nav").css({'border-bottom' : 'none'}); 
	$(".background").animate({backgroundPosition: '-3072px 0px'}, 1500, function(){
	$("div.whatson_page").html('<iframe width="714" height="484" scrolling="no" class="content" src="/WhatsOn/613/n/3/0/0/" id="whatson_page" allowtransparency="true"></iframe>');
		$(".whatson_page").customFadeIn('slow');
		$("#whatson_page").customFadeIn('slow');
		$("#whatson").css({'border-bottom' : '1px solid #6e480c'});
    });
	$("#slider_bar_right").animate({marginLeft: "53px"}, 500, function(){
	$("#slider_bar_left").animate({marginLeft: "0px"});
	});
	$("#slider_bar_left").fadeOut(100, function(){
	$("#slider_bar_right").fadeIn(100);
	});
}

$(".whatson_link2").click(function(){
	$('.content', top.document).hide();
	$('.main_nav img.nav', top.document).css({'border-bottom' : 'none'}); 
	$('.background', top.document).animate({backgroundPosition: '-3072px 0px'}, 1500, function(){
		$("div.whatson_page", top.document).html('<iframe width="714" height="484" scrolling="no" class="content" src="/WhatsOn/613/n/3/0/0/" id="whatson_page" allowtransparency="true"></iframe>');
		$('.whatson_page', top.document).show('slow');
		$('#whatson_page', top.document).show('slow');
		$('#whatson', top.document).css({'border-bottom' : '1px solid #6e480c'});
    });
});

$(".gallery_link").click(function(){
	$('.content', top.document).hide();
	$('.main_nav img.nav', top.document).css({'border-bottom' : 'none'}); 
	$('.background', top.document).animate({backgroundPosition: '-5120px 0px'}, 1500, function(){
		$("div.gallery_page", top.document).html('<iframe width="667" height="280" scrolling="no" class="content" src="/Gallery/618/n/3/0/0/" id="gallery_page" allowtransparency="true"></iframe>');
		$(".gallery_page", top.document).show('slow');
		$("#gallery_page", top.document).show('slow');
		$("#gallery_page_title", top.document).show('slow');
		$('#gallery', top.document).css({'border-bottom' : '1px solid #6e480c'});
    });
});


$("#whatson").click(function(){
	$(".content").hide();
	$(".main_nav img.nav").css({'border-bottom' : 'none'}); 
	$(".background").animate({backgroundPosition: '-3072px 0px'}, 1500, function(){
		$("div.whatson_page").html('<iframe width="714" height="484" scrolling="no" class="content" src="/WhatsOn/613/n/3/0/0/" id="whatson_page" allowtransparency="true"></iframe>');
		$(".whatson_page").customFadeIn('slow');
		$("#whatson_page").customFadeIn('slow');
		$("#whatson").css({'border-bottom' : '1px solid #6e480c'});
    });
	$("#slider_bar_right").animate({marginLeft: "53px"}, 500, function(){
	$("#slider_bar_left").animate({marginLeft: "0px"});
	});
	$("#slider_bar_left").fadeOut(100, function(){
	$("#slider_bar_right").fadeIn(100);
	});
});

$("#goldtv").click(function(){
	$(".content").hide();
	$(".main_nav img.nav").css({'border-bottom' : 'none'}); 
	$(".background").animate({backgroundPosition: '-4096px 0px'}, 1500, function(){
		$("div.goldtv_page").html('<iframe width="457" height="470" scrolling="no" class="content" src="/GoldTv/617/n/3/0/0/" id="goldtv_page" allowtransparency="true"></iframe>');
		$(".goldtv_page").customFadeIn('slow');
		$("#goldtv_page").customFadeIn('slow');
		$("#goldtv").css({'border-bottom' : '1px solid #6e480c'});
    });
	$("#slider_bar_right").animate({marginLeft: "53px"}, 500, function(){
	$("#slider_bar_left").animate({marginLeft: "0px"});
	});
	$("#slider_bar_left").fadeOut(100, function(){
	$("#slider_bar_right").fadeIn(100);
	});
});

$("#gallery").click(function(){
	$(".content").hide();
	$(".background").animate({backgroundPosition: '-5120px 0px'}, 1500, function(){
		$("div.gallery_page").html('<iframe width="667" height="280" scrolling="no" class="content" src="/Gallery/618/n/3/0/0/" id="gallery_page" allowtransparency="true"></iframe>');
		$(".gallery_page").customFadeIn('slow');
		$("#gallery_page").customFadeIn('slow');
		$("#gallery_page_title").fadeIn('slow');
		$("#gallery").css({'border-bottom' : '1px solid #6e480c'});
    });
	$("#slider_bar_right").animate({marginLeft: "53px"}, 500, function(){
	$("#slider_bar_left").animate({marginLeft: "0px"});
	});
	$("#slider_bar_left").fadeOut(100, function(){
	$("#slider_bar_right").fadeIn(100);
	});
});



$("#sleep").click(function(){
	$(".content").hide();
	$(".background").animate({backgroundPosition: '-6144px 0px'}, 1500, function(){
		$("div.sleep_page").html('<iframe width="491" height="502" scrolling="no" class="content" src="/Sleep/626/n/3/0/0/" id="sleep_page" allowtransparency="true"></iframe>');
		$(".sleep_page").customFadeIn('slow');
		$("#sleep_page").customFadeIn('slow');
		$("#sleep").css({'border-bottom' : '1px solid #6e480c'});
	});
	$("#slider_bar_right").animate({marginLeft: "53px"}, 500, function(){
	$("#slider_bar_left").animate({marginLeft: "0px"});
	});
	$("#slider_bar_left").fadeOut(100, function(){
	$("#slider_bar_right").fadeIn(100);
	});
});

$("#contact").click(function(){
	$("div.contact_page").html('<iframe width="1024" height="650" scrolling="no" src="/ContactDetails/35/n/1/0/0/" id="contact_page" allowtransparency="true"></iframe>');
	$("#contact_div").customFadeIn('slow');
});

$("#slider_bar_right").click(function(){
	$(".content").fadeOut('slow');
	$("#slider_bar_right").animate({marginLeft: "0px"}, 500);
	$("#slider_bar_left").animate({marginLeft: "0px"}, 500);
	$("#slider_bar_right").fadeOut(100, function(){
	$("#slider_bar_left").fadeIn(100);
	});
});


$("#slider_bar_left").click(function(){
	if ($(".background").css('background-position-x')) {
		var position = parseInt($(".background").css('background-position-x').split(' ')[0]);}
	else {
		var position = parseInt($(".background").css('background-position').split(' ')[0]);
	};

	if(position == "-1024") {$("#bars_page").fadeIn('slow'); }
	else if (position == "-2048") {$("#functions_page").fadeIn('slow'); }
	else if (position == "-3072") {$("#whatson_page").fadeIn('slow'); }
	else if (position == "-4096") {$("#goldtv_page").fadeIn('slow'); }
	else if (position == "-5120") {$("#gallery_page").fadeIn('slow'); }
	else if (position == "-6144") {$("#sleep_page").fadeIn('slow'); }
	else {$("#welcome_page").fadeIn('slow'); }
	$("#slider_bar_left").animate({marginLeft: "53px"}, 500);
	$("#slider_bar_right").animate({marginLeft: "53px"}, 500);
	$("#slider_bar_left").fadeOut(100, function(){
	$("#slider_bar_right").fadeIn(100);
	});
});

	$("#welcome_page").customFadeIn('slow');
	$("#welcome").css({'border-bottom' : '1px solid #6e480c'});

});
