
var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;

function jsddm_open()
{	jsddm_canceltimer();
	jsddm_close();
	ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');
$(this).css("cursor", "hand");
}

function jsddm_close()
{	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{	closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{	if(closetimer)
	{	window.clearTimeout(closetimer);
		closetimer = null;}}
document.onclick = jsddm_close;

jQuery.preloadImages = function()
{
	for(var i = 0; i<arguments.length; i++)
	{
		jQuery("<img>").attr("src", arguments[i]);
	}
}

$(document).ready(function() {
/// SLIDESHOW ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
	
	    $('.slideshow').cycle({
			fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		});
		
		
/// TOP BANNER ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
		// Preload all rollovers
		$("#nav img").each(function() {
			// Set the original src
			$(this).css("cursor", "hand");
			rollsrc = $(this).attr("src");
			rollON = rollsrc.replace(/.jpg$/ig,"_over.jpg");
			$("<img>").attr("src", rollON);
		});
		
		// Navigation rollovers
		$("#nav a").mouseover(function(){
			imgsrc = $(this).children("img").attr("src");
			matches = imgsrc.match(/_over/);
			
			// don't do the rollover if state is already ON
			if (!matches) {
			imgsrcON = imgsrc.replace(/.jpg$/ig,"_over.jpg"); // strip off extension
			$(this).children("img").attr("src", imgsrcON);
			}
			
		});
		$("#nav a").mouseout(function(){
			$(this).children("img").attr("src", imgsrc);
		});
		
		
/// SMALL FOOTER IMAGES ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// IMAGE 1 ////////////////////////////		
		// Preload all rollovers
		$("#img1 img").each(function() {
			// Set the original src
			$(this).css("cursor", "hand");
			rollsrc = $(this).attr("src");
			rollON = rollsrc.replace(/.jpg$/ig,"_over.jpg");
			$("<img>").attr("src", rollON);
		});
		
		// Navigation rollovers
		$("#img1 a").mouseover(function(){
			imgsrc = $(this).children("img").attr("src");
			matches = imgsrc.match(/_over/);
			
			// don't do the rollover if state is already ON
			if (!matches) {
			imgsrcON = imgsrc.replace(/.jpg$/ig,"_over.jpg"); // strip off extension
			$(this).children("img").attr("src", imgsrcON);
			}
			
		});
		$("#img1 a").mouseout(function(){
			$(this).children("img").attr("src", imgsrc);
		});
		
		
		$("#img1 img").mouseover(function(){			
	    $("#footer_mid")
	      .fadeOut(100, function() { $(this).html("<p><b>THE BEST IN ECO-LIVING</b> UTILISING SOLAR REFLECTIVE GLAZING AND WIND TURBINES TO DEVELOP A SUSTAINABLE FRAMEWORK</p>"); })
	      .delay(100)
	      .fadeIn(100);
	   });
/// IMAGE 1 ////////////////////////////		
/// IMAGE 2 ////////////////////////////		
		
		
		// Preload all rollovers
		$("#img2 img").each(function() {
			// Set the original src
			$(this).css("cursor", "hand");
			rollsrc = $(this).attr("src");
			rollON = rollsrc.replace(/.jpg$/ig,"_over.jpg");
			$("<img>").attr("src", rollON);
		});
		
		// Navigation rollovers
		$("#img2 a").mouseover(function(){
			imgsrc = $(this).children("img").attr("src");
			matches = imgsrc.match(/_over/);
			
			// don't do the rollover if state is already ON
			if (!matches) {
			imgsrcON = imgsrc.replace(/.jpg$/ig,"_over.jpg"); // strip off extension
			$(this).children("img").attr("src", imgsrcON);
			}
			
		});
		$("#img2 a").mouseout(function(){
			$(this).children("img").attr("src", imgsrc);
		});
		
	   	$("#img2 img").mouseover(function(){
	    $("#footer_mid")
	      .fadeOut(100, function() { $(this).html("<p><b>LUXURY APARTMENTS</b> SITUATED ON THE BANK OF THE RIVER TRENT, SOUTH FACING WITH SPECTACULAR RIVER VIEWS</p>"); })
	      .delay(100)
	      .fadeIn(100);
	   });
/// IMAGE 2 ////////////////////////////
/// IMAGE 3 ////////////////////////////

		// Preload all rollovers
		$("#img3 img").each(function() {
			// Set the original src
			$(this).css("cursor", "hand");
			rollsrc = $(this).attr("src");
			rollON = rollsrc.replace(/.jpg$/ig,"_over.jpg");
			$("<img>").attr("src", rollON);
		});
		
		// Navigation rollovers
		$("#img3 a").mouseover(function(){
			imgsrc = $(this).children("img").attr("src");
			matches = imgsrc.match(/_over/);
			
			// don't do the rollover if state is already ON
			if (!matches) {
			imgsrcON = imgsrc.replace(/.jpg$/ig,"_over.jpg"); // strip off extension
			$(this).children("img").attr("src", imgsrcON);
			}
			
		});
		$("#img3 a").mouseout(function(){
			$(this).children("img").attr("src", imgsrc);
		});
	   
		$("#img3 img").mouseover(function(){
	    $("#footer_mid")
	      .fadeOut(100, function() { $(this).html("<p><b>FITNESS STUDIO</b> WELL EQUIPPED WITH STATE OF THE ART WORKOUT MACHINES TO BURN OFF YOUR EXCESSES</p>"); })
	      .delay(100)
	      .fadeIn(100);
	   });
/// IMAGE 3 ////////////////////////////
	   
/// APARTMENT FOOTER IMAGES ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



/// APT IMAGE 1 LAYOUT ////////////////////////////		
		// Preload all rollovers
		$("#img_apt_plan img").each(function() {
			// Set the original src
			$(this).css("cursor", "hand");
			rollsrc = $(this).attr("src");
			rollON = rollsrc.replace(/.jpg$/ig,"_over.jpg");
			rollONLayout = rollsrc.replace(/_t.jpg$/ig,".jpg");
			$("<img>").attr("src", rollON);
		});
		
		// Navigation rollovers
		$("#img_apt_plan").mouseover(function(){
			imgsrc = $(this).children("img").attr("src");
			matches = imgsrc.match(/_over/);
			
			// don't do the rollover if state is already ON
			if (!matches) {
			imgsrcON = imgsrc.replace(/.jpg$/ig,"_over.jpg"); // strip off extension
			$(this).children("img").attr("src", imgsrcON);
			}
			
		});
		$("#img_apt_plan").mouseout(function(){
			$(this).children("img").attr("src", imgsrc);
		});
		
		
		$("#img_apt_plan img").click(function(){			
	    $("#image_right")
	      .fadeOut(100, function() { $(this).html('<img src="'+rollONLayout+'" alt="Apartment room" width="544" height="366"/>'); })
	      //.delay(0)
	      .fadeIn(10);
	   });
/// APT IMAGE 1 LAYOUT ////////////////////////////
/// APT IMAGE 1 ////////////////////////////		
		// Preload all rollovers
		$("#img1apt img").each(function() {
			// Set the original src
			$(this).css("cursor", "hand");
			rollsrc = $(this).attr("src");
			rollON = rollsrc.replace(/.jpg$/ig,"_over.jpg");
			rollONLarge1 = rollsrc.replace(/_t.jpg$/ig,".jpg");
			$("<img>").attr("src", rollON);
		});
		
		// Navigation rollovers
		$("#img1apt").mouseover(function(){
			imgsrc = $(this).children("img").attr("src");
			matches = imgsrc.match(/_over/);
			
			// don't do the rollover if state is already ON
			if (!matches) {
			imgsrcON = imgsrc.replace(/.jpg$/ig,"_over.jpg"); // strip off extension
			$(this).children("img").attr("src", imgsrcON);
			}
			
		});
		$("#img1apt").mouseout(function(){
			$(this).children("img").attr("src", imgsrc);
		});
		
		
		$("#img1apt img").click(function(){			
	    $("#image_right")
	      .fadeOut(100, function() { $(this).html('<img src="'+rollONLarge1+'" alt="Apartment room" width="544" height="366"/>'); })
	      //.delay(0)
	      .fadeIn(10);
	   });
		$("#img1apt img").click(function(){			
	    $("#slideshow")
	      .fadeOut(100, function() { $(this).html('<img src="'+rollONLarge1+'" alt="Apartment room" width="545" height="365"/>'); })
	      //.delay(0)
	      .fadeIn(10);
	   });
/// APT IMAGE 1 ////////////////////////////		
/// APT IMAGE 2 ////////////////////////////		
		// Preload all rollovers
		$("#img2apt img").each(function() {
			// Set the original src
			$(this).css("cursor", "hand");
			rollsrc = $(this).attr("src");
			rollON = rollsrc.replace(/.jpg$/ig,"_over.jpg");
			rollONLarge2 = rollsrc.replace(/_t.jpg$/ig,".jpg");
			$("<img>").attr("src", rollON);
		});
		
		// Navigation rollovers
		$("#img2apt").mouseover(function(){
			imgsrc = $(this).children("img").attr("src");
			matches = imgsrc.match(/_over/);
			
			// don't do the rollover if state is already ON
			if (!matches) {
			imgsrcON = imgsrc.replace(/.jpg$/ig,"_over.jpg"); // strip off extension
			$(this).children("img").attr("src", imgsrcON);
			}
			
		});
		$("#img2apt").mouseout(function(){
			$(this).children("img").attr("src", imgsrc);
		});
		
		
		$("#img2apt img").click(function(){			
	    $("#image_right")
	      .fadeOut(100, function() { $(this).html('<img src="'+rollONLarge2+'" alt="Apartment room" width="544" height="366"/>'); })
	      //.delay(0)
	      .fadeIn(10);
	   });
		
		$("#img2apt img").click(function(){			
	    $("#slideshow")
	      .fadeOut(100, function() { $(this).html('<img src="'+rollONLarge1+'" alt="Apartment room" width="545" height="365"/>'); })
	      //.delay(0)
	      .fadeIn(10);
	   });
/// APT IMAGE 2 ////////////////////////////
/// APT IMAGE 3 ////////////////////////////		
		// Preload all rollovers
		$("#img3apt img").each(function() {
			// Set the original src
			$(this).css("cursor", "hand");
			rollsrc = $(this).attr("src");
			rollON = rollsrc.replace(/.jpg$/ig,"_over.jpg");
			rollONLarge3 = rollsrc.replace(/_t.jpg$/ig,".jpg");
			$("<img>").attr("src", rollON);
		});
		
		// Navigation rollovers
		$("#img3apt").mouseover(function(){
			imgsrc = $(this).children("img").attr("src");
			matches = imgsrc.match(/_over/);
			
			// don't do the rollover if state is already ON
			if (!matches) {
			imgsrcON = imgsrc.replace(/.jpg$/ig,"_over.jpg"); // strip off extension
			$(this).children("img").attr("src", imgsrcON);
			}
			
		});
		$("#img3apt").mouseout(function(){
			$(this).children("img").attr("src", imgsrc);
		});
		
		
		$("#img3apt img").click(function(){			
	    $("#image_right")
	      .fadeOut(100, function() { $(this).html('<img src="'+rollONLarge3+'" alt="Apartment room" width="544" height="366"/>'); })
	      //.delay(0)
	      .fadeIn(10);
	   });
/// APT IMAGE 3 ////////////////////////////
/// APT IMAGE 4 ////////////////////////////		
		// Preload all rollovers
		$("#img4apt img").each(function() {
			// Set the original src
			$(this).css("cursor", "hand");
			rollsrc = $(this).attr("src");
			rollON = rollsrc.replace(/.jpg$/ig,"_over.jpg");
			rollONLarge4 = rollsrc.replace(/_t.jpg$/ig,".jpg");
			$("<img>").attr("src", rollON);
		});
		
		// Navigation rollovers
		$("#img4apt").mouseover(function(){
			imgsrc = $(this).children("img").attr("src");
			matches = imgsrc.match(/_over/);
			
			// don't do the rollover if state is already ON
			if (!matches) {
			imgsrcON = imgsrc.replace(/.jpg$/ig,"_over.jpg"); // strip off extension
			$(this).children("img").attr("src", imgsrcON);
			}
			
		});
		$("#img4apt").mouseout(function(){
			$(this).children("img").attr("src", imgsrc);
		});
		
		
		$("#img4apt img").click(function(){			
	    $("#image_right")
	      .fadeOut(100, function() { $(this).html('<img src="'+rollONLarge4+'" alt="Apartment room" width="544" height="366"/>'); })
	      //.delay(0)
	      .fadeIn(10);
	   });
/// APT IMAGE 4 ////////////////////////////
/// APT IMAGE 5 ////////////////////////////		
		// Preload all rollovers
		$("#img5apt img").each(function() {
			// Set the original src
			$(this).css("cursor", "hand");
			rollsrc = $(this).attr("src");
			rollON = rollsrc.replace(/.jpg$/ig,"_over.jpg");
			rollONLarge5 = rollsrc.replace(/_t.jpg$/ig,".jpg");
			$("<img>").attr("src", rollON);
		});
		
		// Navigation rollovers
		$("#img5apt").mouseover(function(){
			imgsrc = $(this).children("img").attr("src");
			matches = imgsrc.match(/_over/);
			
			// don't do the rollover if state is already ON
			if (!matches) {
			imgsrcON = imgsrc.replace(/.jpg$/ig,"_over.jpg"); // strip off extension
			$(this).children("img").attr("src", imgsrcON);
			}
			
		});
		$("#img5apt").mouseout(function(){
			$(this).children("img").attr("src", imgsrc);
		});
		
		
		$("#img5apt img").click(function(){			
	    $("#image_right")
	      .fadeOut(100, function() { $(this).html('<img src="'+rollONLarge5+'" alt="Apartment room" width="544" height="366"/>'); })
	      //.delay(0)
	      .fadeIn(10);
	   });
/// APT IMAGE 5 ////////////////////////////
/// APT IMAGE VODCAST ////////////////////////////		
		// Preload all rollovers
		// Preload all rollovers
		$("#vodcast img").each(function() {
			// Set the original src
			$(this).css("cursor", "hand");
			rollsrc = $(this).attr("src");
			rollON = rollsrc.replace(/.jpg$/ig,"_over.jpg");
			rollONvodcast = rollsrc.replace(/_t.jpg$/ig,".jpg");
			VODCASTvid = rollsrc.replace(/_t.jpg$/ig,"")
			VODCASTvideo = VODCASTvid.replace('/images/',"")
			$("<img>").attr("src", rollON);
		});
		
		// Navigation rollovers
		$("#vodcast").mouseover(function(){
			imgsrc = $(this).children("img").attr("src");
			matches = imgsrc.match(/_over/);
			
			// don't do the rollover if state is already ON
			if (!matches) {
			imgsrcON = imgsrc.replace(/.jpg$/ig,"_over.jpg"); // strip off extension
			$(this).children("img").attr("src", imgsrcON);
			}
			
		});
		$("#vodcast").mouseout(function(){
			$(this).children("img").attr("src", imgsrc);
		});
		
		
		$("#vodcast img").click(function(){			
	    $("#image_right").load('/_incs/promo_video.php?vid='+VODCASTvideo);
	   });











/// APT IMAGE VODCAST ////////////////////////////
/// INIT MENU //////////////////////////////
$('#jsddm > li').bind('mouseover', jsddm_open);
$('#jsddm > li').bind('mouseout',  jsddm_timer);
/// INIT MENU //////////////////////////////

});
