/*
 * Moneyextra Lightbox plugin
 */
jQuery.fn.mxlightbox = function (task, options) {
    var task = (task) ? task : false;
    switch (task) {
    case 'destroy':
		/*if (jQuery.browser.safari)*/	
    	if (1)
    	{
    		$("*[id^=mx-advert]").contents().find("*[class^=mx-unanimis]").show();
			$("*[id^=mx-advert]").css("visibility", "visible");
		}
		
        $(this).fadeOut();
        $("#mx-lightBoxBg").fadeOut();
        $("#mx-lightBoxBg").remove();
        return;
        break;
    }
    var defaults = {
        height: $(document).height(),
        position: "absolute",
        width: $(document).width(),
        backgroundColor: "#000",
        opacity: "0.5",
        zIndex: "200",
        left: "0",
        top: "0"
    };
	/*if (jQuery.browser.safari)*/
	if(1)  
    {
		$("*[id^=mx-advert]").css("visibility", "hidden");
		$("*[id^=mx-advert]").contents().find("*[class^=mx-unanimis]").hide();
	}

    var opts = $.extend(defaults, options);
    $("body").prepend("<div id=\"mx-lightBoxBg\"></div>");

	
    $("#mx-lightBoxBg").css(opts);
    $("#mx-lightBoxBg").fadeIn();
    var intWindowHeight = $(window).height();
    var intCompareQuotesHeight = $(this).height();
    var intScrollOffset = $(document).scrollTop();
	var intDocHeight = $(document).height();
   /* var intCssTop = (intWindowHeight > intCompareQuotesHeight) ? (intWindowHeight - intCompareQuotesHeight) / 2 + intScrollOffset : 0;*/
    var intCssTop=0;
	if(intWindowHeight > intCompareQuotesHeight){
		intCssTop= (intWindowHeight - intCompareQuotesHeight) / 2 + intScrollOffset;
	}else if(intDocHeight > intCompareQuotesHeight){
		intCssTop=((intDocHeight-intScrollOffset)>intCompareQuotesHeight)?intScrollOffset:(intDocHeight-intCompareQuotesHeight);
	}
	
	
	$(this).css("top", intCssTop + "px");
	$(this).css("z-index", '400');
	$("body").prepend($(this));
	
    $(this).fadeIn();
};

