this.imagePreview = function()
{	
	xOffset = 0;
	yOffset = 30;
	
	$("a.preview").hover(function(e)
	{
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";		
		$("body").append("<p id='preview'><img src='"+ $(this).find("img").attr("src") +"' alt='Image preview' />"+ c +"</p>");								 
		$("#preview")
		.css("top",(e.pageY - xOffset) + "px")
		.css("left",(e.pageX + yOffset) + "px")
		.fadeIn("slow");
	},
	function()
	{
		this.title = this.t;	
		$("#preview").remove();
	});	
	$("a.preview").mousemove(function(e)
	{
		$("#preview")
		.css("top",(e.pageY - xOffset) + "px")
		.css("left",(e.pageX + yOffset) + "px");
	});
};
DY=window.DY||{};
DY.closeFancy=function  (){
    $.fancybox.close();
};

$(document).ready(function()
{	
	$('a.switch').mouseover(function()
	{
		show = $(this).attr('rel');
		if($('#'+show).css('display')=='none')
		{
			$('.switched').css('display','none');
			$('#'+show).fadeIn();
		}
	})
	imagePreview();

        $('#topImageHomeR').cycle();


        //popup per home
    if($('#boxPopUpHome').length>0){
        if($('#boxPopUpHome').html()!='' && !document.location.toString().match(/home\.php/) ){
            $.fancybox(
                $('#boxPopUpHome').html(),
                {
                    'autoDimensions'	: false,
                    'width'         		: 'auto',
                    'height'        		: 'auto',
                    'transitionIn'		: 'none',
                    'transitionOut'		: 'none',
                    'onComplete':function(){
                        var timeoutID = window.setTimeout(DY.closeFancy, 5000);
                    }
                }
                );
        }
    }
});
