/*	
	Format the site search
*/

function jqPngFix() {
    try {
        //ie6 png transperency fix
        $.each($("img[src$=.png],img[src$=.PNG]"), function () {
            var img = $(this);
            img.css({"width": img.width(),"height": img.height(), "filter": "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img.attr("src") + "', sizingMethod='scale')"});
            img.attr("src","/_sites/hsp/templates/images/construct/blank.gif");
        });
    } catch(e) {
        alert(e.description)
    }
}
$(document).ready(function(){
	if ($.browser.msie && $.browser.version == '6.0') {
		jqPngFix();
	}
	
	$labelText = $("#siteSearch label").html();
	$("#keywords").attr("value",$labelText);
	$("#siteSearch label").hide();
	$("#keywords").focus(function() {
		if ($(this).attr("value") == $labelText) {
			$(this).attr("value","");
		}
	});
	$("#keywords").blur(function() {
		if (!$(this).attr("value")) {
			$(this).attr("value",$labelText);
		}
	});
	
	$labelUser = $("#login-username").prev("label").html();
	$labelPass = $("#login-password").prev("label").html();
	$("#clientLogin label").hide();
	$("#clientLogin .formRow input:password").css({display:"none"});
	$("#clientLogin .formRow input:password").after('<input type="text" id="passwordVis" name="passwordVis" value="Password" />');
	$("#passwordVis").focus(function() {
		$(this).css({display:"none"});
		$("#clientLogin .formRow input:password").css({display:"block"}).focus();
		$("#clientLogin .formRow input:password").addClass("focussed");
	});
	$("#clientLogin .formRow input:password").focus(function() {
		$(this).addClass("focussed");
	});
	$("#clientLogin .formRow input:password").blur(function() {
		if (!$(this).attr("value")) {
			$(this).css({display:"none"});
			$("#passwordVis").css({display:"block"});
		}
		$(this).removeClass("focussed");
	});
	$("#login-username").focus(function() {
		if ($(this).attr("value") == $labelUser) {
			$(this).attr("value","");
		}
		$(this).addClass("focussed");
	});
	$("#login-username").blur(function() {
		if (!$(this).attr("value")) {
			$(this).attr("value",$labelUser);
		}
		$(this).removeClass("focussed");
	});
	
	if ($.browser.msie && $.browser.version == '6.0') {
		
	} else {
		//MisterMaker FrameIt Function
		$(".signpost .img, .panel .titleBlock").append('<span class="jsFrame">&nbsp;</span>');
		
		//Signpost hover function
		$(".auxContent li p a, ul.signposts li p a").hover(function() {
			$(this).parents("p").addClass("hover");
		},function() {
			$(this).parents("p").removeClass("hover");
		});
		
		$(".shareLinks ul").hide();
		$(".shareLinks a:first").toggle(function(){
			$(".shareLinks ul").slideDown();
			return false;
		}, function() {
			$(".shareLinks ul").slideUp();
			return false;
		});
	}
	
	$("#floorplan-first").hide();
	$("#floorplan-nav li:first").addClass("active");
	$whatFloor = "floorplan-ground";
	$("#floorplan-nav li a").click(function() {
		$("#floorplan-nav li").removeClass("active");
		$(this).parents("li").addClass("active");
		$floorURL = $(this).attr("href").split("#");
		$("#"+$whatFloor).fadeOut(500,function() {
			$whatFloor = $floorURL[1];
			$("#"+$whatFloor).fadeIn(500);
		});
		
		return false;
	});
	$(".panel .textBlock p:first, .room .panel p:first").addClass("firstchild");
	$(".panel .textBlock blockquote p:first").removeClass("firstchild");
	
});
