﻿/*

function ieVersion() {
var rv = -1;
if (navigator.appName == 'Microsoft Internet Explorer') {
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat(RegExp.$1);
}
return rv;
}
var version = ieVersion();

if ((navigator.appName == "Microsoft Internet Explorer") && (version < 7) && readCookie('end6') != '1') {
createCookie("end6", "1", 60 * 24 * 360);
location.href = "http://www.bioware.ru/ie6/ie6.html";
}


function createCookie(name, value, minutes) {
var minutes = minutes;
if (minutes) {
var date = new Date();
date.setTime(date.getTime() + (minutes * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
} else {
var expires = "";
}
document.cookie = name + "=" + value + expires + "; path=/";
}


function readCookie(the_name) {
var nameEQ = the_name + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
return null;
}*/
/* jQuery lightBox plugin
* This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)
* and adapted to me for use like a plugin from jQuery.
* @name jquery-lightbox-0.5.js
* @author Leandro Vieira Pinho - http://leandrovieira.com
* @version 0.5
* @date April 11, 2008
* @category jQuery plugin
* @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com)
* @license CC Attribution-No Derivative Works 2.5 Brazil - http://creativecommons.org/licenses/by-nd/2.5/br/deed.en_US
* @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin
*/

// Offering a Custom Alias suport - More info: http://docs.jquery.com/Plugins/Authoring#Custom_Alias
(function($) {
    /**
    * $ is an alias to jQuery object
    *
    */
    $.fn.lightBox = function(settings) {
        // Settings to configure the jQuery lightBox plugin how you like
        settings = jQuery.extend({
            maxWidth: null,
            maxHeight: null,
            // Configuration related to overlay
            overlayBgColor: '#000', 	// (string) Background color to overlay; inform a hexadecimal value like: #RRGGBB. Where RR, GG, and BB are the hexadecimal values for the red, green, and blue values of the color.
            overlayOpacity: 0.8, 	// (integer) Opacity value to overlay; inform: 0.X. Where X are number from 0 to 9
            // Configuration related to navigation
            fixedNavigation: false, 	// (boolean) Boolean that informs if the navigation (next and prev button) will be fixed or not in the interface.
            // Configuration related to images
            imageLoading: 'images/lightbox-ico-loading.gif', 	// (string) Path and the name of the loading icon
            imageBtnPrev: 'images/lightbox-btn-prev.gif', 		// (string) Path and the name of the prev button image
            imageBtnNext: 'images/lightbox-btn-next.gif', 		// (string) Path and the name of the next button image
            imageBtnClose: 'images/lightbox-btn-close.gif', 	// (string) Path and the name of the close btn
            imageBlank: 'images/lightbox-blank.gif', 		// (string) Path and the name of a blank image (one pixel)
            // Configuration related to container image box
            containerBorderSize: 10, 		// (integer) If you adjust the padding in the CSS for the container, #lightbox-container-image-box, you will need to update this value
            containerResizeSpeed: 400, 	// (integer) Specify the resize duration of container image. These number are miliseconds. 400 is default.
            // Configuration related to texts in caption. For example: Image 2 of 8. You can alter either "Image" and "of" texts.
            txtImage: 'Image', // (string) Specify text "Image"
            txtOf: 'of', 	// (string) Specify text "of"
            // Configuration related to keyboard navigation
            keyToClose: 'c', 	// (string) (c = close) Letter to close the jQuery lightBox interface. Beyond this letter, the letter X and the SCAPE key is used to.
            keyToPrev: 'p', 	// (string) (p = previous) Letter to show the previous image
            keyToNext: 'n', 	// (string) (n = next) Letter to show the next image.
            // Donґt alter these variables in any way
            imageArray: [],
            activeImage: 0
        }, settings);
        // Caching the jQuery object with all elements matched
        var jQueryMatchedObj = this; // This, in this context, refer to jQuery object
        /**
        * Initializing the plugin calling the start function
        *
        * @return boolean false
        */
        function _initialize() {
            _start(this, jQueryMatchedObj); // This, in this context, refer to object (link) which the user have clicked
            return false; // Avoid the browser following the link
        }
        /**
        * Start the jQuery lightBox plugin
        *
        * @param object objClicked The object (link) whick the user have clicked
        * @param object jQueryMatchedObj The jQuery object with all elements matched
        */
        function _start(objClicked, jQueryMatchedObj) {
            // Hime some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
            $('embed, object, select').css({ 'visibility': 'hidden' });
            // Call the function to create the markup structure; style some elements; assign events in some elements.
            _set_interface();
            // Unset total images in imageArray
            settings.imageArray.length = 0;
            // Unset image active information
            settings.activeImage = 0;
            // We have an image set? Or just an image? Letґs see it.
            if (jQueryMatchedObj.length == 1) {
                settings.imageArray.push(new Array(objClicked.getAttribute('href'), objClicked.getAttribute('title'), objClicked.getAttribute('rel')));
            } else {
                // Add an Array (as many as we have), with href and title atributes, inside the Array that storage the images references		
                for (var i = 0; i < jQueryMatchedObj.length; i++) {
                    settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute('href'), jQueryMatchedObj[i].getAttribute('title'), jQueryMatchedObj[i].getAttribute('rel')));
                }
            }
            while (settings.imageArray[settings.activeImage][0] != objClicked.getAttribute('href')) {
                settings.activeImage++;
            }
            // Call the function that prepares image exibition
            _set_image_to_view();
        }
        /**
        * Create the jQuery lightBox plugin interface
        *
        * The HTML markup will be like that:
        <div id="jquery-overlay"></div>
        <div id="jquery-lightbox">
        <div id="lightbox-container-image-box">
        <div id="lightbox-container-image">
        <img src="../fotos/XX.jpg" id="lightbox-image">
        <div id="lightbox-nav">
        <a href="#" id="lightbox-nav-btnPrev"></a>
        <a href="#" id="lightbox-nav-btnNext"></a>
        </div>
        <div id="lightbox-loading">
        <a href="#" id="lightbox-loading-link">
        <img src="../images/lightbox-ico-loading.gif">
        </a>
        </div>
        </div>
        </div>
        <div id="lightbox-container-image-data-box">
        <div id="lightbox-container-image-data">
        <div id="lightbox-image-details">
        <span id="lightbox-image-details-caption"></span>
        <span id="lightbox-image-details-currentNumber"></span>
        </div>
        <div id="lightbox-secNav">
        <a href="#" id="lightbox-secNav-btnClose">
        <img src="../images/lightbox-btn-close.gif">
        </a>
        </div>
        </div>
        </div>
        </div>
        *
        */
        function _set_interface() {
            // Apply the HTML markup into body tag
            $('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image"><img id="lightbox-image" /><div style="" id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="' + settings.imageLoading + '"></a></div></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span><div id="linksdiv" class="savelink"><a target="_blank" id="savelink" href="">Посмотреть в полный размер</a></div></div><div id="lightbox-secNav"><a href="#" id="lightbox-secNav-btnClose"><img src="' + settings.imageBtnClose + '"></a></div></div></div></div>');
            // Get page sizes
            var arrPageSizes = ___getPageSize();
            // Style overlay and show it
            $('#jquery-overlay').css({
                backgroundColor: settings.overlayBgColor,
                opacity: settings.overlayOpacity,
                width: arrPageSizes[0],
                height: arrPageSizes[1]
            }).fadeIn();
            // Get page scroll
            var arrPageScroll = ___getPageScroll();
            // Calculate top and left offset for the jquery-lightbox div object and show it
            $('#jquery-lightbox').css({
                top: arrPageScroll[1] + (arrPageSizes[3] / 10),
                left: arrPageScroll[0]
            }).show();
            // Assigning click events in elements to close overlay
            $('#jquery-overlay,#jquery-lightbox').click(function() {
                _finish();
            });
            // Assign the _finish function to lightbox-loading-link and lightbox-secNav-btnClose objects
            $('#lightbox-loading-link,#lightbox-secNav-btnClose').click(function() {
                _finish();
                return false;
            });
            // If window was resized, calculate the new overlay dimensions
            $(window).resize(function() {
                // Get page sizes
                var arrPageSizes = ___getPageSize();
                // Style overlay and show it
                $('#jquery-overlay').css({
                    width: arrPageSizes[0],
                    height: arrPageSizes[1]
                });
                // Get page scroll
                var arrPageScroll = ___getPageScroll();
                // Calculate top and left offset for the jquery-lightbox div object and show it
                $('#jquery-lightbox').css({
                    top: arrPageScroll[1] + (arrPageSizes[3] / 10),
                    left: arrPageScroll[0]
                });
            });
        }
        /**
        * Prepares image exibition; doing a imageґs preloader to calculate itґs size
        *
        */
        function _set_image_to_view() { // show the loading
            // Show the loading
            $('#lightbox-loading').show();
            if (settings.fixedNavigation) {
                $('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
            } else {
                // Hide some elements
                $('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
            }
            // Image preload process
            var objImagePreloader = new Image();
            objImagePreloader.onload = function() {
                $('#lightbox-image').attr('src', settings.imageArray[settings.activeImage][0]);
                // Perfomance an effect in the image container resizing it
                _resize_container_image_box(objImagePreloader.width, objImagePreloader.height);
                //	clear onLoad, IE behaves irratically with animated gifs otherwise
                objImagePreloader.onload = function() { };
            };
            objImagePreloader.src = settings.imageArray[settings.activeImage][0];
        };
        /**
        * Perfomance an effect in the image container resizing it
        *
        * @param integer intImageWidth The imageґs width that will be showed
        * @param integer intImageHeight The imageґs height that will be showed
        */
        function _resize_container_image_box(intImageWidth, intImageHeight) {
            //rescale if necessary
            if ((settings.maxWidth != null && settings.maxHeight != null) && (intImageWidth > settings.maxWidth || intImageHeight > settings.maxHeight)) {
                var isWider = intImageWidth > intImageHeight; //is the image wide or tall?
                var scale = isWider ? settings.maxWidth / intImageWidth : settings.maxHeight / intImageHeight;
                intImageWidth = intImageWidth * scale;
                intImageHeight = intImageHeight * scale;
            }

            $('#lightbox-image').height(intImageHeight);
            $('#lightbox-image').width(intImageWidth);
            // Get current width and height
            var intCurrentWidth = $('#lightbox-container-image-box').width();
            var intCurrentHeight = $('#lightbox-container-image-box').height();
            // Get the width and height of the selected image plus the padding
            var intWidth = (intImageWidth + (settings.containerBorderSize * 2)); // Plus the imageґs width and the left and right padding value
            if (intWidth < 350) intWidth = 350;
            var intHeight = (intImageHeight + (settings.containerBorderSize * 2)); // Plus the imageґs height and the left and right padding value
            // Diferences
            var intDiffW = intCurrentWidth - intWidth;
            var intDiffH = intCurrentHeight - intHeight;
            // Perfomance the effect
            $('#lightbox-container-image-box').animate({ width: intWidth, height: intHeight }, settings.containerResizeSpeed, function() { _show_image(); });
            if ((intDiffW == 0) && (intDiffH == 0)) {
                if ($.browser.msie) {
                    ___pause(250);
                } else {
                    ___pause(100);
                }
            }
            $('#lightbox-container-image-data-box').css({ width: (intWidth - (settings.containerBorderSize * 2)) });
            $('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ height: intImageHeight + (settings.containerBorderSize * 2) });


        };
        /**
        * Show the prepared image
        *
        */
        function _show_image() {
            $('#savelink').attr("href", settings.imageArray[settings.activeImage][0]);
            if (settings.imageArray[settings.activeImage][2] != null) {
                var files = unserialize(settings.imageArray[settings.activeImage][2]);
                if (files != null) {
                    var str = "";
                    str = "Посмотреть в полный размер:<br />";
                    if (settings.imageArray[settings.activeImage][1] != null) str += settings.imageArray[settings.activeImage][1] + "<br />";
                    str += "<a class='reslink' href='" + files['prnt']['file'] + "'>" + files['prnt']['res'] + " (" + files['prnt']['size'] + ")</a><br />";
                    $.each(files['chlds'], function() {
                        str = str + "<a class='reslink' href='" + this['file'] + "'>" + this['res'] + " (" + this['size'] + ")</a><br />";
                    });
                    $("#linksdiv").html(str);
                }
            }
            else if (settings.imageArray[settings.activeImage][1] != null) {
                var str = "";
                str = "<a class='reslink' href=\"http://www.bioware.ru" + settings.imageArray[settings.activeImage][0] + "\">Посмотреть в полный размер</a><br />";
                str += settings.imageArray[settings.activeImage][1] + "<br />";
                $("#linksdiv").html(str);
            }
            $('#lightbox-loading').hide();
            $('#lightbox-image').fadeIn(function() {
                _show_image_data();
                _set_navigation();
            });
            _preload_neighbor_images();
        };
        /**
        * Show the image information
        *
        */
        function _show_image_data() {
            $('#lightbox-container-image-data-box').slideDown('fast');
            $('#lightbox-image-details-caption').hide();
            //if (settings.imageArray[settings.activeImage][1]) {
            //$('#lightbox-image-details-caption').html(settings.imageArray[settings.activeImage][1]).show();
            //}
            // If we have a image set, display 'Image X of X'
            if (settings.imageArray.length > 1) {
                $('#lightbox-image-details-currentNumber').html(settings.txtImage + ' ' + (settings.activeImage + 1) + ' ' + settings.txtOf + ' ' + settings.imageArray.length).show();
            }
        }
        /**
        * Display the button navigations
        *
        */
        function _set_navigation() {
            $('#lightbox-nav').show();

            // Instead to define this configuration in CSS file, we define here. And itґs need to IE. Just.
            $('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ 'background': 'transparent url(' + settings.imageBlank + ') no-repeat' });

            // Show the prev button, if not the first image in set
            if (settings.activeImage != 0) {
                if (settings.fixedNavigation) {
                    $('#lightbox-nav-btnPrev').css({ 'background': 'url(' + settings.imageBtnPrev + ') left 15% no-repeat' })
						.unbind()
						.bind('click', function() {
						    settings.activeImage = settings.activeImage - 1;
						    _set_image_to_view();
						    return false;
						});
                } else {
                    // Show the images button for Next buttons
                    $('#lightbox-nav-btnPrev').unbind().hover(function() {
                        $(this).css({ 'background': 'url(' + settings.imageBtnPrev + ') left 15% no-repeat' });
                    }, function() {
                        $(this).css({ 'background': 'transparent url(' + settings.imageBlank + ') no-repeat' });
                    }).show().bind('click', function() {
                        settings.activeImage = settings.activeImage - 1;
                        _set_image_to_view();
                        return false;
                    });
                }
            }

            // Show the next button, if not the last image in set
            if (settings.activeImage != (settings.imageArray.length - 1)) {
                if (settings.fixedNavigation) {
                    $('#lightbox-nav-btnNext').css({ 'background': 'url(' + settings.imageBtnNext + ') right 15% no-repeat' })
						.unbind()
						.bind('click', function() {
						    settings.activeImage = settings.activeImage + 1;
						    _set_image_to_view();
						    return false;
						});
                } else {
                    // Show the images button for Next buttons
                    $('#lightbox-nav-btnNext').unbind().hover(function() {
                        $(this).css({ 'background': 'url(' + settings.imageBtnNext + ') right 15% no-repeat' });
                    }, function() {
                        $(this).css({ 'background': 'transparent url(' + settings.imageBlank + ') no-repeat' });
                    }).show().bind('click', function() {
                        settings.activeImage = settings.activeImage + 1;
                        _set_image_to_view();
                        return false;
                    });
                }
            }
            // Enable keyboard navigation
            _enable_keyboard_navigation();
        }
        /**
        * Enable a support to keyboard navigation
        *
        */
        function _enable_keyboard_navigation() {
            $(document).keydown(function(objEvent) {
                _keyboard_action(objEvent);
            });
        }
        /**
        * Disable the support to keyboard navigation
        *
        */
        function _disable_keyboard_navigation() {
            $(document).unbind();
        }
        /**
        * Perform the keyboard actions
        *
        */
        function _keyboard_action(objEvent) {
            // To ie
            if (objEvent == null) {
                keycode = event.keyCode;
                escapeKey = 27;
                // To Mozilla
            } else {
                keycode = objEvent.keyCode;
                escapeKey = objEvent.DOM_VK_ESCAPE;
            }
            // Get the key in lower case form
            key = String.fromCharCode(keycode).toLowerCase();
            // Verify the keys to close the ligthBox
            if ((key == settings.keyToClose) || (key == 'x') || (keycode == escapeKey)) {
                _finish();
            }
            // Verify the key to show the previous image
            if ((key == settings.keyToPrev) || (keycode == 37)) {
                // If weґre not showing the first image, call the previous
                if (settings.activeImage != 0) {
                    settings.activeImage = settings.activeImage - 1;
                    _set_image_to_view();
                    _disable_keyboard_navigation();
                }
            }
            // Verify the key to show the next image
            if ((key == settings.keyToNext) || (keycode == 39)) {
                // If weґre not showing the last image, call the next
                if (settings.activeImage != (settings.imageArray.length - 1)) {
                    settings.activeImage = settings.activeImage + 1;
                    _set_image_to_view();
                    _disable_keyboard_navigation();
                }
            }
        }
        /**
        * Preload prev and next images being showed
        *
        */
        function _preload_neighbor_images() {
            if ((settings.imageArray.length - 1) > settings.activeImage) {
                objNext = new Image();
                objNext.src = settings.imageArray[settings.activeImage + 1][0];
            }
            if (settings.activeImage > 0) {
                objPrev = new Image();
                objPrev.src = settings.imageArray[settings.activeImage - 1][0];
            }
        }
        /**
        * Remove jQuery lightBox plugin HTML markup
        *
        */
        function _finish() {
            $('#jquery-lightbox').remove();
            $('#jquery-overlay').fadeOut(function() { $('#jquery-overlay').remove(); });
            // Show some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
            $('embed, object, select').css({ 'visibility': 'visible' });
        }
        /**
        / THIRD FUNCTION
        * getPageSize() by quirksmode.com
        *
        * @return Array Return an array with page width, height and window width, height
        */
        function ___getPageSize() {
            var xScroll, yScroll;
            if (window.innerHeight && window.scrollMaxY) {
                xScroll = window.innerWidth + window.scrollMaxX;
                yScroll = window.innerHeight + window.scrollMaxY;
            } else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac
                xScroll = document.body.scrollWidth;
                yScroll = document.body.scrollHeight;
            } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
                xScroll = document.body.offsetWidth;
                yScroll = document.body.offsetHeight;
            }
            var windowWidth, windowHeight;
            if (self.innerHeight) {	// all except Explorer
                if (document.documentElement.clientWidth) {
                    windowWidth = document.documentElement.clientWidth;
                } else {
                    windowWidth = self.innerWidth;
                }
                windowHeight = self.innerHeight;
            } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
                windowWidth = document.documentElement.clientWidth;
                windowHeight = document.documentElement.clientHeight;
            } else if (document.body) { // other Explorers
                windowWidth = document.body.clientWidth;
                windowHeight = document.body.clientHeight;
            }
            // for small pages with total height less then height of the viewport
            if (yScroll < windowHeight) {
                pageHeight = windowHeight;
            } else {
                pageHeight = yScroll;
            }
            // for small pages with total width less then width of the viewport
            if (xScroll < windowWidth) {
                pageWidth = xScroll;
            } else {
                pageWidth = windowWidth;
            }
            arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight);
            return arrayPageSize;
        };
        /**
        / THIRD FUNCTION
        * getPageScroll() by quirksmode.com
        *
        * @return Array Return an array with x,y page scroll values.
        */
        function ___getPageScroll() {
            var xScroll, yScroll;
            if (self.pageYOffset) {
                yScroll = self.pageYOffset;
                xScroll = self.pageXOffset;
            } else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
                yScroll = document.documentElement.scrollTop;
                xScroll = document.documentElement.scrollLeft;
            } else if (document.body) {// all other Explorers
                yScroll = document.body.scrollTop;
                xScroll = document.body.scrollLeft;
            }
            arrayPageScroll = new Array(xScroll, yScroll);
            return arrayPageScroll;
        };
        /**
        * Stop the code execution from a escified time in milisecond
        *
        */
        function ___pause(ms) {
            var date = new Date();
            curDate = null;
            do { var curDate = new Date(); }
            while (curDate - date < ms);
        };

        function unserialize(data) {
            var error = function(type, msg, filename, line) { throw new this.window[type](msg, filename, line); };
            var read_until = function(data, offset, stopchr) {
                var buf = [];
                var chr = data.slice(offset, offset + 1);
                var i = 2;
                while (chr != stopchr) {
                    if ((i + offset) > data.length) {
                        error('Error', 'Invalid');
                    }
                    buf.push(chr);
                    chr = data.slice(offset + (i - 1), offset + i);
                    i += 1;
                }
                return [buf.length, buf.join('')];
            };
            var read_chrs = function(data, offset, length) {
                var buf;

                buf = [];
                for (var i = 0; i < length; i++) {
                    var chr = data.slice(offset + (i - 1), offset + i);
                    buf.push(chr);
                }
                return [buf.length, buf.join('')];
            };
            var _unserialize = function(data, offset) {
                var readdata;
                var readData;
                var chrs = 0;
                var ccount;
                var stringlength;
                var keyandchrs;
                var keys;

                if (!offset) { offset = 0; }
                var dtype = (data.slice(offset, offset + 1)).toLowerCase();

                var dataoffset = offset + 2;
                var typeconvert = new Function('x', 'return x');

                switch (dtype) {
                    case 'i':
                        typeconvert = function(x) { return parseInt(x, 10); };
                        readData = read_until(data, dataoffset, ';');
                        chrs = readData[0];
                        readdata = readData[1];
                        dataoffset += chrs + 1;
                        break;
                    case 'b':
                        typeconvert = function(x) { return parseInt(x, 10) != 0; };
                        readData = read_until(data, dataoffset, ';');
                        chrs = readData[0];
                        readdata = readData[1];
                        dataoffset += chrs + 1;
                        break;
                    case 'd':
                        typeconvert = function(x) { return parseFloat(x); };
                        readData = read_until(data, dataoffset, ';');
                        chrs = readData[0];
                        readdata = readData[1];
                        dataoffset += chrs + 1;
                        break;
                    case 'n':
                        readdata = null;
                        break;
                    case 's':
                        ccount = read_until(data, dataoffset, ':');
                        chrs = ccount[0];
                        stringlength = ccount[1];
                        dataoffset += chrs + 2;

                        readData = read_chrs(data, dataoffset + 1, parseInt(stringlength, 10));
                        chrs = readData[0];
                        readdata = readData[1];
                        dataoffset += chrs + 2;
                        if (chrs != parseInt(stringlength, 10) && chrs != readdata.length) {
                            error('SyntaxError', 'String length mismatch');
                        }
                        break;
                    case 'a':
                        readdata = {};

                        keyandchrs = read_until(data, dataoffset, ':');
                        chrs = keyandchrs[0];
                        keys = keyandchrs[1];
                        dataoffset += chrs + 2;

                        for (var i = 0; i < parseInt(keys, 10); i++) {
                            var kprops = _unserialize(data, dataoffset);
                            var kchrs = kprops[1];
                            var key = kprops[2];
                            dataoffset += kchrs;

                            var vprops = _unserialize(data, dataoffset);
                            var vchrs = vprops[1];
                            var value = vprops[2];
                            dataoffset += vchrs;

                            readdata[key] = value;
                        }

                        dataoffset += 1;
                        break;
                    default:
                        error('SyntaxError', 'Unknown / Unhandled data type(s): ' + dtype);
                        break;
                }
                return [dtype, dataoffset - offset, typeconvert(readdata)];
            };

            return _unserialize((data + ''), 0)[2];
        }

        // Return the jQuery object for chaining. The unbind method is used to avoid click conflict when the plugin is called more than once
        return this.unbind('click').click(_initialize);
    };
})(jQuery);             // Call and execute the function immediately passing the jQuery object


/*
* jQuery EasIng v1.1.2 - http://gsgd.co.uk/sandbox/jquery.easIng.php
*
* Uses the built In easIng capabilities added In jQuery 1.1
* to offer multiple easIng options
*
* Copyright (c) 2007 George Smith
* Licensed under the MIT License:
*   http://www.opensource.org/licenses/mit-license.php
*/

// t: current time, b: begInnIng value, c: change In value, d: duration

jQuery.extend(jQuery.easing,
{
    easeInQuad: function(x, t, b, c, d) {
        return c * (t /= d) * t + b;
    },
    easeOutQuad: function(x, t, b, c, d) {
        return -c * (t /= d) * (t - 2) + b;
    },
    easeInOutQuad: function(x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t + b;
        return -c / 2 * ((--t) * (t - 2) - 1) + b;
    },
    easeInCubic: function(x, t, b, c, d) {
        return c * (t /= d) * t * t + b;
    },
    easeOutCubic: function(x, t, b, c, d) {
        return c * ((t = t / d - 1) * t * t + 1) + b;
    },
    easeInOutCubic: function(x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
        return c / 2 * ((t -= 2) * t * t + 2) + b;
    },
    easeInQuart: function(x, t, b, c, d) {
        return c * (t /= d) * t * t * t + b;
    },
    easeOutQuart: function(x, t, b, c, d) {
        return -c * ((t = t / d - 1) * t * t * t - 1) + b;
    },
    easeInOutQuart: function(x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t * t * t + b;
        return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
    },
    easeInQuint: function(x, t, b, c, d) {
        return c * (t /= d) * t * t * t * t + b;
    },
    easeOutQuint: function(x, t, b, c, d) {
        return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
    },
    easeInOutQuint: function(x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t * t * t * t + b;
        return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
    },
    easeInSine: function(x, t, b, c, d) {
        return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
    },
    easeOutSine: function(x, t, b, c, d) {
        return c * Math.sin(t / d * (Math.PI / 2)) + b;
    },
    easeInOutSine: function(x, t, b, c, d) {
        return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
    },
    easeInExpo: function(x, t, b, c, d) {
        return (t == 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;
    },
    easeOutExpo: function(x, t, b, c, d) {
        return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;
    },
    easeInOutExpo: function(x, t, b, c, d) {
        if (t == 0) return b;
        if (t == d) return b + c;
        if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
        return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;
    },
    easeInCirc: function(x, t, b, c, d) {
        return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;
    },
    easeOutCirc: function(x, t, b, c, d) {
        return c * Math.sqrt(1 - (t = t / d - 1) * t) + b;
    },
    easeInOutCirc: function(x, t, b, c, d) {
        if ((t /= d / 2) < 1) return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
        return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
    },
    easeInElastic: function(x, t, b, c, d) {
        var s = 1.70158; var p = 0; var a = c;
        if (t == 0) return b; if ((t /= d) == 1) return b + c; if (!p) p = d * .3;
        if (a < Math.abs(c)) { a = c; var s = p / 4; }
        else var s = p / (2 * Math.PI) * Math.asin(c / a);
        return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
    },
    easeOutElastic: function(x, t, b, c, d) {
        var s = 1.70158; var p = 0; var a = c;
        if (t == 0) return b; if ((t /= d) == 1) return b + c; if (!p) p = d * .3;
        if (a < Math.abs(c)) { a = c; var s = p / 4; }
        else var s = p / (2 * Math.PI) * Math.asin(c / a);
        return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
    },
    easeInOutElastic: function(x, t, b, c, d) {
        var s = 1.70158; var p = 0; var a = c;
        if (t == 0) return b; if ((t /= d / 2) == 2) return b + c; if (!p) p = d * (.3 * 1.5);
        if (a < Math.abs(c)) { a = c; var s = p / 4; }
        else var s = p / (2 * Math.PI) * Math.asin(c / a);
        if (t < 1) return -.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
        return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
    },
    easeInBack: function(x, t, b, c, d, s) {
        if (s == undefined) s = 1.70158;
        return c * (t /= d) * t * ((s + 1) * t - s) + b;
    },
    easeOutBack: function(x, t, b, c, d, s) {
        if (s == undefined) s = 1.70158;
        return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
    },
    easeInOutBack: function(x, t, b, c, d, s) {
        if (s == undefined) s = 1.70158;
        if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
        return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
    },
    easeInBounce: function(x, t, b, c, d) {
        return c - jQuery.easing.easeOutBounce(x, d - t, 0, c, d) + b;
    },
    easeOutBounce: function(x, t, b, c, d) {
        if ((t /= d) < (1 / 2.75)) {
            return c * (7.5625 * t * t) + b;
        } else if (t < (2 / 2.75)) {
            return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
        } else if (t < (2.5 / 2.75)) {
            return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
        } else {
            return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
        }
    },
    easeInOutBounce: function(x, t, b, c, d) {
        if (t < d / 2) return jQuery.easing.easeInBounce(x, t * 2, 0, c, d) * .5 + b;
        return jQuery.easing.easeOutBounce(x, t * 2 - d, 0, c, d) * .5 + c * .5 + b;
    }
});


/*! jquery.swfobject.license.txt *//*

jQuery SWFObject Plugin v1.0.6 <http://jquery.thewikies.com/swfobject/>
Copyright (c) 2009 Jonathan Neal
This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
This software is released under the GPL License <http://www.opensource.org/licenses/gpl-2.0.php>

SWFObject v2.2 <http://code.google.com/p/swfobject/>
Copyright (c) 2007-2009 Geoff Stearns, Michael Williams, and Bobby van der Sluis
This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>

jQuery v1.3.2 <http://jquery.com/>
Copyright (c) 2009 John Resig
This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
This software is released under the GPL License <http://www.opensource.org/licenses/gpl-2.0.php>

*/

(function($) {
    var doc = document,
	extend = 'extend',
	fn = function() { },
	join = 'join',
	object = 'object',
	verticalAlign = 'style="vertical-align:bottom;',
	x = '';

    /* $.flashPlayerVersion */
    $.flashPlayerVersion = (function() {
        var flashVersion,
		activeX,
		errorA,
		errorB,
		fp6Crash = false,
		shockwaveFlash = 'ShockwaveFlash.ShockwaveFlash';

        /* If Internet Explorer */
        if (!(flashVersion = navigator.plugins['Shockwave Flash'])) {
            try {
                activeX = new ActiveXObject(shockwaveFlash + '.7');
            }
            catch (errorA) {
                try {
                    activeX = new ActiveXObject(shockwaveFlash + '.6');
                    flashVersion = [6, 0, 21];
                    activeX.AllowScriptAccess = 'always';
                }
                catch (errorB) {
                    if (flashVersion && flashVersion[0] == 6) {
                        fp6Crash = true;
                    }
                }
                if (!fp6Crash) {
                    try {
                        activeX = new ActiveXObject(shockwaveFlash);
                    }
                    catch (errorC) {
                        flashVersion = 'X 0,0,0';
                    }
                }
            }
            if (!fp6Crash && activeX) {
                try {
                    /* Will crash fp6.0.21/23/29 */
                    flashVersion = activeX.GetVariable('$version');
                } catch (errorD) { }
            }
        }

        /* If NOT Internet Explorer */
        else {
            flashVersion = flashVersion.description;
        }

        /* Return flash version */
        flashVersion = flashVersion.match(/^[A-Za-z\s]*?(\d+)(\.|,)(\d+)(\s+r|,)(\d+)/);
        return [flashVersion[1] * 1, flashVersion[3] * 1, flashVersion[5] * 1];
    } ());

    /* $.flashExpressInstaller */
    $.flashExpressInstaller = 'expressInstall.swf';

    /* $.hasFlashPlayer */
    $.hasFlashPlayer = ($.flashPlayerVersion[0] != 0);

    /* $.hasFlashPlayerVersion */
    $.hasFlashPlayerVersion = function(options) {
        var flashVersion = $.flashPlayerVersion;
        options = (/string|number/.test(typeof options)) ? options.toString().split('.') : options;
        options = [options.major || options[0] || flashVersion[0], options.minor || options[1] || flashVersion[1], options.release || options[2] || flashVersion[2]];

        /* Return true or false */
        return ($.hasFlashPlayer && (options[0] < flashVersion[0] || (options[0] == flashVersion[0] && (options[1] < flashVersion[1] || (options[1] == flashVersion[1] && options[2] <= flashVersion[2])))));
    };

    /* $.flash */
    $.flash = function(options) {
        /* Check if Flash is installed, return false if it isn't */
        if (!$.hasFlashPlayer) {
            return false;
        }

        var movieFilename = options.swf || x,
		paramAttributes = options.params || {},
		buildDOM = doc.createElement('body'),
		aArr,
		bArr,
		cArr,
		dArr,
		a,
		b;

        /* Set the default height and width if not already set */
        options.height = options.height || 180;
        options.width = options.width || 320;

        /* Inject ExpressInstall if "hasVersion" is requested and the version requirement is not met */
        if (options.hasVersion && !$.hasFlashPlayerVersion(options.hasVersion)) {
            $[extend](options, {
                id: 'SWFObjectExprInst',
                height: Math.max(options.height, 137),
                width: Math.max(options.width, 214)
            });
            movieFilename = options.expressInstaller || $.flashExpressInstaller;
            paramAttributes = {
                flashvars: {
                    MMredirectURL: location.href,
                    MMplayerType: ($.browser.msie && $.browser.win) ? 'ActiveX' : 'PlugIn',
                    MMdoctitle: doc.title.slice(0, 47) + ' - Flash Player Installation'
                }
            };
        }

        /* Append as a param if specified separately */
        if (typeof paramAttributes == object) {
            /* flashvars */
            if (options.flashvars) {
                paramAttributes.flashvars = options.flashvars;
            }

            /* wmode */
            if (options.wmode) {
                paramAttributes.wmode = options.wmode;
            }
        }

        /* Delete the reformatted constructors */
        for (a in (b = ['expressInstall', 'flashvars', 'hasVersion', 'params', 'swf', 'wmode'])) {
            delete options[b[a]];
        }

        /* Create the OBJECT tag attributes */
        aArr = [];
        for (a in options) {
            if (typeof options[a] == object) {
                bArr = [];
                for (b in options[a]) {
                    bArr.push(b.replace(/([A-Z])/, '-$1').toLowerCase() + ':' + options[a][b] + ';');
                }
                options[a] = bArr[join](x);
            }
            aArr.push(a + '="' + options[a] + '"');
        }
        options = aArr[join](' ');

        /* Create the PARAM tags */
        if (typeof paramAttributes == object) {
            aArr = [];
            for (a in paramAttributes) {
                if (typeof paramAttributes[a] == object) {
                    bArr = [];
                    for (b in paramAttributes[a]) {
                        bArr.push([b, '=', encodeURIComponent(paramAttributes[a][b])][join](x));
                    }
                    paramAttributes[a] = bArr[join]('&amp;');
                }
                aArr.push(['<PARAM NAME="', a, '" VALUE="', paramAttributes[a], '">'][join](x));
            }
            paramAttributes = aArr[join](x);
        }

        /* Unify the visual display between all browsers */
        if (!(/style=/.test(options))) {
            options += ' ' + verticalAlign + '"';
        }
        if (!(/style=(.*?)vertical-align/.test(options))) {
            options = options.replace(/style="/, verticalAlign);
        }

        /* Specify the object and param tags between browsers */
        if ($.browser.msie) {
            options += ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
            paramAttributes = '<PARAM NAME="movie" VALUE="' + movieFilename + '">' + paramAttributes;
        } else {
            options += ' type="application/x-shockwave-flash" data="' + movieFilename + '"';
        }

        /* Return the jQuery'd flash OBJECT */
        buildDOM.innerHTML = ['<OBJECT ', options, '>', paramAttributes, '</OBJECT>'][join](x);
        return $(buildDOM.firstChild);
    };

    /* $.fn.flash */
    $.fn.flash = function(options) {
        /* Check if Flash is installed, return the jQuery node if it isn't */
        if (!$.hasFlashPlayer) {
            return this;
        }

        var each = 0,
		eachOptions,
		$each;

        /* Each */
        while (($each = this.eq(each++))[0]) {
            eachOptions = $[extend](
				{
				    beforeEach: fn,
				    afterEach: fn
				},
				options
			);
            eachOptions.beforeEach.apply($each[0], [options]);
            $each.html($.flash(eachOptions));
            if (doc.getElementById('SWFObjectExprInst')) {
                each = this.length;
            }
            eachOptions.afterEach.apply($each[0], [options]);
        }

        /* Return the jQuery node */
        return this;
    };
} (jQuery));


(function($) {
    var pluginName = 'jwPlayer';

    if (!window.console) { console = {}; } // prevent errors from console.log calls
    if (!console.log) { console.log = $.noop; }

    var eventType = {
        ITEM: 'Controller',
        MUTE: 'Controller',
        PLAY: 'Controller',
        PLAYLIST: 'Controller',
        RESIZE: 'Controller',
        SEEK: 'Controller',
        STOP: 'Controller',
        VOLUME: 'Controller',
        BUFFER: 'Model',
        ERROR: 'Model',
        LOADED: 'Model',
        META: 'Model',
        STATE: 'Model',
        TIME: 'Model',
        FULLSCREEN: 'View',
        LINK: 'View',
        LOAD: 'View',
        NEXT: 'View',
        PREV: 'View',
        REDRAW: 'View'
    };

    // Properties to be set in object data when listeners are fired
    var listenerProperties = {
        ITEM: { index: 'item' },
        STATE: { newstate: 'state' },
        TIME: { position: 'position', duration: 'duration' },
        VOLUME: { volume: 'volume' }
    };

    var flashvarNames = [
    'author',
    'autostart',
    'backcolor',
    'bufferlength',
    'config',
    'controlbar',
    'date',
    'debug',
    'description',
    'displaytitle',
    'dock',
    'duration',
    'file',
    'frontcolor',
    'fullscreen',
    'icons',
    'image',
    'item',
    'link',
    'lightcolor',
    'mute',
    'playerready',
    'playlist',
    'playlistfile',
    'playlistsize',
    'plugins',
    'provider',
    'repeat',
    'screencolor',
    'shuffle',
    'skin',
    'smoothing',
    'start',
    'streamer',
    'stretching',
    'tags',
    'title',
    'volume'
];

    // Return global function name that's not being used
    function getFunctionName(base) {
        var name, i = 0;
        while (true) {
            name = pluginName + '_' + base;
            if (i) {
                name += i;
            }
            if (!window[name]) {
                return name;
            }
            i++;
        }
    }

    $.fn[pluginName] = function(opts) {
        var fn, args, data, prop;
        if (typeof opts == 'string') { // it's a method name
            fn = $.fn[pluginName][opts];
            if (!fn) {
                throw ('No such method: ' + pluginName + '.' + opts);
            }
            args = $.makeArray(arguments).slice(1);
            data = this.data(pluginName);
            args.unshift(data);
            return fn.apply(this, args);
        }
        opts = $.extend({}, $.fn[pluginName].defaults, opts);
        // put flashvars into subobject
        for (prop in opts) {
            if ($.inArray(prop, flashvarNames) != -1) {
                opts.flashvars[prop] = opts[prop];
                delete opts[prop];
            }
        }
        // Convert integers to pixels
        if (opts.height.toString().match(/^[0-9]+$/)) {
            opts.height += 'px';
        }
        if (opts.width.toString().match(/^[0-9]+$/)) {
            opts.width += 'px';
        }
        return this.each(function(index) {
            var id = opts.id,
            $this = $(this);
            if (index) {
                id += '-' + index;
            }
            if ($('#' + id).length) {
                $.error('id "' + id + '" already exists in document');
            }

            function makeListener(propMap, listenerName) {
                return function(obj) {
                    var n, seek;
                    for (n in propMap) {
                        $this[pluginName]('set', propMap[n], obj[n]);
                    }
                    if (listenerName == 'statelistener') {
                        seek = $this[pluginName]('get', 'seek');
                        if ((obj.newstate == 'PAUSED' ||
                        obj.newstate == 'PLAYING') && seek !== false) {
                            $this[pluginName]('set', 'seek', false);
                            $this[pluginName]('seek', seek);
                        }
                    }
                    if (opts[listenerName]) {
                        opts[listenerName](obj);
                    }
                };
            }

            // Set up array of listeners to be added in playerReady.
            var eventName, listenerName, propMap,
            listeners = {};
            for (eventName in eventType) {
                listenerName = eventName.toLowerCase() + 'listener';
                if (listenerProperties[eventName]) {
                    propMap = listenerProperties[eventName];
                    listeners[eventName] = makeListener(propMap, listenerName);
                }
                else if (opts[listenerName]) {
                    listeners[eventName] = opts[listenerName];
                }
            }
            console.log('listeners', listeners);

            // Create global function for playerReady that stores data,
            // adds listeners, and then runs the playerready callback 
            // that was passed in the options, if there is one.
            var fnName = getFunctionName('playerReady');
            var extraPlayerready = opts.flashvars.playerready;
            window[fnName] = function(obj) {
                console.log(fnName + '()', arguments);
                // Store player object (DOM node) in data() of jQuery object
                var data = {
                    obj: $('#' + id)[0],
                    duration: null,
                    item: 0,
                    state: 'IDLE',
                    position: 0,
                    seek: false, // queued seek position
                    volume: null
                };
                $this.data(pluginName, data);
                var eventName;
                for (eventName in listeners) {
                    $this[pluginName]('addListener', eventName, listeners[eventName]);
                }
                if (extraPlayerready) {
                    extraPlayerready(obj);
                }
                $this.addClass(pluginName); // to signal it's finished
            };
            opts.flashvars.playerready = fnName;
            $this.empty().flash({
                swf: opts.swf,
                id: id,
                name: id,
                height: opts.height,
                width: opts.width,
                wmode: opts.wmode,
                params: {
                    allowfullscreen: 'true',
                    allowscriptaccess: 'always',
                    enablejs: 'true',
                    flashvars: opts.flashvars
                }
            });
            return this;
        });
    };

    $.extend($.fn[pluginName], {
        defaults: {
            flashvars: {},
            height: 240,
            width: 320,
            id: pluginName,
            swf: 'player.swf',
            wmode: 'opaque'
        },

        set: function(data, property, value) {
            data[property] = value;
        },

        get: function(data, property) {
            return data[property];
        },

        item: function(data, itemNumber) {
            itemNumber = parseInt(itemNumber, 10);
            console.log('jwPlayer.item', itemNumber);
            data.obj.sendEvent('ITEM', itemNumber);
            return this;
        },

        load: function(data, filename) {
            console.log('jwPlayer.load: setting filename to ', filename);
            data.obj.sendEvent('LOAD', filename);
            return this;
        },

        mute: function(data) {
            console.log('jwPlayer.mute');
            data.obj.sendEvent('MUTE');
            return this;
        },

        next: function(data) {
            console.log('jwPlayer.next');
            data.obj.sendEvent('NEXT');
            return this;
        },

        pause: function(data) {
            console.log('jwPlayer.pause');
            data.obj.sendEvent('PLAY', 'false');
            return this;
        },

        play: function(data) {
            console.log('jwPlayer.play');
            data.obj.sendEvent('PLAY', 'true');
            return this;
        },

        resume: function(data) { // same as play
            console.log('jwPlayer.resume');
            data.obj.sendEvent('PLAY', 'true');
            return this;
        },

        start: function(data) { // same as play
            console.log('jwPlayer.start');
            data.obj.sendEvent('PLAY', 'true');
            return this;
        },

        togglePlay: function(data) {
            console.log('jwPlayer.togglePlay');
            data.obj.sendEvent('PLAY');
            return this;
        },

        prev: function(data) {
            console.log('jwPlayer.prev');
            data.obj.sendEvent('PREV');
            return this;
        },

        redraw: function(data) {
            console.log('jwPlayer.redraw');
            data.obj.sendEvent('REDRAW');
            return this;
        },

        seek: function(data, position) {
            var state;
            console.log('jwPlayer.seek', position);
            position = parseFloat(position);
            if (!position) {
                position = 0.001; // weird bug when seeking to 0
            }
            state = this[pluginName]('get', 'state');
            console.log('state', state);
            if (state == 'PLAYING' || state == 'PAUSED') {
                data.obj.sendEvent('SEEK', position);
                data.seek = false;
            }
            else {
                if (state == 'IDLE') {
                    // Play and pause to get media loading
                    data.obj.sendEvent('PLAY', 'true');
                    data.obj.sendEvent('PLAY', 'false');
                }
                data.seek = position;
            }
            return this;
        },

        stop: function(data) {
            console.log('jwPlayer.stop');
            data.obj.sendEvent('STOP');
            return this;
        },

        volume: function(data, volume) {
            volume = parseInt(volume, 10);
            data.obj.sendEvent('VOLUME', volume);
            return this;
        },

        getConfig: function(data, property) {
            var config = data.obj.getConfig();
            return property ? config[property] : config;
        },

        getPlaylist: function(data, itemNumber) {
            var playlist = data.obj.getPlaylist();
            return itemNumber || itemNumber === 0 ? playlist[itemNumber] : playlist;
        },

        addListener: function(data, eventName, callback) {
            console.log('jwPlayer.addListener', eventName, callback);
            var fnName,
            method = 'add' + eventType[eventName] + 'Listener';
            if ($.isFunction(callback)) {
                fnName = getFunctionName(eventName.toLowerCase() + 'Listener');
                window[fnName] = callback;
                callback = fnName;
            }
            return data.obj[method](eventName, callback);
        },

        destroy: function() {
            console.log('jwPlayer.destroy');
            $(this).removeData(pluginName).empty();
        }

    });

})(jQuery);


function showPlayer(id, file, download, url, width, height, auts) {
    var image = "" + id.toString();
    var fullurl = "" + file;
    var fulllink = url;
    var embedCode = escape('<embed src="/pleer/jwplayer4.swf" width="' + width.toString() + '" height="' + height.toString() + '" allowfullscreen="true" allowscriptaccess="always" flashvars="width=' + width.toString() + '&height=' + height.toString() + '&file=' + fullurl + '&smoothing=true&image=' + image + '&stretching=unified&link=' + fulllink + '"></embed>');
    $("#container" + id.toString()).jwPlayer({
        id: "player" + id.toString(),
        swf: '/pleer/jwplayer4.swf',
        file: fullurl,
        image: image,
        height: height,
        width: width,
        flashvars: {
            config: "/pleer/config.xml",
            width: width,
            autostart: auts,
            height: height
        }
    });


}



(function($) {
    var has_VML, create_canvas_for, add_shape_to, clear_canvas, shape_from_area,
		canvas_style, fader, hex_to_decimal, css3color, is_image_loaded, options_from_area;

    has_VML = document.namespaces;
    has_canvas = !!document.createElement('canvas').getContext;

    if (!(has_canvas || has_VML)) {
        $.fn.maphilight = function() { return this; };
        return;
    }

    if (has_canvas) {
        fader = function(element, opacity, interval) {
            if (opacity <= 1) {
                element.style.opacity = opacity;
                window.setTimeout(fader, 10, element, opacity + 0.1, 10);
            }
        };

        hex_to_decimal = function(hex) {
            return Math.max(0, Math.min(parseInt(hex, 16), 255));
        };
        css3color = function(color, opacity) {
            return 'rgba(' + hex_to_decimal(color.substr(0, 2)) + ',' + hex_to_decimal(color.substr(2, 2)) + ',' + hex_to_decimal(color.substr(4, 2)) + ',' + opacity + ')';
        };
        create_canvas_for = function(img) {
            var c = $('<canvas style="width:' + img.width + 'px;height:' + img.height + 'px;"></canvas>').get(0);
            c.getContext("2d").clearRect(0, 0, c.width, c.height);
            return c;
        };
        add_shape_to = function(canvas, shape, coords, options, name) {
            var i, context = canvas.getContext('2d');
            context.beginPath();
            if (shape == 'rect') {
                context.rect(coords[0], coords[1], coords[2] - coords[0], coords[3] - coords[1]);
            } else if (shape == 'poly') {
                context.moveTo(coords[0], coords[1]);
                for (i = 2; i < coords.length; i += 2) {
                    context.lineTo(coords[i], coords[i + 1]);
                }
            } else if (shape == 'circ') {
                context.arc(coords[0], coords[1], coords[2], 0, Math.PI * 2, false);
            }
            context.closePath();
            if (options.fill) {
                context.fillStyle = css3color(options.fillColor, options.fillOpacity);
                context.fill();
            }
            if (options.stroke) {
                context.strokeStyle = css3color(options.strokeColor, options.strokeOpacity);
                context.lineWidth = options.strokeWidth;
                context.stroke();
            }
            if (options.fade) {
                fader(canvas, 0);
            }
        };
        clear_canvas = function(canvas) {
            canvas.getContext('2d').clearRect(0, 0, canvas.width, canvas.height);
        };
    } else {   // ie executes this code
        create_canvas_for = function(img) {
            return $('<var style="zoom:1;overflow:hidden;display:block;width:' + img.width + 'px;height:' + img.height + 'px;"></var>').get(0);
        };
        add_shape_to = function(canvas, shape, coords, options, name) {
            var fill, stroke, opacity, e;
            fill = '<v:fill color="#' + options.fillColor + '" opacity="' + (options.fill ? options.fillOpacity : 0) + '" />';
            stroke = (options.stroke ? 'strokeweight="' + options.strokeWidth + '" stroked="t" strokecolor="#' + options.strokeColor + '"' : 'stroked="f"');
            opacity = '<v:stroke opacity="' + options.strokeOpacity + '"/>';
            if (shape == 'rect') {
                e = $('<v:rect name="' + name + '" filled="t" ' + stroke + ' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:' + coords[0] + 'px;top:' + coords[1] + 'px;width:' + (coords[2] - coords[0]) + 'px;height:' + (coords[3] - coords[1]) + 'px;"></v:rect>');
            } else if (shape == 'poly') {
                e = $('<v:shape name="' + name + '" filled="t" ' + stroke + ' coordorigin="0,0" coordsize="' + canvas.width + ',' + canvas.height + '" path="m ' + coords[0] + ',' + coords[1] + ' l ' + coords.join(',') + ' x e" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:0px;left:0px;width:' + canvas.width + 'px;height:' + canvas.height + 'px;"></v:shape>');
            } else if (shape == 'circ') {
                e = $('<v:oval name="' + name + '" filled="t" ' + stroke + ' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:' + (coords[0] - coords[2]) + 'px;top:' + (coords[1] - coords[2]) + 'px;width:' + (coords[2] * 2) + 'px;height:' + (coords[2] * 2) + 'px;"></v:oval>');
            }
            e.get(0).innerHTML = fill + opacity;
            $(canvas).append(e);
        };
        clear_canvas = function(canvas) {
            $(canvas).find('[name=highlighted]').remove();
        };
    }

    shape_from_area = function(area) {
        var i, coords = area.getAttribute('coords').split(',');
        for (i = 0; i < coords.length; i++) { coords[i] = parseFloat(coords[i]); }
        return [area.getAttribute('shape').toLowerCase().substr(0, 4), coords];
    };

    options_from_area = function(area, options) {
        var $area = $(area);
        return $.extend({}, options, $.metadata ? $area.metadata() : false, $area.data('maphilight'));
    };

    is_image_loaded = function(img) {
        if (!img.complete) { return false; } // IE
        if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) { return false; } // Others
        return true;
    };

    canvas_style = {
        position: 'absolute',
        left: 0,
        top: 0,
        padding: 0,
        border: 0
    };

    var ie_hax_done = false;
    $.fn.maphilight = function(opts) {
        opts = $.extend({}, $.fn.maphilight.defaults, opts);

        if ($.browser.msie && !ie_hax_done) {
            document.namespaces.add("v", "urn:schemas-microsoft-com:vml");
            var style = document.createStyleSheet();
            var shapes = ['shape', 'rect', 'oval', 'circ', 'fill', 'stroke', 'imagedata', 'group', 'textbox'];
            $.each(shapes,
				function() {
				    style.addRule('v\\:' + this, "behavior: url(#default#VML); antialias:true");
				}
			);
            ie_hax_done = true;
        }

        return this.each(function() {
            var img, wrap, options, map, canvas, canvas_always, mouseover, highlighted_shape, usemap;
            img = $(this);

            if (!is_image_loaded(this)) {
                // If the image isn't fully loaded, this won't work right.  Try again later.
                return window.setTimeout(function() {
                    img.maphilight(opts);
                }, 200);
            }

            options = $.extend({}, opts, $.metadata ? img.metadata() : false, img.data('maphilight'));

            // jQuery bug with Opera, results in full-url#usemap being returned from jQuery's attr.
            // So use raw getAttribute instead.
            usemap = img.get(0).getAttribute('usemap');

            map = $('map[name="' + usemap.substr(1) + '"]');

            if (!(img.is('img') && usemap && map.size() > 0)) { return; }

            if (img.hasClass('maphilighted')) {
                // We're redrawing an old map, probably to pick up changes to the options.
                // Just clear out all the old stuff.
                var wrapper = img.parent();
                img.insertBefore(wrapper);
                wrapper.remove();
                $(map).unbind('.maphilight').find('area[coords]').unbind('.maphilight');
            }

            wrap = $('<div></div>').css({
                display: 'block',
                background: 'url(' + this.src + ')',
                position: 'relative',
                padding: 0,
                margin: '0 auto',
                width: this.width,
                height: this.height
            });
            if (options.wrapClass) {
                if (options.wrapClass === true) {
                    wrap.addClass($(this).attr('class'));
                } else {
                    wrap.addClass(options.wrapClass);
                }
            }
            img.before(wrap).css('opacity', 0).css(canvas_style).remove();
            if ($.browser.msie) { img.css('filter', 'Alpha(opacity=0)'); }
            wrap.append(img);

            canvas = create_canvas_for(this);
            $(canvas).css(canvas_style);
            canvas.height = this.height;
            canvas.width = this.width;

            mouseover = function(e) {
                var shape, area_options;
                area_options = options_from_area(this, options);
                if (
					!area_options.neverOn
					&&
					!area_options.alwaysOn
				) {
                    shape = shape_from_area(this);
                    add_shape_to(canvas, shape[0], shape[1], area_options, "highlighted");
                    if (area_options.groupBy && $(this).attr(area_options.groupBy)) {
                        var first = this;
                        map.find('area[' + area_options.groupBy + '=' + $(this).attr(area_options.groupBy) + ']').each(function() {
                            if (this != first) {
                                var subarea_options = options_from_area(this, options);
                                if (!subarea_options.neverOn && !subarea_options.alwaysOn) {
                                    var shape = shape_from_area(this);
                                    add_shape_to(canvas, shape[0], shape[1], subarea_options, "highlighted");
                                }
                            }
                        });
                    }
                }
            }

            $(map).bind('alwaysOn.maphilight', function() {
                // Check for areas with alwaysOn set. These are added to a *second* canvas,
                // which will get around flickering during fading.
                if (canvas_always) {
                    clear_canvas(canvas_always)
                }
                if (!has_canvas) {
                    $(canvas).empty();
                }
                $(map).find('area[coords]').each(function() {
                    var shape, area_options;
                    area_options = options_from_area(this, options);
                    if (area_options.alwaysOn) {
                        if (!canvas_always && has_canvas) {
                            canvas_always = create_canvas_for(img.get());
                            $(canvas_always).css(canvas_style);
                            canvas_always.width = img.width();
                            canvas_always.height = img.height();
                            img.before(canvas_always);
                        }
                        shape = shape_from_area(this);
                        if (has_canvas) {
                            add_shape_to(canvas_always, shape[0], shape[1], area_options, "");
                        } else {
                            add_shape_to(canvas, shape[0], shape[1], area_options, "");
                        }
                    }
                });
            });

            if (options.alwaysOn) {
                $(map).find('area[coords]').each(mouseover);
            } else {
                $(map).find('area[coords]')
					.trigger('alwaysOn.maphilight')
					.bind('mouseover.maphilight', mouseover)
					.bind('mouseout.maphilight', function(e) { clear_canvas(canvas); });
            }

            img.before(canvas); // if we put this after, the mouseover events wouldn't fire.

            img.addClass('maphilighted');
        });
    };
    $.fn.maphilight.defaults = {
        fill: true,
        fillColor: '000000',
        fillOpacity: 0.2,
        stroke: true,
        strokeColor: 'ff0000',
        strokeOpacity: 1,
        strokeWidth: 1,
        fade: true,
        alwaysOn: false,
        neverOn: false,
        groupBy: false,
        wrapClass: true
    };
})(jQuery);




(function($) {

    var colorbox = 'colorbox',
	hover = 'hover',
	TRUE = true,
	FALSE = false,
	cboxPublic,
	isIE = $.browser.msie && !$.support.opacity, // feature detection alone gave false positives in some browsers
	isIE6 = isIE && $.browser.version < 7,

	cbox_open = 'cbox_open',
	cbox_load = 'cbox_load',
	cbox_complete = 'cbox_complete',
	cbox_cleanup = 'cbox_cleanup',
	cbox_closed = 'cbox_closed',
	cbox_resize = 'resize.cbox_resize',


	$overlay,
	$cbox,
	$wrap,
	$content,
	$topBorder,
	$leftBorder,
	$rightBorder,
	$bottomBorder,
	$related,
	$window,
	$loaded,
	$loadingBay,
	$loadingOverlay,
	$loadingGraphic,
	$title,
	$current,
	$slideshow,
	$next,
	$prev,
	$close,


	interfaceHeight,
	interfaceWidth,
	loadedHeight,
	loadedWidth,
	element,
	bookmark,
	index,
	settings,
	open,
	active,


	defaults = {
	    transition: "elastic",
	    speed: 350,
	    width: FALSE,
	    height: FALSE,
	    innerWidth: FALSE,
	    innerHeight: FALSE,
	    initialWidth: "400",
	    initialHeight: "400",
	    maxWidth: FALSE,
	    maxHeight: FALSE,
	    scalePhotos: TRUE,
	    scrolling: TRUE,
	    inline: FALSE,
	    html: FALSE,
	    iframe: FALSE,
	    photo: FALSE,
	    href: FALSE,
	    title: FALSE,
	    rel: FALSE,
	    opacity: 0.9,
	    preloading: TRUE,
	    current: "image {current} of {total}",
	    previous: "previous",
	    next: "next",
	    close: "close",
	    open: FALSE,
	    overlayClose: TRUE,

	    slideshow: FALSE,
	    slideshowAuto: TRUE,
	    slideshowSpeed: 2500,
	    slideshowStart: "start slideshow",
	    slideshowStop: "stop slideshow",

	    onOpen: FALSE,
	    onLoad: FALSE,
	    onComplete: FALSE,
	    onCleanup: FALSE,
	    onClosed: FALSE
	};

    function setSize(size, dimension) {
        dimension = dimension === 'x' ? $window.width() : $window.height(); //document.documentElement.clientWidth : document.documentElement.clientHeight;
        return (typeof size === 'string') ? Math.round((size.match(/%/) ? (dimension / 100) * parseInt(size, 10) : parseInt(size, 10))) : size;
    }

    // Checks an href to see if it is a photo.
    // There is a force photo option (photo: true) for hrefs that cannot be matched by this regex.
    function isImage(url) {
        url = $.isFunction(url) ? url.call(element) : url;
        return settings.photo || url.match(/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i);
    }

    // Assigns functions results to their respective settings.  This allows functions to be used to set ColorBox options.
    function process() {
        for (var i in settings) {
            if ($.isFunction(settings[i]) && i.substring(0, 2) !== 'on') { // checks to make sure the function isn't one of the callbacks, they will be handled at the appropriate time.
                settings[i] = settings[i].call(element);
            }
        }
        settings.rel = settings.rel || element.rel;
        settings.href = settings.href || element.href;
        settings.title = settings.title || element.title;
    }

    function launch(elem) {

        element = elem;

        settings = $.extend({}, $(element).data(colorbox));

        process(); // Convert functions to their returned values.

        if (settings.rel && settings.rel !== 'nofollow') {
            $related = $('.cboxElement').filter(function() {
                var relRelated = $(this).data(colorbox).rel || this.rel;
                return (relRelated === settings.rel);
            });
            index = $related.index(element);

            // Check direct calls to ColorBox.
            if (index < 0) {
                $related = $related.add(element);
                index = $related.length - 1;
            }
        } else {
            $related = $(element);
            index = 0;
        }

        if (!open) {
            open = TRUE;

            active = TRUE; // Prevents the page-change action from queuing up if the visitor holds down the left or right keys.

            bookmark = element;

            bookmark.blur(); // Remove the focus from the calling element.

            // Set Navigation Key Bindings
            $(document).bind("keydown.cbox_close", function(e) {
                if (e.keyCode === 27) {
                    e.preventDefault();
                    cboxPublic.close();
                }
            }).bind("keydown.cbox_arrows", function(e) {
                if ($related.length > 1) {
                    if (e.keyCode === 37) {
                        e.preventDefault();
                        $prev.click();
                    } else if (e.keyCode === 39) {
                        e.preventDefault();
                        $next.click();
                    }
                }
            });

            if (settings.overlayClose) {
                $overlay.css({ "cursor": "pointer" }).one('click', cboxPublic.close);
            }

            $.event.trigger(cbox_open);
            if (settings.onOpen) {
                settings.onOpen.call(element);
            }

            $overlay.css({ "opacity": settings.opacity }).show();

            // Opens inital empty ColorBox prior to content being loaded.
            settings.w = setSize(settings.initialWidth, 'x');
            settings.h = setSize(settings.initialHeight, 'y');
            cboxPublic.position(0);

            if (isIE6) {
                $window.bind('resize.cboxie6 scroll.cboxie6', function() {
                    $overlay.css({ width: $window.width(), height: $window.height(), top: $window.scrollTop(), left: $window.scrollLeft() });
                }).trigger("scroll.cboxie6");
            }
        }

        $current.add($prev).add($next).add($slideshow).add($title).hide();

        $close.html(settings.close).show();

        cboxPublic.slideshow();

        cboxPublic.load();
    }

    // ****************
    // PUBLIC FUNCTIONS
    // Usage format: $.fn.colorbox.close();
    // Usage from within an iframe: parent.$.fn.colorbox.close();
    // ****************

    cboxPublic = $.fn.colorbox = function(options, callback) {
        var $this = this;

        if (!$this.length) {
            if ($this.selector === '') { // empty selector means a direct call, ie: $.fn.colorbox();
                $this = $('<a/>');
                options.open = TRUE;
            } else { // else the selector didn't match anything, and colorbox should go ahead and return.
                return this;
            }
        }

        $this.each(function() {
            var data = $.extend({}, $(this).data(colorbox) ? $(this).data(colorbox) : defaults, options);

            $(this).data(colorbox, data).addClass("cboxElement");

            if (callback) {
                $(this).data(colorbox).onComplete = callback;
            }
        });

        if (options && options.open) {
            launch($this);
        }

        return this;
    };

    // Initialize ColorBox: store common calculations, preload the interface graphics, append the html.
    // This preps colorbox for a speedy open when clicked, and lightens the burdon on the browser by only
    // having to run once, instead of each time colorbox is opened.
    cboxPublic.init = function() {

        // jQuery object generator to save a bit of space
        function $div(id) {
            return $('<div id="cbox' + id + '"/>');
        }

        // Create & Append jQuery Objects
        $window = $(window);
        $cbox = $('<div id="colorbox"/>');
        $overlay = $div("Overlay").hide();
        $wrap = $div("Wrapper");
        $content = $div("Content").append(
			$loaded = $div("LoadedContent").css({ width: 0, height: 0 }),
			$loadingOverlay = $div("LoadingOverlay"),
			$loadingGraphic = $div("LoadingGraphic"),
			$title = $div("Title"),
			$current = $div("Current"),
			$slideshow = $div("Slideshow"),
			$next = $div("Next"),
			$prev = $div("Previous"),
			$close = $div("Close")
		);
        $wrap.append( // The 3x3 Grid that makes up ColorBox
			$('<div/>').append(
				$div("TopLeft"),
				$topBorder = $div("TopCenter"),
				$div("TopRight")
			),
			$('<div/>').append(
				$leftBorder = $div("MiddleLeft"),
				$content,
				$rightBorder = $div("MiddleRight")
			),
			$('<div/>').append(
				$div("BottomLeft"),
				$bottomBorder = $div("BottomCenter"),
				$div("BottomRight")
			)
		).children().children().css({ 'float': 'left' });

        $loadingBay = $("<div style='position:absolute; top:0; left:0; width:9999px; height:0;'/>");

        $('body').prepend($overlay, $cbox.append($wrap, $loadingBay));

        if (isIE) {
            $cbox.addClass('cboxIE');
            if (isIE6) {
                $overlay.css('position', 'absolute');
            }
        }

        // Add rollover event to navigation elements
        $content.children()
		.bind('mouseover mouseout', function() {
		    $(this).toggleClass(hover);
		}).addClass(hover);

        // Cache values needed for size calculations
        interfaceHeight = $topBorder.height() + $bottomBorder.height() + $content.outerHeight(TRUE) - $content.height(); //Subtraction needed for IE6
        interfaceWidth = $leftBorder.width() + $rightBorder.width() + $content.outerWidth(TRUE) - $content.width();
        loadedHeight = $loaded.outerHeight(TRUE);
        loadedWidth = $loaded.outerWidth(TRUE);

        // Setting padding to remove the need to do size conversions during the animation step.
        $cbox.css({ "padding-bottom": interfaceHeight, "padding-right": interfaceWidth }).hide();

        // Setup button & key events.
        $next.click(cboxPublic.next);
        $prev.click(cboxPublic.prev);
        $close.click(cboxPublic.close);

        // Adding the 'hover' class allowed the browser to load the hover-state
        // background graphics.  The class can now can be removed.
        $content.children().removeClass(hover);

        $('.cboxElement').live('click', function(e) {
            if (e.button !== 0 && typeof e.button !== 'undefined') {// checks to see if it was a non-left mouse-click.
                return TRUE;
            } else {
                launch(this);
                return FALSE;
            }
        });
    };

    cboxPublic.position = function(speed, loadedCallback) {
        var 
		animate_speed,
		winHeight = $window.height(),
        // keeps the top and left positions within the browser's viewport.
		posTop = Math.max(winHeight - settings.h - loadedHeight - interfaceHeight, 0) / 2 + $window.scrollTop(),
		posLeft = Math.max(document.documentElement.clientWidth - settings.w - loadedWidth - interfaceWidth, 0) / 2 + $window.scrollLeft();

        // setting the speed to 0 to reduce the delay between same-sized content.
        animate_speed = ($cbox.width() === settings.w + loadedWidth && $cbox.height() === settings.h + loadedHeight) ? 0 : speed;

        // this gives the wrapper plenty of breathing room so it's floated contents can move around smoothly,
        // but it has to be shrank down around the size of div#colorbox when it's done.  If not,
        // it can invoke an obscure IE bug when using iframes.
        $wrap[0].style.width = $wrap[0].style.height = "9999px";

        function modalDimensions(that) {
            // loading overlay size has to be sure that IE6 uses the correct height.
            $topBorder[0].style.width = $bottomBorder[0].style.width = $content[0].style.width = that.style.width;
            $loadingGraphic[0].style.height = $loadingOverlay[0].style.height = $content[0].style.height = $leftBorder[0].style.height = $rightBorder[0].style.height = that.style.height;
        }

        $cbox.dequeue().animate({ width: settings.w + loadedWidth, height: settings.h + loadedHeight, top: posTop, left: posLeft }, { duration: animate_speed,
            complete: function() {
                modalDimensions(this);

                active = FALSE;

                // shrink the wrapper down to exactly the size of colorbox to avoid a bug in IE's iframe implementation.
                $wrap[0].style.width = (settings.w + loadedWidth + interfaceWidth) + "px";
                $wrap[0].style.height = (settings.h + loadedHeight + interfaceHeight) + "px";

                if (loadedCallback) { loadedCallback(); }
            },
            step: function() {
                modalDimensions(this);
            }
        });
    };

    cboxPublic.resize = function(object) {
        if (!open) { return; }

        var topMargin,
		prev,
		prevSrc,
		next,
		nextSrc,
		photo,
		timeout,
		speed = settings.transition === "none" ? 0 : settings.speed;

        $window.unbind(cbox_resize);

        if (!object) {
            timeout = setTimeout(function() { // timer allows IE to render the dimensions before attempting to calculate the height
                var $child = $loaded.wrapInner("<div style='overflow:auto'></div>").children(); // temporary wrapper to get an accurate estimate of just how high the total content should be.
                settings.h = $child.height();
                $loaded.css({ height: settings.h });
                $child.replaceWith($child.children()); // ditch the temporary wrapper div used in height calculation
                cboxPublic.position(speed);
            }, 1);
            return;
        }

        $loaded.remove();
        $loaded = $('<div id="cboxLoadedContent"/>').html(object);

        function getWidth() {
            settings.w = settings.w || $loaded.width();
            settings.w = settings.mw && settings.mw < settings.w ? settings.mw : settings.w;
            return settings.w;
        }
        function getHeight() {
            settings.h = settings.h || $loaded.height();
            settings.h = settings.mh && settings.mh < settings.h ? settings.mh : settings.h;
            return settings.h;
        }

        $loaded.hide()
		.appendTo($loadingBay)// content has to be appended to the DOM for accurate size calculations.  Appended to an absolutely positioned element, rather than BODY, which avoids an extremely brief display of the vertical scrollbar in Firefox that can occur for a small minority of websites.
		.css({ width: getWidth(), overflow: settings.scrolling ? 'auto' : 'hidden' })
		.css({ height: getHeight() })// sets the height independently from the width in case the new width influences the value of height.
		.prependTo($content);

        $('#cboxPhoto').css({ cssFloat: 'none' }); // floating the IMG removes the bottom line-height and fixed a problem where IE miscalculates the width of the parent element as 100% of the document width.

        // Hides SELECT elements in IE6 because they would otherwise sit on top of the overlay.
        if (isIE6) {
            $('select:not(#colorbox select)').filter(function() {
                return this.style.visibility !== 'hidden';
            }).css({ 'visibility': 'hidden' }).one(cbox_cleanup, function() {
                this.style.visibility = 'inherit';
            });
        }

        function setPosition(s) {
            cboxPublic.position(s, function() {
                if (!open) { return; }

                if (isIE) {
                    //This fadeIn helps the bicubic resampling to kick-in.
                    if (photo) { $loaded.fadeIn(100); }
                    //IE adds a filter when ColorBox fades in and out that can cause problems if the loaded content contains transparent pngs.
                    $cbox[0].style.removeAttribute("filter");
                }

                //Waited until the iframe is added to the DOM & it is visible before setting the src.
                //This increases compatability with pages using DOM dependent JavaScript.
                if (settings.iframe) {
                    $loaded.append("<iframe id='cboxIframe'" + (settings.scrolling ? " " : "scrolling='no'") + " name='iframe_" + new Date().getTime() + "' frameborder=0 src='" + settings.href + "' " + (isIE ? "allowtransparency='true'" : '') + " />");
                }

                $loaded.show();

                $title.show().html(settings.title);

                if ($related.length > 1) {
                    $current.html(settings.current.replace(/\{current\}/, index + 1).replace(/\{total\}/, $related.length)).show();
                    $next.html(settings.next).show();
                    $prev.html(settings.previous).show();

                    if (settings.slideshow) {
                        $slideshow.show();
                    }
                }

                $loadingOverlay.hide();
                $loadingGraphic.hide();

                $.event.trigger(cbox_complete);
                if (settings.onComplete) {
                    settings.onComplete.call(element);
                }

                if (settings.transition === 'fade') {
                    $cbox.fadeTo(speed, 1, function() {
                        if (isIE) { $cbox[0].style.removeAttribute("filter"); }
                    });
                }

                $window.bind(cbox_resize, function() {
                    cboxPublic.position(0);
                });
            });
        }

        if ((settings.transition === 'fade' && $cbox.fadeTo(speed, 0, function() { setPosition(0); })) || setPosition(speed)) { }

        // Preloads images within a rel group
        if (settings.preloading && $related.length > 1) {
            prev = index > 0 ? $related[index - 1] : $related[$related.length - 1];
            next = index < $related.length - 1 ? $related[index + 1] : $related[0];
            nextSrc = $(next).data(colorbox).href || next.href;
            prevSrc = $(prev).data(colorbox).href || prev.href;

            if (isImage(nextSrc)) {
                $('<img />').attr('src', nextSrc);
            }

            if (isImage(prevSrc)) {
                $('<img />').attr('src', prevSrc);
            }
        }
    };

    cboxPublic.load = function() {
        var href, img, setResize, resize = cboxPublic.resize;

        active = TRUE;

        /*
		 
        // I decided to comment this out because I can see it causing problems as users
        // really should just set the dimensions on their IMG elements instead,
        // but I'm leaving the code in as it may be useful to someone.
        // To use, uncomment the function and change 'if(textStatus === "success"){ resize(this); }'
        // to 'if(textStatus === "success"){ preload(this); }'
		
        // Preload loops through the HTML to find IMG elements and loads their sources.
        // This allows the resize method to accurately estimate the dimensions of the new content.
        function preload(html){
        var
        $ajax = $(html),
        $imgs = $ajax.find('img'),
        x = $imgs.length;
			
        function loadloop(){
        var img = new Image();
        x = x-1;
        if(x >= 0){
        img.onload = loadloop;
        img.src = $imgs[x].src;
        } else {
        resize($ajax);
        }
        }
			
        loadloop();
        }
        */

        element = $related[index];

        settings = $.extend({}, $(element).data(colorbox));

        //convert functions to static values
        process();

        $.event.trigger(cbox_load);
        if (settings.onLoad) {
            settings.onLoad.call(element);
        }

        // Evaluate the height based on the optional height and width settings.
        settings.h = settings.height ?
				setSize(settings.height, 'y') - loadedHeight - interfaceHeight :
				settings.innerHeight ?
					setSize(settings.innerHeight, 'y') :
					FALSE;
        settings.w = settings.width ?
				setSize(settings.width, 'x') - loadedWidth - interfaceWidth :
				settings.innerWidth ?
					setSize(settings.innerWidth, 'x') :
					FALSE;

        // Sets the minimum dimensions for use in image scaling
        settings.mw = settings.w;
        settings.mh = settings.h;

        // Re-evaluate the minimum width and height based on maxWidth and maxHeight values.
        // If the width or height exceed the maxWidth or maxHeight, use the maximum values instead.
        if (settings.maxWidth) {
            settings.mw = setSize(settings.maxWidth, 'x') - loadedWidth - interfaceWidth;
            settings.mw = settings.w && settings.w < settings.mw ? settings.w : settings.mw;
        }
        if (settings.maxHeight) {
            settings.mh = setSize(settings.maxHeight, 'y') - loadedHeight - interfaceHeight;
            settings.mh = settings.h && settings.h < settings.mh ? settings.h : settings.mh;
        }

        href = settings.href;

        $loadingOverlay.show();
        $loadingGraphic.show();

        if (settings.inline) {
            // Inserts an empty placeholder where inline content is being pulled from.
            // An event is bound to put inline content back when ColorBox closes or loads new content.
            $('<div id="cboxInlineTemp" />').hide().insertBefore($(href)[0]).bind(cbox_load + ' ' + cbox_cleanup, function() {
                $(this).replaceWith($loaded.children());
            });
            resize($(href));
        } else if (settings.iframe) {
            // IFrame element won't be added to the DOM until it is ready to be displayed,
            // to avoid problems with DOM-ready JS that might be trying to run in that iframe.
            resize(" ");
        } else if (settings.html) {
            resize(settings.html);
        } else if (isImage(href)) {
            img = new Image();
            img.onload = function() {
                var percent;

                img.onload = null;

                img.id = 'cboxPhoto';

                $(img).css({ margin: 'auto', border: 'none', display: 'block', cssFloat: 'left' });

                if (settings.scalePhotos) {
                    setResize = function() {
                        img.height -= img.height * percent;
                        img.width -= img.width * percent;
                    };
                    if (settings.mw && img.width > settings.mw) {
                        percent = (img.width - settings.mw) / img.width;
                        setResize();
                    }
                    if (settings.mh && img.height > settings.mh) {
                        percent = (img.height - settings.mh) / img.height;
                        setResize();
                    }
                }

                if (settings.h) {
                    img.style.marginTop = Math.max(settings.h - img.height, 0) / 2 + 'px';
                }

                resize(img);

                if ($related.length > 1) {
                    $(img).css({ cursor: 'pointer' }).click(cboxPublic.next);
                }

                if (isIE) {
                    img.style.msInterpolationMode = 'bicubic';
                }
            };
            img.src = href;
        } else {
            $('<div />').appendTo($loadingBay).load(href, function(data, textStatus) {
                if (textStatus === "success") {
                    resize(this);
                } else {
                    resize($("<p>Request unsuccessful.</p>"));
                }
            });
        }
    };

    // Navigates to the next page/image in a set.
    cboxPublic.next = function() {
        if (!active) {
            index = index < $related.length - 1 ? index + 1 : 0;
            cboxPublic.load();
        }
    };

    cboxPublic.prev = function() {
        if (!active) {
            index = index > 0 ? index - 1 : $related.length - 1;
            cboxPublic.load();
        }
    };

    cboxPublic.slideshow = function() {
        var stop, timeOut, className = 'cboxSlideshow_';

        $slideshow.bind(cbox_closed, function() {
            $slideshow.unbind();
            clearTimeout(timeOut);
            $cbox.removeClass(className + "off" + " " + className + "on");
        });

        function start() {
            $slideshow
			.text(settings.slideshowStop)
			.bind(cbox_complete, function() {
			    timeOut = setTimeout(cboxPublic.next, settings.slideshowSpeed);
			})
			.bind(cbox_load, function() {
			    clearTimeout(timeOut);
			}).one("click", function() {
			    stop();
			    $(this).removeClass(hover);
			});
            $cbox.removeClass(className + "off").addClass(className + "on");
        }

        stop = function() {
            clearTimeout(timeOut);
            $slideshow
			.text(settings.slideshowStart)
			.unbind(cbox_complete + ' ' + cbox_load)
			.one("click", function() {
			    start();
			    timeOut = setTimeout(cboxPublic.next, settings.slideshowSpeed);
			    $(this).removeClass(hover);
			});
            $cbox.removeClass(className + "on").addClass(className + "off");
        };

        if (settings.slideshow && $related.length > 1) {
            if (settings.slideshowAuto) {
                start();
            } else {
                stop();
            }
        }
    };

    // Note: to use this within an iframe use the following format: parent.$.fn.colorbox.close();
    cboxPublic.close = function() {

        $.event.trigger(cbox_cleanup);
        if (settings.onCleanup) {
            settings.onCleanup.call(element);
        }

        open = FALSE;
        $(document).unbind("keydown.cbox_close keydown.cbox_arrows");
        $window.unbind(cbox_resize + ' resize.cboxie6 scroll.cboxie6');
        $overlay.css({ cursor: 'auto' }).fadeOut('fast');

        $cbox
		.stop(TRUE, FALSE)
		.fadeOut('fast', function() {
		    $('#colorbox iframe').attr('src', 'about:blank');
		    $loaded.remove();
		    $cbox.css({ 'opacity': 1 });

		    try {
		        bookmark.focus();
		    } catch (er) {
		        // do nothing
		    }

		    $.event.trigger(cbox_closed);
		    if (settings.onClosed) {
		        settings.onClosed.call(element);
		    }
		});
    };

    // A method for fetching the current element ColorBox is referencing.
    // returns a jQuery object.
    cboxPublic.element = function() { return $(element); };

    cboxPublic.settings = defaults;

    // Initializes ColorBox when the DOM has loaded
    $(cboxPublic.init);

} (jQuery));

function openw(id) {
    if ($('#sub' + id).is(":hidden")) {
        $('.subs').hide(400);
        $('#sub' + id).show(500);
    } else {
        $('#sub' + id).hide(400);
    }
}
function openww(id, video) {
    $('#message' + id).html("<div class='video' id='container" + id + "'></div>");
    showPlayer(id, video, 'true', '', 600, 245, true);
    $('#message' + id).modal();
}
function opensl(id) {
    if ($('#playerr' + id).is(":hidden")) {
        $('#playerr' + id).show();
    } else {
        $('#playerr' + id).hide();
    }
}
function loads(pt){
    $('#imggl').attr('src', pt);
}
