﻿//jQuery.ptibox
;(function(jQuery) {

	jQuery.fn.fixPNG = function() {
		return this.each(function () {
			var image = jQuery(this).css('backgroundImage');

			if (image.match(/^url\(["']?(.*\.png)["']?\)$/i)) {
				image = RegExp.$1;
				jQuery(this).css({
					'backgroundImage': 'none',
					'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=" + (jQuery(this).css('backgroundRepeat') == 'no-repeat' ? 'crop' : 'scale') + ", src='" + image + "')"
				}).each(function () {
					var position = jQuery(this).css('position');
					if (position != 'absolute' && position != 'relative')
						jQuery(this).css('position', 'relative');
				});
			}
		});
	};

	var elem, opts, busy = false, playing = false, imagePreloader = new Image, loadingTimer, loadingFrame = 1, imageRegExp = /\.(jpg|gif|png|bmp|jpeg)(.*)?$/i;
	var isIE = (jQuery.browser.msie && parseInt(jQuery.browser.version.substr(0,1)) < 7);

	jQuery.fn.ptibox = function(settings) {
		settings = jQuery.extend({}, jQuery.fn.ptibox.defaults, settings);
                
		var matchedGroup = this;

		function _initialize() {
			elem = this;
			opts = settings;

			_start();

			return false;
		};

		function _start() {
			if (busy) return;

			if (jQuery.isFunction(opts.callbackOnStart)) {
				opts.callbackOnStart();
			}
            			
			if (settings.itemArray.length > 0) {
				opts.itemArray = settings.itemArray;
			    opts.itemCurrent	= 0;

			} else {
			    opts.itemArray		= [];
			    opts.itemCurrent	= 0;

				var item = {};

				if (!elem.rel || elem.rel == '') {
					var item = {href: elem.href, title: elem.title};

					if (jQuery(elem).children("img:first").length) {
						item.orig = jQuery(elem).children("img:first");
					}
                                        
					opts.itemArray.push( item );

				} else {
					
					var subGroup = jQuery(matchedGroup).filter("a[rel=" + elem.rel + "]");

					var item = {};

					for (var i = 0; i < subGroup.length; i++) {
						item = {href: subGroup[i].href, title: subGroup[i].title};

						if (jQuery(subGroup[i]).children("img:first").length) {
							item.orig = jQuery(subGroup[i]).children("img:first");
						}

						opts.itemArray.push( item );
					}

					while ( opts.itemArray[ opts.itemCurrent ].href != elem.href ) {
						opts.itemCurrent++;
					}
				}
			}

			if (opts.overlayShow) {
				if (isIE) {
					//jQuery('embed, object, select').css('visibility', 'hidden');
					jQuery('select').css('visibility', 'hidden');
				}

				jQuery("#ptibox_overlay").css('opacity', opts.overlayOpacity).show();
			}

			jQuery.fn.ptibox.changeItem();
		};

        _initialize();
        
		return this.unbind('click');
	};


	jQuery.fn.ptibox.changeItem =  function() {
		jQuery("#ptibox_right, #ptibox_left, #ptibox_close, #ptibox_info, #ptibox_play, #ptibox_title, #ptibox_caption").hide();

		var href = opts.itemArray[opts.itemCurrent].href;
		var htmlContent = opts.itemArray[opts.itemCurrent].htmlContent;
		var htmlButton = opts.itemArray[opts.itemCurrent].htmlButton;
        var width = opts.frameWidth;
        var height = opts.frameHeight;
		
		if (opts.itemArray[opts.itemCurrent].frameWidth != null)
		{
		    width = opts.itemArray[opts.itemCurrent].frameWidth;
        }
        
		if (opts.itemArray[opts.itemCurrent].frameHeight != null)
		{
		    height = opts.itemArray[opts.itemCurrent].frameHeight;
        }
        


        if (htmlContent == null)
        {
            htmlContent = "";
        }

        if (htmlContent.length > 0)
        {
            //htmlContent as parameter            
			jQuery.fn.ptibox.setContent('<div id="ptibox_div"><div id="ptibox_div_inner">' + htmlContent + '</div></div>', htmlButton, width, height);                
        }
		else if (href.match(/#/))
		{
		    // Inline Content
			var target = window.location.href.split('#')[0]; target = href.replace(target, ''); target = target.substr(target.indexOf('#'));

			jQuery.fn.ptibox.setContent('<div id="ptibox_div"><div id="ptibox_div_inner">' + jQuery(target).html() + '</div></div>', htmlButton, width, height);

		}
		else if (href.match(imageRegExp))
		{
		    // Images
			imagePreloader = new Image; imagePreloader.src = href;

			if (imagePreloader.complete)
			{
				jQuery.fn.ptibox.proceedImage();

			} 
			else
			{
				jQuery.fn.ptibox.showLoading();

				jQuery(imagePreloader).unbind().bind('load', function() {
                    jQuery.fn.ptibox.hideLoading();
					jQuery.fn.ptibox.proceedImage();
				});
			}
        }
        else if (href.match("iframe") /*|| elem.className.indexOf("iframe") >= 0*/)
        {
	        //iframe
		    jQuery.fn.ptibox.setContent('<iframe id="ptibox_frame" onload="jQuery.fn.ptibox.showIframe()" name="ptibox_iframe' + Math.round(Math.random()*1000) + '" frameborder="0" hspace="0" src="' + href + '"></iframe>', htmlButton, width, height);
        }
        else if (href.match("callback"))
        {
	        //jsonp
			jQuery.fn.ptibox.showLoading();

			jQuery.getJSON(href, function(data) {
                if (data.returnStatus != 1)
                {
                    ptiTrace("JSON ERROR: " + data.returnMessage);
                    return;
                }
			
                jQuery.fn.ptibox.hideLoading();
				jQuery.fn.ptibox.setContent( '<div id="ptibox_div"><div id="ptibox_div_inner">' + data.returnData + '</div></div>', htmlButton, width, height );
			});				
		}
		else
		{
		    //regular ajax
			jQuery.fn.ptibox.showLoading();

			jQuery.get(href, function(data) {
                jQuery.fn.ptibox.hideLoading();
				jQuery.fn.ptibox.setContent( '<div id="ptibox_div"><div id="ptibox_div_inner">' + data + '</div></div>', htmlButton, width, height );
			});
		}
	};

	jQuery.fn.ptibox.proceedImage =  function() {
		if (opts.imageScale) {
			var w = jQuery.fn.ptibox.getViewport();

			var r = Math.min(Math.min(w[0] - 36, imagePreloader.width) / imagePreloader.width, Math.min(w[1] - 60, imagePreloader.height) / imagePreloader.height);

			var width = Math.round(r * imagePreloader.width);
			var height = Math.round(r * imagePreloader.height);

		} else {
			var width = imagePreloader.width;
			var height = imagePreloader.height;
		}

		jQuery.fn.ptibox.setContent('<img alt="" id="ptibox_img" src="' + imagePreloader.src + '" />', "", width, height);
	};

	jQuery.fn.ptibox.preloadNeighborImages =  function() {
		if ((opts.itemArray.length -1) > opts.itemCurrent) {
			var href = opts.itemArray[opts.itemCurrent + 1].href;

			if (href.match(imageRegExp)) {
				objNext = new Image();
				objNext.src = href;
			}
		}

		if (opts.itemCurrent > 0) {
			var href = opts.itemArray[opts.itemCurrent -1].href;

			if (href.match(imageRegExp)) {
				objNext = new Image();
				objNext.src = href;
			}
		}
	};

	jQuery.fn.ptibox.setContent =  function(value, button, width, height) {
		busy = true;

		var pad = opts.padding;
		var heightwithoutpadding = height;
		var heightbutton = 40;
		var heightdiv = (height-heightbutton);


		if (isIE) {
			jQuery("#ptibox_content")[0].style.removeExpression("height");
			jQuery("#ptibox_content")[0].style.removeExpression("width");
		}

		if (pad > 0) {
			width	+= pad * 2;
			height	+= pad * 2;

			jQuery("#ptibox_content").css({
				'top'		: pad + 'px',
				'right'		: pad + 'px',
				'bottom'	: pad + 'px',
				'left'		: pad + 'px',
				'width'		: 'auto',
				'height'	: 'auto'
			});

			if (isIE) {
				jQuery("#ptibox_content")[0].style.setExpression('height', '(this.parentNode.clientHeight - ' + (pad * 2).toString() + ')');
				jQuery("#ptibox_content")[0].style.setExpression('width', '(this.parentNode.clientWidth - ' + (pad * 2).toString() + ')');
			}

		} else {
			jQuery("#ptibox_content").css({
				'top'		: 0,
				'right'		: 0,
				'bottom'	: 0,
				'left'		: 0,
				'width'		: '100%',
				'height'	: '100%'
			});
		}

		if (jQuery("#ptibox_outer").is(":visible") && width == jQuery("#ptibox_outer").width() && height == jQuery("#ptibox_outer").height()) {
			jQuery("#ptibox_content").fadeOut("fast", function() {
			    
			    jQuery("#ptibox_button").html(button);
			    
	            if (button)
	            {
	                // Resize Content
	                jQuery("#ptibox_div").height(heightdiv);
	                jQuery("#ptibox_button").height(heightbutton);
	                jQuery("#ptibox_button").css({'display':'block'});
	            }
	            else
	            {
	                jQuery("#ptibox_div").height(heightwithoutpadding);
	                jQuery("#ptibox_button").css({'display':'none'});	            
	            }
	            
				jQuery("#ptibox_content").empty().append(jQuery(value)).fadeIn("normal", function() {
					jQuery.fn.ptibox.finish();
				});				
			});

            
			return;
		}

		var w = jQuery.fn.ptibox.getViewport();

		var itemLeft	= (width + 36)	> w[0] ? w[2] : (w[2] + Math.round((w[0] - width - 36) / 2));
		var itemTop		= (height + 50)	> w[1] ? w[3] : (w[3] + Math.round((w[1] - height - 50) / 2));


		var itemOpts = {
			'left':		itemLeft,
			'top':		itemTop,
			'width':	width + 'px',
			'height':	height + 'px'
		};

		if (jQuery("#ptibox_outer").is(":visible")) {

			jQuery("#ptibox_content").fadeOut("normal", function() {
				jQuery("#ptibox_content").empty();
				jQuery("#ptibox_outer").animate(itemOpts, opts.zoomSpeedChange, opts.easingChange, function() {
			        jQuery("#ptibox_button").html(button);
	                if (button)
	                {
	                    // Resize Content
	                    jQuery("#ptibox_div").height(heightdiv);
	                    jQuery("#ptibox_button").height(heightbutton);
	                    jQuery("#ptibox_button").css({'display':'block'});
	                }
	                else
	                {
	                    jQuery("#ptibox_div").height(heightwithoutpadding);
	                    jQuery("#ptibox_button").css({'display':'none'});
                    }
					jQuery("#ptibox_content").append(jQuery(value)).fadeIn("normal", function() {
						jQuery.fn.ptibox.finish();
					});                
				});
			});
			
		} else {
			if (opts.zoomSpeedIn > 0 && opts.itemArray[opts.itemCurrent].orig !== undefined) {
			    jQuery("#ptibox_button").html(button);
				jQuery("#ptibox_content").empty().append(jQuery(value));
	            if (button)
	            {
	                // Resize Content
	                jQuery("#ptibox_div").height(heightdiv);
                    jQuery("#ptibox_button").height(heightbutton);
                    jQuery("#ptibox_button").css({'display':'block'});
                }
                else
                {
	                jQuery("#ptibox_div").height(heightwithoutpadding);
                    jQuery("#ptibox_button").css({'display':'none'});
                }

				var orig_item	= opts.itemArray[opts.itemCurrent].orig;
				var orig_pos	= jQuery.fn.ptibox.getPosition(orig_item);

				jQuery("#ptibox_outer").css({
					'left':		(orig_pos.left - 18) + 'px',
					'top':		(orig_pos.top  - 18) + 'px',
					'width':	jQuery(orig_item).width(),
					'height':	jQuery(orig_item).height()
				});

				if (opts.zoomOpacity) {
					itemOpts.opacity = 'show';
				}

				jQuery("#ptibox_outer").animate(itemOpts, opts.zoomSpeedIn, opts.easingIn, function() {
					jQuery.fn.ptibox.finish();
				});

			} else {

			    jQuery("#ptibox_button").html(button);
				jQuery("#ptibox_content").hide().empty().append(jQuery(value)).show();
	            if (button)
	            {
	                // Resize Content
	                jQuery("#ptibox_div").height(heightdiv);
                    jQuery("#ptibox_button").height(heightbutton);
                    jQuery("#ptibox_button").css({'display':'block'});
                }
                else
                {
                    jQuery("#ptibox_div").height(heightwithoutpadding);
                    jQuery("#ptibox_button").css({'display':'none'});
                }
				jQuery("#ptibox_outer").css(itemOpts).fadeIn("normal", function() {
					jQuery.fn.ptibox.finish();
				});
			}
		}
	};

	jQuery.fn.ptibox.setNavigation =  function() {
        jQuery("#ptibox_info").hover(function() {
            jQuery('#ptibox_caption').css({ visibility: "visible" });
        }, function() {

            jQuery('#ptibox_caption').css({ visibility: "hidden" });
        });

		if (opts.itemCurrent != 0) {
			jQuery("#ptibox_left, #ptibox_left_ico").unbind().bind("click", function(e) {
				e.stopPropagation();

				opts.itemCurrent--;
				jQuery.fn.ptibox.changeItem();

				return false;
			});

			jQuery("#ptibox_left").show();
		}

		if (opts.itemCurrent != ( opts.itemArray.length -1)) {
			jQuery("#ptibox_right, #ptibox_right_ico").unbind().bind("click", function(e) {
				e.stopPropagation();

				opts.itemCurrent++;
				jQuery.fn.ptibox.changeItem();

				return false;
			});

			jQuery("#ptibox_right").show();
		}

        if (opts.itemArray.length > 1) {
            jQuery("#ptibox_play").unbind().bind("click", function(e) {
                e.stopPropagation();

                jQuery.fn.ptibox.toggleSlideshow();

                return false;
            });

            jQuery("#ptibox_play").show();
        }
	};

	jQuery.fn.ptibox.toggleSlideshow =  function() {
        if (playing) {
            jQuery.fn.ptibox.stopSlideshow();
        }
        else {
            jQuery.fn.ptibox.startSlideshow();
        }
    }

	jQuery.fn.ptibox.startSlideshow =  function() {
        if (!playing) {
            playing = !playing;

            jQuery("#ptibox_play").addClass("ptibox_pause");
            jQuery("#ptibox_play").removeClass("ptibox_play");

            intInterval = window.setInterval(function() {
                if (opts.itemCurrent == opts.itemArray.length - 1) {
                    opts.itemCurrent = 0;
                }
                else {
                    opts.itemCurrent++;
                }

                jQuery.fn.ptibox.changeItem();
            }, 3000);
        }
    }

	jQuery.fn.ptibox.stopSlideshow =  function() {
        if (playing)
        {
            playing = !playing;

            jQuery("#ptibox_play").addClass("ptibox_play");
            jQuery("#ptibox_play").removeClass("ptibox_pause");

            intInterval = window.clearInterval(intInterval);
        }
    }

	jQuery.fn.ptibox.finish =  function() {
		jQuery.fn.ptibox.setNavigation();

		jQuery.fn.ptibox.preloadNeighborImages();

		jQuery(document).keydown(function(e) {
			if (e.keyCode == 27) {
			    jQuery.fn.ptibox.stopSlideshow();
				jQuery.fn.ptibox.close();
				jQuery(document).unbind("keydown");

			} else if(e.keyCode == 37 && opts.itemCurrent != 0) {
				opts.itemCurrent--;
				jQuery.fn.ptibox.changeItem();
				jQuery(document).unbind("keydown");

			} else if(e.keyCode == 39 && opts.itemCurrent != (opts.itemArray.length - 1)) {
				opts.itemCurrent++;
				jQuery.fn.ptibox.changeItem();
				jQuery(document).unbind("keydown");
			}
		});

		if (opts.centerOnScroll) {
			jQuery(window).bind("resize scroll", jQuery.fn.ptibox.scrollBox);
		} else {
			jQuery("div#ptibox_outer").css("position", "absolute");
		}

		if (opts.hideOnContentClick) {			    
		    jQuery("#ptibox_wrap").click(jQuery.fn.ptibox.stopSlideshow);
			jQuery("#ptibox_wrap").click(jQuery.fn.ptibox.close);
		}


        // shop content clicks closing
		//jQuery("#ptibox_inner").bind("click", function(){alert("click");return false;});
		
		jQuery("#ptibox_overlay, #ptibox_close").bind("click", jQuery.fn.ptibox.stopSlideshow);
		jQuery("#ptibox_overlay, #ptibox_close").bind("click", jQuery.fn.ptibox.close);

        if (opts.showCloseButton)
        {
            jQuery("#ptibox_close").show();
        }
        else
        {
            jQuery("#ptibox_close").hide();
        }
                    
        if (opts.showInfoButton)
        {
            jQuery("#ptibox_info").show();
        }
        else
        {
            jQuery("#ptibox_info").hide();
        }

        if (opts.showPlayButton)
        {
            jQuery("#ptibox_play").show();
        }
        else
        {
            jQuery("#ptibox_play").hide();
        }
                
        jQuery("#ptibox_caption").show();

        if (opts.itemArray[opts.itemCurrent].title !== undefined && opts.itemArray[opts.itemCurrent].title.length > 0) {
            //jQuery('#ptibox_title div').html(opts.itemArray[ opts.itemCurrent ].title);
            //jQuery('#ptibox_title').show();

            var strTitle = "";

            if (opts.itemArray.length > 1) {
                strTitle = "<strong>Image " + (opts.itemCurrent + 1) + " of " + opts.itemArray.length + " </strong><br />" + opts.itemArray[opts.itemCurrent].title;
            }
            else {
                strTitle = opts.itemArray[opts.itemCurrent].title;
            }

            jQuery('#ptibox_caption_inner').html(strTitle);
            //jQuery('#ptibox_title').show();
        }

		if (opts.overlayShow && isIE) {
			//jQuery('embed, object, select', jQuery('#ptibox_content')).css('visibility', 'visible');
			jQuery('select', jQuery('#ptibox_content')).css('visibility', 'visible');
		}

        if (pitIsTouch && jQuery("#ptibox_div_inner").html())
        {
            //iPhone, iPad, or Android and there is some content			
			document.addEventListener('touchmove', jQuery.fn.ptibox.preventDefault, false);            
            iScrollScroller = new iScroll("ptibox_div_inner");            
        }        

		if (jQuery.isFunction(opts.callbackOnShow)) {
			opts.callbackOnShow();
		}

		busy = false;
	};



	jQuery.fn.ptibox.preventDefault = function(e){
		// used by touch
		e.preventDefault();
	}


	jQuery.fn.ptibox.scrollBox = function() {
		var pos = jQuery.fn.ptibox.getViewport();

		jQuery("#ptibox_outer").css('left', ((jQuery("#ptibox_outer").width()	+ 36) > pos[0] ? pos[2] : pos[2] + Math.round((pos[0] - jQuery("#ptibox_outer").width()	- 36)	/ 2)));
		jQuery("#ptibox_outer").css('top',  ((jQuery("#ptibox_outer").height()	+ 50) > pos[1] ? pos[3] : pos[3] + Math.round((pos[1] - jQuery("#ptibox_outer").height()	- 50)	/ 2)));
	};

	jQuery.fn.ptibox.getNumeric = function(el, prop) {
		return parseInt(jQuery.curCSS(el.jquery?el[0]:el,prop,true))||0;
	};

	jQuery.fn.ptibox.getPosition = function(el) {
		var pos = el.offset();

		pos.top	+= jQuery.fn.ptibox.getNumeric(el, 'paddingTop');
		pos.top	+= jQuery.fn.ptibox.getNumeric(el, 'borderTopWidth');

		pos.left += jQuery.fn.ptibox.getNumeric(el, 'paddingLeft');
		pos.left += jQuery.fn.ptibox.getNumeric(el, 'borderLeftWidth');

		return pos;
	};

	jQuery.fn.ptibox.showIframe = function() {
        jQuery.fn.ptibox.hideLoading();
		jQuery("#ptibox_frame").show();
	};

	jQuery.fn.ptibox.getViewport = function() {
		return [jQuery(window).width(), jQuery(window).height(), jQuery(document).scrollLeft(), jQuery(document).scrollTop() ];
	};

	jQuery.fn.ptibox.animateLoading = function() {
		if (!jQuery("#ptibox_loading").is(':visible')){
			clearInterval(loadingTimer);
			return;
		}

		jQuery("#ptibox_loading > div").css('top', (loadingFrame * -40) + 'px');

		loadingFrame = (loadingFrame + 1) % 12;
	};

	jQuery.fn.ptibox.showLoading = function() {
		clearInterval(loadingTimer);

		var pos = jQuery.fn.ptibox.getViewport();

		jQuery("#ptibox_loading").css({'left': ((pos[0] - 40) / 2 + pos[2]), 'top': ((pos[1] - 40) / 2 + pos[3])}).show();

		jQuery("#ptibox_loading").bind('click', jQuery.fn.ptibox.close);

		loadingTimer = setInterval(jQuery.fn.ptibox.animateLoading, 66);
	};

	jQuery.fn.ptibox.hideLoading = function() {
		jQuery(".ptibox_loading").hide();	
	}

	jQuery.fn.ptibox.close = function(pobjCallbackOnClose) {
		busy = true;


        if (iScrollScroller)
        {
			document.removeEventListener('touchmove', jQuery.fn.ptibox.preventDefault, false);            
            iScrollScroller.destroy(true);
            iScrollScroller = null;
        }


        if (pobjCallbackOnClose != null)
        {
            opts.callbackOnClose = pobjCallbackOnClose;
        }        

		jQuery(imagePreloader).unbind();

		jQuery("#ptibox_overlay, #ptibox_inner, #ptibox_close, #ptibox_info, #ptibox_play").unbind();

		if (opts.hideOnContentClick) {
			jQuery("#ptibox_wrap").unbind();
		}

        jQuery("#ptibox_close, #ptibox_info, #ptibox_play, .ptibox_loading, #ptibox_left, #ptibox_right, #ptibox_title").hide();

		if (opts.centerOnScroll) {
			jQuery(window).unbind("resize scroll");
		}

		__cleanup = function() {
			jQuery("#ptibox_overlay, #ptibox_outer").hide();

			if (opts.centerOnScroll) {
				jQuery(window).unbind("resize scroll");
			}

			if (isIE) {
				//jQuery('embed, object, select').css('visibility', 'visible');
				jQuery('select').css('visibility', 'visible');
			}

			if (jQuery.isFunction(opts.callbackOnClose)) {
				opts.callbackOnClose();
			}

			busy = false;
		};

		if (jQuery("#ptibox_outer").is(":visible") !== false) {
			if (opts.zoomSpeedOut > 0 && opts.itemArray[opts.itemCurrent].orig !== undefined) {
				var orig_item	= opts.itemArray[opts.itemCurrent].orig;
				var orig_pos	= jQuery.fn.ptibox.getPosition(orig_item);

				var itemOpts = {
					'left':		(orig_pos.left - 18) + 'px',
					'top': 		(orig_pos.top  - 18) + 'px',
					'width':	jQuery(orig_item).width(),
					'height':	jQuery(orig_item).height()
				};

				if (opts.zoomOpacity) {
					itemOpts.opacity = 'hide';
				}

				jQuery("#ptibox_outer").stop(false, true).animate(itemOpts, opts.zoomSpeedOut, opts.easingOut, __cleanup);

			} else {
				jQuery("#ptibox_outer").stop(false, true).fadeOut("slow", __cleanup);
			}

		} else {
			__cleanup();
		}

		return false;
	};
	
	
	jQuery.fn.ptibox.showItem = function(objItem) {
	    // Clear out the current items and show the one whish is passed.
	    opts.itemArray = new Array();
	    opts.itemArray.push(objItem);
	    
	    jQuery.fn.ptibox.changeItem();
	    
	    jQuery.fn.ptibox.hideLoading();
	}
	
	


	jQuery.fn.ptibox.build = function() {
		var html = '';

        html += '<div id="ptibox_overlay"></div>';
        html += '<div id="ptibox_wrap">';
        html += '<div class="ptibox_loading" id="ptibox_loading"><div></div></div>';
        html += '<div id="ptibox_outer">';
        html += '<div id="ptibox_inner">';
        html += '<div id="ptibox_close"></div>';
        html += '<div id="ptibox_info"></div>';
        html += '<div id="ptibox_play" class="ptibox_play"></div>';
        html += '<div id="ptibox_bg"><div class="ptibox_bg ptibox_bg_n"></div><div class="ptibox_bg ptibox_bg_ne"></div><div class="ptibox_bg ptibox_bg_e"></div><div class="ptibox_bg ptibox_bg_se"></div><div class="ptibox_bg ptibox_bg_s"></div><div class="ptibox_bg ptibox_bg_sw"></div><div class="ptibox_bg ptibox_bg_w"></div><div class="ptibox_bg ptibox_bg_nw"></div></div>';
        html += '<a href="javascript:;" id="ptibox_left"><span class="ptibox_ico" id="ptibox_left_ico"></span></a><a href="javascript:;" id="ptibox_right"><span class="ptibox_ico" id="ptibox_right_ico"></span></a>';
        html += '<div id="ptibox_content"></div>';
        html += '<div id="ptibox_caption"><div id="ptibox_caption_inner"></div></div>';
        html += '<div id="ptibox_title"></div>';
        html += '<div id="ptibox_button"></div>';
        html += '</div>';
        html += '</div>';
        html += '</div>';

        jQuery(html).appendTo("body");

        jQuery('<table cellspacing="0" cellpadding="0" border="0"><tr><td class="ptibox_title" id="ptibox_title_left"></td><td class="ptibox_title" id="ptibox_title_main"><div></div></td><td class="ptibox_title" id="ptibox_title_right"></td></tr></table>').appendTo('#ptibox_title');
        
		if (isIE) {
			jQuery("#ptibox_inner").prepend('<iframe class="ptibox_bigIframe" scrolling="no" frameborder="0"></iframe>');
            jQuery("#ptibox_close, #ptibox_info, #ptibox_play, .ptibox_bg, .ptibox_title, .ptibox_ico").fixPNG();
		}
	};

	jQuery.fn.ptibox.defaults = {
		padding				:	10,
		imageScale			:	true,
		zoomOpacity			:	false,
		zoomSpeedIn			:	0,
		zoomSpeedOut		:	0,
		zoomSpeedChange		:	300,
		easingIn			:	'swing',
		easingOut			:	'swing',
		easingChange		:	'swing',
		frameWidth			:	500,
		frameHeight			:	400,
		overlayShow			:	true,
		overlayOpacity		:	0.3,
		hideOnContentClick	:	false,
		centerOnScroll		:	true,
		itemArray			:	[],
		callbackOnStart		:	null,
		callbackOnShow		:	null,
		callbackOnClose		:	null,
		showInfoButton      :   true,
		showPlayButton      :   true,
		showCloseButton     :   true
	};

    jQuery.fn.ptibox.itemDefaults = function (){
        var obj = new Object();
        
        obj.htmlContent         = ""; 
        obj.href                = ""; 
        obj.title               = ""; 
        obj.orig                = null; 
        obj.frameWidth          = 500; 
        obj.frameHeight         = 400    
        
        return obj;
    };

    jQuery.fn.ptibox.generateItemObject = function(htmlContent, htmlButton, href, title, orig, frameWidth, frameHeight)
    {
        return {htmlContent: htmlContent, htmlButton: htmlButton, href: href, title: title, orig: orig, frameWidth: frameWidth, frameHeight: frameHeight};
    }

	jQuery(document).ready(function() {
		jQuery.fn.ptibox.build();
	});

})(jQuery);

