/********************************************************************
* Pro-Links Lightbox http://www.pro-links.com
*********************************************************************
* Author: 			Pro-Links Marketing and Web Services
* Version:			1.0
* Last Modified: 	6/17/2009
* Requirements: 	JQuery
* Description: 		Custom Lightbox, this code is sole property of Pro-Links
*					Development and may not be used, distributed, or copied
* 					without written consent from Pro-LInks Development LLC.
* Change Log:		-
*********************************************************************/


	function PLZLightbox(){
		this.pgMaskId = "plzLightboxLargerPicPgMask";
		this.picContId = "plzLightboxLargerPic";
		this.closeWindowId = "plzLightboxLargerPicCloseWind";
		
		this.html = "<div id=\"" + this.pgMaskId + "\" onclick=\"return !(plzLightboxHide());\"></div>" + 
					"<div id=\"" + this.picContId + "\" onclick=\"return !(plzLightboxHide());\">" +
						"<div id=\"" + this.closeWindowId + "\">Click Image to Close.</div>" +
						"<img src=\"\" />" +
					"</div>";
		
		
	}
	
	PLZLightbox.prototype.draw = function(){

		$("body").append(this.html);
		$("#" + this.picContId).css({
			"position" 			: "absolute",
			"z-index" 			: "9999",
			"display" 			: "none",
			"background-color" 	: "#799b9c",
			"border"			: "solid 1px #486bc",
			"padding" 			: "5px",
			"height"			: "443px",
			"width"				: "645px",
			"top" 				: "40px",
			"left" 				: "40px"
		});
		$("#" + this.pgMaskId).css({
			"position" 			: "absolute",
			"background-color" 	: "#000000",
			"display" 			: "none",
			"z-index" 			: "9998",
			"top" 				: "0px",
			"left" 				: "0px"				
		});
		
		$("#" + this.closeWindowId).css({
			"position" 			: "relative",
			"top" 				: "1px",
			"left" 				: "2px",
			"color" 			: "#FFFFFF",
			"font-weight" 		: "bold"
		});
	}
	

		
	function finishToggle(id){
		var h = $(id + " img").height();
		var w = $(id + " img").width();
		alert("H: " + h + " | W: " + w);
		if(h > 1 && w > 1){
			$(id).css({
					  "height" 		: (h + 10) + "px", 
					  "width"		: (w + 10) + "px"
					  });
		}
		
	}
	function plzLightboxToggle(op, imgUrl, w, h){
		
		var id = "#plzLightboxLargerPic";
		var mid = "#plzLightboxLargerPicPgMask";
		switch(op){
			case 1:
				$(id + " img").attr("src",imgUrl);
				$(id + " img").css({
					  "height" 		: (h) + "px", 
					  "width"		: (w) + "px"		  
				});
				$(id).css({
					  "height" 		: (h + 18) + "px", 
					  "width"		: (w) + "px"
					  });
				//setTimeout("finishToggle('" + id + "','" + mid + "')", 500);
				var winH = $(window).height();   
				var winW = $(window).width();  
				/*Load and run mask*/
				var maskHeight = $(document).height();   
				var maskWidth = $(window).width();
				
				/*
				if($(id).height() > 500){
					$(id).height(520);
					$(id + " img").height(500);
				}else if($(id).width() > 600){
					$(id).width(600);
					$(id + " img").width(600);
				}
				*/
				
				var ts = $(document).scrollTop();
		
				$(mid).css({"width":maskWidth,"height":maskHeight});
				$(id).css("top",  (winH/2-$(id).height()/2) + ts);   
				$(id).css("left", winW/2-$(id).width()/2); 
				
				$(id).show(750,function(){
					$(mid).fadeIn(500);
					$(mid).fadeTo("slow",0.8);
				});
				break;
			default:
				$(mid).hide();
				$(id).hide("slow");
				
		}
		return false;
	}
	function plzLightboxHide(){
		plzLightboxToggle(0,'');
		return true;
	}
	
	
			  	 
				
			
