$(document).ready(function(){
	
	SetRollOvers();
	
	$('iframe').show();
	
	if ( $('#photos').length ) {
		$('#photos').galleryView({
			panel_width: 600,
			panel_height: 330,
			frame_width: 30,
			frame_height: 30,
			border: "none",
			background_color: "#252525",
			transition_interval: 3700
		});
	}
	
	/* set height of window for placement of greenwire logo */
	if($('#wrapper').height() < $(window).height()){
		//alert($('#wrapper').height());
		$('#wrapper').height($(window).height()-25);
	}
	
	$('.links li').biggerlink({
		clickableclass:'link',
		hoverclass:'hover'
	});
	
	$('#level-photos p').css("display","block");
	$('#level-photos img.top-floor').css("display","none");
		
	
	
	$("#level-photos p span").click(function(){
		var id = $(this).attr('id');
		var imgsrc = "/images/floorplan-"+id+".gif";
		$("img.floor").attr("src",imgsrc);
		if(id == "family-unit2"){
			$(this).removeClass("link");
			$(this).text("Top Floor");
			$("#family-unit1").addClass("link");
			$("#family-unit1").text("View First Floor");
		}
		else {
			$(this).removeClass("link");
			$(this).text("First Floor");
			$("#family-unit2").addClass("link");
			$("#family-unit2").text("View Top Floor");
		}
	});
	
	/* open external links in new window */
	$('a[rel=external]').click(function(){ window.open(this.href); return false; });
	
	if($('textarea.tinymce').length > 0) {
		$('textarea.tinymce').tinymce({
			script_url : '/js/tiny_mce/tiny_mce.js',
	      	theme : "advanced",
	      	skin : "o2k7",
	      	skin_variant: "silver",
	      	theme_advanced_toolbar_location : "top",
		  	theme_advanced_toolbar_align : "left",
		  	theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,bullist,numlist,|,link,unlink",
			theme_advanced_buttons2 : "",
			theme_advanced_buttons3 : "",
			theme_advanced_buttons4 : "",
			theme_advanced_statusbar_location : "bottom",
			cleanup: true
	   	});
	}

	
});

function SetRollOvers(){
	// usage: add the class 'rollover' to image elements
	jQuery("input[type=image].rollover, a.rollover img, img.rollover").hover(function(){
		    $(this).attr("src",jQuery(this).attr("src").replace(/(\.[^.]+)$/, '-hi$1'));
	    },function(){
		    $(this).attr("src",jQuery(this).attr("src").replace(/-hi(\.[^.]+)$/, '$1'));
	});
}