// CB Cinema Plugin JS
// Author: Fawaz
// Date Created: 24th Feb, 2010

// Function to insert the div
// @Div : Name of the Div used as an overlay
// @element : Name of the element to which Div will be appended
// @type : Type of Div ID or Class
function insert_overlay(Div,element,type) {
	$('<div '+type+'="'+Div+'" />').appendTo(element);
}


// Function used to turn lights off and on
// @Div : Name of the Div used as an overlay
// @element : element is jQuery Object
// @type : Type of Div ID or Class
function cb_cinema(Div,element,type) {
		
	if(type == "id" || type == "ID") {
		var Divname = "#"+Div;	
	} else {
		var Divname = "."+Div;	
	}
	
	$(Divname).hide();
	
	$(window).bind("load",function() {
		$(Divname).css("height", $(document).height());
		
		$(element).click(function() {
			if ($(Divname).is(":hidden")){
				$(Divname).fadeIn('normal');
				$(this).addClass('lightson');
			} else {
				$(Divname).fadeOut('normal');
				$(this).removeClass('lightson');
			}
		});
		
		$(Divname).click(function() {		
				$(Divname).fadeOut('normal');
				$("a.lightsoff").removeClass('lightson');
		});
	});
}
