$(document).ready(function(){
	
	if (document.all) {
		$("#menu li").hoverClass("hover");
		
	}
	$("#menu li").hover(
	    function()
	    {
	        $(this).addClass("hover");
	    },
	    function()
	    {
	        $(this).removeClass("hover");
	    }
	);
	
	// Accessible Target links
	$(".external-window").click( function(e) {
		// Abort if a modifier key is pressed
		if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) {
			return true;
		} else {
			// Change "_blank" to something like "newWindow" to load all links in the same new window
		    var newWindow = window.open(this.getAttribute('href'), '_blank');
			if (newWindow) {
				if (newWindow.focus) {
					newWindow.focus();
				}
				return false;
			}
			return true;
		}
		
	});
	$(".external-window").attr("title", "Link opens in an external window");
	
	/*
		** ClientName Specific Components
	*/
	
	if(document.getElementById("simpleCarousel"))
	{
		$('#simpleCarousel').jcarousel({
			itemScroll: 1,
			scrollAnimation: "normal",
			wrap: true,
			wrapPrev: true,
			autoScroll: 6,
			itemVisible: 1
		});
		
	}
	
	if(document.getElementById("imageCarousel"))
	{
		$('#imageCarousel').jcarousel({
			itemScroll: 1,
			scrollAnimation: "normal",
			wrap: true,
			wrapPrev: true,
			autoScroll: 0,
			itemVisible: 3
		});
		
	}
	
	
	if(document.getElementById("shadowboxes"))
	{
	    Shadowbox.init({
            loadingImage: '/basemedia/images/shadowbox/loading.gif',
            keysClose:          [27],       //  esc
            keysNext:           [39],       //  right arrow
            keysPrev:           [37],      //  left arrow
            overlayColor:       '#5B5B5B',
            overlayOpacity:     0.95
        });
	    links = [];
	    $("#shadowboxes .shadowbox").each(
		    function(i)
		    {
			    links[i] = this;
		    }
	    );
	    if(links.length > 0)
	    {
	        Shadowbox.setup(links, {
		        gallery: "property image gallery",
		        continuous:	true
	        });
	    }
	    links = [];
	    $(".shadowbox-single").each(
		    function(i)
		    {
			    links[i] = this;
		    }
	    );
	    if(links.length > 0)
	    {
	        Shadowbox.setup(links, {});
	    }
	}
	links = [];
    $(".shadowbox-inline").each(
	    function(i)
	    {
		    links[i] = this;
	    }
    );
    if(links.length > 0)
    {
        Shadowbox.init({
            loadingImage: '/basemedia/images/shadowbox/loading.gif',
            keysClose:          [27],       //  esc
            keysNext:           [39],       //  right arrow
            keysPrev:           [37],      //  left arrow
            overlayColor:       '#5B5B5B',
            overlayOpacity:     0.95
        });
        Shadowbox.setup(links, {});
    }
	
});

/*
	** Global functions
*/
$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c);  },
			function() { $(this).removeClass(c); }
		);
	});
};

jQuery.fn.vjustify=function() {
    var maxHeight=0;
    this.each(function(){
        if (this.offsetHeight>maxHeight) {maxHeight=this.offsetHeight;}
    });
    this.each(function(){
        $(this).height(maxHeight + "px");
        if (this.offsetHeight>maxHeight) {
            $(this).height((maxHeight-(this.offsetHeight-maxHeight))+"px");
        }
    });
};

jQuery.fn.log = function (msg) {
	return this;
};

function enableJSClass()
{
	document.body.className = "jsEnabled";
}

function printPage() { 
	if (window.print) { 
		window.print() ; 
	} else { 
		var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>'; 
		document.body.insertAdjacentHTML('beforeEnd', WebBrowser); 
		WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box WebBrowser1.outerHTML = ""; 
	}
}

function iframeCloseShadowBox()
{
    parent.Shadowbox.close();
}