﻿ // document.writeln('<script type="text/javascript" src="/Library/js/jquery.easing.1.3.js"></script>');
 // document.writeln('<script type="text/javascript" src="/Library/js/jquery.galleryview-1.1.js"></script>');
 // document.writeln('<script type="text/javascript" src="/Library/js/jquery.galleryview-1.2.js"></script>');
 // document.writeln('<script type="text/javascript" src="/Library/js/jquery.FlashGameBox.js"></script>');
 // document.writeln('<script type="text/javascript" src="/Library/js/jquery.timers-1.1.2.js"></script>');
 // document.writeln('<script type="text/javascript" src="/library/js/jquery.FlashGameBox.js"></script>');
// 3 Box

function GetPostVariable(vName, vDef)
{
	var	str=location.href;
	var	pos=str.indexOf('?'.concat(vName).concat('='));

	if (pos==-1)
	{
		pos=str.indexOf('&'.concat(vName).concat('='));
		if (pos==-1) return vDef;
	}
	
	str=str.substring(pos + vName.length + 2);
	pos=str.indexOf('&');

	if (pos==-1)
	{
		pos=str.length;
	}	

	if (pos > 0)
	{
		str=str.substring(0, pos);
	}

	return (typeof(vDef)=='number') ? parseInt(str) : CharReplace(str);
}



﻿//Topstory
var thread;
var lockTherad;
var mouseThread;
var selected = 0;
var toSelect = 0;
var lock = false;
var maxData = 4;
//var timeout = 10000;
var timeout = 15000;
var lockTime = 500;
var mouseOverLockTime = 1000;

document.writeln('<script language="javascript" type="text/javascript" src="/Library/js/jquery.innerfade.js"></script>');

$(document).ready(
	function(){
		$('.TPlagerImg').innerfade({
			speed: 'slow',
			timeout: timeout,
			type: 'sequence',
			containerheight: '305px'
		});
		$('.TitleText').innerfade({
			speed: 'slow',
			timeout: timeout,
			type: 'sequence',
			containerheight: '22px'
		});
		/*
		$('.GameType').innerfade({
			speed: 'slow',
			timeout: timeout,
			type: 'sequence',
			containerheight: '22px'
		});
		*/
		$('.DescritpTion').innerfade({
			speed: 'slow',
			timeout: timeout,
			type: 'sequence',
			containerheight: '50px'
        });
					
	}
);
thread = setInterval("NextStatus()", timeout);

function NextStatus()
{
	toSelect = selected + 1;
	if (toSelect >= maxData)
	{
		toSelect = 0;
		ChangeStatus(toSelect);
	}
	else
	{
		//alert(selected);
		ChangeStatus(toSelect);
	}
}

function ChangeStatus(to)
{
	if (lock == true)
	{
		return;
	}
	if (to == selected)
	{
		return
	}
	lock = true;
	for (i = 0; i < maxData; i++)
	{
		if (i != to) {
		    if (document.getElementById("SmallImage" + i) != null) {
		        document.getElementById("SmallImage" + i).className = "SmallImageNormal";
		    }
		}
		else {
		    if (document.getElementById("SmallImage" + i) != null) {
		        document.getElementById("SmallImage" + i).className = "SmallImageSelect";
		    }
		}
	}
	var settings = {
		'animationtype':    'fade',
		'speed':            'slow',
		'type':             'sequence',
		'timeout':          timeout,
		'containerheight':  'auto'
	};
	var elements = $('.TitleText').children();
		$(elements[selected]).hide();
		$(elements[to]).show();
	/*
	elements = $('.GameType').children();
		$(elements[selected]).hide();
		$(elements[to]).show();
	*/
	elements = $('.DescritpTion').children();
		$(elements[selected]).hide();
		$(elements[to]).show();
	elements = $('.TPlagerImg').children();
	$(elements[selected]).fadeOut(settings.speed);
	$(elements[to]).fadeIn(settings.speed, function() {
		removeFilter($(this)[0]);
	});
	selected = to;
	clearTimeout(thread);
	clearTimeout(lockTherad);
	clearTimeout(mouseThread);
	thread = setInterval("NextStatus()", timeout);
	NextStatus();
	//lockTherad = setInterval("setLock(false)", lockTime);
	setLock(false);
}

function setLock(key)
{
	lock = key;
}

function waitMouseover(to)
{
	clearTimeout(mouseThread);
    //mouseThread = setInterval("ChangeStatus(" + to + ")", mouseOverLockTime);
	ChangeStatus(to);
}

function createHTML(arItemTS) {
    var iTSCount = arItemTS.length;
    var strBigImage = "";
    var strSmallImage = "";
    var strTitle = "";
    var strGameType = "";
    var strDescription = "";

    if (iTSCount < maxData) {
        maxData = iTSCount
    }
    for (i = 0; i < maxData; i++) {
        strBigImage += '<li><a onfocus="this.blur();" hidefocus="" href="' + arItemTS[i][7] + '" title="' + arItemTS[i][2] + '"><img alt="' + arItemTS[i][2] + '" src="' + arItemTS[i][1] + arItemTS[i][5] + '" width="644px" height="305px"/></a></li>';
        if (i == 0) {
            strSmallImage += '<li class="SmallImageSelect" id="SmallImage' + i + '" onClick="ChangeStatus(' + i + ')" onmouseover="waitMouseover(' + i + ')"><a onfocus="this.blur();" hidefocus="" title="' + arItemTS[i][2] + '"><img alt="' + arItemTS[i][2] + '" src="' + arItemTS[i][1] + arItemTS[i][6] + '" class="game"/></a></li>';
        }
        else {
            strSmallImage += '<li class="SmallImageNormal" id="SmallImage' + i + '" onClick="ChangeStatus(' + i + ')" onmouseover="waitMouseover(' + i + ')"><a onfocus="this.blur();" hidefocus="" title="' + arItemTS[i][2] + '"><img alt="' + arItemTS[i][2] + '" src="' + arItemTS[i][1] + arItemTS[i][6] + '" class="game"/></a></li>';
        }

        strTitle += '<li><a href="' + arItemTS[i][7] + '">' + arItemTS[i][2] + '</a><a href="#" >'
        if (arItemTS[i][8] == '1') {
            strTitle += '<img class="videoIcon" alt="video" src="/Images/TopPromotion/videoIcon.gif" />';
        }
        strTitle += '</a></li>';
        strGameType += '<li>' + arItemTS[i][4] + '</li>';
        strDescription += '<li>';
		if(arItemTS[i][4] != "")
		{
			strDescription += '<p class="gametypehome">';
			strDescription += arItemTS[i][4];
			strDescription += '</p>';
		}
		strDescription += '<p class="descriptionhome">';		
		strDescription += arItemTS[i][3];
		strDescription += '</p>';
		strDescription += '</li>';
	}
    document.getElementById("TPlagerImg").innerHTML = strBigImage;
    document.getElementById("SmallImage").innerHTML = strSmallImage;
    document.getElementById("TitleText").innerHTML = strTitle;
    //document.getElementById("GameType").innerHTML = strGameType;
    document.getElementById("DescritpTion").innerHTML = strDescription;
}
/* =========================================================

// jquery.innerfade.js

// Datum: 2008-02-14
// Firma: Medienfreunde Hofmann & Baldes GbR
// Author: Torsten Baldes
// Mail: t.baldes@medienfreunde.com
// Web: http://medienfreunde.com

// based on the work of Matt Oakes http://portfolio.gizone.co.uk/applications/slideshow/
// and Ralf S. Engelschall http://trainofthoughts.org/

 *
 *  <ul id="news"> 
 *      <li>content 1</li>
 *      <li>content 2</li>
 *      <li>content 3</li>
 *  </ul>
 *  
 *  $('#news').innerfade({ 
 *	  animationtype: Type of animation 'fade' or 'slide' (Default: 'fade'), 
 *	  speed: Fading-/Sliding-Speed in milliseconds or keywords (slow, normal or fast) (Default: 'normal'), 
 *	  timeout: Time between the fades in milliseconds (Default: '2000'), 
 *	  type: Type of slideshow: 'sequence', 'random' or 'random_start' (Default: 'sequence'), 
 * 		containerheight: Height of the containing element in any css-height-value (Default: 'auto'),
 *	  runningclass: CSS-Class which the container get’s applied (Default: 'innerfade'),
 *	  children: optional children selector (Default: null)
 *  }); 
 *

// ========================================================= */


(function($) {

    $.fn.innerfade = function(options) {
        return this.each(function() {   
            $.innerfade(this, options);
        });
    };

    $.innerfade = function(container, options) {
        var settings = {
        	'animationtype':    'fade',
            'speed':            'slow',
            'type':             'sequence',
            'timeout':          2000,
            'containerheight':  'auto',
            'runningclass':     'innerfade',
            'children':         null
        };
		//alert($('.TitleText').children(settings.children)[1].innerHTML);
        if (options)
            $.extend(settings, options);
        if (settings.children === null)
            var elements = $(container).children();
        else
            var elements = $(container).children(settings.children);
        if (elements.length > 1) {
            //$(container).css('position', 'relative').css('height', settings.containerheight).addClass(settings.runningclass);
            $(container).css('height', settings.containerheight).addClass(settings.runningclass);
			for (var i = 0; i < elements.length; i++) {
                $(elements[i]).css('z-index', String(elements.length-i)).css('position', 'absolute').hide();
            };
            if (settings.type == "sequence") {
                //setTimeout(function() {
                //    $.innerfade.next(elements, settings, 1, 0);
                //}, settings.timeout);
				//alert(elements[0].innerHTML);
                $(elements[0]).show();
            } else if (settings.type == "random") {
            		var last = Math.floor ( Math.random () * ( elements.length ) );
                setTimeout(function() {
                    do { 
												current = Math.floor ( Math.random ( ) * ( elements.length ) );
										} while (last == current );             
										$.innerfade.next(elements, settings, current, last);
                }, settings.timeout);
                $(elements[last]).show();
						} else if ( settings.type == 'random_start' ) {
								settings.type = 'sequence';
								var current = Math.floor ( Math.random () * ( elements.length ) );
								setTimeout(function(){
									$.innerfade.next(elements, settings, (current + 1) %  elements.length, current);
								}, settings.timeout);
								$(elements[current]).show();
						}	else {
							alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');
						}
				}
    };

    $.innerfade.next = function(elements, settings, current, last) {
		//to next commands
		//alert(elements + ";" + settings + ";" + current + ";" + last);
        if (settings.animationtype == 'slide') {
            $(elements[last]).slideUp(settings.speed);
            $(elements[current]).slideDown(settings.speed);
        } else if (settings.animationtype == 'fade') {
            $(elements[last]).fadeOut(settings.speed);
            $(elements[current]).fadeIn(settings.speed, function() {
							removeFilter($(this)[0]);
						});
        } else
            alert('Innerfade-animationtype must either be \'slide\' or \'fade\'');
        if (settings.type == "sequence") {
            if ((current + 1) < elements.length) {
                current = current + 1;
                last = current - 1;
            } else {
                current = 0;
                last = elements.length - 1;
            }
        } else if (settings.type == "random") {
            last = current;
            while (current == last)
                current = Math.floor(Math.random() * elements.length);
        } else
            alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');
        setTimeout((function() {
            $.innerfade.next(elements, settings, current, last);
        }), settings.timeout);
		//alert("set time out");
		//alert(elements + ";" + settings + ";" + current + ";" + last);
		//to next commands
    };

})(jQuery);

// **** remove Opacity-Filter in ie ****
function removeFilter(element) {
	if(element.style.removeAttribute){
		element.style.removeAttribute('filter');
	}
}/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1
 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2008 George McGinley Smith
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
*/

// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	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;
	}
});

/*
 *
 * TERMS OF USE - EASING EQUATIONS
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2001 Robert Penner
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
 *//*

	GalleryView - jQuery Content Gallery Plugin
	Author: 		Jack Anderson
	Version:		1.1 (April 5, 2009)
	Documentation: 	http://www.spaceforaname.com/jquery/galleryview/
	
	Please use this development script if you intend to make changes to the
	plugin code.  For production sites, please use jquery.galleryview-1.0.1-pack.js.
	
*/
(function($){
	$.fn.galleryViewImage0 = function(options) {
		var opts = $.extend($.fn.galleryViewImage0.defaults,options);
		
		var id;
		var iterator = 0;
		var gallery_width;
		var gallery_height;
		var frame_margin = 18;
		var strip_width;
		var wrapper_width;
		var item_count = 0;
		var slide_method;
		var img_path;
		var paused = false;
		var frame_caption_size = 20;
		var frame_margin_top = 0;
		var pointer_width = 2;
		
		//Define jQuery objects for reuse
		var j_gallery;
		var j_filmstrip;
		var j_frames;
		var j_panels;
		var j_pointer;
		
/************************************************/
/*	Plugin Methods					*/
/************************************************/
		function showItem(i) {
			//Disable next/prev buttons until transition is complete
			$('img.nav-nextImage0').unbind('click');
			$('img.nav-prev').unbind('click');
			j_frames.unbind('click');
			if(has_panels) {
				if(opts.fade_panels) {
					//Fade out all panels and fade in target panel
					j_panels.fadeOut(opts.transition_speed).eq(i%item_count).fadeIn(opts.transition_speed,function(){
						if(!has_filmstrip) {
							$('img.nav-prev').click(showPrevItemImage0);
							$('img.nav-nextImage0').click(showNextItemImage0);		
						}
					});
				} 
			}
			
			if(has_filmstrip) {
				//Slide either pointer or filmstrip, depending on transition method
				if(slide_method=='strip') {
					//Stop filmstrip if it's currently in motion
					j_filmstrip.stop();
					
					//Determine distance between pointer (eventual destination) and target frame
					var distance = getPos(j_frames[i]).left - (getPos(j_pointer[0]).left+2);
					var leftstr = (distance>=0?'-=':'+=')+Math.abs(distance)+'px';
					
					//Animate filmstrip and slide target frame under pointer
					//If target frame is a duplicate, jump back to 'original' frame
					j_filmstrip.animate({
						'left':leftstr
					},opts.transition_speed,opts.easing,function(){
						//Always ensure that there are a sufficient number of hidden frames on either
						//side of the filmstrip to avoid empty frames
						if(i>item_count) {
							i = i%item_count;
							iterator = i;
							j_filmstrip.css('left','-'+((opts.frame_width+frame_margin)*i)+'px');
						} else if (i<=(item_count-strip_size)) {
							i = (i%item_count)+item_count;
							iterator = i;
							j_filmstrip.css('left','-'+((opts.frame_width+frame_margin)*i)+'px');
						}
						
						if(!opts.fade_panels) {
							j_panels.hide().eq(i%item_count).show();
						}
						$('img.nav-prev').click(showPrevItemImage0);
						$('img.nav-nextImage0').click(showNextItemImage0);
						enableFrameClicking();
					});
				} else if(slide_method=='pointer') {
					//Stop pointer if it's currently in motion
					j_pointer.stop();
					//Get position of target frame
					var pos = getPos(j_frames[i]);
					//Slide the pointer over the target frame
					j_pointer.animate({
						'left':(pos.left-2+'px')
					},opts.transition_speed,opts.easing,function(){	
						if(!opts.fade_panels) {
							j_panels.hide().eq(i%item_count).show();
						}	
						$('img.nav-prev').click(showPrevItemImage0);
						$('img.nav-nextImage0').click(showNextItemImage0);
						enableFrameClicking();
					});
				}
			
				if($('a',j_frames[i])[0]) {
					j_pointer.unbind('click').click(function(){
						var a = $('a',j_frames[i]).eq(0);
						if(a.attr('target')=='_blank') {window.open(a.attr('href'));}
						else {location.href = a.attr('href');}
					});
	            }
	            //alert(iterator);
			}
		};
		function showNextItemImage0() {
			//alert("hello");
			
			$(document).stopTime("transition");
			if(++iterator==j_frames.length) {iterator=0;}
			showItem(iterator);
			/*
			$(document).everyTime(opts.transition_interval,"transition",function(){
				showNextItemImage0();
            });
			*/
			
		};
		function showPrevItemImage0() {
			$(document).stopTime("transition");
			if(--iterator<0) {iterator = item_count-1;}
			//alert(iterator);
			showItem(iterator);
			/*
			$(document).everyTime(opts.transition_interval,"transition",function(){
				showNextItemImage0();
            });
			*/
		};
		function getPos(el) {
			var left = 0, top = 0;
			var el_id = el.id;
			if(el.offsetParent) {
				do {
					left += el.offsetLeft;
					top += el.offsetTop;
				} while(el = el.offsetParent);
			}
			//If we want the position of the gallery itself, return it
			if(el_id == id) {return {'left':left,'top':top};}
			//Otherwise, get position of element relative to gallery
			else {
				var gPos = getPos(j_gallery[0]);
				var gLeft = gPos.left;
				var gTop = gPos.top;
				
				return {'left':left-gLeft,'top':top-gTop};
			}
		};
		function enableFrameClicking() {
			j_frames.each(function(i){
				//If there isn't a link in this frame, set up frame to slide on click
				//Frames with links will handle themselves
				if($('a',this).length==0) {
					$(this).click(function(){
						$(document).stopTime("transition");
						showItem(i);
						iterator = i;
						/*
						$(document).everyTime(opts.transition_interval,"transition",function(){
							showNextItemImage0();
						});
						*/
					});
				}
			});
		};
		
		function buildPanels() {
			//If there are panel captions, add overlay divs
			if($('.panel-overlay').length>0) {j_panels.append('<div class="overlay"></div>');}
			
			if(!has_filmstrip) {
				//Add navigation buttons
				
				$('<img />').addClass('nav-nextImage0').attr('src',img_path+opts.nav_theme+'/next.png').appendTo(j_gallery).css({
					'position':'absolute',
					'zIndex':'1100',
					'cursor':'pointer',
					'top':((opts.panel_height-22)/2)+'px',
					'right':'10px',
					'display':'none'
				}).click(showNextItemImage0);
				$('<img />').addClass('nav-prev').attr('src',img_path+opts.nav_theme+'/prev.png').appendTo(j_gallery).css({
					'position':'absolute',
					'zIndex':'1100',
					'cursor':'pointer',
					'top':((opts.panel_height-22)/2)+'px',
					'left':'10px',
					'display':'none'
				}).click(showPrevItemImage0);
				$('<img />').addClass('nav-overlay').attr('src',img_path+opts.nav_theme+'/panel-nav-next.png').appendTo(j_gallery).css({
					'position':'absolute',
					'zIndex':'1099',
					'top':((opts.panel_height-22)/2)-10+'px',
					'right':'0',
					'display':'none'
				});
				
				$('<img />').addClass('nav-overlay').attr('src',img_path+opts.nav_theme+'/panel-nav-prev.png').appendTo(j_gallery).css({
					'position':'absolute',
					'zIndex':'1099',
					'top':((opts.panel_height-22)/2)-10+'px',
					'left':'0',
					'display':'none'
				});
			}
			j_panels.css({
				'width':(opts.panel_width-parseInt(j_panels.css('paddingLeft').split('px')[0],10)-parseInt(j_panels.css('paddingRight').split('px')[0],10))+'px',
				'height':(opts.panel_height-parseInt(j_panels.css('paddingTop').split('px')[0],10)-parseInt(j_panels.css('paddingBottom').split('px')[0],10))+'px',
				'position':'absolute',
				'top':(opts.filmstrip_position=='top'?(opts.frame_height+frame_margin_top+(opts.show_captions?frame_caption_size:frame_margin_top))+'px':'0px'),
				'left':'0px',
				'overflow':'hidden',
				'background':'white',
				'display':'none'
			});
			$('.panel-overlay',j_panels).css({
				'position':'absolute',
				'zIndex':'999',
				'width':(opts.panel_width-20)+'px',
				'height':opts.overlay_height+'px',
				'top':(opts.overlay_position=='top'?'0':opts.panel_height-opts.overlay_height+'px'),
				'left':'0',
				'padding':'0 10px',
				'color':opts.overlay_text_color,
				'fontSize':opts.overlay_font_size
			});
			$('.panel-overlay a',j_panels).css({
				'color':opts.overlay_text_color,
				'textDecoration':'underline',
				'fontWeight':'bold'
			});
			$('.overlay',j_panels).css({
				'position':'absolute',
				'zIndex':'998',
				'width':opts.panel_width+'px',
				'height':opts.overlay_height+'px',
				'top':(opts.overlay_position=='top'?'0':opts.panel_height-opts.overlay_height+'px'),
				'left':'0',
				'background':opts.overlay_color,
				'opacity':opts.overlay_opacity
			});
			$('.panel iframe',j_panels).css({
				'width':opts.panel_width+'px',
				'height':(opts.panel_height-opts.overlay_height)+'px',
				'border':'0'
			});
		};
		
		function buildFilmstrip() {
			//Add wrapper to filmstrip to hide extra frames
			j_filmstrip.wrap('<div class="strip_wrapper"></div>');
			if(slide_method=='strip') {
				j_frames.clone().appendTo(j_filmstrip);
				j_frames.clone().appendTo(j_filmstrip);
				j_frames = $('li',j_filmstrip);
			}
			//If captions are enabled, add caption divs and fill with the image titles
			if(opts.show_captions) {
				j_frames.append('<div class="caption"></div>').each(function(i){
					$(this).find('.caption').html($(this).find('img').attr('title'));			   
				});
			}
			
			j_filmstrip.css({
				'listStyle':'none',
				'margin':'0',
				'padding':'0',
				'width':strip_width+'px',
				'position':'absolute',
				'zIndex':'900',
				'top':'0',
				'left':'0',
				'height':'84px',//(opts.frame_height+10)+'px',
				'background':opts.background_color
			});
			j_frames.css({
				'float':'left',
				'position':'relative',
				'height':opts.frame_height+'px',
				'zIndex':'901',
				'marginTop':frame_margin_top+'px',
				'marginBottom':'0px',
				'marginRight':frame_margin+'px',
				'padding':'0',
				'cursor':'pointer'
			});
			/*
			$('img',j_frames).css({
				'border':'none'
			});
			*/
			$('.strip_wrapper',j_gallery).css({
				'position':'absolute',
				'top':(opts.filmstrip_position=='top'?'0px':opts.panel_height+'px'),
				'left':((gallery_width-wrapper_width)/2)+'px',
				'width':wrapper_width+'px',
				'height':(opts.frame_height+frame_margin_top+(opts.show_captions?frame_caption_size:frame_margin_top))+'px',
				'overflow':'hidden'
			});
			$('.caption',j_gallery).css({
				'position':'absolute',
				'top':opts.frame_height+'px',
				'left':'0',
				'margin':'0',
				'width':opts.frame_width+'px',
				'padding':'0',
				'color':opts.caption_text_color,
				'textAlign':'center',
				'fontSize':'10px',
				'height':frame_caption_size+'px',
				
				'lineHeight':frame_caption_size+'px'
			});
			var pointer = $('<div></div>');
			pointer.attr('id','pointer').appendTo(j_gallery).css({
				 'position':'absolute',
				 'zIndex':'1000',
				 'cursor':'pointer',
				 'top':getPos(j_frames[0]).top-(pointer_width/2)+'px',
				 'left':getPos(j_frames[0]).left-(pointer_width/2)+'px',
				 'height':opts.frame_height-pointer_width+'px',
				 'width':opts.frame_width-pointer_width+'px',
				 'border':(has_panels?pointer_width+'px solid '+(opts.nav_theme=='dark'?'black':'white'):'none')
			});
			j_pointer = $('#pointer',j_gallery);
			if(has_panels) {
				var pointerArrow = $('<img />');
				pointerArrow.attr('src',img_path+opts.nav_theme+'/pointer'+(opts.filmstrip_position=='top'?'-down':'')+'.png').appendTo($('#pointer')).css({
					'position':'absolute',
					'zIndex':'1001',
					'top':(opts.filmstrip_position=='bottom'?'-'+(10+pointer_width)+'px':opts.frame_height+'px'),
					'left':((opts.frame_width/2)-10)+'px'
				});
			}
			
			//If the filmstrip is animating, move the strip to the middle third
			if(slide_method=='strip') {
				j_filmstrip.css('left','-'+((opts.frame_width+frame_margin)*item_count)+'px');
				iterator = item_count;
			}
			//If there's a link under the pointer, enable clicking on the pointer
			if($('a',j_frames[iterator])[0]) {
				j_pointer.click(function(){
					var a = $('a',j_frames[iterator]).eq(0);
					if(a.attr('target')=='_blank') {window.open(a.attr('href'));}
					else {location.href = a.attr('href');}
				});
			}
			
			//Add navigation buttons img_path=>/library/js/themes/
			$('<img />').addClass('nav-nextImage0').attr('src','/library/js/themes/'+opts.nav_theme+'/next.png').appendTo(j_gallery).css({
				'position':'absolute',
				'cursor':'pointer',
				'top':(opts.filmstrip_position=='top'?0:opts.panel_height)+frame_margin_top+((opts.frame_height-22)/2)+'px',
				'right':'6px'
			}).click(showNextItemImage0);
			$('<img />').addClass('nav-prev').attr('src','/library/js/themes/'+opts.nav_theme+'/prev.png').appendTo(j_gallery).css({
				'position':'absolute',
				'cursor':'pointer',
				'top':(opts.filmstrip_position=='top'?0:opts.panel_height)+frame_margin_top+((opts.frame_height-22)/2)+'px',
				'left':'6px'
			}).click(showPrevItemImage0);
		};
		
		//Check mouse to see if it is within the borders of the panel
		//More reliable than 'mouseover' event when elements overlay the panel
		function mouseIsOverPanels(x,y) {		
			var pos = getPos(j_gallery[0]);
			var top = pos.top;
			var left = pos.left;
			return x > left && x < left+opts.panel_width && y > top && y < top+opts.panel_height;				
		};
		
/************************************************/
/*	Main Plugin Code							*/
/************************************************/
		return this.each(function() {
			j_gallery = $(this);
			//Determine path between current page and filmstrip images
			//Scan script tags and look for path to GalleryView plugin
			$('script').each(function(i){
				var s = $(this);
				if(s.attr('src') && s.attr('src').match(/jquery\.galleryview/)){
					img_path = s.attr('src').split('jquery.galleryview')[0]+'themes/';	
				}
			});
			
			//Hide gallery to prevent Flash of Unstyled Content (FoUC) in IE
			j_gallery.css('visibility','hidden');
			
			//Assign elements to variables for reuse
			j_filmstrip = $('.filmstrip',j_gallery);
			j_frames = $('li',j_filmstrip);
			j_panels = $('.panel',j_gallery);
			
			id = j_gallery.attr('id');
			
			has_panels = j_panels.length > 0;
			has_filmstrip = j_frames.length > 0;
			
			if(!has_panels) opts.panel_height = 0;
			
			//Number of frames in filmstrip
			item_count = has_panels?j_panels.length:j_frames.length;
			
			//Number of frames that can display within the screen's width
			//64 = width of block for navigation button * 2
			//5 = minimum frame margin
			strip_size = has_panels?Math.floor((opts.panel_width-64)/(opts.frame_width+frame_margin)):Math.min(item_count,opts.filmstrip_size); 
			
			
			/************************************************/
			/*	Determine transition method for filmstrip	*/
			/************************************************/
					//If more items than strip size, slide filmstrip
					//Otherwise, slide pointer
					if(strip_size >= item_count) {
						slide_method = 'pointer';
						strip_size = item_count;
					}
					else {slide_method = 'strip';}
			
			/************************************************/
			/*	Determine dimensions of various elements	*/
			/************************************************/
					
					//Width of gallery block
					gallery_width = has_panels?opts.panel_width:(strip_size*(opts.frame_width+frame_margin))-frame_margin+64;
					
					//Height of gallery block = screen + filmstrip + captions (optional)
					gallery_height = (has_panels?opts.panel_height:0)+(has_filmstrip?opts.frame_height+frame_margin_top+(opts.show_captions?frame_caption_size:frame_margin_top):0);
					
					//Width of filmstrip
					if(slide_method == 'pointer') {strip_width = (opts.frame_width*item_count)+(frame_margin*(item_count));}
					else {strip_width = (opts.frame_width*item_count*3)+(frame_margin*(item_count*3));}
					
					//Width of filmstrip wrapper (to hide overflow)
					wrapper_width = ((strip_size*opts.frame_width)+((strip_size-1)*frame_margin));
			
			/************************************************/
			/*	Apply CSS Styles							*/
			/************************************************/
					j_gallery.css({
						'position':'relative',
						'margin':'0 0 0 -3px',
						'background':opts.background_color,
						'border':opts.border,
						'width':gallery_width+'px',
						'height':gallery_height+'px'
					});
			
			/************************************************/
			/*	Build filmstrip and/or panels				*/
			/************************************************/
					if(has_filmstrip) {
						buildFilmstrip();
					}
					if(has_panels) {
						buildPanels();
					}

			
			/************************************************/
			/*	Add events to various elements				*/
			/************************************************/
					if(has_filmstrip) enableFrameClicking();
					
						
						
						$().mousemove(function(e){							
							if(mouseIsOverPanels(e.pageX,e.pageY)) {
								if(opts.pause_on_hover) {
									$(document).oneTime(500,"animation_pause",function(){
										$(document).stopTime("transition");
										paused=true;
									});
								}
								if(has_panels && !has_filmstrip) {
									$('.nav-overlay').fadeIn('fast');
									$('.nav-nextImage0').fadeIn('fast');
									$('.nav-prev').fadeIn('fast');
								}
							} else {
								if(opts.pause_on_hover) {
									$(document).stopTime("animation_pause");
									if (paused) {
									    /*
										$(document).everyTime(opts.transition_interval,"transition",function(){
											showNextItemImage0();
										});
										*/
										paused = false;
									}
								}
								if(has_panels && !has_filmstrip) {
									$('.nav-overlay').fadeOut('fast');
									$('.nav-nextImage0').fadeOut('fast');
									$('.nav-prev').fadeOut('fast');
								}
							}
						});
			
			
			/************************************************/
			/*	Initiate Automated Animation				*/
			/************************************************/
					//Show the first panel
					j_panels.eq(0).show();

					//If we have more than one item, begin automated transitions
					if (item_count > 1) {
					    /*
						$(document).everyTime(opts.transition_interval,"transition",function(){
							showNextItemImage0();
						});
						*/
					}
					
					//Make gallery visible now that work is complete
					j_gallery.css('visibility','visible');
		});
	};
	
	$.fn.galleryViewImage0.defaults = {
		panel_width: 400,
		panel_height: 300,
		frame_width: 133,
		frame_height: 80,
		filmstrip_size: 4,
		overlay_height: 70,
		overlay_font_size: '1em',
		transition_speed: 400,
		transition_interval: 20000,
		overlay_opacity: 0.6,
		overlay_color: 'black',
		background_color: 'black',
		overlay_text_color: 'white',
		caption_text_color: 'white',
		border: '1px solid black',
		nav_theme: 'light',
		easing: 'swing',
		filmstrip_position: 'bottom',
		overlay_position: 'bottom',
		show_captions: false,
		fade_panels: true,
		pause_on_hover: false
	};
})(jQuery);/*

	GalleryView - jQuery Content Gallery Plugin
	Author: 		Jack Anderson
	Version:		1.1 (April 5, 2009)
	Documentation: 	http://www.spaceforaname.com/jquery/galleryview/
	
	Please use this development script if you intend to make changes to the
	plugin code.  For production sites, please use jquery.galleryview-1.0.1-pack.js.
	
*/
(function($) {
    $.fn.galleryViewImage1 = function(options) {
        var opts = $.extend($.fn.galleryViewImage1.defaults, options);

        var id;
        var iterator = 0;
        var gallery_width;
        var gallery_height;
        var frame_margin = 18;
        var strip_width;
        var wrapper_width;
        var item_count = 0;
        var slide_method;
        var img_path;
        var paused = false;
        var frame_caption_size = 20;
        var frame_margin_top = 0;
        var pointer_width = 2;

        //Define jQuery objects for reuse
        var j_gallery;
        var j_filmstrip;
        var j_frames;
        var j_panels;
        var j_pointer;

        /************************************************/
        /*	Plugin Methods					*/
        /************************************************/
        function showItem(i) {
            //Disable next/prev buttons until transition is complete
            $('img.nav-nextImage1').unbind('click');
            $('img.nav-prevImage1').unbind('click');
            j_frames.unbind('click');
            if (has_panels) {
                if (opts.fade_panels) {
                    //Fade out all panels and fade in target panel
                    j_panels.fadeOut(opts.transition_speed).eq(i % item_count).fadeIn(opts.transition_speed, function() {
                        if (!has_filmstrip) {
                            $('img.nav-prevImage1').click(showPrevItemImage1);
                            $('img.nav-nextImage1').click(showNextItemImage1);
                        }
                    });
                }
            }

            if (has_filmstrip) {
                //Slide either pointer or filmstrip, depending on transition method
                if (slide_method == 'strip') {
                    //Stop filmstrip if it's currently in motion
                    j_filmstrip.stop();

                    //Determine distance between pointer (eventual destination) and target frame
                    var distance = getPos(j_frames[i]).left - (getPos(j_pointer[0]).left + 2);
                    var leftstr = (distance >= 0 ? '-=' : '+=') + Math.abs(distance) + 'px';

                    //Animate filmstrip and slide target frame under pointer
                    //If target frame is a duplicate, jump back to 'original' frame
                    j_filmstrip.animate({
                        'left': leftstr
                    }, opts.transition_speed, opts.easing, function() {
                        //Always ensure that there are a sufficient number of hidden frames on either
                        //side of the filmstrip to avoid empty frames
                        if (i > item_count) {
                            i = i % item_count;
                            iterator = i;
                            j_filmstrip.css('left', '-' + ((opts.frame_width + frame_margin) * i) + 'px');
                        } else if (i <= (item_count - strip_size)) {
                            i = (i % item_count) + item_count;
                            iterator = i;
                            j_filmstrip.css('left', '-' + ((opts.frame_width + frame_margin) * i) + 'px');
                        }

                        if (!opts.fade_panels) {
                            j_panels.hide().eq(i % item_count).show();
                        }
                        $('img.nav-prevImage1').click(showPrevItemImage1);
                        $('img.nav-nextImage1').click(showNextItemImage1);
                        enableFrameClicking();
                    });
                } else if (slide_method == 'pointer') {
                    //Stop pointer if it's currently in motion
                    j_pointer.stop();
                    //Get position of target frame
                    var pos = getPos(j_frames[i]);
                    //Slide the pointer over the target frame
                    j_pointer.animate({
                        'left': (pos.left - 2 + 'px')
                    }, opts.transition_speed, opts.easing, function() {
                        if (!opts.fade_panels) {
                            j_panels.hide().eq(i % item_count).show();
                        }
                        $('img.nav-prevImage1').click(showPrevItemImage1);
                        $('img.nav-nextImage1').click(showNextItemImage1);
                        enableFrameClicking();
                    });
                }

                if ($('a', j_frames[i])[0]) {
                    j_pointer.unbind('click').click(function() {
                        var a = $('a', j_frames[i]).eq(0);
                        if (a.attr('target') == '_blank') { window.open(a.attr('href')); }
                        else { location.href = a.attr('href'); }
                    });
                }
                //alert(iterator);
            }
        };
        function showNextItemImage1() {
            //alert("hello");

            $(document).stopTime("transition");
            if (++iterator == j_frames.length) { iterator = 0; }
            showItem(iterator);
            //alert(iterator);
            /*
            $(document).everyTime(opts.transition_interval, "transition", function() {
                showNextItemImage1();
            });
            */
        };
        function showPrevItemImage1() {
            $(document).stopTime("transition");
            if (--iterator < 0) { iterator = item_count - 1; }
            //alert(iterator);
            showItem(iterator);
            /*
            $(document).everyTime(opts.transition_interval, "transition", function() {
                showNextItemImage1();
            });
            */
        };
        function getPos(el) {
            var left = 0, top = 0;
            var el_id = el.id;
            if (el.offsetParent) {
                do {
                    left += el.offsetLeft;
                    top += el.offsetTop;
                } while (el = el.offsetParent);
            }
            //If we want the position of the gallery itself, return it
            if (el_id == id) { return { 'left': left, 'top': top }; }
            //Otherwise, get position of element relative to gallery
            else {
                var gPos = getPos(j_gallery[0]);
                var gLeft = gPos.left;
                var gTop = gPos.top;

                return { 'left': left - gLeft, 'top': top - gTop };
            }
        };
        function enableFrameClicking() {
            j_frames.each(function(i) {
                //If there isn't a link in this frame, set up frame to slide on click
                //Frames with links will handle themselves
                if ($('a', this).length == 0) {
                    $(this).click(function() {
                        $(document).stopTime("transition");
                        showItem(i);
                        iterator = i;
                        /*
                        $(document).everyTime(opts.transition_interval, "transition", function() {
                            showNextItemImage1();
                        });
                        */
                    });
                }
            });
        };

        function buildPanels() {
            //If there are panel captions, add overlay divs
            if ($('.panel-overlay').length > 0) { j_panels.append('<div class="overlay"></div>'); }

            if (!has_filmstrip) {
                //Add navigation buttons

                $('<img />').addClass('nav-nextImage1').attr('src', img_path + opts.nav_theme + '/next.png').appendTo(j_gallery).css({
                    'position': 'absolute',
                    'zIndex': '1100',
                    'cursor': 'pointer',
                    'top': ((opts.panel_height - 22) / 2) + 'px',
                    'right': '10px',
                    'display': 'none'
                }).click(showNextItemImage1);
                $('<img />').addClass('nav-prevImage1').attr('src', img_path + opts.nav_theme + '/prev.png').appendTo(j_gallery).css({
                    'position': 'absolute',
                    'zIndex': '1100',
                    'cursor': 'pointer',
                    'top': ((opts.panel_height - 22) / 2) + 'px',
                    'left': '10px',
                    'display': 'none'
                }).click(showPrevItemImage1);
                $('<img />').addClass('nav-overlay').attr('src', img_path + opts.nav_theme + '/panel-nav-next.png').appendTo(j_gallery).css({
                    'position': 'absolute',
                    'zIndex': '1099',
                    'top': ((opts.panel_height - 22) / 2) - 10 + 'px',
                    'right': '0',
                    'display': 'none'
                });

                $('<img />').addClass('nav-overlay').attr('src', img_path + opts.nav_theme + '/panel-nav-prev.png').appendTo(j_gallery).css({
                    'position': 'absolute',
                    'zIndex': '1099',
                    'top': ((opts.panel_height - 22) / 2) - 10 + 'px',
                    'left': '0',
                    'display': 'none'
                });
            }
            j_panels.css({
                'width': (opts.panel_width - parseInt(j_panels.css('paddingLeft').split('px')[0], 10) - parseInt(j_panels.css('paddingRight').split('px')[0], 10)) + 'px',
                'height': (opts.panel_height - parseInt(j_panels.css('paddingTop').split('px')[0], 10) - parseInt(j_panels.css('paddingBottom').split('px')[0], 10)) + 'px',
                'position': 'absolute',
                'top': (opts.filmstrip_position == 'top' ? (opts.frame_height + frame_margin_top + (opts.show_captions ? frame_caption_size : frame_margin_top)) + 'px' : '0px'),
                'left': '0px',
                'overflow': 'hidden',
                'background': 'white',
                'display': 'none'
            });
            $('.panel-overlay', j_panels).css({
                'position': 'absolute',
                'zIndex': '999',
                'width': (opts.panel_width - 20) + 'px',
                'height': opts.overlay_height + 'px',
                'top': (opts.overlay_position == 'top' ? '0' : opts.panel_height - opts.overlay_height + 'px'),
                'left': '0',
                'padding': '0 10px',
                'color': opts.overlay_text_color,
                'fontSize': opts.overlay_font_size
            });
            $('.panel-overlay a', j_panels).css({
                'color': opts.overlay_text_color,
                'textDecoration': 'underline',
                'fontWeight': 'bold'
            });
            $('.overlay', j_panels).css({
                'position': 'absolute',
                'zIndex': '998',
                'width': opts.panel_width + 'px',
                'height': opts.overlay_height + 'px',
                'top': (opts.overlay_position == 'top' ? '0' : opts.panel_height - opts.overlay_height + 'px'),
                'left': '0',
                'background': opts.overlay_color,
                'opacity': opts.overlay_opacity
            });
            $('.panel iframe', j_panels).css({
                'width': opts.panel_width + 'px',
                'height': (opts.panel_height - opts.overlay_height) + 'px',
                'border': '0'
            });
        };

        function buildFilmstrip() {
            //Add wrapper to filmstrip to hide extra frames
            j_filmstrip.wrap('<div class="strip_wrapper"></div>');
            if (slide_method == 'strip') {
                j_frames.clone().appendTo(j_filmstrip);
                j_frames.clone().appendTo(j_filmstrip);
                j_frames = $('li', j_filmstrip);
            }
            //If captions are enabled, add caption divs and fill with the image titles
            if (opts.show_captions) {
                j_frames.append('<div class="caption"></div>').each(function(i) {
                    $(this).find('.caption').html($(this).find('img').attr('title'));
                });
            }

            j_filmstrip.css({
                'listStyle': 'none',
                'margin': '0',
                'padding': '0',
                'width': strip_width + 'px',
                'position': 'absolute',
                'zIndex': '900',
                'top': '0',
                'left': '0',
                'height': '84px',//(opts.frame_height + 10) + 'px',
                'background': opts.background_color
            });
            j_frames.css({
                'float': 'left',
                'position': 'relative',
                'height': opts.frame_height + 'px',
                'zIndex': '901',
                'marginTop': frame_margin_top + 'px',
                'marginBottom': '0px',
                'marginRight': frame_margin + 'px',
                'padding': '0',
                'cursor': 'pointer'
            });
            /*
            $('img',j_frames).css({
            'border':'none'
            });
            */
            $('.strip_wrapper', j_gallery).css({
                'position': 'absolute',
                'top': (opts.filmstrip_position == 'top' ? '0px' : opts.panel_height + 'px'),
                'left': ((gallery_width - wrapper_width) / 2) + 'px',
                'width': wrapper_width + 'px',
                'height': (opts.frame_height + frame_margin_top + (opts.show_captions ? frame_caption_size : frame_margin_top)) + 'px',
                'overflow': 'hidden'
            });
            $('.caption', j_gallery).css({
                'position': 'absolute',
                'top': opts.frame_height + 'px',
                'left': '0',
                'margin': '0',
                'width': opts.frame_width + 'px',
                'padding': '0',
                'color': opts.caption_text_color,
                'textAlign': 'center',
                'fontSize': '10px',
                'height': frame_caption_size + 'px',

                'lineHeight': frame_caption_size + 'px'
            });
            var pointer = $('<div></div>');
            pointer.attr('id', 'pointer').appendTo(j_gallery).css({
                'position': 'absolute',
                'zIndex': '1000',
                'cursor': 'pointer',
                'top': getPos(j_frames[0]).top - (pointer_width / 2) + 'px',
                'left': getPos(j_frames[0]).left - (pointer_width / 2) + 'px',
                'height': opts.frame_height - pointer_width + 'px',
                'width': opts.frame_width - pointer_width + 'px',
                'border': (has_panels ? pointer_width + 'px solid ' + (opts.nav_theme == 'dark' ? 'black' : 'white') : 'none')
            });
            j_pointer = $('#pointer', j_gallery);
            if (has_panels) {
                var pointerArrow = $('<img />');
                pointerArrow.attr('src', img_path + opts.nav_theme + '/pointer' + (opts.filmstrip_position == 'top' ? '-down' : '') + '.png').appendTo($('#pointer')).css({
                    'position': 'absolute',
                    'zIndex': '1001',
                    'top': (opts.filmstrip_position == 'bottom' ? '-' + (10 + pointer_width) + 'px' : opts.frame_height + 'px'),
                    'left': ((opts.frame_width / 2) - 10) + 'px'
                });
            }

            //If the filmstrip is animating, move the strip to the middle third
            if (slide_method == 'strip') {
                j_filmstrip.css('left', '-' + ((opts.frame_width + frame_margin) * item_count) + 'px');
                iterator = item_count;
            }
            //If there's a link under the pointer, enable clicking on the pointer
            if ($('a', j_frames[iterator])[0]) {
                j_pointer.click(function() {
                    var a = $('a', j_frames[iterator]).eq(0);
                    if (a.attr('target') == '_blank') { window.open(a.attr('href')); }
                    else { location.href = a.attr('href'); }
                });
            }

            //Add navigation buttons img_path=>/library/js/themes/
            $('<img />').addClass('nav-nextImage1').attr('src', '/library/js/themes/' + opts.nav_theme + '/next.png').appendTo(j_gallery).css({
                'position': 'absolute',
                'cursor': 'pointer',
                'top': (opts.filmstrip_position == 'top' ? 0 : opts.panel_height) + frame_margin_top + ((opts.frame_height - 22) / 2) + 'px',
                'right': '6px'
            }).click(showNextItemImage1);
            $('<img />').addClass('nav-prevImage1').attr('src', '/library/js/themes/' + opts.nav_theme + '/prev.png').appendTo(j_gallery).css({
                'position': 'absolute',
                'cursor': 'pointer',
                'top': (opts.filmstrip_position == 'top' ? 0 : opts.panel_height) + frame_margin_top + ((opts.frame_height - 22) / 2) + 'px',
                'left': '6px'
            }).click(showPrevItemImage1);
        };

        //Check mouse to see if it is within the borders of the panel
        //More reliable than 'mouseover' event when elements overlay the panel
        function mouseIsOverPanels(x, y) {
            var pos = getPos(j_gallery[0]);
            var top = pos.top;
            var left = pos.left;
            return x > left && x < left + opts.panel_width && y > top && y < top + opts.panel_height;
        };

        /************************************************/
        /*	Main Plugin Code							*/
        /************************************************/
        return this.each(function() {
            j_gallery = $(this);
            //Determine path between current page and filmstrip images
            //Scan script tags and look for path to GalleryView plugin
            $('script').each(function(i) {
                var s = $(this);
                if (s.attr('src') && s.attr('src').match(/jquery\.galleryview/)) {
                    img_path = s.attr('src').split('jquery.galleryview')[0] + 'themes/';
                }
            });

            //Hide gallery to prevent Flash of Unstyled Content (FoUC) in IE
            j_gallery.css('visibility', 'hidden');

            //Assign elements to variables for reuse
            j_filmstrip = $('.filmstrip', j_gallery);
            j_frames = $('li', j_filmstrip);
            j_panels = $('.panel', j_gallery);

            id = j_gallery.attr('id');

            has_panels = j_panels.length > 0;
            has_filmstrip = j_frames.length > 0;

            if (!has_panels) opts.panel_height = 0;

            //Number of frames in filmstrip
            item_count = has_panels ? j_panels.length : j_frames.length;

            //Number of frames that can display within the screen's width
            //64 = width of block for navigation button * 2
            //5 = minimum frame margin
            strip_size = has_panels ? Math.floor((opts.panel_width - 64) / (opts.frame_width + frame_margin)) : Math.min(item_count, opts.filmstrip_size);


            /************************************************/
            /*	Determine transition method for filmstrip	*/
            /************************************************/
            //If more items than strip size, slide filmstrip
            //Otherwise, slide pointer
            if (strip_size >= item_count) {
                slide_method = 'pointer';
                strip_size = item_count;
            }
            else { slide_method = 'strip'; }

            /************************************************/
            /*	Determine dimensions of various elements	*/
            /************************************************/

            //Width of gallery block
            gallery_width = has_panels ? opts.panel_width : (strip_size * (opts.frame_width + frame_margin)) - frame_margin + 64;

            //Height of gallery block = screen + filmstrip + captions (optional)
            gallery_height = (has_panels ? opts.panel_height : 0) + (has_filmstrip ? opts.frame_height + frame_margin_top + (opts.show_captions ? frame_caption_size : frame_margin_top) : 0);

            //Width of filmstrip
            if (slide_method == 'pointer') { strip_width = (opts.frame_width * item_count) + (frame_margin * (item_count)); }
            else { strip_width = (opts.frame_width * item_count * 3) + (frame_margin * (item_count * 3)); }

            //Width of filmstrip wrapper (to hide overflow)
            wrapper_width = ((strip_size * opts.frame_width) + ((strip_size - 1) * frame_margin));

            /************************************************/
            /*	Apply CSS Styles							*/
            /************************************************/
            j_gallery.css({
                'position': 'relative',
                'margin': '0 0 0 -3px',
                'background': opts.background_color,
                'border': opts.border,
                'width': gallery_width + 'px',
                'height': gallery_height + 'px'
            });

            /************************************************/
            /*	Build filmstrip and/or panels				*/
            /************************************************/
            if (has_filmstrip) {
                buildFilmstrip();
            }
            if (has_panels) {
                buildPanels();
            }


            /************************************************/
            /*	Add events to various elements				*/
            /************************************************/
            if (has_filmstrip) enableFrameClicking();



            $().mousemove(function(e) {
                if (mouseIsOverPanels(e.pageX, e.pageY)) {
                    if (opts.pause_on_hover) {
                        $(document).oneTime(500, "animation_pause", function() {
                            $(document).stopTime("transition");
                            paused = true;
                        });
                    }
                    if (has_panels && !has_filmstrip) {
                        $('.nav-overlay').fadeIn('fast');
                        $('.nav-nextImage1').fadeIn('fast');
                        $('.nav-prevImage1').fadeIn('fast');
                    }
                } else {
                    if (opts.pause_on_hover) {
                        $(document).stopTime("animation_pause");
                        if (paused) {
                            /*
                            $(document).everyTime(opts.transition_interval, "transition", function() {
                                showNextItemImage1();
                            });
                            */
                            paused = false;
                        }
                    }
                    if (has_panels && !has_filmstrip) {
                        $('.nav-overlay').fadeOut('fast');
                        $('.nav-nextImage1').fadeOut('fast');
                        $('.nav-prevImage1').fadeOut('fast');
                    }
                }
            });


            /************************************************/
            /*	Initiate Automated Animation				*/
            /************************************************/
            //Show the first panel
            j_panels.eq(0).show();

            //If we have more than one item, begin automated transitions
            if (item_count > 1) {
                /*
                $(document).everyTime(opts.transition_interval, "transition", function() {
                    showNextItemImage1();
                });
                */
            }

            //Make gallery visible now that work is complete
            j_gallery.css('visibility', 'visible');
        });
    };

    $.fn.galleryViewImage1.defaults = {
        panel_width: 400,
        panel_height: 300,
        frame_width: 133,
        frame_height: 80,
        filmstrip_size: 4,
        overlay_height: 70,
        overlay_font_size: '1em',
        transition_speed: 400,
        transition_interval: 20000,
        overlay_opacity: 0.6,
        overlay_color: 'black',
        background_color: 'black',
        overlay_text_color: 'white',
        caption_text_color: 'white',
        border: '1px solid black',
        nav_theme: 'light',
        easing: 'swing',
        filmstrip_position: 'bottom',
        overlay_position: 'bottom',
        show_captions: false,
        fade_panels: true,
        pause_on_hover: false
    };
})(jQuery);﻿/**
 * jQuery.timers - Timer abstractions for jQuery
 * Written by Blair Mitchelmore (blair DOT mitchelmore AT gmail DOT com)
 * Licensed under the WTFPL (http://sam.zoy.org/wtfpl/).
 * Date: 2009/02/08
 *
 * @author Blair Mitchelmore
 * @version 1.1.2
 *
 **/

jQuery.fn.extend({
	everyTime: function(interval, label, fn, times, belay) {
		return this.each(function() {
			jQuery.timer.add(this, interval, label, fn, times, belay);
		});
	},
	oneTime: function(interval, label, fn) {
		return this.each(function() {
			jQuery.timer.add(this, interval, label, fn, 1);
		});
	},
	stopTime: function(label, fn) {
		return this.each(function() {
			jQuery.timer.remove(this, label, fn);
		});
	}
});

jQuery.event.special

jQuery.extend({
	timer: {
		global: [],
		guid: 1,
		dataKey: "jQuery.timer",
		regex: /^([0-9]+(?:\.[0-9]*)?)\s*(.*s)?$/,
		powers: {
			// Yeah this is major overkill...
			'ms': 1,
			'cs': 10,
			'ds': 100,
			's': 1000,
			'das': 10000,
			'hs': 100000,
			'ks': 1000000
		},
		timeParse: function(value) {
			if (value == undefined || value == null)
				return null;
			var result = this.regex.exec(jQuery.trim(value.toString()));
			if (result[2]) {
				var num = parseFloat(result[1]);
				var mult = this.powers[result[2]] || 1;
				return num * mult;
			} else {
				return value;
			}
		},
		add: function(element, interval, label, fn, times, belay) {
			var counter = 0;
			
			if (jQuery.isFunction(label)) {
				if (!times) 
					times = fn;
				fn = label;
				label = interval;
			}
			
			interval = jQuery.timer.timeParse(interval);

			if (typeof interval != 'number' || isNaN(interval) || interval <= 0)
				return;

			if (times && times.constructor != Number) {
				belay = !!times;
				times = 0;
			}
			
			times = times || 0;
			belay = belay || false;
			
			var timers = jQuery.data(element, this.dataKey) || jQuery.data(element, this.dataKey, {});
			
			if (!timers[label])
				timers[label] = {};
			
			fn.timerID = fn.timerID || this.guid++;
			
			var handler = function() {
				if (belay && this.inProgress) 
					return;
				this.inProgress = true;
				if ((++counter > times && times !== 0) || fn.call(element, counter) === false)
					jQuery.timer.remove(element, label, fn);
				this.inProgress = false;
			};
			
			handler.timerID = fn.timerID;
			
			if (!timers[label][fn.timerID])
				timers[label][fn.timerID] = window.setInterval(handler,interval);
			
			this.global.push( element );
			
		},
		remove: function(element, label, fn) {
			var timers = jQuery.data(element, this.dataKey), ret;
			
			if ( timers ) {
				
				if (!label) {
					for ( label in timers )
						this.remove(element, label, fn);
				} else if ( timers[label] ) {
					if ( fn ) {
						if ( fn.timerID ) {
							window.clearInterval(timers[label][fn.timerID]);
							delete timers[label][fn.timerID];
						}
					} else {
						for ( var fn in timers[label] ) {
							window.clearInterval(timers[label][fn]);
							delete timers[label][fn];
						}
					}
					
					for ( ret in timers[label] ) break;
					if ( !ret ) {
						ret = null;
						delete timers[label];
					}
				}
				
				for ( ret in timers ) break;
				if ( !ret ) 
					jQuery.removeData(element, this.dataKey);
			}
		}
	}
});

jQuery(window).bind("unload", function() {
	jQuery.each(jQuery.timer.global, function(index, item) {
		jQuery.timer.remove(item);
	});
});/*

	GalleryView - jQuery Content Gallery Plugin
	Author: 		Jack Anderson
	Version:		1.1 (April 5, 2009)
	Documentation: 	http://www.spaceforaname.com/jquery/galleryview/
	
	Please use this development script if you intend to make changes to the
	plugin code.  For production sites, please use jquery.galleryview-1.0.1-pack.js.
	
*/
(function($) {
    $.fn.FlashGameBox = function(options) {
        var opts = $.extend($.fn.FlashGameBox.defaults, options);

        var id;
        var iterator = 0;
        var gallery_width;
        var gallery_height;
        var frame_margin = 0;
        var strip_width;
        var wrapper_width;
        var item_count = 0;
        var slide_method;
        var img_path;
        var paused = false;
        var frame_caption_size = 20;
        var frame_margin_top = 0;
        var pointer_width = 2;

        //Define jQuery objects for reuse
        var j_gallery;
        var j_filmstrip;
        var j_frames;
        var j_panels;
        var j_pointer;

        /************************************************/
        /*	Plugin Methods								*/
        /************************************************/
        function showItem(i) {
            //Disable next/prev buttons until transition is complete
            $('img.nav_nextFlash').unbind('click');
            $('img.nav_prevFlash').unbind('click');
            j_frames.unbind('click');
            if (has_panels) {
                if (opts.fade_panels) {
                    //Fade out all panels and fade in target panel
                    j_panels.fadeOut(opts.transition_speed).eq(i % item_count).fadeIn(opts.transition_speed, function() {
                        if (!has_filmstrip) {
                            $('img.nav_prevFlash').click(showPrevItem);
                            $('img.nav_nextFlash').click(showNextItem);
                        }
                    });
                }
            }

            if (has_filmstrip) {
                //Slide either pointer or filmstrip, depending on transition method
                if (slide_method == 'strip') {
                    //Stop filmstrip if it's currently in motion
                    j_filmstrip.stop();

                    //Determine distance between pointer (eventual destination) and target frame
                    var distance = getPos(j_frames[i]).left - (getPos(j_pointer[0]).left + 2);
                    //alert(distance);
                    //var leftstr = '-=148px'; //(distance >= 0 ? '-=' : '+=') + Math.abs(distance) + 'px';
                    var leftstr = (distance >= 0 ? '-=' : '+=') + '148' + 'px';
                    //alert(leftstr);
                    //Animate filmstrip and slide target frame under pointer
                    //If target frame is a duplicate, jump back to 'original' frame
                    j_filmstrip.animate({
                        'left': leftstr
                    }, opts.transition_speed, opts.easing, function() {
                        //Always ensure that there are a sufficient number of hidden frames on either
                        //side of the filmstrip to avoid empty frames
                        //alert("i:" + i + ";item_count:" + item_count + ";strip_size:" + strip_size)
                        if (i > item_count) {
                            i = i % item_count;
                            iterator = i;
                            j_filmstrip.css('left', '-' + ((opts.frame_width + frame_margin) * i) + 'px');
                            //alert('left'+ '-' + ((opts.frame_width + frame_margin) * i) + 'px');
                        } else if (i <= (item_count - strip_size)) {
                            i = (i % item_count) + item_count;
                            iterator = i;
                            j_filmstrip.css('left', '-' + ((opts.frame_width + frame_margin) * i) + 'px');
                            //alert('left'+ '-' + ((opts.frame_width + frame_margin) * i) + 'px');
                        }

                        if (!opts.fade_panels) {
                            j_panels.hide().eq(i % item_count).show();
                        }
                        $('img.nav_prevFlash').click(showPrevItem);
                        $('img.nav_nextFlash').click(showNextItem);
                        enableFrameClicking();
                    });
                } else if (slide_method == 'pointer') {
                    //Stop pointer if it's currently in motion
                    j_pointer.stop();
                    //Get position of target frame
                    var pos = getPos(j_frames[i]);
                    //Slide the pointer over the target frame
                    j_pointer.animate({
                        'left': (pos.left - 2 + 'px')
                    }, opts.transition_speed, opts.easing, function() {
                        if (!opts.fade_panels) {
                            j_panels.hide().eq(i % item_count).show();
                        }
                        $('img.nav_prevFlash').click(showPrevItem);
                        $('img.nav_nextFlash').click(showNextItem);
                        enableFrameClicking();
                    });
                }

                if ($('a', j_frames[i])[0]) {
                    j_pointer.unbind('click').click(function() {
                        var a = $('a', j_frames[i]).eq(0);
                        if (a.attr('target') == '_blank') { window.open(a.attr('href')); }
                        else { location.href = a.attr('href'); }
                    });
                }
            }
        };
        function showNextItem() {
            $(document).stopTime("transition");
            if (++iterator == j_frames.length) { iterator = 0; }
            showItem(iterator);
            // $(document).everyTime(opts.transition_interval,"transition",function(){
            // showNextItem();
            // });
        };
        function showPrevItem() {
            $(document).stopTime("transition");
            if (--iterator < 0) { iterator = item_count - 1; }
            //alert(iterator);
            showItem(iterator);
            // $(document).everyTime(opts.transition_interval,"transition",function(){
            // showNextItem();
            // });
        };
        function getPos(el) {
            var left = 0, top = 0;
            var el_id = el.id;
            if (el.offsetParent) {
                do {
                    left += el.offsetLeft;
                    top += el.offsetTop;
                } while (el = el.offsetParent);
            }
            //If we want the position of the gallery itself, return it
            if (el_id == id) { return { 'left': left, 'top': top }; }
            //Otherwise, get position of element relative to gallery
            else {
                var gPos = getPos(j_gallery[0]);
                var gLeft = gPos.left;
                var gTop = gPos.top;

                return { 'left': left - gLeft, 'top': top - gTop };
            }
        };
        function enableFrameClicking() {
            j_frames.each(function(i) {
                //If there isn't a link in this frame, set up frame to slide on click
                //Frames with links will handle themselves
                if ($('a', this).length == 0) {
                    $(this).click(function() {
                        $(document).stopTime("transition");
                        showItem(i);
                        iterator = i;
                        // $(document).everyTime(opts.transition_interval,"transition",function(){
                        // showNextItem();
                        // });
                    });
                }
            });
        };

        function buildPanels() {
            //If there are panel captions, add overlay divs
            if ($('.panel-overlay').length > 0) { j_panels.append('<div class="overlay"></div>'); }

            if (!has_filmstrip) {
                //Add navigation buttons
                $('<img />').addClass('nav_nextFlash').attr('src', img_path + opts.nav_theme + '/next.png').appendTo(j_gallery).css({
                    'position': 'absolute',
                    'zIndex': '1100',
                    'cursor': 'pointer',
                    'top': ((opts.panel_height - 22) / 2) + 'px',
                    'right': '10px',
                    'display': 'none'
                }).click(showNextItem);
                $('<img />').addClass('nav_prevFlash').attr('src', img_path + opts.nav_theme + '/prev.png').appendTo(j_gallery).css({
                    'position': 'absolute',
                    'zIndex': '1100',
                    'cursor': 'pointer',
                    'top': ((opts.panel_height - 22) / 2) + 'px',
                    'left': '10px',
                    'display': 'none'
                }).click(showPrevItem);

                $('<img />').addClass('nav-overlay').attr('src', img_path + opts.nav_theme + '/panel-nav-next.png').appendTo(j_gallery).css({
                    'position': 'absolute',
                    'zIndex': '1099',
                    'top': ((opts.panel_height - 22) / 2) - 10 + 'px',
                    'right': '0',
                    'display': 'none'
                });

                $('<img />').addClass('nav-overlay').attr('src', img_path + opts.nav_theme + '/panel-nav-prev.png').appendTo(j_gallery).css({
                    'position': 'absolute',
                    'zIndex': '1099',
                    'top': ((opts.panel_height - 22) / 2) - 10 + 'px',
                    'left': '0',
                    'display': 'none'
                });
            }
            j_panels.css({
                'width': (opts.panel_width - parseInt(j_panels.css('paddingLeft').split('px')[0], 10) - parseInt(j_panels.css('paddingRight').split('px')[0], 10)) + 'px',
                'height': (opts.panel_height - parseInt(j_panels.css('paddingTop').split('px')[0], 10) - parseInt(j_panels.css('paddingBottom').split('px')[0], 10)) + 'px',
                'position': 'absolute',
                'top': (opts.filmstrip_position == 'top' ? (opts.frame_height + frame_margin_top + (opts.show_captions ? frame_caption_size : frame_margin_top)) + 'px' : '0px'),
                'left': '0px',
                'overflow': 'hidden',
                'background': 'white',
                'display': 'none'
            });
            $('.panel-overlay', j_panels).css({
                'position': 'absolute',
                'zIndex': '999',
                'width': (opts.panel_width - 20) + 'px',
                'height': opts.overlay_height + 'px',
                'top': (opts.overlay_position == 'top' ? '0' : opts.panel_height - opts.overlay_height + 'px'),
                'left': '0',
                'padding': '0 10px',
                'color': opts.overlay_text_color,
                'fontSize': opts.overlay_font_size
            });
            $('.panel-overlay a', j_panels).css({
                'color': opts.overlay_text_color,
                'textDecoration': 'underline',
                'fontWeight': 'bold'
            });
            $('.overlay', j_panels).css({
                'position': 'absolute',
                'zIndex': '998',
                'width': opts.panel_width + 'px',
                'height': opts.overlay_height + 'px',
                'top': (opts.overlay_position == 'top' ? '0' : opts.panel_height - opts.overlay_height + 'px'),
                'left': '0',
                'background': opts.overlay_color,
                'opacity': opts.overlay_opacity
            });
            $('.panel iframe', j_panels).css({
                'width': opts.panel_width + 'px',
                'height': (opts.panel_height - opts.overlay_height) + 'px',
                'border': '0'
            });
        };

        function buildFilmstrip() {
            //Add wrapper to filmstrip to hide extra frames
            j_filmstrip.wrap('<div class="strip_wrapper"></div>');
            if (slide_method == 'strip') {
                j_frames.clone().appendTo(j_filmstrip);
                j_frames.clone().appendTo(j_filmstrip);
                j_frames = $('li', j_filmstrip);
            }
            //If captions are enabled, add caption divs and fill with the image titles
            if (opts.show_captions) {
                j_frames.append('<div class="caption"></div>').each(function(i) {
                    $(this).find('.caption').html($(this).find('img').attr('title'));
                });
            }

            j_filmstrip.css({
                'listStyle': 'none',
                'margin': '0',
                'padding': '0',
                'width': strip_width + 'px',
                'position': 'absolute',
                'zIndex': '900',
                'top': '0',
                'left': '0',
                'height': (opts.frame_height + 10) + 'px',
                'background': opts.background_color
            });
            j_frames.css({
                'float': 'left',
                'position': 'relative',
                'height': opts.frame_height + 'px',
                'zIndex': '901',
                'marginTop': frame_margin_top + 'px',
                'marginBottom': '0px',
                'marginRight': frame_margin + 'px',
                'padding': '0',
                'cursor': 'pointer'
            });
            $('img', j_frames).css({
            //'border':'none'
        });
        $('.strip_wrapper', j_gallery).css({
            'position': 'absolute',
            'top': (opts.filmstrip_position == 'top' ? '0px' : opts.panel_height + 'px'),
            'left': '26px', //((gallery_width-wrapper_width)/2)+'px',
            'width': wrapper_width - 1 + 'px',
            'height': (opts.frame_height + frame_margin_top + (opts.show_captions ? frame_caption_size : frame_margin_top)) + 'px',
            'overflow': 'hidden'
        });
        $('.caption', j_gallery).css({
            'position': 'absolute',
            'top': opts.frame_height + 'px',
            'left': '0',
            'margin': '0',
            'width': opts.frame_width + 'px',
            'padding': '0',
            'color': opts.caption_text_color,
            'textAlign': 'center',
            'fontSize': '10px',
            'height': frame_caption_size + 'px',

            'lineHeight': frame_caption_size + 'px'
        });
        var pointer = $('<div></div>');
        pointer.attr('id', 'pointer').appendTo(j_gallery).css({
            'position': 'absolute',
            'zIndex': '1000',
            'cursor': 'pointer',
            'top': getPos(j_frames[0]).top - (pointer_width / 2) + 'px',
            'left': getPos(j_frames[0]).left - (pointer_width / 2) + 'px',
            'height': opts.frame_height - pointer_width + 'px',
            'width': '148px', //opts.frame_width - pointer_width + 'px',
            'border': (has_panels ? pointer_width + 'px solid ' + (opts.nav_theme == 'dark' ? 'black' : 'white') : 'none')
        });
        j_pointer = $('#pointer', j_gallery);
        if (has_panels) {
            var pointerArrow = $('<img />');
            pointerArrow.attr('src', img_path + opts.nav_theme + '/pointer' + (opts.filmstrip_position == 'top' ? '-down' : '') + '.png').appendTo($('#pointer')).css({
                'position': 'absolute',
                'zIndex': '1001',
                'top': (opts.filmstrip_position == 'bottom' ? '-' + (10 + pointer_width) + 'px' : opts.frame_height + 'px'),
                'left': ((opts.frame_width / 2) - 10) + 'px'
            });
        }

        //If the filmstrip is animating, move the strip to the middle third
        if (slide_method == 'strip') {
            j_filmstrip.css('left', '-' + ((opts.frame_width + frame_margin) * item_count) + 'px');
            iterator = item_count;
        }
        //If there's a link under the pointer, enable clicking on the pointer
        if ($('a', j_frames[iterator])[0]) {
            j_pointer.click(function() {
                var a = $('a', j_frames[iterator]).eq(0);
                if (a.attr('target') == '_blank') { window.open(a.attr('href')); }
                else { location.href = a.attr('href'); }
            });
        }

        //Add navigation buttons
        $('<img />').addClass('nav_nextFlash').attr('src', img_path + opts.nav_theme + '/next.png').appendTo(j_gallery).css({
            'position': 'absolute',
            'cursor': 'pointer',
            'top': '40px', //(opts.filmstrip_position=='top'?0:opts.panel_height)+frame_margin_top+((opts.frame_height-22)/2)+'px',
            'right': '24px'//(gallery_width/2)-(wrapper_width/2)-10-22+'px'
        }).click(showNextItem);
        $('<img />').addClass('nav_prevFlash').attr('src', img_path + opts.nav_theme + '/prev.png').appendTo(j_gallery).css({
            'position': 'absolute',
            'cursor': 'pointer',
            'top': '40px', //(opts.filmstrip_position=='top'?0:opts.panel_height)+frame_margin_top+((opts.frame_height-22)/2)+'px',
            'left': '12px'//(gallery_width/2)-(wrapper_width/2)-10-22+'px'
        }).click(showPrevItem);
    };

    //Check mouse to see if it is within the borders of the panel
    //More reliable than 'mouseover' event when elements overlay the panel
    function mouseIsOverPanels(x, y) {
        var pos = getPos(j_gallery[0]);
        var top = pos.top;
        var left = pos.left;
        return x > left && x < left + opts.panel_width && y > top && y < top + opts.panel_height;
    };

    /************************************************/
    /*	Main Plugin Code							*/
    /************************************************/
    return this.each(function() {
        j_gallery = $(this);
        //Determine path between current page and filmstrip images
        //Scan script tags and look for path to GalleryView plugin
        // $('script').each(function(i){
        // var s = $(this);
        // if(s.attr('src') && s.attr('src').match(/jquery\.FlashGameBox/)){
        // img_path = s.attr('src').split('jquery.galleryview')[0]+'themes/';	
        // }
        // });
        img_path = '/library/js/themes/'
        //Hide gallery to prevent Flash of Unstyled Content (FoUC) in IE
        j_gallery.css('visibility', 'hidden');

        //Assign elements to variables for reuse
        j_filmstrip = $('.filmstrip', j_gallery);
        j_frames = $('li', j_filmstrip);
        j_panels = $('.panel', j_gallery);

        id = j_gallery.attr('id');

        has_panels = j_panels.length > 0;
        has_filmstrip = j_frames.length > 0;

        if (!has_panels) opts.panel_height = 0;

        //Number of frames in filmstrip
        item_count = has_panels ? j_panels.length : j_frames.length;

        //Number of frames that can display within the screen's width
        //64 = width of block for navigation button * 2
        //5 = minimum frame margin
        strip_size = has_panels ? Math.floor((opts.panel_width - 64) / (opts.frame_width + frame_margin)) : Math.min(item_count, opts.filmstrip_size);


        /************************************************/
        /*	Determine transition method for filmstrip	*/
        /************************************************/
        //If more items than strip size, slide filmstrip
        //Otherwise, slide pointer
        if (strip_size >= item_count) {
            slide_method = 'pointer';
            strip_size = item_count;
        }
        else { slide_method = 'strip'; }

        /************************************************/
        /*	Determine dimensions of various elements	*/
        /************************************************/

        //Width of gallery block
        gallery_width = has_panels ? opts.panel_width : (strip_size * (opts.frame_width + frame_margin)) - frame_margin + 64;

        //Height of gallery block = screen + filmstrip + captions (optional)
        gallery_height = (has_panels ? opts.panel_height : 0) + (has_filmstrip ? opts.frame_height + frame_margin_top + (opts.show_captions ? frame_caption_size : frame_margin_top) : 0);

        //Width of filmstrip
        if (slide_method == 'pointer') { strip_width = (opts.frame_width * item_count) + (frame_margin * (item_count)); }
        else { strip_width = (opts.frame_width * item_count * 3) + (frame_margin * (item_count * 3)); }

        //Width of filmstrip wrapper (to hide overflow)
        wrapper_width = ((strip_size * opts.frame_width) + ((strip_size - 1) * frame_margin));

        /************************************************/
        /*	Apply CSS Styles							*/
        /************************************************/
        j_gallery.css({
            'position': 'relative',
            'margin': '0',
            'background': opts.background_color,
            'border': opts.border,
            'width': gallery_width + 'px',
            'height': gallery_height + 'px'
        });

        /************************************************/
        /*	Build filmstrip and/or panels				*/
        /************************************************/
        if (has_filmstrip) {
            buildFilmstrip();
        }
        if (has_panels) {
            buildPanels();
        }


        /************************************************/
        /*	Add events to various elements				*/
        /************************************************/
        if (has_filmstrip) enableFrameClicking();



        $().mousemove(function(e) {
            if (mouseIsOverPanels(e.pageX, e.pageY)) {
                if (opts.pause_on_hover) {
                    $(document).oneTime(500, "animation_pause", function() {
                        $(document).stopTime("transition");
                        paused = true;
                    });
                }
                if (has_panels && !has_filmstrip) {
                    $('.nav-overlay').fadeIn('fast');
                    $('.nav_nextFlash').fadeIn('fast');
                    $('.nav_prevFlash').fadeIn('fast');
                }
            } else {
                if (opts.pause_on_hover) {
                    $(document).stopTime("animation_pause");
                    if (paused) {
                        // $(document).everyTime(opts.transition_interval,"transition",function(){
                        // showNextItem();
                        // });
                        paused = false;
                    }
                }
                if (has_panels && !has_filmstrip) {
                    $('.nav-overlay').fadeOut('fast');
                    $('.nav_nextFlash').fadeOut('fast');
                    $('.nav_prevFlash').fadeOut('fast');
                }
            }
        });


        /************************************************/
        /*	Initiate Automated Animation				*/
        /************************************************/
        //Show the first panel
        j_panels.eq(0).show();

        //If we have more than one item, begin automated transitions
        if (item_count > 1) {
            // $(document).everyTime(opts.transition_interval,"transition",function(){
            // showNextItem();
            // });
        }

        //Make gallery visible now that work is complete
        j_gallery.css('visibility', 'visible');
    });
};

$.fn.FlashGameBox.defaults = {
    panel_width: 400,
    panel_height: 300,
    frame_width: 80,
    frame_height: 80,
    filmstrip_size: 3,
    overlay_height: 70,
    overlay_font_size: '1em',
    transition_speed: 400,
    transition_interval: 6000,
    overlay_opacity: 0.6,
    overlay_color: 'black',
    background_color: 'black',
    overlay_text_color: 'white',
    caption_text_color: 'white',
    border: '1px solid black',
    nav_theme: 'light',
    easing: 'swing',
    filmstrip_position: 'bottom',
    overlay_position: 'bottom',
    show_captions: false,
    fade_panels: true,
    pause_on_hover: false
};
})(jQuery);