function loadLibs() {
	$('#wrap').append(al);
	$('#wrap').append(lb);
	var sto = setTimeout(prepareLaunchBox, 100);
}

function prepareLaunchBox() {
	$('#launchlightbox').livequery('click', function(){
	    	$('#sb_overlay').css({visible:"visible",display:""});
	    	$('.lightbox').css({display:"block"});
	    	$('#lbox_inner').draggable();
	
	    	var scrWidth = document.body.clientWidth;
	    	var scrHeight = document.body.clientHeight;
	    	scrHeight = scrHeight+100;
	    	//$('.lightbox').css({width:scrWidth+"px", height:scrHeight+"px"});
			var popWidth = document.getElementById('img_alpha_'+currScreen).offsetWidth;
			var popHeight = document.getElementById('img_alpha_'+currScreen).offsetHeight;
	
			$('.lightbox-inner').css({width:popWidth+8});
			$('.lightbox-ml').css({height: (popHeight+48)});
			$('.lightbox-mr').css({height: (popHeight+48)});
	    });
	    $('.lightbox-close').livequery('click', function(){
	    	$('#sb_overlay').css({display:"none"});
	    	$('.lightbox').css({display:"none"});
	    });
	
	    $('#lbox_inner').livequery('click', function(e) {
	    	e.stopPropagation();
	    });
	
	    $('#lbox_container').livequery('click', function(e){
	    	$('#sb_overlay').css({display:"none"});
	    	$('.lightbox').css({display:"none"});
	    });
	    $('.lightbox-rightnav').livequery('click', function(){
			var totalPreviews = $('.lightbox-preview img').length;
	
			$("#pre_"+currScreen).css({display:"none"});
			currScreen += 1;
			if(currScreen>$('.lightbox-preview img').length){
				currScreen=1;
			}
			var popWidth = document.getElementById('img_alpha_'+currScreen).offsetWidth;
			var popHeight = document.getElementById('img_alpha_'+currScreen).offsetHeight;
	
			$('.lightbox-inner').css({width: popWidth+8});
			$('.lightbox-ml').css({height: popHeight+48});
			$('.lightbox-mr').css({height: popHeight+48});
			$("#pre_"+currScreen).fadeIn(200);
	
	    });
	    $('.lightbox-leftnav').livequery('click', function(){
			var totalPreviews = $('.lightbox-preview img').length;
			//console.log(totalPreviews+": #pre_"+currScreen);
			$("#pre_"+currScreen).css({display:"none"});
			currScreen -= 1;
			if(currScreen<1){
				currScreen=$('.lightbox-preview img').length;
			}
			var popWidth = document.getElementById('img_alpha_'+currScreen).offsetWidth;
			var popHeight = document.getElementById('img_alpha_'+currScreen).offsetHeight;
	
			$('.lightbox-inner').css({width: popWidth+8});
			$('.lightbox-ml').css({height: popHeight+48});
			$('.lightbox-mr').css({height: popHeight+48});
			$("#pre_"+currScreen).fadeIn(200);
	    });
	    
	    
	$(document).livequery('keyup', function(e) {
		//alert(e);
	
		var code;
		if (!e) var e = window.event;
		if (e.keyCode) code = e.keyCode;
		else if (e.which) code = e.which;
		//alert(e.which);
		if(e.which == '39')
		{
			{
				var totalPreviews = $('.lightbox-preview img').length;
	
				$("#pre_"+currScreen).css({display:"none"});
				currScreen += 1;
				if(currScreen>$('.lightbox-preview img').length){
					currScreen=1;
				}
				var popWidth = document.getElementById('img_alpha_'+currScreen).offsetWidth;
				var popHeight = document.getElementById('img_alpha_'+currScreen).offsetHeight;
	
				$('.lightbox-inner').css({width: popWidth+8});
				$('.lightbox-ml').css({height: popHeight+48});
				$('.lightbox-mr').css({height: popHeight+48});
				$("#pre_"+currScreen).fadeIn(200);
	
	    	}
	
			//alert("Right 39");
		}
		else if(e.which == '37')
		{
			{
				var totalPreviews = $('.lightbox-preview img').length;
				//console.log(totalPreviews+": #pre_"+currScreen);
				$("#pre_"+currScreen).css({display:"none"});
				currScreen -= 1;
				if(currScreen<1){
					currScreen=$('.lightbox-preview img').length;
				}
				var popWidth = document.getElementById('img_alpha_'+currScreen).offsetWidth;
				var popHeight = document.getElementById('img_alpha_'+currScreen).offsetHeight;
	
				$('.lightbox-inner').css({width: popWidth+8});
				$('.lightbox-ml').css({height: popHeight+48});
				$('.lightbox-mr').css({height: popHeight+48});
				$("#pre_"+currScreen).fadeIn(200);
	   		}
	
			//alert("Left 37");
		}
		else if(e.which == '27')
		{
			{
		    	$('#sb_overlay').css({display:"none"});
		    	$('.lightbox').css({display:"none"});
	    	}
	
			//alert("Esc");
		}
		//alert(e.which);
		//var character = String.fromCharCode(code);
		//alert('Character was ' + character);
	
	
	
	});
	    
}


