function validateForm(e) {
var elem = $(e + " :input");
var err = "";
for (var i=0; i<elem.length; i++) {
    if ($(elem[i]).hasClass("required") && $(elem[i]).val() == "")
    {
      err += "<li><strong>"+ $(elem[i]).attr("placeholder") +"</strong> - required to be filled</li>";
	  $(elem[i].parentNode).addClass('error');
    }
	else
	{
		  $(elem[i].parentNode).addClass('ok');
	}
	if ($(elem[i]).hasClass("email") && $(elem[i]).val() !== "" )
    {
		if (!checkEmail($(elem[i]).val()) )
		{
		  err += "<li><strong>"+ $(elem[i]).attr("placeholder") +"</strong> - must be valid</li>";
		  $(elem[i].parentNode).addClass('error');
		  $(elem[i].parentNode).removeClass('ok');
		}
		else
		{
			  $(elem[i].parentNode).addClass('ok');
		}

	}

	if ($(elem[i]).hasClass("required") && (elem[i].selectedIndex <= 0))
    {
      err += "<li><strong>"+ $(elem[i]).attr("placeholder") +"</strong> - necessarily need to choose</li>";
	  $(elem[i].parentNode).addClass('error');
	  $(elem[i].parentNode).removeClass('ok');

	}

	if ($(elem[i]).hasClass("phone") && $(elem[i]).val() !== "" )
    {
		if (!checkPhone($(elem[i]).val()) )
		{
		  err += "<li><strong>"+ $(elem[i]).attr("placeholder") +"</strong> - must be valid</li>";
		  $(elem[i].parentNode).addClass('error');
		  $(elem[i].parentNode).removeClass('ok');
		}
		else
		{
			  $(elem[i].parentNode).addClass('ok');
		}

	}

  }
  if (err != "") {
    err = "<span>You forgot or did not correctly enter one or more fields. Please correct these errors:</span><ul>" + err + "</ul>";
    $("#fill_form2").html(err).addClass("visible");
    return false;
  }
  else return true;
}

/**
* LightGallery v1.3
* Author: Dmitri Ischenko ischenkodv@gmail.com
* Freely distributable under MIT-style license
* Patched by iDeus.biz
*/
var lightgallery=(function(){var h,g,c,a,H,ad,J={showOverlay:true,overlayColor:"#000",overlayOpacity:0.85,zoomStep:0.2,animate:true,framesNumber:20,speed:30,resizeSync:false,enableZoom:true,fadeImage:true,alias:"lightgallery",fullSize:false,minPadding:15},al={next:"Next",prev:"Previous",zoomIn:"Zoom In",zoomOut:"Zoom Out",fullSize:"Full Size",fitScreen:"Fit screen",close:"Close",image:"Image",of:"of"},p,T,Q,s,L,b,k,x,l,aj,d,B,w,ai,af="hidden",am="visible",y="block",U="none",z="opacity",I="left",S="top",i="width",P="height",an="px",A="div",Y=window,R=document,f;var r={setLangVars:function(G){t(al,G)},init:function(at){if(at){t(J,at)}J.fullSize=J.fullSize?1:0;if(/MSIE ([^;]+)/.test(navigator.userAgent)){p=parseFloat(RegExp["$1"])}f=[];var av=R.getElementsByTagName("a"),au=new RegExp("^"+J.alias+"\\[([a-zA-Z]+)\\]|"+J.alias+"$"),ar;for(var aq=0,ap=av.length;aq<ap;aq++){if(av[aq].rel&&(ar=av[aq].rel.match(au))){m(av[aq],"click",r.showImage);if(ar=ar[1]){av[aq].__gallery__=ar;if(!f[ar]){f[ar]=[]}av[aq].__index__=f[ar].push(av[aq])-1}}}var G=R.getElementsByTagName("body")[0];G.appendChild(ai=ao(A,{id:"LG_overlay",events:{click:r.close}}));G.appendChild(T=D());innerCont=T.lastChild;m((G.attachEvent)?G:Y,"keypress",v);(x=ao("img")).onload=function(){e();l.setAttribute("src",x.src);q(J.fullSize,true);o()};g=T.offsetHeight;c=p?200:T.offsetWidth;h=0;ab(ai,{background:(J.overlayColor),display:U});aa(ai,J.overlayOpacity)},open:function(){if(d){return}n();l.style.display=y;q();ab(T,{visibility:am,display:y});d=1},close:function(){M();ab(T,{visibility:af,display:U});d=0;x.src=l.src=""},zoomIn:function(){r.Zoom(1+J.zoomStep)},zoomOut:function(){r.Zoom(1-J.zoomStep)},zoomNormal:function(){if(this.$disabled){return}r.Zoom(l.width==x.width&&l.height==x.height?0:1)},Zoom:function(G){ah();q(G)},showImage:function(ap){var G=this.__index__;N(ap||Y.event);if(this.__gallery__&&G>-1){aj=this.__gallery__;r.show(G)}else{r.showSingle(this)}},showSingle:function(G){r.open();ah();E();x.src=G.href;Q.innerHTML=G.title;b.innerHTML="";s.style.visibility=L.style.visibility=af},show:function(ap){if(ap<0||ap>f[aj].length-1||(J.animate&&ad)){return}r.open();var G=f[aj],aq=L.style,ar=s.style;ah();E();ad=1;x.src=G[ap].href;Q.innerHTML=G[ap].title;b.innerHTML=al.image+" "+(ap+1)+" "+al.of+" "+G.length;B=ap;ac()?aq.visibility=am:aq.visibility=af;u()?ar.visibility=am:ar.visibility=af;Y.focus()},next:function(){r.show(B+1)},prev:function(){r.show(B-1)}};function ac(){return(B<(f[aj].length-1))?true:false}function u(){return(B)?true:false}function o(){var G=f[aj];if(!G){return}if(G[B+1]){(new Image).src=G[B+1].href}if(G[B-1]){(new Image).src=G[B-1].href}}function n(ap){if(J.showOverlay){var G=C();ab(ai,{width:G[0]+"px",height:G[1]+"px"});if(ai.style.display!=y){ab(ai,{display:y});F(ai,{end:J.overlayOpacity*100,onend:ap})}}else{if(typeof ap=="function"){ap.call(this)}}}function M(){ae(ai,{start:J.overlayOpacity*100,onEnd:function(){ai.style.display=U}})}function q(aH,aB){var au,aL,az,aJ,aE=J.minPadding*2,aD=J.framesNumber,aI=x.width,aK=x.height,aF=C(),aq=aF[2],av=aF[3],aw=aq-aE-h,aM=av-aE-g;if(aH==0||(aB&&!aH)){if(aI>aw||aK>aM){var aA=aw,aG=aw*aK/aI;if(aG>aM){aG=aM;aA=aM*aI/aK}az=(l.width=aA)+h;aJ=(l.height=aG)+g}else{az=(l.width=aI)+h;aJ=(l.height=aK)+g}}else{if(aH==1){az=(l.width=aI)+h;aJ=(l.height=aK)+g}else{if(aH<1||aH>1){az=(l.width*=aH)+h;aJ=(l.height*=aH)+g}else{az=aJ=300;var ap=true}}}if(au=(az>(aw+h)||aJ>(aM+g))){aL=al.fitScreen;fsClass="LG_fitScreen"}else{if(l.width!=aI||l.height!=aK){aL=al.fullSize;fsClass="LG_zoomNormal"}}k.$disabled=false;if(l.width==aI){if(au){k.id=fsClass;k.setAttribute("title",aL)}else{k.id="LG_zoom_disabled";k.$disabled=true}}else{k.id="LG_zoomNormal";k.setAttribute("title",al.fullSize)}az=Math.max(az,c);var aN=W(),ax=(av>aJ?(av-aJ)/2:J.minPadding)+aN[1],ay=(aq>az?(aq-az)/2:J.minPadding)+aN[0],aC=(az/3)+"px",G=(aJ-g-10)+"px";ab(L,{width:aC,height:G});ab(s,{width:aC,height:G});if(J.animate&&!ap){var at=new K(T,aD,J.speed);if(J.resizeSync){at.addThread(i,0,az,0,aD).addThread(I,0,ay,0,aD).addThread(P,0,aJ,0,aD).addThread(S,0,ax,0,aD)}else{var aO=Math.ceil(aD/2);at.addThread(i,0,az,0,aO).addThread(I,0,ay,0,aO).addThread(P,0,aJ,aO,aD).addThread(S,0,ax,aO,aD)}at.onEnd=function(){n();O()};at.run()}else{ab(T,{top:ax+an,left:ay+an,width:az+an,height:aJ+an});n();O()}}function O(){innerCont.style.display=y;if(J.fadeImage){F(l,{frames:8,speed:J.speed,onEnd:function(){ad=0}})}else{aa(l,100);ad=0}}function ah(){innerCont.style.display=U}function E(){w.style.display=y}function e(){w.style.display=U}function D(){var ap,G;if(J.enableZoom){ap=ao(A,{id:"LG_zoomIn",title:al.zoomIn,events:{click:r.zoomIn}});G=ao(A,{id:"LG_zoomOut",title:al.zoomOut,events:{click:r.zoomOut}})}return ao(A,{id:"LG_container"},w=ao(A,{id:"LG_loading"}),ao(A,{id:"LG_innerCont"},ao(A,{id:"LG_panel"},ap,G,k=ao(A,{id:"LG_zoomNormal",title:al.fullSize,events:{click:r.zoomNormal}}),b=ao(A,{id:"LG_imgIndex"},al.image+" 20 "+al.of+" 20 "),ao(A,{id:"LG_closeBtn",title:al.close,events:{click:r.close}}),ao(A,{style:"clear:both"})),l=ao("img",{id:"LG_pic",width:300,height:300}),Q=ao(A,{id:"LG_titleBar"}),s=ao(A,{id:"LG_prevLink",title:al.prev,events:{click:r.prev,mouseover:Z,mouseout:ag}}),L=ao(A,{id:"LG_nextLink",title:al.next,events:{click:r.next,mouseover:Z,mouseout:ag}})))}function v(ap){if(!d){return}var ap=ap||Y.event,G=ap.keyCode?ap.keyCode:(ap.which?ap.which:ap.charCode);switch(G){case 110:r.next();break;case 98:r.prev();break;case 102:r.zoomNormal();break;case 43:r.zoomIn();break;case 45:r.zoomOut();break;case 27:r.close();default:return}N(ap)}function Z(){F(this)}function ag(){ae(this)}function F(ap,G){G=G||{};G.start=G.start||0;G.end=G.end||100;ak(ap,G)}function ae(ap,G){G=G||{};G.start=G.start||100;G.end=G.end||0;ak(ap,G)}function ak(aq,ap){if(J.animate){var G=new K(aq,ap.frames||5,ap.speed||40);G.addThread(z,ap.start,ap.end);G.onStart=ap.onStart;G.onEnd=ap.onEnd;G.run()}else{aa(aq,ap.end);if(typeof ap.onEnd=="function"){ap.onEnd()}}}function N(G){if(G.preventDefault){G.preventDefault()}else{G.returnValue=false}}function m(aq,ap,G){if(Y.addEventListener){m=function(au,at,ar){au.addEventListener(at,ar,false)}}else{if(Y.attachEvent){m=function(au,at,ar){var av=function(){ar.call(au,Y.event)};au.attachEvent("on"+at,av)}}}return m(aq,ap,G)}function t(aq,ap){for(var G in ap){aq[G]=ap[G]}}function ab(ap,G){if(ap){t(ap.style,G)}}function C(){var ar,ap,aq,au,G=R.body,at=R.documentElement;if(Y.innerHeight&&Y.scrollMaxY){ar=G.scrollWidth;ap=Y.innerHeight+Y.scrollMaxY}else{if(G.scrollHeight>G.offsetHeight){ar=G.scrollWidth;ap=G.scrollHeight}else{if(at&&at.scrollHeight>at.offsetHeight){ar=at.scrollWidth;ap=at.scrollHeight}else{ar=G.offsetWidth;ap=G.offsetHeight}}}if(Y.innerHeight){aq=G.clientWidth;au=Y.innerHeight}else{if(at&&at.clientHeight){aq=at.clientWidth;au=at.clientHeight}else{if(G){aq=G.clientWidth;au=G.clientHeight}}}return[ar<aq?aq:ar,ap<au?au:ap,aq,au]}function W(){var aq=0,ap=0,G=R.body,ar=R.documentElement;if(typeof(Y.pageYOffset)=="number"){ap=Y.pageYOffset;aq=Y.pageXOffset}else{if(G&&(G.scrollLeft||G.scrollTop)){ap=G.scrollTop;aq=G.scrollLeft}else{if(ar&&(ar.scrollLeft||ar.scrollTop)){ap=ar.scrollTop;aq=ar.scrollLeft}}}return[aq,ap]}function X(aq,G){var ar=R.defaultView;if(aq.style[G]){return aq.style[G]}else{if(aq.currentStyle){return aq.currentStyle[G]}else{if(ar&&ar.getComputedStyle){G=G.replace(/([A-Z])/g,"-$1");var ap=ar.getComputedStyle(aq,"");return ap&&ap.getPropertyValue(G.toLowerCase())}}}return null}function aa(){aa=arguments[0].filters?function(G,ap){G.style.filter="alpha(opacity="+ap+")"}:function(G,ap){G.style.opacity=ap/100};aa(arguments[0],arguments[1])}function ao(aq,ap){var av=R.createElement(aq);if(ap){for(var at in ap){if(at=="events"){for(var ar in ap[at]){m(av,ar,ap[at][ar])}}else{var aw=ap[at];if(typeof aw!="undefined"){if(at=="class"){av.className=aw}else{av.setAttribute(at,aw)}}}}}for(var au=2,G=arguments.length;au<G;au++){switch(typeof arguments[au]){case"string":av.innerHTML+=arguments[au];break;case"object":av.appendChild(arguments[au])}}return av}function j(){if(!H){if(!R.body){return setTimeout(j,13)}H=true;r.init()}}function V(){if(a){return}a=true;if(R.readyState==="complete"){return j()}if(R.addEventListener){R.addEventListener("DOMContentLoaded",function ap(){R.removeEventListener("DOMContentLoaded",ap,false);j()},false)}else{if(R.attachEvent){R.attachEvent("onreadystatechange",function at(){if(document.readyState==="complete"){R.detachEvent("onreadystatechange",at);j()}});var aq=false;try{aq=Y.frameElement==null}catch(ar){}if(R.documentElement.doScroll&&aq){function G(){if(H){return}try{R.documentElement.doScroll("left")}catch(au){setTimeout(G,1);return}j()}G()}}}}function K(aq,ap,G){if(!aq){return null}this.E=aq;this.N=ap||0;this.F=[];this.S=G||10}K.prototype={addThread:function(at,aq,G,ar,ap){if(!at||G===undefined||G===null){return}if(at!=z){aq=parseFloat(X(this.E,at))}ar=ar||0;ap=ap||this.N;var aw=this.F,av=(ap-ar)||1,au=(aq-G)/av;for(;ar<ap;ar++){if(!aw[ar]){aw[ar]={}}aw[ar][at]=(aq-=au)}return this},P:function(){var ar=this.F.shift(),ap=[],aq=p;if(ar){for(var G in ar){ap.push(G=="opacity"?(aq?"filter: alpha(opacity="+ar[G]+")":"opacity: "+ar[G]/100):G+": "+ar[G]+"px")}this.E.style.cssText+="; "+ap.join("; ")}else{if(typeof this.onEnd=="function"){this.onEnd()}clearInterval(this.I)}},run:function(){clearInterval(this.I);this.P();if(typeof this.onStart=="function"){this.onStart()}var G=this;if(this.N>1){this.I=setInterval(function(){G.P()},this.S)}}};return r})();

/* *********************************
        ON LOAD
********************************* */
/* --========================--*/
function checkEmail(e)
{
 ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

 for(i=0; i < e.length ;i++)
  if(ok.indexOf(e.charAt(i))<0)
   return (false);

 if (document.images)
 {
  re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
  re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
  if (!e.match(re) && e.match(re_two))
   return true;
  else
   return false;

 }
 return true;

}

function checkPhone(e)
{
	if(e.match(/^\+?[0-9\- ]{5,}$/))
		return true
	else
   		return false;
}

function elementSupportsAttribute(element,attribute) {
	var test = document.createElement(element);
	if (attribute in test) {
		return true;
	} else {
		return false;
	}
}

/*
CUSTOM FORM ELEMENTS
*/

var checkboxHeight = "25";
var radioHeight = "25";


/* No need to change anything after this */

document.write('<style type="text/css">input.styled { display: none; } select.styled { position: relative; opacity: 0; filter: alpha(opacity=0); z-index: 5; }</style>');

var Custom = {
	init: function() {
		var inputs = document.getElementsByTagName("input"), span = Array(), textnode, option, active;
		for(a = 0; a < inputs.length; a++) {
			if((inputs[a].type == "checkbox" || inputs[a].type == "radio") && inputs[a].className == "styled") {
				span[a] = document.createElement("span");
				span[a].className = inputs[a].type;
				if(inputs[a].checked == true) {
					if(inputs[a].type == "checkbox") {
						position = "0 -" + (checkboxHeight*2) + "px";
						span[a].style.backgroundPosition = position;
					} else {
						position = "0 -" + (radioHeight*2) + "px";
						span[a].style.backgroundPosition = position;
					}
				}
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				inputs[a].onchange = Custom.clear;
				span[a].onmousedown = Custom.pushed;
				span[a].onmouseup = Custom.check;
				document.onmouseup = Custom.clear;
			}
		}
		inputs = document.getElementsByTagName("select");
		for(a = 0; a < inputs.length; a++) {

			if($(inputs[a]).hasClass("styled")) {
				
				option = inputs[a].getElementsByTagName("option");
				active = option[0].childNodes[0].nodeValue;
				textnode = document.createTextNode(active);
				for(b = 0; b < option.length; b++) {
					if(option[b].selected == true) {
						textnode = document.createTextNode(option[b].childNodes[0].nodeValue);
					}
				}
				span[a] = document.createElement("span");
				span[a].className = "select";
				span[a].id = "select" + inputs[a].name;
				span[a].appendChild(textnode);
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				inputs[a].onchange = Custom.choose;
			}
		}
	},
	pushed: function() {
		element = this.nextSibling;
		if(element.checked == true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 -" + checkboxHeight*3 + "px";
		} else if(element.checked == true && element.type == "radio") {
			this.style.backgroundPosition = "0 -" + radioHeight*3 + "px";
		} else if(element.checked != true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 -" + checkboxHeight + "px";
		} else {
			this.style.backgroundPosition = "0 -" + radioHeight + "px";
		}
	},
	check: function() {
		element = this.nextSibling;
		if(element.checked == true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 0";
			element.checked = false;
		} else {
			if(element.type == "checkbox") {
				this.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";
			} else {
				this.style.backgroundPosition = "0 -" + radioHeight*2 + "px";
				group = this.nextSibling.name;
				inputs = document.getElementsByTagName("input");
				for(a = 0; a < inputs.length; a++) {
					if(inputs[a].name == group && inputs[a] != this.nextSibling) {
						inputs[a].previousSibling.style.backgroundPosition = "0 0";
					}
				}
			}
			element.checked = true;
		}
	},
	clear: function() {
		inputs = document.getElementsByTagName("input");
		for(var b = 0; b < inputs.length; b++) {
			if(inputs[b].type == "checkbox" && inputs[b].checked == true && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";
			} else if(inputs[b].type == "checkbox" && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 0";
			} else if(inputs[b].type == "radio" && inputs[b].checked == true && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 -" + radioHeight*2 + "px";
			} else if(inputs[b].type == "radio" && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 0";
			}
		}
	},
	choose: function() {
		option = this.getElementsByTagName("option");
		for(d = 0; d < option.length; d++) {
			if(option[d].selected == true) {
				document.getElementById("select" + this.name).childNodes[0].nodeValue = option[d].childNodes[0].nodeValue;
			}
		}

		if (this.getAttribute('onchange1'))
		{
			eval(this.getAttribute('onchange1'))
		}
	}
}


/**
 * 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/10/16
 *
 * @author Blair Mitchelmore
 * @version 1.2
 *
 **/

jQuery.fn.extend({
	everyTime: function(interval, label, fn, times) {
		return this.each(function() {
			jQuery.timer.add(this, interval, label, fn, times);
		});
	},
	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.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) {
			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 (typeof times != 'number' || isNaN(times) || times < 0)
				times = 0;

			times = times || 0;

			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 ((++counter > times && times !== 0) || fn.call(element, counter) === false)
					jQuery.timer.remove(element, label, fn);
			};

			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);
	});
});

/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
*/

// 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;
	}
});

/*
**
**	GalleryView - jQuery Content Gallery Plugin
**	Author: 		Jack Anderson
**	Version:		3.0b3 (March 15, 2011)
**
**	Please use this development script if you intend to make changes to the
**	plugin code.  For production sites, it is recommended you use jquery.galleryview-3.0.min.js.
**
**  See README.txt for instructions on how to markup your HTML
**
**	See CHANGELOG.txt for a review of changes and LICENSE.txt for the applicable
**	licensing information.
**
*/

//Global variable to check if window is already loaded
//Used for calling GalleryView after page has loaded
var window_loaded = false;
$(window).load(function(){
	window_loaded = true;
});
(function($){
	$.fn.galleryView = function(options) {
		var opts = $.extend($.fn.galleryView.defaults,options);

		var id;
		var iterator = 0;			// INT - Currently visible panel/frame
		var item_count = 0;			// INT - Total number of panels/frames
		var slide_method;			// STRING - indicator to slide entire filmstrip or just the pointer ('strip','pointer')
		var paused = false;			// BOOLEAN - flag to indicate whether automated transitions are active
		var pointer_speed = 0;		// INT - Speed (in milliseconds) of pointer animation
		var animate_panels = true;	// BOOLEAN - flag to indicate whether panels will animate during transitions
		var current = 1;			// INT - index of current panel/frame
		var gallery_images;			// OBJECT - container for images within UL passed to plugin
		var image_count = 0;		// INT - number of images within gallery
		var loaded_images = 0;		// INT - number of gallery images that have been loaded in the browser

	// Element dimensions
		var gallery_width;
		var gallery_height;
		var pointer_height;
		var pointer_width;
		var strip_width;
		var strip_height;
		var wrapper_width;
		var wrapper_height;
		var f_frame_width;
		var f_frame_height;
		var filmstrip_orientation;


	// Arrays used to scale frames and panels
		var frame_img_scale = {};
		var panel_img_scale = {};
		var img_h = {};
		var img_w = {};

	// Flag indicating whether to scale panel images
		var scale_panel_images = true;

		var panel_nav_displayed = false;

	// Define jQuery objects for reuse
		var j_gallery;
		var j_filmstrip;
		var j_frames;
		var j_frame_img_wrappers;
		var j_panels;
		var j_pointer;
		var j_panel_wrapper;


/*
**	Plugin Functions
*/

	/*
	**	showItem(int,boolean,function)
	**		Transition from current frame to frame i (1-based index)
	**		skip_animation flag let's us override transition speed to show an item instantly
	**		(useful when loading gallery for the first time)
	**		If provided, run callback function after transition completes
	*/
		function showItem(i,speed,callback) {
			// A scrolling filmstrip will contain three copies of each frame, we want to know the relative position of the target frame
			var mod_i = i%item_count;
			var distance;
			var diststr;

			// Disable next/prev buttons until transition is complete
			// This prevents overlapping of animations
			$('.gv-nav-next, .gv-panel-nav-next, .gv-nav-prev, .gv-panel-nav-prev',j_gallery).unbind('click');
			j_frames.unbind('click');

			// Use timer to rebind navigation buttons when transition ends
			$(document).oneTime(speed,'bindNavButtons',function(){
				$('.gv-nav-next, .gv-panel-nav-next',j_gallery).click(showNextItem);
				$('.gv-nav-prev, .gv-panel-nav-prev',j_gallery).click(showPrevItem);
				enableFrameClicking();
			});

			if(opts.show_filmstrip) {

				// Fade out all frames
				j_frames.removeClass('current').find('img').stop().animate({opacity:opts.frame_opacity},speed);

				// Fade in target frame
				j_frames.eq(i).addClass('current').find('img').stop().animate({opacity:1},speed);
			}

			//If necessary, transition between panels
			if(opts.show_panels) {
				if(animate_panels) {
					if(opts.panel_animation=='slide') {

						// Move target frame just to the right of the current frame
						j_panels.eq(mod_i).css({
							left: getInt($('.gv-panel.current').eq(0).css('left'))+opts.panel_width+'px',
							zIndex: 50
						}).show().animate({
							left: '-='+opts.panel_width+'px'
						},speed,opts.easing,function(){
							$(this).addClass('current');
						});

						// Slide current frame and target frame to the left
						$('.gv-panel.current').css({zIndex:49}).animate({
							left: '-='+opts.panel_width+'px'
						},speed,opts.easing,function(){
							$(this).removeClass('current').hide();
						});
					} else if(opts.panel_animation=='zoomOut') {

						// After zoom is complete, add 'current' class to now visible panel and move it to top of stack via z-index
						$(document).oneTime(speed,'setCurrentFrame',function(){
							j_panels.eq(mod_i).addClass('current').css('zIndex',50);
						});

						// Show target panel and place below current frame via z-index
						j_panels.eq(mod_i).show().css('zIndex',49);

						// Shrink panel container to center while moving image in opposite direction
						// End result is an image that remains static while borders of container shrink
						$('.gv-panel.current img').animate({
							top: '-='+opts.panel_height/2+'px',
							left:'-='+opts.panel_width/2+'px'
						},speed,'swing',function(){

							// After zoom is complete, immediately animate it back to its original position for next time
							$(this).animate({
								top: '+='+opts.panel_height/2+'px',
								left: '+='+opts.panel_width/2+'px'
							},0);
						});

						$('.gv-panel.current').animate({
							top:'+='+opts.panel_height/2+'px',
							left:'+='+opts.panel_width/2+'px',
							height:0,
							width:0
						},speed,'swing',function(){
							$(this).removeClass('current').hide().css({
								top:getPos(j_panels[mod_i]).top+'px',
								left:getPos(j_panels[mod_i]).left+'px',
								height:opts.panel_height+'px',
								width:opts.panel_width+'px'
							});
						});
					} else if(opts.panel_animation == 'crossfade') {

						// Default behavior is to fade panel into view
						j_panels.removeClass('current').fadeOut(speed,function(){$(this).css('filter','');}).eq(mod_i).addClass('current').fadeIn(speed,function(){$(this).css('filter','');});
					} else {

						// Fade out panels, and then fade in target panel
						// Use timer due to inconsistency in fadeIn/fadeOut callback reliability
						j_panels.removeClass('current').stop().fadeOut(speed/2);
						$(document).oneTime(speed/2,'fadeInPanel',function(){
							j_panels.eq(mod_i).addClass('current').stop().fadeIn(speed/2);
						});
					}
				} else {

					// If no animation style is chosen, simply show the new panel instantly
					$(document).oneTime(speed,'switch_panels',function(){j_panels.hide().eq(mod_i).show();});
				}
			}

			// If gallery has a filmstrip, handle animation of frames
			if(opts.show_filmstrip) {

				// Slide either pointer or filmstrip, depending on transition method
				if(opts.filmstrip_style == 'scroll' && slide_method=='strip') {

					// Stop filmstrip if it's currently in motion
					j_filmstrip.stop();

					if(filmstrip_orientation=='horizontal') {

						// Determine distance between pointer (eventual destination) and target frame
						distance = getPos(j_frames[i]).left - (getPos(j_pointer[0]).left+(pointer_width/2)-(f_frame_width/2));
						diststr = (distance>=0?'-=':'+=')+Math.abs(distance)+'px';

						// Animate filmstrip and slide target frame under pointer
						j_filmstrip.animate({left:diststr},speed,opts.easing,function(){
							var old_i = i;

							// After transition is complete, shift filmstrip so that a sufficient number of frames
							// remain on either side of the visible filmstrip
							if(i>item_count) {
								i = mod_i;
								iterator = i;
								j_filmstrip.css('left','-'+((f_frame_width+opts.frame_gap)*i)+'px');
							} else if (i<=(item_count-strip_size)) {
								i = (mod_i)+item_count;
								iterator = i;
								j_filmstrip.css('left','-'+((f_frame_width+opts.frame_gap)*i)+'px');
							}

							// If the target frame has changed due to filmstrip shifting,
							// make sure new target frame has 'current' class and correct size/opacity settings
							if(old_i != i) {
								j_frames.eq(old_i).removeClass('current').find('img').css({opacity:opts.frame_opacity});
								j_frames.eq(i).addClass('current').find('img').css({opacity:1});
							}
						});
					} else {

						//Determine distance between pointer (eventual destination) and target frame
						distance = getPos(j_frames[i]).top-getPos($('.gv-strip_wrapper',j_gallery)[0]).top;
						diststr = (distance>=0?'-=':'+=')+Math.abs(distance)+'px';

						// Animate filmstrip and slide target frame under pointer
						j_filmstrip.animate({
							'top':diststr
						},speed,opts.easing,function(){

							// After transition is complete, shift filmstrip so that a sufficient number of frames
							// remain on either side of the visible filmstrip
							var old_i = i;
							if(i>item_count) {
								i = mod_i;
								iterator = i;
								j_filmstrip.css('top','-'+((f_frame_height+opts.frame_gap)*i)+'px');
							} else if (i<=(item_count-strip_size)) {
								i = (mod_i)+item_count;
								iterator = i;
								j_filmstrip.css('top','-'+((f_frame_height+opts.frame_gap)*i)+'px');
							}

							//If the target frame has changed due to filmstrip shifting,
							//Make sure new target frame has 'current' class and correct size/opacity settings
							if(old_i != i) {
								j_frames.eq(old_i).removeClass('current').find('img').css({opacity:opts.frame_opacity});
								j_frames.eq(i).addClass('current').find('img').css({opacity:1});
							}

							// If panels are not set to fade in/out, simply hide all panels and show the target panel
							if(!animate_panels) {
								j_panels.hide().eq(mod_i).show();
							}
						});
					}
				} else if(slide_method=='pointer') {

					// Stop pointer if it's currently in motion
					j_pointer.stop();

					// Get screen position of target frame
					var pos = getPos(j_frames[i]);

					if(filmstrip_orientation=='horizontal') {

						// Slide the pointer over the target frame
						j_pointer.animate({
							left:pos.left+(f_frame_width/2)-(pointer_width/2)+'px'
						},pointer_speed,opts.easing,function(){
							if(!animate_panels) {j_panels.hide().eq(mod_i).show();}
						});
					} else {

						// Slide the pointer over the target frame
						j_pointer.animate({
							top:pos.top+(f_frame_height/2)-(pointer_height)+'px'
						},pointer_speed,opts.easing,function(){
							if(!animate_panels) {j_panels.hide().eq(mod_i).show();}
						});
					}
				}
			}
			if(callback) {$(document).oneTime(speed,'showItemCallback',callback);}
			current = i;
		};

	/*
	**	extraWidth(jQuery element)
	**		Return the combined width of the border and padding to the elements left and right.
	**		If the border is non-numerical, assume zero (not ideal, will fix later)
	**		RETURNS - int
	*/
		function extraWidth(el) {
			if(!el) { return 0; }
			if(el.length==0) { return 0; }
			el = el.eq(0);
			var ew = 0;
			ew += getInt(el.css('paddingLeft'));
			ew += getInt(el.css('paddingRight'));
			ew += getInt(el.css('borderLeftWidth'));
			ew += getInt(el.css('borderRightWidth'));
			return ew;
		};

	/*
	**	extraHeight(jQuery element)
	**		Return the combined height of the border and padding above and below the element
	**		If the border is non-numerical, assume zero (not ideal, will fix later)
	**		RETURN - int
	*/
		function extraHeight(el) {
			if(!el) { return 0; }
			if(el.length==0) { return 0; }
			el = el.eq(0);
			var eh = 0;
			eh += getInt(el.css('paddingTop'));
			eh += getInt(el.css('paddingBottom'));
			eh += getInt(el.css('borderTopWidth'));
			eh += getInt(el.css('borderBottomWidth'));
			return eh;
		};

	/*
	**	showNextItem()
	**		Transition from current frame to next frame
	*/
		function showNextItem() {

			// Cancel any transition timers until we have completed this function
			$(document).stopTime("transition");
			if(++iterator==j_frames.length) {iterator=0;}

			// We've already written the code to transition to an arbitrary panel/frame, so use it
			showItem(iterator,opts.transition_speed);

			// If automated transitions haven't been cancelled by an option or paused on hover, re-enable them
			if(!paused && opts.transition_interval > 0) {
				$(document).everyTime(opts.transition_interval,"transition",function(){showNextItem();});
			}
		};

	/*
	**	showPrevItem()
	**		Transition from current frame to previous frame
	*/
		function showPrevItem() {

			// Cancel any transition timers until we have completed this function
			$(document).stopTime("transition");
			if(--iterator<0) {iterator = item_count-1;}

			// We've already written the code to transition to an arbitrary panel/frame, so use it
			showItem(iterator,opts.transition_speed);

			// If automated transitions haven't been cancelled by an option or paused on hover, re-enable them
			if(!paused && opts.transition_interval > 0) {
				$(document).everyTime(opts.transition_interval,"transition",function(){showNextItem();});
			}
		};

	/*
	**	getPos(jQuery element)
	**		Calculate position of an element relative to top/left corner of gallery
	**		If the gallery bounding box itself is passed to the function, calculate position of gallery relative to top/left corner of browser window
	** 		RETURNS - JSON {left: int, top: int}
	*/
		function getPos(el) {
			if(!el) return {top:0,left:0};
			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};
			}
		};

	/*
	**	enableFrameClicking()
	**		Add an onclick event handler to each frame
	**		Exception: if a frame has an anchor tag, do not add an onlick handler
	*/
		function enableFrameClicking() {
			j_frames.each(function(i){
				if($('a',this).length==0) {
					$(this).click(function(){

						// Prevent transitioning to the current frame (unnecessary)
						if(iterator!=i) {
							$(document).stopTime("transition");
							showItem(i,opts.transition_speed);
							iterator = i;
							if(!paused && opts.transition_interval > 0) {
								$(document).everyTime(opts.transition_interval,"transition",function(){showNextItem();});
							}
						}
					});
				}
			});
		};

	/*
	**	buildPanels()
	**		Construct gallery panels: <div class="gv-panel"> elements
	**		NOTE - These DIVs are generated automatically from the content of the UL passed to the plugin
	*/
		function buildPanels() {

			// If panel overlay content exists, add the necessary overlay background DIV
			// The overlay content and background are separate elements so the background's opacity isn't inherited by the content
			j_panels.each(function(i){
		   		if($('.gv-panel-overlay',this).length>0) {
					$(this).append('<div class="gv-overlay-background"></div>');
				}
		   	});

			// If there is no filmstrip in this gallery, add navigation buttons to the panel itself
			if(opts.show_panel_nav) {
				$('<div></div>').addClass('gv-panel-nav-next').appendTo(j_gallery).css({
					position:'absolute',
					zIndex:'1100',
					top:((opts.filmstrip_position=='top'?opts.frame_gap+wrapper_height:0)+(opts.panel_height-22)/2)+'px',
					right:((opts.filmstrip_position=='right'?opts.frame_gap+wrapper_width:0)+10)+'px',
					display:'none'
				}).click(showNextItem);
				$('<div></div>').addClass('gv-panel-nav-prev').appendTo(j_gallery).css({
					position:'absolute',
					zIndex:'1100',
					top:((opts.filmstrip_position=='top'?opts.frame_gap+wrapper_height:0)+(opts.panel_height-22)/2)+'px',
					left:((opts.filmstrip_position=='left'?opts.frame_gap+wrapper_width:0)+10)+'px',
					display:'none'
				}).click(showPrevItem);
			}

			//Set size and position of panel container
			j_panel_wrapper.css({
				width:opts.panel_width+'px',
				height:opts.panel_height+'px',
				position:'absolute',
				overflow:'hidden'
			});

			if(opts.show_filmstrip) {
				switch(opts.filmstrip_position) {
					case 'top': j_panel_wrapper.css({top:wrapper_height+opts.frame_gap+'px'}); break;
					case 'left': j_panel_wrapper.css({left:wrapper_width+opts.frame_gap+'px'}); break;
					default: break;
				}
			}

			// Set the height and width of each panel, and position it appropriately within the gallery
			j_panels.each(function(i){
				$(this).css({
					width:(opts.panel_width-extraWidth(j_panels))+'px',
					height:(opts.panel_height-extraHeight(j_panels))+'px',
					position:'absolute',
					top:0,
					left:0,
					display:'none'
				});
			});

			// Position each panel overlay within panel
			$('.gv-panel-overlay',j_panels).css({
				position:'absolute',
				zIndex:'999',
				width:(opts.panel_width-extraWidth($('.gv-panel-overlay',j_panels)))+'px',
				left:0
			});
			$('.gv-overlay-background',j_panels).css({
				position:'absolute',
				zIndex:'998',
				width:opts.panel_width+'px',
				left:0,
				opacity:opts.overlay_opacity
			});
			if(opts.overlay_position=='top') {
				$('.gv-panel-overlay',j_panels).css('top',0);
				$('.gv-overlay-background',j_panels).css('top',0);
			} else {
				$('.gv-panel-overlay',j_panels).css('bottom',0);
				$('.gv-overlay-background',j_panels).css('bottom',0);
			}

			$('.gv-panel iframe',j_panels).css({
				width:opts.panel_width+'px',
				height:opts.panel_height+'px',
				border:0
			});

			// If panel images have to be scaled to fit within frame, do so and position them accordingly
			if(scale_panel_images) {
				$('img',j_panels).each(function(i){
					$(this).css({
						height:panel_img_scale[i%item_count]*img_h[i%item_count],
						width:panel_img_scale[i%item_count]*img_w[i%item_count],
						position:'relative',
						top:(opts.panel_height-(panel_img_scale[i%item_count]*img_h[i%item_count]))/2+'px',
						left:(opts.panel_width-(panel_img_scale[i%item_count]*img_w[i%item_count]))/2+'px'
					});
				});
			}
		};

	/*
	**	buildFilmstrip()
	**		Construct filmstrip from <ul class="gv-filmstrip"> element
	**		NOTE - 'filmstrip' class is automatically added to UL passed to plugin
	*/
		function buildFilmstrip() {

			// Add wrapper to filmstrip to hide extra frames
			j_filmstrip.wrap('<div class="gv-strip_wrapper"></div>');
			if(opts.filmstrip_style == 'scroll' && 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 DIV to each frame and fill with the image titles
			if(opts.show_captions) {
				j_frames.append('<div class="gv-caption"></div>').each(function(i){
					$(this).find('.gv-caption').html($(this).find('img').attr('title'));
				});
			}

			// Position the filmstrip within the gallery
			j_filmstrip.css({
				listStyle:'none',
				margin:0,
				padding:0,
				width:strip_width+'px',
				position:'absolute',
				zIndex:'900',
				top:(filmstrip_orientation=='vertical' && opts.filmstrip_style == 'scroll' && slide_method=='strip'?-((f_frame_height+opts.frame_gap)*iterator):0)+'px',
				left:(filmstrip_orientation=='horizontal' && opts.filmstrip_style == 'scroll' && slide_method=='strip'?-((f_frame_width+opts.frame_gap)*iterator):0)+'px',
				height:strip_height+'px'
			});

			j_frames.css({
				float:'left',
				position:'relative',
				height:f_frame_height+(opts.show_captions?f_caption_height:0)+'px',
				width:f_frame_width+'px',
				zIndex:'901',
				padding:0,
				marginBottom:opts.frame_gap+'px',
				marginRight:opts.frame_gap+'px'
			});

			// Apply styling to individual image wrappers. These will eventually hide overflow in the case of cropped filmstrip images
			$('.gv-img_wrap',j_frames).each(function(i){
				$(this).css({
					height:Math.min(opts.frame_height,img_h[i%item_count]*frame_img_scale[i%item_count])+'px',
					width:Math.min(opts.frame_width,img_w[i%item_count]*frame_img_scale[i%item_count])+'px',
					position:'relative',
					top:(opts.show_captions && opts.filmstrip_position=='top'?f_caption_height:0)+Math.max(0,(opts.frame_height-(frame_img_scale[i%item_count]*img_h[i%item_count]))/2)+'px',
					left:Math.max(0,(opts.frame_width-(frame_img_scale[i%item_count]*img_w[i%item_count]))/2)+'px',
					overflow:'hidden'
				});
			});

			// Scale each filmstrip image if necessary and position it within the image wrapper
			$('img',j_frames).each(function(i){
				$(this).css({
					opacity:opts.frame_opacity,
					height:img_h[i%item_count]*frame_img_scale[i%item_count]+'px',
					width:img_w[i%item_count]*frame_img_scale[i%item_count]+'px',
					position:'relative',
					top:Math.min(0,(opts.frame_height-(frame_img_scale[i%item_count]*img_h[i%item_count]))/2)+'px',
					left:Math.min(0,(opts.frame_width-(frame_img_scale[i%item_count]*img_w[i%item_count]))/2)+'px'
				}).mouseover(function(){
					$(this).stop().animate({opacity:1},300);
				}).mouseout(function(){
					//Don't fade out current frame on mouseout
					if(!$(this).parent().parent().hasClass('current')){$(this).stop().animate({opacity:opts.frame_opacity},300);}
				});
			});

			// Set overflow of filmstrip wrapper to hidden so as to hide frames that don't fit within the gallery
			$('.gv-strip_wrapper',j_gallery).css({
				position:'absolute',
				overflow:'hidden'
			});

			// Position filmstrip within gallery based on user options
			if(filmstrip_orientation=='horizontal') {
				$('.gv-strip_wrapper',j_gallery).css({
					top:opts.show_panels ? opts.filmstrip_position=='top'?0:opts.panel_height+opts.frame_gap+'px' : 0,
					left:((gallery_width-wrapper_width)/2)+'px',
					width:wrapper_width+'px',
					height:wrapper_height+'px'
				});
			} else {
				$('.gv-strip_wrapper',j_gallery).css({
					left:opts.show_panels ? opts.filmstrip_position=='left'?0:opts.panel_width+opts.frame_gap+'px' : 0,
					top:0,
					width:wrapper_width+'px',
					height:wrapper_height+'px'
				});
			}

			// Style frame captions
			$('.gv-caption',j_gallery).css({
				position:'absolute',
				top:(opts.filmstrip_position=='bottom'?f_frame_height:0)+'px',
				left:0,
				margin:0,
				width:f_caption_width+'px',
				overflow:'hidden'
			});

			// Create pointer for current frame
			var pointer = $('<div></div>');
			pointer.addClass('gv-pointer').appendTo(j_gallery).css({
				 position:'absolute',
				 zIndex:'1000',
				 width:0,
				 fontSize:0,
				 lineHeight:0,
				 borderTopWidth:pointer_height+'px',
				 borderRightWidth:(pointer_width/2)+'px',
				 borderBottomWidth:pointer_height+'px',
				 borderLeftWidth:(pointer_width/2)+'px',
				 borderStyle:'solid'
			});

			// For IE6, use predefined color string in place of transparent (IE6 bug fix, see stylesheet)
			var transColor = $.browser.msie && $.browser.version.substr(0,1) == '6' ? 'pink' : 'transparent';

			// If there are no panels, make pointer transparent (nothing to point to)
			// This is not the optimal solution, but we need the pointer to exist as a reference for transition animations
			if(!opts.show_panels) { pointer.css('borderColor',transColor); }
			switch(opts.filmstrip_position) {
				case 'top': pointer.css({
								top:wrapper_height+'px',
								left:((gallery_width-wrapper_width)/2)+(slide_method=='strip'?0:((f_frame_width+opts.frame_gap)*iterator))+((f_frame_width/2)-(pointer_width/2))+'px',
								borderBottomColor:transColor,
								borderRightColor:transColor,
								borderLeftColor:transColor
							}); break;
				case 'bottom': pointer.css({
									bottom:wrapper_height+'px',
									left:((gallery_width-wrapper_width)/2)+(slide_method=='strip'?0:((f_frame_width+opts.frame_gap)*iterator))+((f_frame_width/2)-(pointer_width/2))+'px',
									borderTopColor:transColor,
									borderRightColor:transColor,
									borderLeftColor:transColor
								}); break;
				case 'left': pointer.css({
								left:wrapper_width+'px',
								top:(f_frame_height/2)-(pointer_height)+(slide_method=='strip'?0:((f_frame_height+opts.frame_gap)*iterator))+'px',
								borderBottomColor:transColor,
								borderRightColor:transColor,
								borderTopColor:transColor
							}); break;
				case 'right': pointer.css({
								right:wrapper_width+'px',
								top:(f_frame_height/2)-(pointer_height)+(slide_method=='strip'?0:((f_frame_height+opts.frame_gap)*iterator))+'px',
								borderBottomColor:transColor,
								borderLeftColor:transColor,
								borderTopColor:transColor
							}); break;
			}

			j_pointer = $('.gv-pointer',j_gallery);

			// Add navigation buttons
			if(opts.show_filmstrip_nav) {
				var navNext = $('<div></div>');
				navNext.addClass('gv-nav-next').appendTo(j_gallery).css({
					position:'absolute'
				}).click(showNextItem);

				var navPrev = $('<div></div>');
				navPrev.addClass('gv-nav-prev').appendTo(j_gallery).css({
					position:'absolute'
				}).click(showPrevItem);

				if(filmstrip_orientation=='horizontal') {
					navNext.css({
						top:(opts.show_panels ? (opts.filmstrip_position=='top'?0:opts.panel_height+opts.frame_gap) : 0)+((strip_height-22)/2)+'px',
						right:((gallery_width)/2)-(wrapper_width/2)-opts.frame_gap-22+'px'
					});
					navPrev.css({
						top:(opts.show_panels ? (opts.filmstrip_position=='top'?0:opts.panel_height+opts.frame_gap) : 0)+((strip_height-22)/2)+'px',
						left:((gallery_width)/2)-(wrapper_width/2)-opts.frame_gap-22+'px'
					 });
				} else {
					navNext.css({
						left:(opts.show_panels ? (opts.filmstrip_position=='left'?0:opts.panel_width+opts.frame_gap) : 0)+((strip_width-22)/2)+13+'px',
						top:wrapper_height+opts.frame_gap+'px'
					});
					navPrev.css({
						left:(opts.show_panels ? (opts.filmstrip_position=='left'?0:opts.panel_width+opts.frame_gap) : 0)+((strip_width-22)/2)-13+'px',
						top:wrapper_height+opts.frame_gap+'px'
					});
				}
			}
		};

	/*
	**	mouseIsOverGallery(int,int)
	**		Check to see if mouse coordinates lie within borders of gallery
	**		This is a more reliable method than using the mouseover event
	**		RETURN - boolean
	*/
		function mouseIsOverGallery(x,y) {
			var pos = getPos(j_gallery[0]);
			var top = pos.top;
			var left = pos.left;
			return x > left && x < left+j_gallery.outerWidth() && y > top && y < top+j_gallery.outerHeight();
		};

	/*
	**	mouseIsOverPanel(int,int)
	**		Check to see if mouse coordinates lie within borders of panel
	**		This is a more reliable method than using the mouseover event
	**		RETURN - boolean
	*/
		function mouseIsOverPanel(x,y) {

			// Get position of panel wrapper in relation to gallery
			var pos = getPos($('#'+id+' .gv-panel_wrap')[0]);
			var gPos = getPos(j_gallery[0]);

			// Add wrap position to gallery position
			var top = pos.top+gPos.top;
			var left = pos.left+gPos.left;

			return x > left && x < left+j_panels.outerWidth() && y > top && y < top+j_panels.outerHeight();
		};

	/*
	**	getInt(string)
	**		Parse a string to obtain the integer value contained
	**		If the string contains no number, return zero
	**		RETURN - int
	*/
		function getInt(i) {
			i = parseInt(i,10);
			if(isNaN(i)) { i = 0; }
			return i;
		};

	/*
	**	buildGallery()
	**		Construct HTML and CSS for the gallery, based on user options
	*/
		function buildGallery() {

			// Get gallery images
			var gallery_images = opts.show_filmstrip?$('img',j_frames):$('img',j_panels);

			// For each image in the gallery, add its original dimensions and scaled dimensions to the appropriate arrays for later reference
			gallery_images.each(function(i){
				img_h[i] = this.height;
				img_w[i] = this.width;

				if(opts.frame_scale=='nocrop') {
					frame_img_scale[i] = Math.min(opts.frame_height/img_h[i],opts.frame_width/img_w[i]);
				} else {
					frame_img_scale[i] = Math.max(opts.frame_height/img_h[i],opts.frame_width/img_w[i]);
				}

				if(opts.panel_scale=='nocrop') {
					panel_img_scale[i] = Math.min(opts.panel_height/img_h[i],opts.panel_width/img_w[i]);
				} else {
					panel_img_scale[i] = Math.max(opts.panel_height/img_h[i],opts.panel_width/img_w[i]);
				}
			});

			// Set gallery dimensions
			j_gallery.css({
				position:'relative',
				width:gallery_width+'px',
				height:gallery_height+'px'
			});

			// Build filmstrip if necessary
			if(opts.show_filmstrip) {
				buildFilmstrip();
				enableFrameClicking();
			}

			//Strip out panel overlays if the user does not want to display them
			if(!opts.show_overlays) {
				$('.gv-panel-overlay',j_gallery).remove();
			}

			// Build panels if necessary
			if(opts.show_panels) {
				buildPanels();
			}

			// If user opts to pause on hover, or no filmstrip exists, add some mouseover functionality
			if(opts.pause_on_hover || opts.show_panel_nav) {
				$(document).mousemove(function(e){

					// If user wants to pause on hover and mouse is over the gallery, halt any animations
					if(opts.pause_on_hover) {
						if(mouseIsOverGallery(e.pageX,e.pageY) && !paused) {
							// Pause slideshow in 500ms. This allows for brief swipes of the mouse over the gallery without unnecessarily pausing it
							$(document).oneTime(500,"animation_pause",function(){
								$(document).stopTime("transition");
								paused=true;
							});
						} else {
							$(document).stopTime("animation_pause");
							if(paused && opts.transition_interval > 0) {
								$(document).everyTime(opts.transition_interval,"transition",function(){
									showNextItem();
								});
								paused = false;
							}
						}
					}

					// If panel navigation is turned on, display or hide it based on mouse position
					if(opts.show_panel_nav) {
						if(mouseIsOverPanel(e.pageX,e.pageY) && !panel_nav_displayed) {
							$('.gv-panel-nav-next, .gv-panel-nav-prev',j_gallery).show();
							panel_nav_displayed = true;
						} else if(!mouseIsOverPanel(e.pageX,e.pageY) && panel_nav_displayed) {
							$('.gv-panel-nav-next, .gv-panel-nav-prev',j_gallery).hide();
							panel_nav_displayed = false;
						}
					}
				});
			}

			// Hide loading box and display gallery
			j_filmstrip.css('visibility','visible');
			j_gallery.css('visibility','visible');

			// Show the 'first' item and then fade out the loader box and begin slideshow timer if necessary
			showItem(iterator,10,function(){
				$('.gv-loader',j_gallery).fadeOut('1000',function(){

					// If we have more than one item, begin automated transitions
					if(item_count > 1 && opts.transition_interval > 0) {
						$(document).everyTime(opts.transition_interval,"transition",function(){
							showNextItem();
						});
					}
				});
			});


		};

	/*
	**	MAIN PLUGIN CODE
	*/
		return this.each(function() {

			// Get UL passed to plugin
			var _t = $(this);

			// Hide the unstyled UL until we've created the gallery
			_t.css('visibility','hidden');

			// Reference images for later use (we'll wait for each to load before building gallery)
			gallery_images = $('img',_t);
			image_count = gallery_images.length;

			// Set the current frame index to that chosen by the user
			// current is 0-based and opts.start_frame is 1-based
			current = opts.start_frame-1;

			// Wrap UL in DIV and transfer ID to container DIV
			_t.wrap("<div></div>");
			j_gallery = _t.parent();
			j_gallery.css('visibility','hidden').attr('id',_t.attr('id')).addClass('gv-gallery').addClass(_t.attr('class'));

			// Assign filmstrip class to the UL sent to the plugin
			_t.removeAttr('id').addClass('gv-filmstrip');

			// If the transition or pause timers exist for any reason, stop them now.
			$(document).stopTime("transition");
			$(document).stopTime("animation_pause");

			// Save the id of the UL passed to the plugin
			id = j_gallery.attr('id');

			// If the UL does not contain any <div class="gv-panel-content"> elements, we will scale the UL images to fill the panels
			scale_panel_images = $('.gv-panel-content',j_gallery).length==0;

			animate_panels = (opts.panel_animation != 'none');

			// Determine filmstrip orientation (vertical or horizontal)
			filmstrip_orientation = (opts.filmstrip_position=='top'||opts.filmstrip_position=='bottom'?'horizontal':'vertical');

			// Do not show captions on vertical filmstrips (override user set option)
			if(filmstrip_orientation=='vertical') { opts.show_captions = false; }


			// Make sure pointer does not extend past width of frame
			if(filmstrip_orientation == 'horizontal' && opts.pointer_size > opts.frame_width/2) {
				opts.pointer_size = opts.frame_width/2;
			}
			if(filmstrip_orientation == 'vertical' && opts.pointer_size > opts.frame_height/2) {
				opts.pointer_size = opts.frame_height/2;
			}


			// Assign elements to variables to minimize calls to jQuery
			j_filmstrip = $('.gv-filmstrip',j_gallery);
			j_frames = $('li',j_filmstrip);
			j_frames.addClass('gv-frame');
			j_panel_wrapper = $('<div>');
			j_panel_wrapper.addClass('gv-panel_wrap').prependTo(j_gallery);

			// If the user wants panels, generate them using the filmstrip images
			if(opts.show_panels) {
				for(i=j_frames.length-1;i>=0;i--) {
					jf = j_frames.eq(i);
					if(jf.find('.gv-panel-content').length>0) {
						jf.find('.gv-panel-content').remove().prependTo(j_panel_wrapper).addClass('gv-panel').addClass(jf.attr('class')).removeClass('gv-frame');
					} else {
						p = $('<div>');
						p.addClass('gv-panel');
						p.addClass(jf.attr('class')).removeClass('gv-frame');
						im = $('<img />');
						jfimg = jf.find('img').eq(0)
						im.attr('src',jfimg.attr('src'));
						if(jfimg.parent('a').length > 0){
							ima = $('<a></a>');
							ima.attr('href',jfimg.parent('a').eq(0).attr('href'));
							ima.attr('target',jfimg.parent('a').eq(0).attr('target'));
							ima.append(im);
							ima.appendTo(p);
						} else {
							im.appendTo(p);
						}
						p.prependTo(j_panel_wrapper);
						j_frames.eq(i).find('.gv-panel-overlay').remove().appendTo(p);
					}
				}
			} else {
				$('.gv-panel-overlay',j_frames).remove();
				$('.gv-panel-content',j_frames).remove();
			}

			// If the user doesn't want a filmstrip, delete it
			if(!opts.show_filmstrip) { j_filmstrip.remove(); }
			else {
				// Wrap the frame images (and links, if applicable) in container divs
				// These divs will handle cropping and zooming of the images
				j_frames.each(function(i){
					if($(this).find('a').length>0) {
						$(this).find('a').wrap('<div class="gv-img_wrap"></div>');
					} else {
						$(this).find('img').wrap('<div class="gv-img_wrap"></div>');
					}
				});
				j_frame_img_wrappers = $('.gv-img_wrap',j_frames);
			}

			j_panels = $('.gv-panel',j_gallery);

			if(!opts.show_panels) {
				opts.panel_height = 0;
				opts.panel_width = 0;
			}

			// Briefly create a caption element so galleryView can determine any padding or borders applied by the user
			$('<div class="gv-caption"></div>').appendTo(j_frames);

			// Determine final frame dimensions, accounting for user-added padding and border
			f_frame_width = opts.frame_width+extraWidth(j_frame_img_wrappers);
			f_frame_height = opts.frame_height+extraHeight(j_frame_img_wrappers);
			frame_caption_size = getInt($('.gv-caption',j_gallery).css('height'));
			f_caption_width = f_frame_width - extraWidth($('.gv-caption',j_gallery));
			f_caption_height = frame_caption_size + extraHeight($('.gv-caption',j_gallery));

			// Delete the temporary caption element
			$('.gv-caption',j_gallery).remove();

			// Number of frames in filmstrip
			item_count = opts.show_panels?j_panels.length:j_frames.length;

			// Number of frames that can display within the gallery block
			// 64 = width of block for navigation button * 2 + 20
			if(filmstrip_orientation=='horizontal') {
				strip_size = opts.show_panels?Math.floor((opts.panel_width+opts.frame_gap-(!opts.show_filmstrip_nav?0:(opts.frame_gap+22)*2))/(f_frame_width+opts.frame_gap)):Math.min(item_count,opts.filmstrip_size);
			} else {
				strip_size = opts.show_panels?Math.floor((opts.panel_height+opts.frame_gap-(!opts.show_filmstrip_nav?0:opts.frame_gap+22))/(f_frame_height+opts.frame_gap)):Math.min(item_count,opts.filmstrip_size);
			}

			// Determine animation 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';
			}

			// Do not show pointer if there are multiple rows in the filmstrip
			if(Math.ceil(item_count/strip_size) > 1) { opts.pointer_size = 0; }

			// Define dimensions of pointer <div>
			pointer_height = opts.pointer_size;
			pointer_width = opts.pointer_size*2;

			iterator = opts.start_frame-1;
			if(opts.filmstrip_style == 'scroll' && strip_size < item_count) {
				iterator += item_count;
			}

			// Determine dimensions of various gallery elements
			//_filmstrip_margin = (opts.show_panels?getInt(j_filmstrip.css('marginTop')):0);
			j_filmstrip.css('margin',0);

			// Width of filmstrip
			if(filmstrip_orientation=='horizontal') {
				if(opts.filmstrip_style == 'show all' || (opts.filmstrip_style == 'scroll' && slide_method == 'pointer')) {
					strip_width = (f_frame_width*strip_size)+(opts.frame_gap*(strip_size));
				}
				else {
					strip_width = (f_frame_width*item_count*3)+(opts.frame_gap*((item_count*3)));
				}
			} else {
				if(opts.filmstrip_style == 'show all') {
					strip_width = (f_frame_width*Math.ceil(item_count/strip_size))+(opts.frame_gap*(Math.ceil(item_count/strip_size)));
				} else {
					strip_width = (f_frame_width);
				}
			}

			// Height of filmstrip
			if(filmstrip_orientation=='horizontal') {
				if(opts.filmstrip_style == 'show all') {
					strip_height = ((f_frame_height+(opts.show_captions?f_caption_height:0))*Math.ceil(item_count/strip_size))+(opts.frame_gap*(Math.ceil(item_count/strip_size)-1));
				} else {
					strip_height = (f_frame_height+(opts.show_captions?f_caption_height:0));
				}
			} else {
				if(opts.filmstrip_style =='show all' || (opts.filmstrip_style == 'scroll' && slide_method == 'pointer')) {
					strip_height = ((f_frame_height*strip_size)+opts.frame_gap*(strip_size-1));
				}
				else {
					strip_height = (f_frame_height*item_count*3)+(opts.frame_gap*((item_count*3)-1));
				}
			}

			// Width of filmstrip wrapper (to hide overflow)
			if(filmstrip_orientation=='horizontal') {
				wrapper_width = ((strip_size*f_frame_width)+((strip_size-1)*opts.frame_gap));
				if(opts.filmstrip_style == 'show all') {
					wrapper_height = ((f_frame_height+(opts.show_captions?f_caption_height:0))*Math.ceil(item_count/strip_size))+(opts.frame_gap*(Math.ceil(item_count/strip_size)-1));
				} else {
					wrapper_height = (f_frame_height+(opts.show_captions?f_caption_height:0));
				}
			} else {
				wrapper_height = ((strip_size*f_frame_height)+((strip_size-1)*opts.frame_gap));
				if(opts.filmstrip_style == 'show all') {
					wrapper_width = (f_frame_width*Math.ceil(item_count/strip_size))+(opts.frame_gap*(Math.ceil(item_count/strip_size)-1));
				} else {
					wrapper_width = f_frame_width;
				}
			}

			// There shouldn't be any padding on the gallery element
			j_gallery.css('padding',0);

			// Determine final dimensions of gallery
			if(filmstrip_orientation=='horizontal') {

				// Width of gallery block
				gallery_width = opts.show_panels?opts.panel_width:wrapper_width+44+(opts.frame_gap*2);

				// Height of gallery block = screen + filmstrip + captions (optional)
				gallery_height = (opts.show_panels?opts.panel_height+(opts.show_filmstrip?opts.frame_gap:0):0)+(opts.show_filmstrip?wrapper_height:0);
			} else {

				// Width of gallery block
				gallery_height = opts.show_panels?opts.panel_height:wrapper_height+22;

				// Height of gallery block = screen + filmstrip + captions (optional)
				gallery_width = (opts.show_panels?opts.panel_width+(opts.show_filmstrip?opts.frame_gap:0):0)+(opts.show_filmstrip?wrapper_width:0);
			}

			// Place loading box over gallery until page loads
			galleryPos = getPos(j_gallery[0]);
			$('<div>').addClass('gv-loader').css({
				position:'absolute',
				zIndex:'32666',
				opacity:1,
				top:0,
				left:0,
				width:gallery_width+'px',
				height:gallery_height+'px'
			}).appendTo(j_gallery);

			// We don't want to move to the next frame before the current one is done loading
			// If the animation speed is greater than the delay between animations, set them equal
			if(opts.transition_speed > opts.transition_interval && opts.transition_interval > 0) {
				opts.transition_speed = opts.transition_interval;
			}

			// Set pointer animation speed based on user options
			pointer_speed = opts.animate_pointer ? opts.transition_speed : 0;

			// Build gallery as soon as all images are loaded or pulled from cache
			if(!window_loaded) {
				gallery_images.each(function(i){

					// First, see if image is already loaded (gallery being built after window loads or image is pulled from cache)
					if($(this).attr('complete')) {
						loaded_images++;
						if(loaded_images==image_count) {
							buildGallery();
							window_loaded;
						}
					} else {

						// Otherwise, increment counter once image loads
						$(this).load(function(){
							loaded_images++;
							if(loaded_images==image_count) {
								buildGallery();
								window_loaded;
							}
						});
					}
				});
			} else {
				buildGallery();
			}
		});
	};

/*
**	GalleryView options and default values
*/
	$.fn.galleryView.defaults = {

		transition_speed: 800,				//INT - duration of panel/frame transition (in milliseconds)
		transition_interval: 4000,			//INT - delay between panel/frame transitions (in milliseconds)
		easing: 'swing',					//STRING - easing method to use for animations (jQuery provides 'swing' or 'linear', more available with jQuery UI or Easing plugin)
		pause_on_hover: false,				//BOOLEAN - flag to pause slideshow when user hovers over the gallery


		show_panels: true,					//BOOLEAN - flag to show or hide panel portion of gallery
		panel_width: 600,					//INT - width of gallery panel (in pixels)
		panel_height: 400,					//INT - height of gallery panel (in pixels)
		panel_animation: 'crossfade',		//STRING - animation method for panel transitions (crossfade,fade,slide,zoomOut,none)
		overlay_opacity: 0.7,				//FLOAT - transparency for panel overlay (1.0 = opaque, 0.0 = transparent)
		overlay_position: 'bottom',			//STRING - position of panel overlay (bottom, top)
		panel_scale: 'crop',				//STRING - cropping option for panel images (crop = scale image and fit to aspect ratio determined by panel_width and panel_height, nocrop = scale image and preserve original aspect ratio)
		show_panel_nav: true,				//BOOLEAN - flag to show or hide panel navigation buttons
		show_overlays: false,				//BOOLEAN - flag to show or hide panel overlays


		show_filmstrip: true,				//BOOLEAN - flag to show or hide filmstrip portion of gallery
		frame_width: 60,					//INT - width of filmstrip frames (in pixels)
		frame_height: 40,					//INT - width of filmstrip frames (in pixels)
		start_frame: 1,						//INT - index of panel/frame to show first when gallery loads
		filmstrip_size: 3,					//INT - number of frames to show in filmstrip-only gallery
		frame_opacity: 0.3,					//FLOAT - transparency of non-active frames (1.0 = opaque, 0.0 = transparent)
		filmstrip_style: 'scroll',			//STRING - type of filmstrip to use (scroll, show all)
		filmstrip_position: 'bottom',		//STRING - position of filmstrip within gallery (bottom, top, left, right)
		show_filmstrip_nav: true,			//BOOLEAN - flag indicating whether to display navigation buttons
		frame_scale: 'crop',				//STRING - cropping option for filmstrip images (same as above)
		frame_gap: 5,						//INT - spacing between frames within filmstrip (in pixels)
		show_captions: false,				//BOOLEAN - flag to show or hide frame captions


		pointer_size: 8,					//INT - Height of frame pointer (in pixels)
		animate_pointer: true				//BOOLEAN - flag to animate pointer or move it instantly to target frame

	};
})(jQuery);


function blockHeight()
{
	var sh = $("#left-column-menu").height();
	var ch = $("#right-column-menu").height();	
	if (sh > ch)
	{
		$('#right-column-menu').css("height" , $('#left-column-menu').height());

	} else {
		$('#left-column-menu').css("height" , $('#right-column-menu').height());
	}
}

window.onload = function()
{
	blockHeight();
	
    if ($("#banner_fixed").length && !($.browser.msie && $.browser.version < 9)) {
        var sh = $("#right-column-menu").height();
	   var myHeight = window.innerHeight;

        $("#right-column-menu").css("position","relative");
		var banner_fixed_position = $("#banner_fixed").position();
		var banner_fixed_offset = $("#banner_fixed").offset();
        $("#banner_fixed").css("position","absolute");
        $("#right-column-menu").css("min-height",sh);

	$(window).scroll(function() {
		if (($(window).scrollTop() - banner_fixed_offset.top) > 0) {
               var banner_top = $(window).scrollTop() + (myHeight/2) - ($("#banner_fixed").height()/2) ;

                if (($("#banner_fixed").parent().height() - banner_top) > $("#banner_fixed").height()) 
			 {
                    $("#banner_fixed").stop().animate({top: banner_top});
                };
	   			}
   		else {$("#banner_fixed").stop().css("top",banner_fixed_position.top);};
		});
    }
}


/* *********************************
        ON LOAD
********************************* */
$(function(){
  $('#container :input[required]').addClass("required").removeAttr('required');
    Custom.init();
	if(document.getElementById('contact-form') )
	{
		if (!elementSupportsAttribute('input','placeholder') && !(jQuery.browser.safari && (navigator.appVersion.indexOf('3.') != -1)))
		{

			var el = $(" input, select, textarea");
			for (var i=0; i<el.length; i++) {
			    if ($(el[i]).val() == "")
			    {
				  $(el[i]).addClass('placeholder');
			    }

				$(el[i]).blur(function() {
					if ($(this).val() =='')
					{
						$(this).addClass('placeholder');
					}
					else
					{
						$(this).removeClass('placeholder');
					}
									   })
			}
		}
	}
         $("a.faq_link").click(function() {
        var id = $(this).attr("rel");
        $("#faq_wrapper").addClass("visible");
        $("#" +id).addClass("visible");
        return false;
    })
    $("a.btn_close").click(function() {
        $("#faq_wrapper").removeClass("visible");
        $(".faq_text").removeClass("visible");
        return false;
    })
	lightgallery.init();
	
$('span.older-link').click(
	function (){
	$('tr.older').removeClass('older');
	$('span.older-link').css('display','none');	
});
	
});
