// JavaScript Document
$(document).ready(function() {
	$('.nav_top_li:first > a').css({'background-image':'none'}); //starting settings
	$('.footer_ul li:first').css({'border':'none'});
	
	//correct the banner layout settings based on screen size
	correct_screensize();
	$(window).resize(function() {
		correct_screensize();
	});
	
	window_height = $(window).height();
	fullpage_height = $('body').height();
	
	if( window_height > fullpage_height )
		correctpage_height = window_height;
	else
		correctpage_height = fullpage_height;
	
	$('body').append('<div id="trans_overlay"></div>');//creates the black overlay
	$('#trans_overlay').css({'opacity':0.8, 'height': correctpage_height});
	
	$('.header_dropdown').css({'display':'block', 'opacity':'0'});//gets the carousels up and running
	/*$('.dropdown_main_ul_li').each(function() { //the arrow disabled function is not working with this code
			this_dropdown = $(this);
			$(this).children('.dropdown_result').jCarouselLite({
				visible: 5,
				circular: false,
				start: 0,
				btnNext: this_dropdown.children()[1],//'.a_drop_prev'),
	            btnPrev: this_dropdown.children()[0]//'.a_drop_next')
			});
		});*/
		
	$('#apartment_result').jCarouselLite({
				visible: 4,
				circular: false,
				start: 0,
				btnNext: "#a_1_drop_next",
	            btnPrev: "#a_1_drop_prev"
			});
	$('#bungalow_result').jCarouselLite({
			visible: 2,
			circular: false,
			start: 0,
			btnNext: "#a_2_drop_next",
			btnPrev: "#a_2_drop_prev"
		});
	$('#villa_result').jCarouselLite({
			visible: 4,
			circular: false,
			start: 0,
			btnNext: "#a_3_drop_next",
			btnPrev: "#a_3_drop_prev"
		});
	$('#weekend_homes_result').jCarouselLite({
			visible: 4,
			circular: false,
			start: 0,
			btnNext: "#a_4_drop_next",
			btnPrev: "#a_5_drop_prev"
		});
	$('#other_result').jCarouselLite({
			visible: 4,
			circular: false,
			start: 0,
			btnNext: "#a_5_drop_next",
			btnPrev: "#a_5_drop_prev"
		});
			
	$('.header_dropdown').css({'display':'none', 'opacity':'1'});
	
	$('.drop_down_p_wrapper').hover(function() {  //hover effect on the individual projects
		$(this).data('this_bk_color', $(this).css('background-color'));
		$(this).animate({'background-color':'#ccc', 'padding-top': '15px'}, 200);		
		$(this).children('.dropdown_proj_type').animate({'padding-top':'0px'}, 200);
	}, function() {
		$(this).animate({'background-color': $(this).data('this_bk_color'), 'padding-top': '5px'}, 200);	
		$(this).children('.dropdown_proj_type').animate({'padding-top':'3px'}, 200);			
	});
	
	$('#nav_div').hoverIntent(function() {/*hoverIntent*/
		$('.header_inner').css({'background-color':'#fff'});
		$('.header').css({'background-image':'none'});
		$('#trans_overlay').css({'display':'block', 'opacity': 0}).animate({'opacity':0.8}, 300);
		$('.header_dropdown').slideDown(200);
		$('#dropdown_main_ul').css({'margin-top':0});/*problem root*/
	}, function() {
		$('.header_dropdown').slideUp(200);
		$('.header_inner').css({'background-color':'transparent'});
		$('.header').css({'background':'url(images/layout_images/header_bk.png) no-repeat center top'});
		$('#trans_overlay').css({'display':'none'});
		
	});
	
	$('.nav_top_li').hoverIntent(function() {/*hoverIntent*/
		if($(this).attr('id') == ('apartments_li')) {
				$('#apartment_what_more_1').css({'display':'block'});	
				if($('#txt_newsLetter').val() == '') {
					$('#txt_newsLetter').val('Email Id');
				}
		}
		this_index = $(this).index();
		li_height = 210; //this is the height of the inside li
		margin_to_move = (-1) * this_index * li_height;
		$('#dropdown_main_ul').stop().animate({'margin-top':margin_to_move}, 200);	
	}, function() {
	
	});
	
	$('.dropdown_main_ul_li').hover(function() {
			this_index = $(this).index();
			$('.nav_top_li:eq('+this_index+') a').addClass('hover_on');	
	}, function() {
			$('.nav_top_li:eq('+this_index+') a').removeClass('hover_on');	
	});
	
	/*$('#newsletter_signup_btn').fancybox({
			'scrolling'		: 'no',
			'titleShow'		: false,
			'padding'		: 20});*/
 	$('#newsletter_signup_btn').click(function(){
		$('#apartment_what_more_1').slideUp();

	});	
	
	$('#txt_newsLetter').focus(function() {
		$(this).select();
	});
	
	$("#txt_newsLetter").mouseup(function(e){
			e.preventDefault();
	});	


});

function correct_screensize() {
		current_screensize = $(window).width();
		if(current_screensize < 1100) {
			$('.banner_needed_wrapper').css({'margin-left':'-13%'});
			$('.nivo-prevNav').css({'left':'12%'});
			$('.nivo-nextNav').css({'right':'13%'});	
		}
		else {
			$('.banner_needed_wrapper').css({'margin':'0 auto'});
			$('.nivo-prevNav').css({'left':'2%'});
			$('.nivo-nextNav').css({'right':'4%'});		
		}		
}
