/***************************/
//@Author: Adrian "yEnS" Mato Gondelle
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!					
/***************************/

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;

function loadPopup(id){
	if(popupStatus==0){
		$("#popup-background").css({
			"opacity": "0.7",
			"background": "#323232"
		});
		var winH = $(window).height();
		var winW = $(window).width();
		$("#popup-"+id).css('top', winH/2-$("#popup-"+id).height()/2);
		$("#popup-"+id).css('left', winW/2-$("#popup-"+id).width()/2);
		$("#popup-background").fadeIn("slow");
		$("#popup-"+id).fadeIn("slow");
		$("#popup-background").css({
			"height": winH
		});
		popupStatus = 1;
	}
}

function disablePopup(id){
	if (id==0 ) {
		if(popupStatus==1){
			$("#popup-background").fadeOut("slow");
			$(".jpopup-window").fadeOut("slow");
			popupStatus = 0;
		}
	} else {
		if(popupStatus==1){
			$("#popup-background").fadeOut("slow");
			$(".jpopup-window").fadeOut("slow");
			popupStatus = 0;
		}
	}
}


//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event!
	$("#launch-BulbType").click(function(){
		disablePopup("ColourTemperature");
		//centering with css
		//centerPopup();
		//load popup
		loadPopup("BulbType");
	});
	
	$("#launch-ColourTemperature").click(function(){
		disablePopup("BulbType");
		//centering with css
		//centerPopup();
		//load popup
		loadPopup("ColourTemperature");
	});
				
	//CLOSING POPUP
	//Click the x event!
	$(".jpopup-close").click(function(){
		disablePopup(0);
	});
	//Click out event!
	$("#popup-background").click(function(){
		disablePopup(0);
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});
	
	$(".popup-tab1").click(function(){
		$(".popup-tab1").addClass("popup-tab-off").removeClass("popup-tab-on");
		$(this).addClass("popup-tab-on");
		var clicked = "#"+$(this).attr("id")+"x";
		$(".popup-content1").addClass("popup-img-off").removeClass("popup-img-on");
		$(clicked).addClass("popup-img-on").removeClass("popup-img-off");
	});
	
	$(".popup-tab2").click(function(){
		$(".popup-tab2").addClass("popup-tab-off").removeClass("popup-tab-on");
		$(this).addClass("popup-tab-on");
		var clicked = "#"+$(this).attr("id")+"x";
		$(".popup-content2").addClass("popup-img-off").removeClass("popup-img-on");
		$(clicked).addClass("popup-img-on").removeClass("popup-img-off");
	});

});


function click(param) {
	document.getEl("fhdsf").cvkjhdvd

	
}