$(document).ready(function(){
	// For aligned images
	$('img[align=right]').addClass('float-right');
	$('img[align=left]').addClass('float-left');	

	// Property module tabs
	//$('#tab_nav').show();
	//$("#property_tabs").tabs();

	// Adds an icon and title for links that open in a new window
	$('p a[target=_blank]').attr('title', 'Opens in a new window').addClass('newindow');
	
	// Gallery Plugin
	/*$("a[rel=image_gallery]").fancybox({
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'titlePosition' 	: 'inside',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	
	$("a.lightbox").fancybox({
		'titleShow'		: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
	});*/
	
	//media file transcripts
	$(".mediaFileTranscript").hide();
	$(".toggleTranscriptView").click(function (ev) {
		ev.preventDefault();
		$(this).parent().next(".mediaFileTranscript").slideToggle(300);
	});
	
	$("#quicklinks li").hover(
	    function () {
	        var $this = $(this)
	        $this.css({
	            backgroundColor : "#" + $this.attr("data-qlColor")
	        });
	    },
	    function () {
            $(this).css({
                backgroundColor : "#cdd6db"
            });
        }
	);
	
	$(".slider").v1Slider({
		fx : "scrollLeft",
		timeout : 8000,
		speed : 3000,
		next : $("a[rel=next]"),
		prev : $("a[rel=prev]"),
		pauseBtn : $("a[rel=pause]")
	});
	
	setColHeights();
	
});	

function setColHeights () {
	var $colLeft = $("#phHomeLeft"); // left long placeholder
	var h = $("#homeRightCol").height();
	var padTop = parseInt($colLeft.css("padding-top"));
	var padBot = parseInt($colLeft.css("padding-bottom"));
	var $topPh = $("#homeRightInnerWrap .placeholder");
	h = (h - (padTop + padBot));
	$colLeft.height(h);
	h = 0;
	$topPh.each(function () {
		var phHeight = $(this).height();
		if (phHeight > h) h = phHeight;
	});
	$topPh.height(h);
}

function cleanOnFocus(field,defaultText){
	try{
		if(!field.tagName == "INPUT" || !field.type=="text" || !field.value)
			return false;
		if(field.value == defaultText)
			field.value='';
	}catch(e){
		return false;
	}
}
function resetOnLostFocus(field,defaultText){
	try{
		if(!field.tagName == "INPUT" || !field.type=="text")
			return false;
		if(!field.value)
			field.value=defaultText;
	}catch(e){
		return false;
	}
}


