$(document).ready(function(){
	$("#iCTA ul li#iCTA01").mouseenter(function(){
 		setTimeout("$('div#iCTA01info').animate( { bottom:'-100px' })",100);
	});
	$("#iCTA ul li#iCTA01").mouseleave(function(){
		$("div#iCTA01info").animate( { bottom:"-170px" })
	});

	$("#iCTA ul li#iCTA02").mouseenter(function(){
		$("div#iCTA02info").animate( { bottom:"-100px" })
	});
	$("#iCTA ul li#iCTA02").mouseleave(function(){
		$("div#iCTA02info").animate( { bottom:"-170px" })
	});

	$("#iCTA ul li#iCTA03").mouseenter(function(){
		$("div#iCTA03info").animate( { bottom:"-100px" })
	});
	$("#iCTA ul li#iCTA03").mouseleave(function(){
		$("div#iCTA03info").animate( { bottom:"-170px" })
	});
	
	/**
	 * News Box
	 */
	// Init News Item 1
	$("#iNews ul li#news1 a").addClass("active");
	$("#newsThumb").css( { background:"url(" + $("#iNews ul li#news1 a").attr("thumb") + ")" }).attr( { href: $("#iNews ul li#news1 a").attr("href") } );
	// Dynamic Listener
	$("#iNews ul li a").each(function(){
		$(this).mouseenter(function(){
			$(this).parent().siblings("li").each(function(){
				$(this).children("a").removeClass("active");
			});
			$(this).addClass("active");
			$("#newsThumb").css( { background:"url(" + $(this).attr("thumb") + ")" }).attr( { href: $(this).attr("href") } );
		});
	});
	// Thumb Click
	$("#newsThumb").click(function(){
		if($(this).attr("href") !== ""){
			window.location = $(this).attr("href");
		}
	});
			
<!-- =================================== show and hide navigation =============================================== -->

	$("div#slider a").click(function(){
		if(!$(this).hasClass("shut")){
			$("div#locationNav").animate({left:"-183px"} , 300);
			$(this).addClass("shut");
		}else{
			$("div#locationNav").animate({left:"0px" }, 500);
			$(this).removeClass("shut");
		}
	});
	
	$("div#sliderM a").click(function(){
		if(!$(this).hasClass("shut")){
			$("div#masterplanNav").animate({left:"-183px"} , 300);
			$(this).addClass("shut");
		}else{
			$("div#masterplanNav").animate({left:"0px" }, 500);
			$(this).removeClass("shut");
		}
	});
	
<!-- =================================== show and hide email to friend =============================================== -->

	$("a.email").click(function(){
		$("div#emailToFriend").show();
	});
	$("div#emailToFriend img.close").click(function(){
		$("div#emailToFriend").hide();
	});
	$("a#closeEmailToFriend").click(function(){
		$("div#emailToFriend").hide();
	});
	
<!-- ================================================= print ========================================================= -->
	
	$("a.print").click(function(){
		window.print();
	});
			
<!-- =================================== masterplan land parcels =============================================== -->
			
	$("div#masterplanNav ul li a.01").mouseenter(function(){
		$("div#masterplanMapContainer").css( { 'background-position':"center -3150px" })
	});
	$("div#masterplanNav ul li a.01").mouseleave(function(){
		$("div#masterplanMapContainer").css( { 'background-position':"center -3500px" })
	});
	$("div#masterplanNav ul li a.02").mouseenter(function(){
		$("div#masterplanMapContainer").css( { 'background-position':"center -2800px" })
	});
	$("div#masterplanNav ul li a.02").mouseleave(function(){
		$("div#masterplanMapContainer").css( { 'background-position':"center -3500px" })
	});
	$("div#masterplanNav ul li a.03").mouseenter(function(){
		$("div#masterplanMapContainer").css( { 'background-position':"center -2450px" })
	});
	$("div#masterplanNav ul li a.03").mouseleave(function(){
		$("div#masterplanMapContainer").css( { 'background-position':"center -3500px"} )
	});
	$("div#masterplanNav ul li a.04").mouseenter(function(){
		$("div#masterplanMapContainer").css( { 'background-position':"center -2100px" })
	});
	$("div#masterplanNav ul li a.04").mouseleave(function(){
		$("div#masterplanMapContainer").css( { 'background-position':"center -3500px"} )
	});
	$("div#masterplanNav ul li a.05").mouseenter(function(){
		$("div#masterplanMapContainer").css( { 'background-position':"center -1750px" })
	});
	$("div#masterplanNav ul li a.05").mouseleave(function(){
		$("div#masterplanMapContainer").css( { 'background-position':"center -3500px"} )
	});
	$("div#masterplanNav ul li a.06").mouseenter(function(){
		$("div#masterplanMapContainer").css( { 'background-position':"center -1400px" })
	});
	$("div#masterplanNav ul li a.06").mouseleave(function(){
		$("div#masterplanMapContainer").css( { 'background-position':"center -3500px"} )
	});
	$("div#masterplanNav ul li a.07").mouseenter(function(){
		$("div#masterplanMapContainer").css( { 'background-position':"center -1050px" })
	});
	$("div#masterplanNav ul li a.07").mouseleave(function(){
		$("div#masterplanMapContainer").css( { 'background-position':"center -3500px"} )
	});
	$("div#masterplanNav ul li a.08").mouseenter(function(){
		$("div#masterplanMapContainer").css( { 'background-position':"center -700px" })
	});
	$("div#masterplanNav ul li a.08").mouseleave(function(){
		$("div#masterplanMapContainer").css( { 'background-position':"center -3500px"} )
	});
	$("div#masterplanNav ul li a.09").mouseenter(function(){
		$("div#masterplanMapContainer").css( { 'background-position':"center -350px" })
	});
	$("div#masterplanNav ul li a.09").mouseleave(function(){
		$("div#masterplanMapContainer").css( { 'background-position':"center -3500px"} )
	});
	$("div#masterplanNav ul li a.10").mouseenter(function(){
		$("div#masterplanMapContainer").css( { 'background-position':"center 0px" })
	});
	$("div#masterplanNav ul li a.10").mouseleave(function(){
		$("div#masterplanMapContainer").css( { 'background-position':"center -3500px"} )
	});
<!-- =================================== Stylesheets =============================================== 
	//$.stylesheetInit();
	//$('a.styleswitch').click(function(){
	//	$.stylesheetSwitch($(this).attr('rel'));
	//	return false;
	//});
<!-- =================================== rotatingImages =============================================== -->
	$(function() {
	    setInterval( "slideSwitch()", 5000 );
	});
});
<!-- =================================== rotatingImages =============================================== -->
function slideSwitch()
{
	var $active = $('#slideshow IMG.activate');
	if ( $active.length == 0 ) $active = $('#slideshow IMG:last');
	var $next = $active.next().length ? $active.next() : $('#slideshow IMG:first');
	$active.addClass('last-active');
	$next.css({opacity: 0.0}).addClass('activate').animate({opacity: 1.0}, 1000, function() {
		$active.removeClass('activate last-active');
	});
}

function clearDefault(ele)
{
	if($(ele).val() == $(ele).attr("default") || $(ele).attr("default") == null || $(ele).attr("default") == "")
	{
		$(ele).val("");
	}
}

function fillDefault(ele)
{
	if($(ele).val() == "")
	{
		$(ele).val($(ele).attr("default"));
	}
}

function newsletter_submit()
{
	var email = $("#newsletter_email").val();
	var href="/newsletter.php?email="+email+"&keepThis=true&TB_iframe=true&height=320&width=330";
	tb_show("newsletter",href,null);
	return false;
}

function full_movie()
{
	window.location = "/?full_movie";
}

function initTimelapse()
{
	swfobject.embedSWF("/swf/Timelapse.swf", "flashcontent", "500", "390", "8.0.0");
}

function validate_text(ele)
{
	if($(ele).val() == $(ele).attr("default"))
	{
		$(ele).css('color','red');
		return false;
	}
	else
	{
		$(ele).css('color','#777');
		return true;
	}
}

function validate_emailToFriend(form)
{
	var success = true;
	regex = /^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i;
	if(!regex.test($("input#recipient_email").val()))
	{
		$("input#recipient_email").css('color','red');
		success = false;
	}
	else
	{
		$("input#recipient_email").css('color','#777');
	}
	if(!validate_text($("input#sender_name")))
	{
		success = false;
	}
	if(!validate_text($("input#recipient_name")))
	{
		success = false;
	}
	return success;
}

/* Proper ThickBox Popup */
function galleryview(url)
{
	tb_show("Image Gallery",url + "&KeepThis=true&TB_iframe=true&height=587&width=710");
}
