var p_currPageId = 'nullstate';

$(".clickable").mouseover(function() {	
	jQuery(this).css('cursor', 'pointer');
});

function setPMenuPos() {
	var y = $("#main").height() * 0.94;	
	y = $("#main").height() - 27 < y ? $("#main").height() - 27 : y;
	if (isiPodiPhone()){
		y -= 1;
	}
	$("#p_menu_container").css('top', y);
//	$("#p_menu_container").css('left',-75); // -75 is the magic# to fix the half cut menu issue [reproduce: full size broswer -> open a price page -> resize the window]
	$("#p_menu_table").css('width', $("#main").width());
}

function setGalleriesPos() {
	$("#p_galleries").css('top',  $("#main").height() * 0.05 );
	$("#p_galleries").css('left', w * 0.05);
	$("#p_galleries").css('width', w * 0.9);
	$("#p_galleries").css('height',  $("#main").height() * 0.85 );
}

function setFloorPlanPos() {
	$("#p_floorplan").css('top',  $("#main").height() * 0.05 );
	$("#p_floorplan").css('left', w * 0.05);
	$("#p_floorplan").css('width', w * 0.9);
	$("#p_floorplan").css('height',  $("#main").height() * 0.85 );
}


function popupLoanWindow(url,width,height) 
{
 var left   = (screen.width  - width)/2;
 var top    = (screen.height - height)/2;
 var params = 'width='+width+', height='+height;
 params += ', top='+top+', left='+left;
 params += ', directories=no';
 params += ', location=no';
 params += ', menubar=no';
 params += ', resizable=yes';
 params += ', scrollbars=yes';
 params += ', status=no';
 params += ', toolbar=no';
 newwin=window.open(url,'CalculatePayment', params);
 if (window.focus) {newwin.focus()}
	 return false;
}

$("span.p_menu_txt").mouseover(function() {
	$(this).css('color', 'white');	
	if (p_currPageId != $(this).attr('id')) {	
		jQuery(this).css('cursor', 'pointer');
	} else {		
		jQuery(this).css('cursor', 'default');		
	}
});
$("span.p_menu_txt").mouseout(function() {
	if (p_currPageId != $(this).attr('id')) {
		$(this).css('color', 'black');	
	}
});
$("span.p_menu_txt").click(function() {	
	//jQuery(this).css('cursor', 'wait');	
	// do loading image	
	var id = $(this).attr('id');		
	showLoader();
	if (id == 'ave_construction' || id == 'hom_construction') {
		setConstructionNavPos();
		$("#p_construction_nav").show();
		var jqxhr = $.get('z/inc/p_construction.php?d=' + id, function(data){
			//alert(data);
			$("#construction_placeholder").html(data);
		});
		jqxhr.complete(function(){
			hideLoader();
			});
	} else {
		$("#p_construction_nav").hide();
		var jqxhr = $.get('z/img/p/' + id + '.jpg', function(data){
			// do nothing
		});
		jqxhr.complete(function(){
			$("#p_main_img").attr('src', 'z/img/p/' + id + '.jpg');
			hideLoader();
			});
	}
	if (p_currPageId != id) {
		$("#"+p_currPageId).css('color', 'black');
		p_currPageId = id;
	}
	if (id != 'pop_galleries' && id.indexOf('_galleries') != -1) {		
		setGalleriesPos();
		$("#p_galleries").show();
	} else {		
		$("#p_galleries").hide();
	}
	if ('gld_floorplan' == id) {		
		setFloorPlanPos();
		$("#p_floorplan").show();
	} else {		
		$("#p_floorplan").hide();
	}		
	/*
	if ('ave_floorplan' == id) {	
		setConstructionBtnPos();			
		$("#p_construction_btn").show();
					
	} else {		
		$("#p_construction_btn").hide();
	}*/
	
	if ('pop_ad' == id || 'gld_ad' == id || 'hom_ad' == id) {	
		setMoviePos();
		setInvisBtnPos();					
		$(".p_movie").show();		
		if (isiPodiPhone()) {				
			$(".p_movie_invis_btn").hide();		
			var fileName;
			if ('pop_ad' == id) {
				fileName = 'popular';
			} else if ('gld_ad' == id) {
				fileName = 'goldenlake';
			} else if ('hom_ad' == id) {
				fileName = 'hometown';
			} 
			//var fileName = 	'pop_ad' == id ? 'popular' : 'goldenlake';				
			$.get("z/inc/p_" + fileName + "_video.html", function(data){					
				$("#video_container").html(data);					
			});					
			$("#video_container").show();
		} else {
			$(".p_movie_invis_btn").show();					
		}			
	} else {		
		$(".p_movie").hide();
		$(".p_movie_invis_btn").hide();
	}			
	if (id.indexOf('_price') != -1) {		
		setInvisBtnPos();		
		$("#p_invis_dl_btn").show();
		$("#p_invis_loan_btn").show();
	} else {
		$("#p_invis_dl_btn").hide();
		$("#p_invis_loan_btn").hide();
	}
	if ('hom_concept' == id) {
		$("#p_hom_nav").show();				
	} else {
		$("#p_hom_nav").hide();
		$("#p_hom_nav").text('next');
	}		
	if ('pop_price' == id) {
		$("#p_pop_nav").show();				
	} else {
		$("#p_pop_nav").hide();
		$("#p_pop_price2").hide();
		$("#p_pop_nav").text('next');
	}

	$("#p_main_img").attr('src', 'z/img/p/' + id + '.jpg');
	jQuery(this).css('cursor', 'default');		
	
});
