//Developed by ACME Krisshen

(function($) {
		  
// code block start//
 
   $.fn.KrisLightBox = function(innerW,innerH,innerURL) {
	   
	// set the owned values;
	var ww =  document.body.offsetWidth;
	var hh =  document.body.offsetHeight;
	var opacity = 9;
	var initW = 20;
	var initH = 20;
	var initL = (document.body.clientWidth-initW)/2;
	var initT =(document.body.clientHeight-initH)/2;
	var innerL=(document.body.clientWidth-innerW)/2;
	var offsetTT = document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop;
	var innerT = offsetTT+50;
	/*var innerT=(document.body.clientHeight-innerH)/2;*/
	var coverBackGround = '#023C6E';
	
	// build reference object;
    var me = this;
	var eachme = $(this);

		// for each this to do ;
		me.each(function(){
						 
		function coverMe(){
	$("<div></div>").attr({id:'lightbox'}).appendTo("body");
	$('#lightbox').css({'width':initW+'px','height':initH+'px','left':initL+'px','top':initT+'px','background':coverBackGround});
	$('#lightbox').animate({'width':ww+'px','height':hh+'px','opacity':'0.'+opacity,'filter':'alpha(opacity='+opacity+'0)','left':'0px','top':'0px'},"fast",pushMe);
	$('#lightbox').click(function(){});
	}
	
function pushMe(){
	$("<div></div>").attr({id:'frameContainer'}).appendTo("body");
	$("<div></div>").attr({id:'frameClose'}).appendTo("#frameContainer");
	$('#frameContainer').css({'width':initW+'px','height':initH+'px','left':initL+'px','top':initT+'px','background':'white','display':'none'});
	
	$('#frameContainer').animate({'width':innerW+'px','height':innerH+'px','left':innerL+'px','top':innerT+'px'},"normal",showFrame);
	$('#frameClose').click(function(){
	
	$('#lightbox').next().remove();$('#lightbox').remove();
	
	
	});
}

function showFrame(){
	var frameCode = "<iframe id='frameID' name='foot' width='"+innerW+"px' height='"+innerH+"px' frameborder='0' scrolling='no' marginwidth='0' marginheight='0' src='"+innerURL+"'></iframe>";
	$('#frameContainer').append(frameCode);
	var ww =  document.body.offsetWidth;
	var hh =  document.body.offsetHeight;
	$('#lightbox').css({'width':ww+'px','height':hh+'px'});
}

$(window).resize(function(){
		var ww =  document.body.offsetWidth;
		var hh =  document.body.offsetHeight;
		var offsetTT = document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop
		var innercL=(ww-innerW)/2;
		var innercT=offsetTT+50;
		$('#lightbox').css({'width':ww+'px','height':hh+'px'});
		$('#frameContainer').css({'left':innercL+'px','top':innercT+'px'});
	});

eachme.click(function(event){
						//if(eachme.attr("href")!=null){
							var offsetTT = document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop
							
	
					   /*innerT = event.clientY + offsetTT-100;*/
					   innerT = offsetTT+50;
					   if((innerT+innerH)>hh){
					   innerT = innerT-(innerT+innerH-hh)-20;
					   
					   }
						//}
					   event.preventDefault();
					   coverMe();
												   
												   });
			
		});	
 	return me;
	
	}
	
// code block ends //
 
 })(jQuery);