﻿function showLightBox(index, center, w, h) {
	
    height_center = jQuery(window).height() / 2;
    width_center = jQuery(window).width() / 2;
    currTopPos = jQuery(window).scrollTop();

	if(w!=null && h!=null){
		configWidth = (width_center - (w/2));
		jQuery("#lightBox.outerContainer").css({
			height:h+"px",
			width:w+"px"
		});
		jQuery("#fbMainDiv").css({
			height:(h-24)+"px",	
			width:(w-24)+"px"
		});		
	}
	else{
		configWidth = (width_center - 462);
	}
	
	if(center){
		configTop = (height_center - (h/3));
	}
	else{
		configTop = "100";	
	}
    
    

    jQuery("#lightBox.outerContainer").css({
        top: configTop + "px",
        left:configWidth+"px"
    })

    jQuery("#fbContent").hide();
    jQuery("#fbContent_" + index).show();

    jQuery("#lightBoxOverlay").fadeIn(300, function () {
        jQuery("#lightBoxOverlay").css("opacity", "0.6");
		
		
		
        jQuery("#lightBox").fadeIn(300);
        
        var innerHeight = jQuery("#lightBoxContainer").height();
        jQuery("#fbMainDiv").height(innerHeight + 40);
        jQuery("#lightBox").height(innerHeight + 84);
    });
}

function hideLightBox() {
    jQuery("#lightBox").fadeOut(300, function () {
        jQuery("#lightBoxOverlay").fadeOut(300);
    });
}

function setIframeLightBox(iframeId, url, width, height) {
    var iframeObj = document.getElementById(iframeId);
    iframeObj.src = url;
    iframeObj.width = width;
    iframeObj.height = height;
    showLightBox(0, true, (width + 65), (width + 40));
}

function findParentObjectByClassName(obj, className) {
    if (obj == null)
        return null;
    if (obj.className == className) {
        return obj;
    }
    return findParentObjectByClassName(obj.parentNode, className);
}
