
//Launch lightbox upon load of document
$(document).ready(function() {
	
	$('#sliderBox').stop().slideTo({
		transition:1000,
		left:'center',
		inside:window
	});

	//Remember if user was shown lightbox
	var cookieName = 'swag-email';
	if($.cookie(cookieName)!=cookieName){
		$.cookie(cookieName, cookieName,{ path: '/' });	
			
		$('#sliderBox').slideTo({
			transition:1000,
			top:'center',
			left:'center',
			inside:window
		});
	}
	
	jQuery(window).resize(function() {
		$('#sliderBox').stop().slideTo({
			transition:300,
			top:'center',
			left:'center',
			inside:window
		});
	});

	var closeWelcomeBox;

/*
	$(window).scroll(function(){ 
		if(!closeWelcomeBox){
			$('#sliderBox').stop().slideTo({
				transition:300,
				top:'center',
				left:'center',
				inside:window
			});
		}
	});
*/
	$("#closebtn").click(function(){
		$('#sliderBox').stop().slideTo({ 
			transition:1000,
			top:-2000
	    	});
	    	$('#background').fadeOut(500);
		closeWelcomeBox = true;
	});

});


//Hide the window
function hideWindow(id){
	$('#modal-mask').fadeOut(500);	
	$('.modal-window').hide();
}

//Launch (animate) the window
function launchWindow(id){
	
	//Remember if user was shown lightbox
	var cookieName = 'swag-email';
	if($.cookie(cookieName)!=cookieName){
		$.cookie(cookieName, cookieName,{ path: '/' });
	}	
	
	//Get the screen height and width
	var maskHeight = $(document).height();
	var maskWidth = $(window).width();

	//Set height and width to mask to fill up the whole screen
	$('#modal-mask').css({'width':maskWidth,'height':maskHeight});
	
	//transition effect		
	$('#modal-mask').fadeIn(500);	
	$('#modal-mask').fadeTo("slow",0.85);	

	//Get the window height and width
	var winH = $(window).height();
	var winW = $(window).width();

	//Dialog Dimensions
	var dialogH = $(id).height();
	var dialogW = $(id).width();
		  
	//Set the popup window to center
	$(id).css('top',  winH/2-dialogH/2);
	$(id).css('left', winW/2-dialogW/2);

	//transition effect
	$(id).fadeIn(1000); 
}
