﻿(function(jQuery) {
	jQuery.fn.customFadeIn = function(speed, callback) {
		jQuery(this).fadeIn(speed, function() {
			if(jQuery.browser.msie)
				jQuery(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	jQuery.fn.customFadeOut = function(speed, callback) {
		jQuery(this).fadeOut(speed, function() {
			if(jQuery.browser.msie)
				jQuery(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
})(jQuery);

function FadeHouse() {
    jQuery(this).click(function() {
		jQuery("a.more").removeClass("active");
		jQuery(this).addClass("active");
		jQuery('div.more').hide();
        var e = "div." + jQuery(this).attr("title");
		jQuery(e).customFadeIn('slow', function() {});
        return false;
    });
}

function BackgroundImage() {
    jQuery(this).click(function() {
		var largePath = jQuery(this).attr("href");
		var largeAlt = jQuery(this).attr("title");
		jQuery(".LargeImage").attr({ src: largePath, alt: largeAlt });
		jQuery("div.TooltipRight p").html("" + largeAlt + ""); 
        return false;
    });
}

var popupStatus = 0;
function loadPopup(){
	if(popupStatus==0){
		jQuery('#Content,#pic').customFadeIn('slow', function() {});
		popupStatus = 1;
	}
}
function disablePopup(){
	if(popupStatus==1){
		jQuery('#Content,#pic').customFadeOut('slow', function() {});
		popupStatus = 0;
	}
}

function centerPopup(){
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = jQuery("#Content,#pic").height();
	var popupWidth = jQuery("#Content,#pic").width();
	jQuery("#Content,#pic").css({
		"position": "absolute",
		"top": windowHeight/4-popupHeight/4
	});
	jQuery(".TooltipWrap").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2+510
	});
}

jQuery(document).ready(function(){
	centerPopup();
	loadPopup();
	
	jQuery('a[rel="external"]').click( function() {
        window.open( jQuery(this).attr('href') );
        return false;
    });
	


	

	

	



});