// Flash Player Version Detection - Rev 1.6
// Detect Client Browser type
// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
			//alert("flashVer="+flashVer);
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];
		
        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
    var str = '';
    if (isIE && isWin && !isOpera)
    {
  		str += '<object ';
  		for (var i in objAttrs)
  			str += i + '="' + objAttrs[i] + '" ';
  		for (var i in params)
  			str += '><param name="' + i + '" value="' + params[i] + '" /> ';
  		str += '></object>';
    } else {
  		str += '<embed ';
  		for (var i in embedAttrs)
  			str += i + '="' + embedAttrs[i] + '" ';
  		str += '> </embed>';
    }

    document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "id":
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}




/** 
 * flowplayer.js 3.0.0. The Flowplayer API
 * 
 * Copyright 2008 Flowplayer Oy
 * 
 * This file is part of Flowplayer.
 * 
 * Flowplayer is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Flowplayer is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Flowplayer.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Version: 3.0.0 - Tue Nov 25 2008 16:25:46 GMT-0000 (GMT+00:00)
 */
(function(){function log(args){if(typeof opera=='object'){opera.postError("$f.fireEvent: "+args.join(" | "));}else if(typeof console=='object'){console.log("$f.fireEvent",[].slice.call(args));}}function clone(obj){if(!obj||typeof obj!='object'){return obj;}var temp=new obj.constructor();for(var key in obj){if(obj.hasOwnProperty(key)){temp[key]=clone(obj[key]);}}return temp;}function each(obj,fn){if(!obj){return;}var name,i=0,length=obj.length;if(length===undefined){for(name in obj){if(fn.call(obj[name],name,obj[name])===false){break;}}}else{for(var value=obj[0];i<length&&fn.call(value,i,value)!==false;value=obj[++i]){}}return obj;}function el(id){return document.getElementById(id);}function extend(to,from,skipFuncs){if(to&&from){each(from,function(name,value){if(!skipFuncs||typeof value!='function'){to[name]=value;}});}}function select(query){var index=query.indexOf(".");if(index!=-1){var tag=query.substring(0,index)||"*";var klass=query.substring(index+1,query.length);var els=[];each(document.getElementsByTagName(tag),function(){if(this.className&&this.className.indexOf(klass)!=-1){els.push(this);}});return els;}}function stopEvent(e){e=e||window.event;if(e.preventDefault){e.stopPropagation();e.preventDefault();}else{e.returnValue=false;e.cancelBubble=true;}return false;}function bind(to,evt,fn){to[evt]=to[evt]||[];to[evt].push(fn);}function makeId(){return"_"+(""+Math.random()).substring(2,10);}var Clip=function(json,index,player){var self=this;var cuepoints={};var listeners={};this.index=index;if(typeof json=='string'){json={url:json};}extend(this,json,true);each(("Begin*,Start,Pause*,Resume*,Seek*,Stop*,Finish*,LastSecond,Update,BufferFull,BufferEmpty,BufferStop").split(","),function(){var evt="on"+this;if(evt.indexOf("*")!=-1){evt=evt.substring(0,evt.length-1);var before="onBefore"+evt.substring(2);self[before]=function(fn){bind(listeners,before,fn);return self;};}self[evt]=function(fn){bind(listeners,evt,fn);return self;};if(index==-1){if(self[before]){player[before]=self[before];}if(self[evt]){player[evt]=self[evt];}}});extend(this,{onCuepoint:function(points,fn){if(arguments.length==1){cuepoints.embedded=[null,points];return self;}if(typeof points=='number'){points=[points];}var fnId=makeId();cuepoints[fnId]=[points,fn];if(player.isLoaded()){player._api().fp_addCuepoints(points,index,fnId);}return self;},update:function(json){extend(self,json);if(player.isLoaded()){player._api().fp_updateClip(json,index);}var conf=player.getConfig();var clip=(index==-1)?conf.clip:conf.playlist[index];extend(clip,json,true);},_fireEvent:function(evt,arg1,arg2,target){if(evt=='onLoad'){each(cuepoints,function(key,val){player._api().fp_addCuepoints(val[0],index,key);});return false;}if(index!=-1){target=self;}if(evt=='onCuepoint'){var fn=cuepoints[arg1];if(fn){return fn[1].call(player,target,arg2);}}if(evt=='onStart'||evt=='onUpdate'){extend(target,arg1);if(!target.duration){target.duration=arg1.metaData.duration;}else{target.fullDuration=arg1.metaData.duration;}}var ret=true;each(listeners[evt],function(){ret=this.call(player,target,arg1);});return ret;}});if(json.onCuepoint){self.onCuepoint.apply(self,json.onCuepoint);delete json.onCuepoint;}each(json,function(key,val){if(typeof val=='function'){bind(listeners,key,val);delete json[key];}});if(index==-1){player.onCuepoint=this.onCuepoint;}};var Plugin=function(name,json,player,fn){var listeners={};var self=this;var hasMethods=false;if(fn){extend(listeners,fn);}each(json,function(key,val){if(typeof val=='function'){listeners[key]=val;delete json[key];}});extend(this,{animate:function(props,speed,fn){if(!props){return self;}if(typeof speed=='function'){fn=speed;speed=500;}if(typeof props=='string'){var key=props;props={};props[key]=speed;speed=500;}if(fn){var fnId=makeId();listeners[fnId]=fn;}if(speed===undefined){speed=500;}json=player._api().fp_animate(name,props,speed,fnId);return self;},css:function(props,val){if(val!==undefined){var css={};css[props]=val;props=css;}json=player._api().fp_css(name,props);extend(self,json);return self;},show:function(){this.display='block';player._api().fp_showPlugin(name);return self;},hide:function(){this.display='none';player._api().fp_hidePlugin(name);return self;},toggle:function(){this.display=player._api().fp_togglePlugin(name);return self;},fadeTo:function(o,speed,fn){if(typeof speed=='function'){fn=speed;speed=500;}if(fn){var fnId=makeId();listeners[fnId]=fn;}this.display=player._api().fp_fadeTo(name,o,speed,fnId);this.opacity=o;return self;},fadeIn:function(speed,fn){return self.fadeTo(1,speed,fn);},fadeOut:function(speed,fn){return self.fadeTo(0,speed,fn);},getName:function(){return name;},_fireEvent:function(evt,arg){if(evt=='onUpdate'){var json=arg||player._api().fp_getPlugin(name);if(!json){return;}extend(self,json);delete self.methods;if(!hasMethods){each(json.methods,function(){var method=""+this;self[method]=function(){var a=[].slice.call(arguments);var ret=player._api().fp_invoke(name,method,a);return ret=='undefined'?self:ret;};});hasMethods=true;}}var fn=listeners[evt];if(fn){fn.call(self,arg);if(evt.substring(0,1)=="_"){delete listeners[evt];}}}});};function Player(wrapper,params,conf){var
self=this,api=null,html,commonClip,playlist=[],plugins={},listeners={},playerId,apiId,activeIndex,swfHeight,wrapperHeight;extend(self,{id:function(){return playerId;},isLoaded:function(){return(api!==null);},getParent:function(){return wrapper;},hide:function(all){if(all){wrapper.style.height="0px";}if(api){api.style.height="0px";}return self;},show:function(){wrapper.style.height=wrapperHeight+"px";if(api){api.style.height=swfHeight+"px";}return self;},isHidden:function(){return api&&parseInt(api.style.height,10)===0;},load:function(fn){if(!api&&self._fireEvent("onBeforeLoad")!==false){each(players,function(){this.unload();});html=wrapper.innerHTML;flashembed(wrapper,params,{config:conf});if(fn){fn.cached=true;bind(listeners,"onLoad",fn);}}return self;},unload:function(){if(api&&html.replace(/\s/g,'')!==''&&!api.fp_isFullscreen()&&self._fireEvent("onBeforeUnload")!==false){api.fp_close();wrapper.innerHTML=html;self._fireEvent("onUnload");api=null;}return self;},getClip:function(index){if(index===undefined){index=activeIndex;}return playlist[index];},getCommonClip:function(){return commonClip;},getPlaylist:function(){return playlist;},getPlugin:function(name){var plugin=plugins[name];if(!plugin&&self.isLoaded()){var json=self._api().fp_getPlugin(name);if(json){plugin=new Plugin(name,json,self);plugins[name]=plugin;}}return plugin;},getScreen:function(){return self.getPlugin("screen");},getControls:function(){return self.getPlugin("controls");},getConfig:function(copy){return copy?clone(conf):conf;},getFlashParams:function(){return params;},loadPlugin:function(name,url,props,fn){if(typeof props=='function'){fn=props;props={};}var fnId=fn?makeId():"_";self._api().fp_loadPlugin(name,url,props,fnId);var arg={};arg[fnId]=fn;var p=new Plugin(name,null,self,arg);plugins[name]=p;return p;},getState:function(){return api?api.fp_getState():-1;},play:function(clip){function play(){if(clip!==undefined){self._api().fp_play(clip);}else{self._api().fp_play();}}if(api){play();}else{self.load(function(){play();});}return self;},getVersion:function(){var js="flowplayer.js 3.0.0-rc5";if(api){var ver=api.fp_getVersion();ver.push(js);return ver;}return js;},_api:function(){if(!api){throw"Flowplayer "+self.id()+" not loaded. Try moving your call to player's onLoad event";}return api;},_dump:function(){console.log(listeners);}});each(("Click*,Load*,Unload*,Keypress*,Volume*,Mute*,Unmute*,PlaylistReplace,Fullscreen*,FullscreenExit,Error").split(","),function(){var name="on"+this;if(name.indexOf("*")!=-1){name=name.substring(0,name.length-1);var name2="onBefore"+name.substring(2);self[name2]=function(fn){bind(listeners,name2,fn);return self;};}self[name]=function(fn){bind(listeners,name,fn);return self;};});each(("pause,resume,mute,unmute,stop,toggle,seek,getStatus,getVolume,setVolume,getTime,isPaused,isPlaying,startBuffering,stopBuffering,isFullscreen,reset").split(","),function(){var name=this;self[name]=function(arg){if(!api){return self;}var ret=(arg===undefined)?api["fp_"+name]():api["fp_"+name](arg);return ret=='undefined'?self:ret;};});self._fireEvent=function(evt,arg0,arg1,arg2){if(conf.debug){log(arguments);}if(evt=='onLoad'&&!api){api=api||el(apiId);swfHeight=api.clientHeight;each(playlist,function(){this._fireEvent("onLoad");});each(plugins,function(name,p){p._fireEvent("onUpdate");});commonClip._fireEvent("onLoad");}if(evt=='onContextMenu'){each(conf.contextMenu[arg0],function(key,fn){fn.call(self);});return;}if(evt=='onPluginEvent'){var name=arg0.name||arg0;var p=plugins[name];if(p){if(arg0.name){p._fireEvent("onUpdate",arg0);}p._fireEvent(arg1);}return;}if(evt=='onPlaylistReplace'){playlist=[];var index=0;each(arg0,function(){playlist.push(new Clip(this,index++));});}var ret=true;if(arg0===0||(arg0&&arg0>=0)){activeIndex=arg0;var clip=playlist[arg0];if(clip){ret=clip._fireEvent(evt,arg1,arg2);}if(!clip||ret!==false){ret=commonClip._fireEvent(evt,arg1,arg2,clip);}}var i=0;each(listeners[evt],function(){ret=this.call(self,arg0);if(this.cached){listeners[evt].splice(i,1);}if(ret===false){return false;}i++;});return ret;};function init(){if($f(wrapper)){return null;}wrapperHeight=parseInt(wrapper.style.height,10)||wrapper.clientHeight;players.push(self);if(typeof params=='string'){params={src:params};}playerId=wrapper.id||"fp"+makeId();apiId=params.id||playerId+"_api";params.id=apiId;conf.playerId=playerId;if(typeof conf=='string'){conf={clip:{url:conf}};}conf.clip=conf.clip||{};commonClip=new Clip(conf.clip,-1,self);if(wrapper.getAttribute("href")){conf.playlist=[{url:wrapper.getAttribute("href",2)}];}conf.playlist=conf.playlist||[conf.clip];var index=0;each(conf.playlist,function(){var clip=this;if(typeof clip=='object'&&clip.length){clip=""+clip;}if(!clip.url&&typeof clip=='string'){clip={url:clip};}extend(clip,conf.clip,true);conf.playlist[index]=clip;clip=new Clip(clip,index,self);playlist.push(clip);index++;});each(conf,function(key,val){if(typeof val=='function'){bind(listeners,key,val);delete conf[key];}});each(conf.plugins,function(name,val){if(val){plugins[name]=new Plugin(name,val,self);}});if(!conf.plugins||conf.plugins.controls===undefined){plugins.controls=new Plugin("controls",null,self);}params.bgcolor=params.bgcolor||"#000000";params.version=params.version||[9,0];params.expressInstall='http://www.flowplayer.org/swf/expressinstall.swf';function doClick(e){if(self._fireEvent("onBeforeClick")!==false){self.load();}return stopEvent(e);}html=wrapper.innerHTML;if(html.replace(/\s/g,'')!==''){if(wrapper.addEventListener){wrapper.addEventListener("click",doClick,false);}else if(wrapper.attachEvent){wrapper.attachEvent("onclick",doClick);}}else{if(wrapper.addEventListener){wrapper.addEventListener("click",stopEvent,false);}self.load();}}if(typeof wrapper=='string'){flashembed.domReady(function(){var node=el(wrapper);if(!node){throw"Flowplayer cannot access element: "+wrapper;}else{wrapper=node;init();}});}else{init();}}var players=[];function Iterator(arr){this.length=arr.length;this.each=function(fn){each(arr,fn);};this.size=function(){return arr.length;};}window.flowplayer=window.$f=function(){var instance=null;var arg=arguments[0];if(!arguments.length){each(players,function(){if(this.isLoaded()){instance=this;return false;}});return instance||players[0];}if(arguments.length==1){if(typeof arg=='number'){return players[arg];}else{if(arg=='*'){return new Iterator(players);}each(players,function(){if(this.id()==arg.id||this.id()==arg||this.getParent()==arg){instance=this;return false;}});return instance;}}if(arguments.length>1){var swf=arguments[1];var conf=(arguments.length==3)?arguments[2]:{};if(typeof arg=='string'){if(arg.indexOf(".")!=-1){var instances=[];each(select(arg),function(){instances.push(new Player(this,clone(swf),clone(conf)));});return new Iterator(instances);}else{var node=el(arg);return new Player(node!==null?node:arg,swf,conf);}}else if(arg){return new Player(arg,swf,conf);}}return null;};extend(window.$f,{fireEvent:function(id,evt,a0,a1,a2){var p=$f(id);return p?p._fireEvent(evt,a0,a1,a2):null;},addPlugin:function(name,fn){Player.prototype[name]=fn;return $f;},each:each,extend:extend});if(typeof jQuery=='function'){jQuery.prototype.flowplayer=function(params,conf){if(!arguments.length||typeof arguments[0]=='number'){var arr=[];this.each(function(){var p=$f(this);if(p){arr.push(p);}});return arguments.length?arr[arguments[0]]:new Iterator(arr);}return this.each(function(){$f(this,clone(params),conf?clone(conf):{});});};}})();(function(){var jQ=typeof jQuery=='function';function isDomReady(){if(domReady.done){return false;}var d=document;if(d&&d.getElementsByTagName&&d.getElementById&&d.body){clearInterval(domReady.timer);domReady.timer=null;for(var i=0;i<domReady.ready.length;i++){domReady.ready[i].call();}domReady.ready=null;domReady.done=true;}}var domReady=jQ?jQuery:function(f){if(domReady.done){return f();}if(domReady.timer){domReady.ready.push(f);}else{domReady.ready=[f];domReady.timer=setInterval(isDomReady,13);}};function extend(to,from){if(from){for(key in from){if(from.hasOwnProperty(key)){to[key]=from[key];}}}return to;}function concatVars(vars){var out="";for(var key in vars){if(vars[key]){out+=[key]+'='+asString(vars[key])+'&';}}return out.substring(0,out.length-1);}function asString(obj){switch(typeOf(obj)){case'string':obj=obj.replace(new RegExp('(["\\\\])','g'),'\\$1');obj=obj.replace(/^\s?(\d+)%/,"$1pct");return'"'+obj+'"';case'array':return'['+map(obj,function(el){return asString(el);}).join(',')+']';case'function':return'"function()"';case'object':var str=[];for(var prop in obj){if(obj.hasOwnProperty(prop)){str.push('"'+prop+'":'+asString(obj[prop]));}}return'{'+str.join(',')+'}';}return String(obj).replace(/\s/g," ").replace(/\'/g,"\"");}function typeOf(obj){if(obj===null||obj===undefined){return false;}var type=typeof obj;return(type=='object'&&obj.push)?'array':type;}if(window.attachEvent){window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};});}function map(arr,func){var newArr=[];for(var i in arr){if(arr.hasOwnProperty(i)){newArr[i]=func(arr[i]);}}return newArr;}function getEmbedCode(p,c){var html='<embed type="application/x-shockwave-flash" ';if(p.id){extend(p,{name:p.id});}for(var key in p){if(p[key]!==null){html+=key+'="'+p[key]+'"\n\t';}}if(c){html+='flashvars=\''+concatVars(c)+'\'';}html+='/>';return html;}function getObjectCode(p,c,embeddable){var html='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';html+='width="'+p.width+'" height="'+p.height+'"';if(!p.id&&document.all){p.id="_"+(""+Math.random()).substring(5);}if(p.id){html+=' id="'+p.id+'"';}html+='>';if(document.all){p.src+=((p.src.indexOf("?")!=-1?"&":"?")+Math.random());}html+='\n\t<param name="movie" value="'+p.src+'" />';var e=extend({},p);e.id=e.width=e.height=e.src=null;for(var k in e){if(e[k]!==null){html+='\n\t<param name="'+k+'" value="'+e[k]+'" />';}}if(c){html+='\n\t<param name="flashvars" value=\''+concatVars(c)+'\' />';}if(embeddable){html+=getEmbedCode(p,c);}html+="</object>";return html;}function getFullHTML(p,c){return getObjectCode(p,c,true);}function getHTML(p,c){var isNav=navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length;return(isNav)?getEmbedCode(p,c):getObjectCode(p,c);}window.flashembed=function(root,userParams,flashvars){var params={src:'#',width:'100%',height:'100%',version:null,onFail:null,expressInstall:null,debug:false,allowfullscreen:true,allowscriptaccess:'always',quality:'high',type:'application/x-shockwave-flash',pluginspage:'http://www.adobe.com/go/getflashplayer'};if(typeof userParams=='string'){userParams={src:userParams};}extend(params,userParams);var version=flashembed.getVersion();var required=params.version;var express=params.expressInstall;var debug=params.debug;if(typeof root=='string'){var el=document.getElementById(root);if(el){root=el;}else{domReady(function(){flashembed(root,userParams,flashvars);});return;}}if(!root){return;}if(!required||flashembed.isSupported(required)){params.onFail=params.version=params.expressInstall=params.debug=null;root.innerHTML=getHTML(params,flashvars);return root.firstChild;}else if(params.onFail){var ret=params.onFail.call(params,flashembed.getVersion(),flashvars);if(ret===true){root.innerHTML=ret;}}else if(required&&express&&flashembed.isSupported([6,65])){extend(params,{src:express});flashvars={MMredirectURL:location.href,MMplayerType:'PlugIn',MMdoctitle:document.title};root.innerHTML=getHTML(params,flashvars);}else{if(root.innerHTML.replace(/\s/g,'')!==''){}else{root.innerHTML="<h2>Flash version "+required+" or greater is required</h2>"+"<h3>"+(version[0]>0?"Your version is "+version:"You have no flash plugin installed")+"</h3>"+"<p>Download latest version from <a href='"+params.pluginspage+"'>here</a></p>";}}return root;};extend(window.flashembed,{getVersion:function(){var version=[0,0];if(navigator.plugins&&typeof navigator.plugins["Shockwave Flash"]=="object"){var _d=navigator.plugins["Shockwave Flash"].description;if(typeof _d!="undefined"){_d=_d.replace(/^.*\s+(\S+\s+\S+$)/,"$1");var _m=parseInt(_d.replace(/^(.*)\..*$/,"$1"),10);var _r=/r/.test(_d)?parseInt(_d.replace(/^.*r(.*)$/,"$1"),10):0;version=[_m,_r];}}else if(window.ActiveXObject){try{var _a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{_a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");version=[6,0];_a.AllowScriptAccess="always";}catch(ee){if(version[0]==6){return;}}try{_a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(eee){}}if(typeof _a=="object"){_d=_a.GetVariable("$version");if(typeof _d!="undefined"){_d=_d.replace(/^\S+\s+(.*)$/,"$1").split(",");version=[parseInt(_d[0],10),parseInt(_d[2],10)];}}}return version;},isSupported:function(version){var now=flashembed.getVersion();var ret=(now[0]>version[0])||(now[0]==version[0]&&now[1]>=version[1]);return ret;},domReady:domReady,asString:asString,getHTML:getHTML,getFullHTML:getFullHTML});if(jQ){jQuery.prototype.flashembed=function(params,flashvars){return this.each(function(){flashembed(this,params,flashvars);});};}})();


/**
 * Main Seagull JavaScript library.
 *
 * @package seagull
 * @subpackage SGL
 */
var SGL = {
    isReady: false,
    ready: function(f) {
        // If the DOM is already ready
        if (SGL.isReady) {
            // Execute the function immediately
            if (typeof f == 'string') {
                eval(f);
            } else if (typeof f == 'function') {
                f.apply(document);
            }
        // Otherwise add the function to the wait list
        } else {
            SGL.onReadyDomEvents.push(f);
        }
    },
    onReadyDomEvents: [],
    onReadyDom: function() {
        // make sure that the DOM is not already loaded
        if (!SGL.isReady) {
            // Flag the DOM as ready
            SGL.isReady = true;

            if (SGL.onReadyDomEvents) {
                for (var i = 0, j = SGL.onReadyDomEvents.length; i < j; i++) {
                    if (typeof SGL.onReadyDomEvents[i] == 'string') {
                        eval(SGL.onReadyDomEvents[i]);
                    } else if (typeof SGL.onReadyDomEvents[i] == 'function') {
                        SGL.onReadyDomEvents[i].apply(document);
                    }
                }
                // Reset the list of functions
				SGL.onReadyDomEvents = null;
            }
        }
    }
};

/**
 *  Cross-browser onDomReady solution
 *  Dean Edwards/Matthias Miller/John Resig
 */
new function() {
    /* for Mozilla/Opera9 */
    if (document.addEventListener) {
        document.addEventListener("DOMContentLoaded", SGL.onReadyDom, false);
    }

    /* for Internet Explorer */
    /*@cc_on @*/
    /*@if (@_win32)
        document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
        var script = document.getElementById("__ie_onload");
        script.onreadystatechange = function() {
            if (this.readyState == "complete") {
                SGL.onReadyDom(); // call the onload handler
            }
        };
    /*@end @*/

    /* for Safari */
    if (/WebKit/i.test(navigator.userAgent)) { // sniff
        SGL.webkitTimer = setInterval(function() {
            if (/loaded|complete/.test(document.readyState)) {
                // Remove the timer
                clearInterval(SGL.webkitTimer);
                SGL.webkitTimer = null;
                // call the onload handler
                SGL.onReadyDom();
            }
        }, 10);
    }

    /* for other browsers */
    oldWindowOnload = window.onload || null;
    window.onload = function() {
        if (oldWindowOnload) {
            oldWindowOnload();
        }
        SGL.onReadyDom();
    }
}

// ----------
// --- BC ---
// ----------

/**
 * Used for async load of sourcefourge bloody button,
 */
function async_load()
{
    var node;
    try {
        // variable _asyncDom is set from JavaScript in the iframe
        // node = top._asyncDom.cloneNode(true); // kills Safari 1.2.4
        node = top._asyncDom;
        // try to remove the first script element, the one that
        // executed all document.writes().
        node.removeChild(node.getElementsByTagName('script')[0]);
    } catch (e) {}
    try {
        // insert DOM fragment at a DIV with id "async_demo" on current page
        document.getElementById('async_demo').appendChild(node);
    } catch (e) {
        try {
            // fallback for some non DOM compliant browsers
            document.getElementById('async_demo').innerHTML = node.innerHTML;
        } catch (e2) {};
    }
}

/**
 * Make Seagull SEF URL.
 *
 * @param object params
 *
 * @return string
 */
function makeUrl(params)
{
    var ret = SGL_JS_FRONT_CONTROLLER != ''
        ? SGL_JS_WEBROOT + '/' + SGL_JS_FRONT_CONTROLLER
        : SGL_JS_WEBROOT;
    var moduleName = params.module ? params.module : '';
    var managerName = params.manager ? params.manager : moduleName;

    switch (SGL_JS_URL_STRATEGY) {

    // make classic URL
    case 'SGL_UrlParser_ClassicStrategy':
        if (ret.charAt(ret.length - 1) != '?') {
            ret = ret + '?';
        }
        ret = ret + 'moduleName=' + escape(moduleName) + '&managerName=' + escape(managerName);
        for (x in params) {
            if (x == 'module' || x == 'manager') {
                continue;
            }
            // add param
            ret = '&' + ret + escape(x) + '=' + escape(params[x]);
        }
        break;

    // make default Seagull SEF URL
    default:
        var langPrefix = document.getElementsByTagName('html')[0].lang;
        ret = ret + '/' + langPrefix + '/' + escape(moduleName) + '/' + escape(managerName) + '/';
        for (x in params) {
            if (x == 'module' || x == 'manager') {
                continue;
            }
            ret = ret + escape(x) + '/' + escape(params[x]) + '/';
        }
 
        break;
    }
    return ret;
}

SGL.ready(function() {
    var msg = document.getElementById('broadcastMessage');
    if (msg) {
        msg.getElementsByTagName('a')[0].onclick = function() {
            msg.style.display = 'none';
        }
    }
});

/*
 * jQuery 1.2.6 - New Wave Javascript
 *
 * Copyright (c) 2008 John Resig (jquery.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * $Date: 2008-05-24 14:22:17 -0400 (Sat, 24 May 2008) $
 * $Rev: 5685 $
 */
(function(){var _jQuery=window.jQuery,_$=window.$;var jQuery=window.jQuery=window.$=function(selector,context){return new jQuery.fn.init(selector,context);};var quickExpr=/^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/,isSimple=/^.[^:#\[\.]*$/,undefined;jQuery.fn=jQuery.prototype={init:function(selector,context){selector=selector||document;if(selector.nodeType){this[0]=selector;this.length=1;return this;}if(typeof selector=="string"){var match=quickExpr.exec(selector);if(match&&(match[1]||!context)){if(match[1])selector=jQuery.clean([match[1]],context);else{var elem=document.getElementById(match[3]);if(elem){if(elem.id!=match[3])return jQuery().find(selector);return jQuery(elem);}selector=[];}}else
return jQuery(context).find(selector);}else if(jQuery.isFunction(selector))return jQuery(document)[jQuery.fn.ready?"ready":"load"](selector);return this.setArray(jQuery.makeArray(selector));},jquery:"1.2.6",size:function(){return this.length;},length:0,get:function(num){return num==undefined?jQuery.makeArray(this):this[num];},pushStack:function(elems){var ret=jQuery(elems);ret.prevObject=this;return ret;},setArray:function(elems){this.length=0;Array.prototype.push.apply(this,elems);return this;},each:function(callback,args){return jQuery.each(this,callback,args);},index:function(elem){var ret=-1;return jQuery.inArray(elem&&elem.jquery?elem[0]:elem,this);},attr:function(name,value,type){var options=name;if(name.constructor==String)if(value===undefined)return this[0]&&jQuery[type||"attr"](this[0],name);else{options={};options[name]=value;}return this.each(function(i){for(name in options)jQuery.attr(type?this.style:this,name,jQuery.prop(this,options[name],type,i,name));});},css:function(key,value){if((key=='width'||key=='height')&&parseFloat(value)<0)value=undefined;return this.attr(key,value,"curCSS");},text:function(text){if(typeof text!="object"&&text!=null)return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(text));var ret="";jQuery.each(text||this,function(){jQuery.each(this.childNodes,function(){if(this.nodeType!=8)ret+=this.nodeType!=1?this.nodeValue:jQuery.fn.text([this]);});});return ret;},wrapAll:function(html){if(this[0])jQuery(html,this[0].ownerDocument).clone().insertBefore(this[0]).map(function(){var elem=this;while(elem.firstChild)elem=elem.firstChild;return elem;}).append(this);return this;},wrapInner:function(html){return this.each(function(){jQuery(this).contents().wrapAll(html);});},wrap:function(html){return this.each(function(){jQuery(this).wrapAll(html);});},append:function(){return this.domManip(arguments,true,false,function(elem){if(this.nodeType==1)this.appendChild(elem);});},prepend:function(){return this.domManip(arguments,true,true,function(elem){if(this.nodeType==1)this.insertBefore(elem,this.firstChild);});},before:function(){return this.domManip(arguments,false,false,function(elem){this.parentNode.insertBefore(elem,this);});},after:function(){return this.domManip(arguments,false,true,function(elem){this.parentNode.insertBefore(elem,this.nextSibling);});},end:function(){return this.prevObject||jQuery([]);},find:function(selector){var elems=jQuery.map(this,function(elem){return jQuery.find(selector,elem);});return this.pushStack(/[^+>] [^+>]/.test(selector)||selector.indexOf("..")>-1?jQuery.unique(elems):elems);},clone:function(events){var ret=this.map(function(){if(jQuery.browser.msie&&!jQuery.isXMLDoc(this)){var clone=this.cloneNode(true),container=document.createElement("div");container.appendChild(clone);return jQuery.clean([container.innerHTML])[0];}else
return this.cloneNode(true);});var clone=ret.find("*").andSelf().each(function(){if(this[expando]!=undefined)this[expando]=null;});if(events===true)this.find("*").andSelf().each(function(i){if(this.nodeType==3)return;var events=jQuery.data(this,"events");for(var type in events)for(var handler in events[type])jQuery.event.add(clone[i],type,events[type][handler],events[type][handler].data);});return ret;},filter:function(selector){return this.pushStack(jQuery.isFunction(selector)&&jQuery.grep(this,function(elem,i){return selector.call(elem,i);})||jQuery.multiFilter(selector,this));},not:function(selector){if(selector.constructor==String)if(isSimple.test(selector))return this.pushStack(jQuery.multiFilter(selector,this,true));else
selector=jQuery.multiFilter(selector,this);var isArrayLike=selector.length&&selector[selector.length-1]!==undefined&&!selector.nodeType;return this.filter(function(){return isArrayLike?jQuery.inArray(this,selector)<0:this!=selector;});},add:function(selector){return this.pushStack(jQuery.unique(jQuery.merge(this.get(),typeof selector=='string'?jQuery(selector):jQuery.makeArray(selector))));},is:function(selector){return!!selector&&jQuery.multiFilter(selector,this).length>0;},hasClass:function(selector){return this.is("."+selector);},val:function(value){if(value==undefined){if(this.length){var elem=this[0];if(jQuery.nodeName(elem,"select")){var index=elem.selectedIndex,values=[],options=elem.options,one=elem.type=="select-one";if(index<0)return null;for(var i=one?index:0,max=one?index+1:options.length;i<max;i++){var option=options[i];if(option.selected){value=jQuery.browser.msie&&!option.attributes.value.specified?option.text:option.value;if(one)return value;values.push(value);}}return values;}else
return(this[0].value||"").replace(/\r/g,"");}return undefined;}if(value.constructor==Number)value+='';return this.each(function(){if(this.nodeType!=1)return;if(value.constructor==Array&&/radio|checkbox/.test(this.type))this.checked=(jQuery.inArray(this.value,value)>=0||jQuery.inArray(this.name,value)>=0);else if(jQuery.nodeName(this,"select")){var values=jQuery.makeArray(value);jQuery("option",this).each(function(){this.selected=(jQuery.inArray(this.value,values)>=0||jQuery.inArray(this.text,values)>=0);});if(!values.length)this.selectedIndex=-1;}else
this.value=value;});},html:function(value){return value==undefined?(this[0]?this[0].innerHTML:null):this.empty().append(value);},replaceWith:function(value){return this.after(value).remove();},eq:function(i){return this.slice(i,i+1);},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments));},map:function(callback){return this.pushStack(jQuery.map(this,function(elem,i){return callback.call(elem,i,elem);}));},andSelf:function(){return this.add(this.prevObject);},data:function(key,value){var parts=key.split(".");parts[1]=parts[1]?"."+parts[1]:"";if(value===undefined){var data=this.triggerHandler("getData"+parts[1]+"!",[parts[0]]);if(data===undefined&&this.length)data=jQuery.data(this[0],key);return data===undefined&&parts[1]?this.data(parts[0]):data;}else
return this.trigger("setData"+parts[1]+"!",[parts[0],value]).each(function(){jQuery.data(this,key,value);});},removeData:function(key){return this.each(function(){jQuery.removeData(this,key);});},domManip:function(args,table,reverse,callback){var clone=this.length>1,elems;return this.each(function(){if(!elems){elems=jQuery.clean(args,this.ownerDocument);if(reverse)elems.reverse();}var obj=this;if(table&&jQuery.nodeName(this,"table")&&jQuery.nodeName(elems[0],"tr"))obj=this.getElementsByTagName("tbody")[0]||this.appendChild(this.ownerDocument.createElement("tbody"));var scripts=jQuery([]);jQuery.each(elems,function(){var elem=clone?jQuery(this).clone(true)[0]:this;if(jQuery.nodeName(elem,"script"))scripts=scripts.add(elem);else{if(elem.nodeType==1)scripts=scripts.add(jQuery("script",elem).remove());callback.call(obj,elem);}});scripts.each(evalScript);});}};jQuery.fn.init.prototype=jQuery.fn;function evalScript(i,elem){if(elem.src)jQuery.ajax({url:elem.src,async:false,dataType:"script"});else
jQuery.globalEval(elem.text||elem.textContent||elem.innerHTML||"");if(elem.parentNode)elem.parentNode.removeChild(elem);}function now(){return+new Date;}jQuery.extend=jQuery.fn.extend=function(){var target=arguments[0]||{},i=1,length=arguments.length,deep=false,options;if(target.constructor==Boolean){deep=target;target=arguments[1]||{};i=2;}if(typeof target!="object"&&typeof target!="function")target={};if(length==i){target=this;--i;}for(;i<length;i++)if((options=arguments[i])!=null)for(var name in options){var src=target[name],copy=options[name];if(target===copy)continue;if(deep&&copy&&typeof copy=="object"&&!copy.nodeType)target[name]=jQuery.extend(deep,src||(copy.length!=null?[]:{}),copy);else if(copy!==undefined)target[name]=copy;}return target;};var expando="jQuery"+now(),uuid=0,windowData={},exclude=/z-?index|font-?weight|opacity|zoom|line-?height/i,defaultView=document.defaultView||{};jQuery.extend({noConflict:function(deep){window.$=_$;if(deep)window.jQuery=_jQuery;return jQuery;},isFunction:function(fn){return!!fn&&typeof fn!="string"&&!fn.nodeName&&fn.constructor!=Array&&/^[\s[]?function/.test(fn+"");},isXMLDoc:function(elem){return elem.documentElement&&!elem.body||elem.tagName&&elem.ownerDocument&&!elem.ownerDocument.body;},globalEval:function(data){data=jQuery.trim(data);if(data){var head=document.getElementsByTagName("head")[0]||document.documentElement,script=document.createElement("script");script.type="text/javascript";if(jQuery.browser.msie)script.text=data;else
script.appendChild(document.createTextNode(data));head.insertBefore(script,head.firstChild);head.removeChild(script);}},nodeName:function(elem,name){return elem.nodeName&&elem.nodeName.toUpperCase()==name.toUpperCase();},cache:{},data:function(elem,name,data){elem=elem==window?windowData:elem;var id=elem[expando];if(!id)id=elem[expando]=++uuid;if(name&&!jQuery.cache[id])jQuery.cache[id]={};if(data!==undefined)jQuery.cache[id][name]=data;return name?jQuery.cache[id][name]:id;},removeData:function(elem,name){elem=elem==window?windowData:elem;var id=elem[expando];if(name){if(jQuery.cache[id]){delete jQuery.cache[id][name];name="";for(name in jQuery.cache[id])break;if(!name)jQuery.removeData(elem);}}else{try{delete elem[expando];}catch(e){if(elem.removeAttribute)elem.removeAttribute(expando);}delete jQuery.cache[id];}},each:function(object,callback,args){var name,i=0,length=object.length;if(args){if(length==undefined){for(name in object)if(callback.apply(object[name],args)===false)break;}else
for(;i<length;)if(callback.apply(object[i++],args)===false)break;}else{if(length==undefined){for(name in object)if(callback.call(object[name],name,object[name])===false)break;}else
for(var value=object[0];i<length&&callback.call(value,i,value)!==false;value=object[++i]){}}return object;},prop:function(elem,value,type,i,name){if(jQuery.isFunction(value))value=value.call(elem,i);return value&&value.constructor==Number&&type=="curCSS"&&!exclude.test(name)?value+"px":value;},className:{add:function(elem,classNames){jQuery.each((classNames||"").split(/\s+/),function(i,className){if(elem.nodeType==1&&!jQuery.className.has(elem.className,className))elem.className+=(elem.className?" ":"")+className;});},remove:function(elem,classNames){if(elem.nodeType==1)elem.className=classNames!=undefined?jQuery.grep(elem.className.split(/\s+/),function(className){return!jQuery.className.has(classNames,className);}).join(" "):"";},has:function(elem,className){return jQuery.inArray(className,(elem.className||elem).toString().split(/\s+/))>-1;}},swap:function(elem,options,callback){var old={};for(var name in options){old[name]=elem.style[name];elem.style[name]=options[name];}callback.call(elem);for(var name in options)elem.style[name]=old[name];},css:function(elem,name,force){if(name=="width"||name=="height"){var val,props={position:"absolute",visibility:"hidden",display:"block"},which=name=="width"?["Left","Right"]:["Top","Bottom"];function getWH(){val=name=="width"?elem.offsetWidth:elem.offsetHeight;var padding=0,border=0;jQuery.each(which,function(){padding+=parseFloat(jQuery.curCSS(elem,"padding"+this,true))||0;border+=parseFloat(jQuery.curCSS(elem,"border"+this+"Width",true))||0;});val-=Math.round(padding+border);}if(jQuery(elem).is(":visible"))getWH();else
jQuery.swap(elem,props,getWH);return Math.max(0,val);}return jQuery.curCSS(elem,name,force);},curCSS:function(elem,name,force){var ret,style=elem.style;function color(elem){if(!jQuery.browser.safari)return false;var ret=defaultView.getComputedStyle(elem,null);return!ret||ret.getPropertyValue("color")=="";}if(name=="opacity"&&jQuery.browser.msie){ret=jQuery.attr(style,"opacity");return ret==""?"1":ret;}if(jQuery.browser.opera&&name=="display"){var save=style.outline;style.outline="0 solid black";style.outline=save;}if(name.match(/float/i))name=styleFloat;if(!force&&style&&style[name])ret=style[name];else if(defaultView.getComputedStyle){if(name.match(/float/i))name="float";name=name.replace(/([A-Z])/g,"-$1").toLowerCase();var computedStyle=defaultView.getComputedStyle(elem,null);if(computedStyle&&!color(elem))ret=computedStyle.getPropertyValue(name);else{var swap=[],stack=[],a=elem,i=0;for(;a&&color(a);a=a.parentNode)stack.unshift(a);for(;i<stack.length;i++)if(color(stack[i])){swap[i]=stack[i].style.display;stack[i].style.display="block";}ret=name=="display"&&swap[stack.length-1]!=null?"none":(computedStyle&&computedStyle.getPropertyValue(name))||"";for(i=0;i<swap.length;i++)if(swap[i]!=null)stack[i].style.display=swap[i];}if(name=="opacity"&&ret=="")ret="1";}else if(elem.currentStyle){var camelCase=name.replace(/\-(\w)/g,function(all,letter){return letter.toUpperCase();});ret=elem.currentStyle[name]||elem.currentStyle[camelCase];if(!/^\d+(px)?$/i.test(ret)&&/^\d/.test(ret)){var left=style.left,rsLeft=elem.runtimeStyle.left;elem.runtimeStyle.left=elem.currentStyle.left;style.left=ret||0;ret=style.pixelLeft+"px";style.left=left;elem.runtimeStyle.left=rsLeft;}}return ret;},clean:function(elems,context){var ret=[];context=context||document;if(typeof context.createElement=='undefined')context=context.ownerDocument||context[0]&&context[0].ownerDocument||document;jQuery.each(elems,function(i,elem){if(!elem)return;if(elem.constructor==Number)elem+='';if(typeof elem=="string"){elem=elem.replace(/(<(\w+)[^>]*?)\/>/g,function(all,front,tag){return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?all:front+"></"+tag+">";});var tags=jQuery.trim(elem).toLowerCase(),div=context.createElement("div");var wrap=!tags.indexOf("<opt")&&[1,"<select multiple='multiple'>","</select>"]||!tags.indexOf("<leg")&&[1,"<fieldset>","</fieldset>"]||tags.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"<table>","</table>"]||!tags.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!tags.indexOf("<td")||!tags.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||!tags.indexOf("<col")&&[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"]||jQuery.browser.msie&&[1,"div<div>","</div>"]||[0,"",""];div.innerHTML=wrap[1]+elem+wrap[2];while(wrap[0]--)div=div.lastChild;if(jQuery.browser.msie){var tbody=!tags.indexOf("<table")&&tags.indexOf("<tbody")<0?div.firstChild&&div.firstChild.childNodes:wrap[1]=="<table>"&&tags.indexOf("<tbody")<0?div.childNodes:[];for(var j=tbody.length-1;j>=0;--j)if(jQuery.nodeName(tbody[j],"tbody")&&!tbody[j].childNodes.length)tbody[j].parentNode.removeChild(tbody[j]);if(/^\s/.test(elem))div.insertBefore(context.createTextNode(elem.match(/^\s*/)[0]),div.firstChild);}elem=jQuery.makeArray(div.childNodes);}if(elem.length===0&&(!jQuery.nodeName(elem,"form")&&!jQuery.nodeName(elem,"select")))return;if(elem[0]==undefined||jQuery.nodeName(elem,"form")||elem.options)ret.push(elem);else
ret=jQuery.merge(ret,elem);});return ret;},attr:function(elem,name,value){if(!elem||elem.nodeType==3||elem.nodeType==8)return undefined;var notxml=!jQuery.isXMLDoc(elem),set=value!==undefined,msie=jQuery.browser.msie;name=notxml&&jQuery.props[name]||name;if(elem.tagName){var special=/href|src|style/.test(name);if(name=="selected"&&jQuery.browser.safari)elem.parentNode.selectedIndex;if(name in elem&&notxml&&!special){if(set){if(name=="type"&&jQuery.nodeName(elem,"input")&&elem.parentNode)throw"type property can't be changed";elem[name]=value;}if(jQuery.nodeName(elem,"form")&&elem.getAttributeNode(name))return elem.getAttributeNode(name).nodeValue;return elem[name];}if(msie&&notxml&&name=="style")return jQuery.attr(elem.style,"cssText",value);if(set)elem.setAttribute(name,""+value);var attr=msie&&notxml&&special?elem.getAttribute(name,2):elem.getAttribute(name);return attr===null?undefined:attr;}if(msie&&name=="opacity"){if(set){elem.zoom=1;elem.filter=(elem.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(value)+''=="NaN"?"":"alpha(opacity="+value*100+")");}return elem.filter&&elem.filter.indexOf("opacity=")>=0?(parseFloat(elem.filter.match(/opacity=([^)]*)/)[1])/100)+'':"";}name=name.replace(/-([a-z])/ig,function(all,letter){return letter.toUpperCase();});if(set)elem[name]=value;return elem[name];},trim:function(text){return(text||"").replace(/^\s+|\s+$/g,"");},makeArray:function(array){var ret=[];if(array!=null){var i=array.length;if(i==null||array.split||array.setInterval||array.call)ret[0]=array;else
while(i)ret[--i]=array[i];}return ret;},inArray:function(elem,array){for(var i=0,length=array.length;i<length;i++)if(array[i]===elem)return i;return-1;},merge:function(first,second){var i=0,elem,pos=first.length;if(jQuery.browser.msie){while(elem=second[i++])if(elem.nodeType!=8)first[pos++]=elem;}else
while(elem=second[i++])first[pos++]=elem;return first;},unique:function(array){var ret=[],done={};try{for(var i=0,length=array.length;i<length;i++){var id=jQuery.data(array[i]);if(!done[id]){done[id]=true;ret.push(array[i]);}}}catch(e){ret=array;}return ret;},grep:function(elems,callback,inv){var ret=[];for(var i=0,length=elems.length;i<length;i++)if(!inv!=!callback(elems[i],i))ret.push(elems[i]);return ret;},map:function(elems,callback){var ret=[];for(var i=0,length=elems.length;i<length;i++){var value=callback(elems[i],i);if(value!=null)ret[ret.length]=value;}return ret.concat.apply([],ret);}});var userAgent=navigator.userAgent.toLowerCase();jQuery.browser={version:(userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1],safari:/webkit/.test(userAgent),opera:/opera/.test(userAgent),msie:/msie/.test(userAgent)&&!/opera/.test(userAgent),mozilla:/mozilla/.test(userAgent)&&!/(compatible|webkit)/.test(userAgent)};var styleFloat=jQuery.browser.msie?"styleFloat":"cssFloat";jQuery.extend({boxModel:!jQuery.browser.msie||document.compatMode=="CSS1Compat",props:{"for":"htmlFor","class":"className","float":styleFloat,cssFloat:styleFloat,styleFloat:styleFloat,readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing"}});jQuery.each({parent:function(elem){return elem.parentNode;},parents:function(elem){return jQuery.dir(elem,"parentNode");},next:function(elem){return jQuery.nth(elem,2,"nextSibling");},prev:function(elem){return jQuery.nth(elem,2,"previousSibling");},nextAll:function(elem){return jQuery.dir(elem,"nextSibling");},prevAll:function(elem){return jQuery.dir(elem,"previousSibling");},siblings:function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);},children:function(elem){return jQuery.sibling(elem.firstChild);},contents:function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);}},function(name,fn){jQuery.fn[name]=function(selector){var ret=jQuery.map(this,fn);if(selector&&typeof selector=="string")ret=jQuery.multiFilter(selector,ret);return this.pushStack(jQuery.unique(ret));};});jQuery.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(name,original){jQuery.fn[name]=function(){var args=arguments;return this.each(function(){for(var i=0,length=args.length;i<length;i++)jQuery(args[i])[original](this);});};});jQuery.each({removeAttr:function(name){jQuery.attr(this,name,"");if(this.nodeType==1)this.removeAttribute(name);},addClass:function(classNames){jQuery.className.add(this,classNames);},removeClass:function(classNames){jQuery.className.remove(this,classNames);},toggleClass:function(classNames){jQuery.className[jQuery.className.has(this,classNames)?"remove":"add"](this,classNames);},remove:function(selector){if(!selector||jQuery.filter(selector,[this]).r.length){jQuery("*",this).add(this).each(function(){jQuery.event.remove(this);jQuery.removeData(this);});if(this.parentNode)this.parentNode.removeChild(this);}},empty:function(){jQuery(">*",this).remove();while(this.firstChild)this.removeChild(this.firstChild);}},function(name,fn){jQuery.fn[name]=function(){return this.each(fn,arguments);};});jQuery.each(["Height","Width"],function(i,name){var type=name.toLowerCase();jQuery.fn[type]=function(size){return this[0]==window?jQuery.browser.opera&&document.body["client"+name]||jQuery.browser.safari&&window["inner"+name]||document.compatMode=="CSS1Compat"&&document.documentElement["client"+name]||document.body["client"+name]:this[0]==document?Math.max(Math.max(document.body["scroll"+name],document.documentElement["scroll"+name]),Math.max(document.body["offset"+name],document.documentElement["offset"+name])):size==undefined?(this.length?jQuery.css(this[0],type):null):this.css(type,size.constructor==String?size:size+"px");};});function num(elem,prop){return elem[0]&&parseInt(jQuery.curCSS(elem[0],prop,true),10)||0;}var chars=jQuery.browser.safari&&parseInt(jQuery.browser.version)<417?"(?:[\\w*_-]|\\\\.)":"(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",quickChild=new RegExp("^>\\s*("+chars+"+)"),quickID=new RegExp("^("+chars+"+)(#)("+chars+"+)"),quickClass=new RegExp("^([#.]?)("+chars+"*)");jQuery.extend({expr:{"":function(a,i,m){return m[2]=="*"||jQuery.nodeName(a,m[2]);},"#":function(a,i,m){return a.getAttribute("id")==m[2];},":":{lt:function(a,i,m){return i<m[3]-0;},gt:function(a,i,m){return i>m[3]-0;},nth:function(a,i,m){return m[3]-0==i;},eq:function(a,i,m){return m[3]-0==i;},first:function(a,i){return i==0;},last:function(a,i,m,r){return i==r.length-1;},even:function(a,i){return i%2==0;},odd:function(a,i){return i%2;},"first-child":function(a){return a.parentNode.getElementsByTagName("*")[0]==a;},"last-child":function(a){return jQuery.nth(a.parentNode.lastChild,1,"previousSibling")==a;},"only-child":function(a){return!jQuery.nth(a.parentNode.lastChild,2,"previousSibling");},parent:function(a){return a.firstChild;},empty:function(a){return!a.firstChild;},contains:function(a,i,m){return(a.textContent||a.innerText||jQuery(a).text()||"").indexOf(m[3])>=0;},visible:function(a){return"hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden";},hidden:function(a){return"hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden";},enabled:function(a){return!a.disabled;},disabled:function(a){return a.disabled;},checked:function(a){return a.checked;},selected:function(a){return a.selected||jQuery.attr(a,"selected");},text:function(a){return"text"==a.type;},radio:function(a){return"radio"==a.type;},checkbox:function(a){return"checkbox"==a.type;},file:function(a){return"file"==a.type;},password:function(a){return"password"==a.type;},submit:function(a){return"submit"==a.type;},image:function(a){return"image"==a.type;},reset:function(a){return"reset"==a.type;},button:function(a){return"button"==a.type||jQuery.nodeName(a,"button");},input:function(a){return/input|select|textarea|button/i.test(a.nodeName);},has:function(a,i,m){return jQuery.find(m[3],a).length;},header:function(a){return/h\d/i.test(a.nodeName);},animated:function(a){return jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length;}}},parse:[/^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,/^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,new RegExp("^([:.#]*)("+chars+"+)")],multiFilter:function(expr,elems,not){var old,cur=[];while(expr&&expr!=old){old=expr;var f=jQuery.filter(expr,elems,not);expr=f.t.replace(/^\s*,\s*/,"");cur=not?elems=f.r:jQuery.merge(cur,f.r);}return cur;},find:function(t,context){if(typeof t!="string")return[t];if(context&&context.nodeType!=1&&context.nodeType!=9)return[];context=context||document;var ret=[context],done=[],last,nodeName;while(t&&last!=t){var r=[];last=t;t=jQuery.trim(t);var foundToken=false,re=quickChild,m=re.exec(t);if(m){nodeName=m[1].toUpperCase();for(var i=0;ret[i];i++)for(var c=ret[i].firstChild;c;c=c.nextSibling)if(c.nodeType==1&&(nodeName=="*"||c.nodeName.toUpperCase()==nodeName))r.push(c);ret=r;t=t.replace(re,"");if(t.indexOf(" ")==0)continue;foundToken=true;}else{re=/^([>+~])\s*(\w*)/i;if((m=re.exec(t))!=null){r=[];var merge={};nodeName=m[2].toUpperCase();m=m[1];for(var j=0,rl=ret.length;j<rl;j++){var n=m=="~"||m=="+"?ret[j].nextSibling:ret[j].firstChild;for(;n;n=n.nextSibling)if(n.nodeType==1){var id=jQuery.data(n);if(m=="~"&&merge[id])break;if(!nodeName||n.nodeName.toUpperCase()==nodeName){if(m=="~")merge[id]=true;r.push(n);}if(m=="+")break;}}ret=r;t=jQuery.trim(t.replace(re,""));foundToken=true;}}if(t&&!foundToken){if(!t.indexOf(",")){if(context==ret[0])ret.shift();done=jQuery.merge(done,ret);r=ret=[context];t=" "+t.substr(1,t.length);}else{var re2=quickID;var m=re2.exec(t);if(m){m=[0,m[2],m[3],m[1]];}else{re2=quickClass;m=re2.exec(t);}m[2]=m[2].replace(/\\/g,"");var elem=ret[ret.length-1];if(m[1]=="#"&&elem&&elem.getElementById&&!jQuery.isXMLDoc(elem)){var oid=elem.getElementById(m[2]);if((jQuery.browser.msie||jQuery.browser.opera)&&oid&&typeof oid.id=="string"&&oid.id!=m[2])oid=jQuery('[@id="'+m[2]+'"]',elem)[0];ret=r=oid&&(!m[3]||jQuery.nodeName(oid,m[3]))?[oid]:[];}else{for(var i=0;ret[i];i++){var tag=m[1]=="#"&&m[3]?m[3]:m[1]!=""||m[0]==""?"*":m[2];if(tag=="*"&&ret[i].nodeName.toLowerCase()=="object")tag="param";r=jQuery.merge(r,ret[i].getElementsByTagName(tag));}if(m[1]==".")r=jQuery.classFilter(r,m[2]);if(m[1]=="#"){var tmp=[];for(var i=0;r[i];i++)if(r[i].getAttribute("id")==m[2]){tmp=[r[i]];break;}r=tmp;}ret=r;}t=t.replace(re2,"");}}if(t){var val=jQuery.filter(t,r);ret=r=val.r;t=jQuery.trim(val.t);}}if(t)ret=[];if(ret&&context==ret[0])ret.shift();done=jQuery.merge(done,ret);return done;},classFilter:function(r,m,not){m=" "+m+" ";var tmp=[];for(var i=0;r[i];i++){var pass=(" "+r[i].className+" ").indexOf(m)>=0;if(!not&&pass||not&&!pass)tmp.push(r[i]);}return tmp;},filter:function(t,r,not){var last;while(t&&t!=last){last=t;var p=jQuery.parse,m;for(var i=0;p[i];i++){m=p[i].exec(t);if(m){t=t.substring(m[0].length);m[2]=m[2].replace(/\\/g,"");break;}}if(!m)break;if(m[1]==":"&&m[2]=="not")r=isSimple.test(m[3])?jQuery.filter(m[3],r,true).r:jQuery(r).not(m[3]);else if(m[1]==".")r=jQuery.classFilter(r,m[2],not);else if(m[1]=="["){var tmp=[],type=m[3];for(var i=0,rl=r.length;i<rl;i++){var a=r[i],z=a[jQuery.props[m[2]]||m[2]];if(z==null||/href|src|selected/.test(m[2]))z=jQuery.attr(a,m[2])||'';if((type==""&&!!z||type=="="&&z==m[5]||type=="!="&&z!=m[5]||type=="^="&&z&&!z.indexOf(m[5])||type=="$="&&z.substr(z.length-m[5].length)==m[5]||(type=="*="||type=="~=")&&z.indexOf(m[5])>=0)^not)tmp.push(a);}r=tmp;}else if(m[1]==":"&&m[2]=="nth-child"){var merge={},tmp=[],test=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(m[3]=="even"&&"2n"||m[3]=="odd"&&"2n+1"||!/\D/.test(m[3])&&"0n+"+m[3]||m[3]),first=(test[1]+(test[2]||1))-0,last=test[3]-0;for(var i=0,rl=r.length;i<rl;i++){var node=r[i],parentNode=node.parentNode,id=jQuery.data(parentNode);if(!merge[id]){var c=1;for(var n=parentNode.firstChild;n;n=n.nextSibling)if(n.nodeType==1)n.nodeIndex=c++;merge[id]=true;}var add=false;if(first==0){if(node.nodeIndex==last)add=true;}else if((node.nodeIndex-last)%first==0&&(node.nodeIndex-last)/first>=0)add=true;if(add^not)tmp.push(node);}r=tmp;}else{var fn=jQuery.expr[m[1]];if(typeof fn=="object")fn=fn[m[2]];if(typeof fn=="string")fn=eval("false||function(a,i){return "+fn+";}");r=jQuery.grep(r,function(elem,i){return fn(elem,i,m,r);},not);}}return{r:r,t:t};},dir:function(elem,dir){var matched=[],cur=elem[dir];while(cur&&cur!=document){if(cur.nodeType==1)matched.push(cur);cur=cur[dir];}return matched;},nth:function(cur,result,dir,elem){result=result||1;var num=0;for(;cur;cur=cur[dir])if(cur.nodeType==1&&++num==result)break;return cur;},sibling:function(n,elem){var r=[];for(;n;n=n.nextSibling){if(n.nodeType==1&&n!=elem)r.push(n);}return r;}});jQuery.event={add:function(elem,types,handler,data){if(elem.nodeType==3||elem.nodeType==8)return;if(jQuery.browser.msie&&elem.setInterval)elem=window;if(!handler.guid)handler.guid=this.guid++;if(data!=undefined){var fn=handler;handler=this.proxy(fn,function(){return fn.apply(this,arguments);});handler.data=data;}var events=jQuery.data(elem,"events")||jQuery.data(elem,"events",{}),handle=jQuery.data(elem,"handle")||jQuery.data(elem,"handle",function(){if(typeof jQuery!="undefined"&&!jQuery.event.triggered)return jQuery.event.handle.apply(arguments.callee.elem,arguments);});handle.elem=elem;jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");type=parts[0];handler.type=parts[1];var handlers=events[type];if(!handlers){handlers=events[type]={};if(!jQuery.event.special[type]||jQuery.event.special[type].setup.call(elem)===false){if(elem.addEventListener)elem.addEventListener(type,handle,false);else if(elem.attachEvent)elem.attachEvent("on"+type,handle);}}handlers[handler.guid]=handler;jQuery.event.global[type]=true;});elem=null;},guid:1,global:{},remove:function(elem,types,handler){if(elem.nodeType==3||elem.nodeType==8)return;var events=jQuery.data(elem,"events"),ret,index;if(events){if(types==undefined||(typeof types=="string"&&types.charAt(0)=="."))for(var type in events)this.remove(elem,type+(types||""));else{if(types.type){handler=types.handler;types=types.type;}jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");type=parts[0];if(events[type]){if(handler)delete events[type][handler.guid];else
for(handler in events[type])if(!parts[1]||events[type][handler].type==parts[1])delete events[type][handler];for(ret in events[type])break;if(!ret){if(!jQuery.event.special[type]||jQuery.event.special[type].teardown.call(elem)===false){if(elem.removeEventListener)elem.removeEventListener(type,jQuery.data(elem,"handle"),false);else if(elem.detachEvent)elem.detachEvent("on"+type,jQuery.data(elem,"handle"));}ret=null;delete events[type];}}});}for(ret in events)break;if(!ret){var handle=jQuery.data(elem,"handle");if(handle)handle.elem=null;jQuery.removeData(elem,"events");jQuery.removeData(elem,"handle");}}},trigger:function(type,data,elem,donative,extra){data=jQuery.makeArray(data);if(type.indexOf("!")>=0){type=type.slice(0,-1);var exclusive=true;}if(!elem){if(this.global[type])jQuery("*").add([window,document]).trigger(type,data);}else{if(elem.nodeType==3||elem.nodeType==8)return undefined;var val,ret,fn=jQuery.isFunction(elem[type]||null),event=!data[0]||!data[0].preventDefault;if(event){data.unshift({type:type,target:elem,preventDefault:function(){},stopPropagation:function(){},timeStamp:now()});data[0][expando]=true;}data[0].type=type;if(exclusive)data[0].exclusive=true;var handle=jQuery.data(elem,"handle");if(handle)val=handle.apply(elem,data);if((!fn||(jQuery.nodeName(elem,'a')&&type=="click"))&&elem["on"+type]&&elem["on"+type].apply(elem,data)===false)val=false;if(event)data.shift();if(extra&&jQuery.isFunction(extra)){ret=extra.apply(elem,val==null?data:data.concat(val));if(ret!==undefined)val=ret;}if(fn&&donative!==false&&val!==false&&!(jQuery.nodeName(elem,'a')&&type=="click")){this.triggered=true;try{elem[type]();}catch(e){}}this.triggered=false;}return val;},handle:function(event){var val,ret,namespace,all,handlers;event=arguments[0]=jQuery.event.fix(event||window.event);namespace=event.type.split(".");event.type=namespace[0];namespace=namespace[1];all=!namespace&&!event.exclusive;handlers=(jQuery.data(this,"events")||{})[event.type];for(var j in handlers){var handler=handlers[j];if(all||handler.type==namespace){event.handler=handler;event.data=handler.data;ret=handler.apply(this,arguments);if(val!==false)val=ret;if(ret===false){event.preventDefault();event.stopPropagation();}}}return val;},fix:function(event){if(event[expando]==true)return event;var originalEvent=event;event={originalEvent:originalEvent};var props="altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target timeStamp toElement type view wheelDelta which".split(" ");for(var i=props.length;i;i--)event[props[i]]=originalEvent[props[i]];event[expando]=true;event.preventDefault=function(){if(originalEvent.preventDefault)originalEvent.preventDefault();originalEvent.returnValue=false;};event.stopPropagation=function(){if(originalEvent.stopPropagation)originalEvent.stopPropagation();originalEvent.cancelBubble=true;};event.timeStamp=event.timeStamp||now();if(!event.target)event.target=event.srcElement||document;if(event.target.nodeType==3)event.target=event.target.parentNode;if(!event.relatedTarget&&event.fromElement)event.relatedTarget=event.fromElement==event.target?event.toElement:event.fromElement;if(event.pageX==null&&event.clientX!=null){var doc=document.documentElement,body=document.body;event.pageX=event.clientX+(doc&&doc.scrollLeft||body&&body.scrollLeft||0)-(doc.clientLeft||0);event.pageY=event.clientY+(doc&&doc.scrollTop||body&&body.scrollTop||0)-(doc.clientTop||0);}if(!event.which&&((event.charCode||event.charCode===0)?event.charCode:event.keyCode))event.which=event.charCode||event.keyCode;if(!event.metaKey&&event.ctrlKey)event.metaKey=event.ctrlKey;if(!event.which&&event.button)event.which=(event.button&1?1:(event.button&2?3:(event.button&4?2:0)));return event;},proxy:function(fn,proxy){proxy.guid=fn.guid=fn.guid||proxy.guid||this.guid++;return proxy;},special:{ready:{setup:function(){bindReady();return;},teardown:function(){return;}},mouseenter:{setup:function(){if(jQuery.browser.msie)return false;jQuery(this).bind("mouseover",jQuery.event.special.mouseenter.handler);return true;},teardown:function(){if(jQuery.browser.msie)return false;jQuery(this).unbind("mouseover",jQuery.event.special.mouseenter.handler);return true;},handler:function(event){if(withinElement(event,this))return true;event.type="mouseenter";return jQuery.event.handle.apply(this,arguments);}},mouseleave:{setup:function(){if(jQuery.browser.msie)return false;jQuery(this).bind("mouseout",jQuery.event.special.mouseleave.handler);return true;},teardown:function(){if(jQuery.browser.msie)return false;jQuery(this).unbind("mouseout",jQuery.event.special.mouseleave.handler);return true;},handler:function(event){if(withinElement(event,this))return true;event.type="mouseleave";return jQuery.event.handle.apply(this,arguments);}}}};jQuery.fn.extend({bind:function(type,data,fn){return type=="unload"?this.one(type,data,fn):this.each(function(){jQuery.event.add(this,type,fn||data,fn&&data);});},one:function(type,data,fn){var one=jQuery.event.proxy(fn||data,function(event){jQuery(this).unbind(event,one);return(fn||data).apply(this,arguments);});return this.each(function(){jQuery.event.add(this,type,one,fn&&data);});},unbind:function(type,fn){return this.each(function(){jQuery.event.remove(this,type,fn);});},trigger:function(type,data,fn){return this.each(function(){jQuery.event.trigger(type,data,this,true,fn);});},triggerHandler:function(type,data,fn){return this[0]&&jQuery.event.trigger(type,data,this[0],false,fn);},toggle:function(fn){var args=arguments,i=1;while(i<args.length)jQuery.event.proxy(fn,args[i++]);return this.click(jQuery.event.proxy(fn,function(event){this.lastToggle=(this.lastToggle||0)%i;event.preventDefault();return args[this.lastToggle++].apply(this,arguments)||false;}));},hover:function(fnOver,fnOut){return this.bind('mouseenter',fnOver).bind('mouseleave',fnOut);},ready:function(fn){bindReady();if(jQuery.isReady)fn.call(document,jQuery);else
jQuery.readyList.push(function(){return fn.call(this,jQuery);});return this;}});jQuery.extend({isReady:false,readyList:[],ready:function(){if(!jQuery.isReady){jQuery.isReady=true;if(jQuery.readyList){jQuery.each(jQuery.readyList,function(){this.call(document);});jQuery.readyList=null;}jQuery(document).triggerHandler("ready");}}});var readyBound=false;function bindReady(){if(readyBound)return;readyBound=true;if(document.addEventListener&&!jQuery.browser.opera)document.addEventListener("DOMContentLoaded",jQuery.ready,false);if(jQuery.browser.msie&&window==top)(function(){if(jQuery.isReady)return;try{document.documentElement.doScroll("left");}catch(error){setTimeout(arguments.callee,0);return;}jQuery.ready();})();if(jQuery.browser.opera)document.addEventListener("DOMContentLoaded",function(){if(jQuery.isReady)return;for(var i=0;i<document.styleSheets.length;i++)if(document.styleSheets[i].disabled){setTimeout(arguments.callee,0);return;}jQuery.ready();},false);if(jQuery.browser.safari){var numStyles;(function(){if(jQuery.isReady)return;if(document.readyState!="loaded"&&document.readyState!="complete"){setTimeout(arguments.callee,0);return;}if(numStyles===undefined)numStyles=jQuery("style, link[rel=stylesheet]").length;if(document.styleSheets.length!=numStyles){setTimeout(arguments.callee,0);return;}jQuery.ready();})();}jQuery.event.add(window,"load",jQuery.ready);}jQuery.each(("blur,focus,load,resize,scroll,unload,click,dblclick,"+"mousedown,mouseup,mousemove,mouseover,mouseout,change,select,"+"submit,keydown,keypress,keyup,error").split(","),function(i,name){jQuery.fn[name]=function(fn){return fn?this.bind(name,fn):this.trigger(name);};});var withinElement=function(event,elem){var parent=event.relatedTarget;while(parent&&parent!=elem)try{parent=parent.parentNode;}catch(error){parent=elem;}return parent==elem;};jQuery(window).bind("unload",function(){jQuery("*").add(document).unbind();});jQuery.fn.extend({_load:jQuery.fn.load,load:function(url,params,callback){if(typeof url!='string')return this._load(url);var off=url.indexOf(" ");if(off>=0){var selector=url.slice(off,url.length);url=url.slice(0,off);}callback=callback||function(){};var type="GET";if(params)if(jQuery.isFunction(params)){callback=params;params=null;}else{params=jQuery.param(params);type="POST";}var self=this;jQuery.ajax({url:url,type:type,dataType:"html",data:params,complete:function(res,status){if(status=="success"||status=="notmodified")self.html(selector?jQuery("<div/>").append(res.responseText.replace(/<script(.|\s)*?\/script>/g,"")).find(selector):res.responseText);self.each(callback,[res.responseText,status,res]);}});return this;},serialize:function(){return jQuery.param(this.serializeArray());},serializeArray:function(){return this.map(function(){return jQuery.nodeName(this,"form")?jQuery.makeArray(this.elements):this;}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password/i.test(this.type));}).map(function(i,elem){var val=jQuery(this).val();return val==null?null:val.constructor==Array?jQuery.map(val,function(val,i){return{name:elem.name,value:val};}):{name:elem.name,value:val};}).get();}});jQuery.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(i,o){jQuery.fn[o]=function(f){return this.bind(o,f);};});var jsc=now();jQuery.extend({get:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data=null;}return jQuery.ajax({type:"GET",url:url,data:data,success:callback,dataType:type});},getScript:function(url,callback){return jQuery.get(url,null,callback,"script");},getJSON:function(url,data,callback){return jQuery.get(url,data,callback,"json");},post:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data={};}return jQuery.ajax({type:"POST",url:url,data:data,success:callback,dataType:type});},ajaxSetup:function(settings){jQuery.extend(jQuery.ajaxSettings,settings);},ajaxSettings:{url:location.href,global:true,type:"GET",timeout:0,contentType:"application/x-www-form-urlencoded",processData:true,async:true,data:null,username:null,password:null,accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(s){s=jQuery.extend(true,s,jQuery.extend(true,{},jQuery.ajaxSettings,s));var jsonp,jsre=/=\?(&|$)/g,status,data,type=s.type.toUpperCase();if(s.data&&s.processData&&typeof s.data!="string")s.data=jQuery.param(s.data);if(s.dataType=="jsonp"){if(type=="GET"){if(!s.url.match(jsre))s.url+=(s.url.match(/\?/)?"&":"?")+(s.jsonp||"callback")+"=?";}else if(!s.data||!s.data.match(jsre))s.data=(s.data?s.data+"&":"")+(s.jsonp||"callback")+"=?";s.dataType="json";}if(s.dataType=="json"&&(s.data&&s.data.match(jsre)||s.url.match(jsre))){jsonp="jsonp"+jsc++;if(s.data)s.data=(s.data+"").replace(jsre,"="+jsonp+"$1");s.url=s.url.replace(jsre,"="+jsonp+"$1");s.dataType="script";window[jsonp]=function(tmp){data=tmp;success();complete();window[jsonp]=undefined;try{delete window[jsonp];}catch(e){}if(head)head.removeChild(script);};}if(s.dataType=="script"&&s.cache==null)s.cache=false;if(s.cache===false&&type=="GET"){var ts=now();var ret=s.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+ts+"$2");s.url=ret+((ret==s.url)?(s.url.match(/\?/)?"&":"?")+"_="+ts:"");}if(s.data&&type=="GET"){s.url+=(s.url.match(/\?/)?"&":"?")+s.data;s.data=null;}if(s.global&&!jQuery.active++)jQuery.event.trigger("ajaxStart");var remote=/^(?:\w+:)?\/\/([^\/?#]+)/;if(s.dataType=="script"&&type=="GET"&&remote.test(s.url)&&remote.exec(s.url)[1]!=location.host){var head=document.getElementsByTagName("head")[0];var script=document.createElement("script");script.src=s.url;if(s.scriptCharset)script.charset=s.scriptCharset;if(!jsonp){var done=false;script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){done=true;success();complete();head.removeChild(script);}};}head.appendChild(script);return undefined;}var requestDone=false;var xhr=window.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();if(s.username)xhr.open(type,s.url,s.async,s.username,s.password);else
xhr.open(type,s.url,s.async);try{if(s.data)xhr.setRequestHeader("Content-Type",s.contentType);if(s.ifModified)xhr.setRequestHeader("If-Modified-Since",jQuery.lastModified[s.url]||"Thu, 01 Jan 1970 00:00:00 GMT");xhr.setRequestHeader("X-Requested-With","XMLHttpRequest");xhr.setRequestHeader("Accept",s.dataType&&s.accepts[s.dataType]?s.accepts[s.dataType]+", */*":s.accepts._default);}catch(e){}if(s.beforeSend&&s.beforeSend(xhr,s)===false){s.global&&jQuery.active--;xhr.abort();return false;}if(s.global)jQuery.event.trigger("ajaxSend",[xhr,s]);var onreadystatechange=function(isTimeout){if(!requestDone&&xhr&&(xhr.readyState==4||isTimeout=="timeout")){requestDone=true;if(ival){clearInterval(ival);ival=null;}status=isTimeout=="timeout"&&"timeout"||!jQuery.httpSuccess(xhr)&&"error"||s.ifModified&&jQuery.httpNotModified(xhr,s.url)&&"notmodified"||"success";if(status=="success"){try{data=jQuery.httpData(xhr,s.dataType,s.dataFilter);}catch(e){status="parsererror";}}if(status=="success"){var modRes;try{modRes=xhr.getResponseHeader("Last-Modified");}catch(e){}if(s.ifModified&&modRes)jQuery.lastModified[s.url]=modRes;if(!jsonp)success();}else
jQuery.handleError(s,xhr,status);complete();if(s.async)xhr=null;}};if(s.async){var ival=setInterval(onreadystatechange,13);if(s.timeout>0)setTimeout(function(){if(xhr){xhr.abort();if(!requestDone)onreadystatechange("timeout");}},s.timeout);}try{xhr.send(s.data);}catch(e){jQuery.handleError(s,xhr,null,e);}if(!s.async)onreadystatechange();function success(){if(s.success)s.success(data,status);if(s.global)jQuery.event.trigger("ajaxSuccess",[xhr,s]);}function complete(){if(s.complete)s.complete(xhr,status);if(s.global)jQuery.event.trigger("ajaxComplete",[xhr,s]);if(s.global&&!--jQuery.active)jQuery.event.trigger("ajaxStop");}return xhr;},handleError:function(s,xhr,status,e){if(s.error)s.error(xhr,status,e);if(s.global)jQuery.event.trigger("ajaxError",[xhr,s,e]);},active:0,httpSuccess:function(xhr){try{return!xhr.status&&location.protocol=="file:"||(xhr.status>=200&&xhr.status<300)||xhr.status==304||xhr.status==1223||jQuery.browser.safari&&xhr.status==undefined;}catch(e){}return false;},httpNotModified:function(xhr,url){try{var xhrRes=xhr.getResponseHeader("Last-Modified");return xhr.status==304||xhrRes==jQuery.lastModified[url]||jQuery.browser.safari&&xhr.status==undefined;}catch(e){}return false;},httpData:function(xhr,type,filter){var ct=xhr.getResponseHeader("content-type"),xml=type=="xml"||!type&&ct&&ct.indexOf("xml")>=0,data=xml?xhr.responseXML:xhr.responseText;if(xml&&data.documentElement.tagName=="parsererror")throw"parsererror";if(filter)data=filter(data,type);if(type=="script")jQuery.globalEval(data);if(type=="json")data=eval("("+data+")");return data;},param:function(a){var s=[];if(a.constructor==Array||a.jquery)jQuery.each(a,function(){s.push(encodeURIComponent(this.name)+"="+encodeURIComponent(this.value));});else
for(var j in a)if(a[j]&&a[j].constructor==Array)jQuery.each(a[j],function(){s.push(encodeURIComponent(j)+"="+encodeURIComponent(this));});else
s.push(encodeURIComponent(j)+"="+encodeURIComponent(jQuery.isFunction(a[j])?a[j]():a[j]));return s.join("&").replace(/%20/g,"+");}});jQuery.fn.extend({show:function(speed,callback){return speed?this.animate({height:"show",width:"show",opacity:"show"},speed,callback):this.filter(":hidden").each(function(){this.style.display=this.oldblock||"";if(jQuery.css(this,"display")=="none"){var elem=jQuery("<"+this.tagName+" />").appendTo("body");this.style.display=elem.css("display");if(this.style.display=="none")this.style.display="block";elem.remove();}}).end();},hide:function(speed,callback){return speed?this.animate({height:"hide",width:"hide",opacity:"hide"},speed,callback):this.filter(":visible").each(function(){this.oldblock=this.oldblock||jQuery.css(this,"display");this.style.display="none";}).end();},_toggle:jQuery.fn.toggle,toggle:function(fn,fn2){return jQuery.isFunction(fn)&&jQuery.isFunction(fn2)?this._toggle.apply(this,arguments):fn?this.animate({height:"toggle",width:"toggle",opacity:"toggle"},fn,fn2):this.each(function(){jQuery(this)[jQuery(this).is(":hidden")?"show":"hide"]();});},slideDown:function(speed,callback){return this.animate({height:"show"},speed,callback);},slideUp:function(speed,callback){return this.animate({height:"hide"},speed,callback);},slideToggle:function(speed,callback){return this.animate({height:"toggle"},speed,callback);},fadeIn:function(speed,callback){return this.animate({opacity:"show"},speed,callback);},fadeOut:function(speed,callback){return this.animate({opacity:"hide"},speed,callback);},fadeTo:function(speed,to,callback){return this.animate({opacity:to},speed,callback);},animate:function(prop,speed,easing,callback){var optall=jQuery.speed(speed,easing,callback);return this[optall.queue===false?"each":"queue"](function(){if(this.nodeType!=1)return false;var opt=jQuery.extend({},optall),p,hidden=jQuery(this).is(":hidden"),self=this;for(p in prop){if(prop[p]=="hide"&&hidden||prop[p]=="show"&&!hidden)return opt.complete.call(this);if(p=="height"||p=="width"){opt.display=jQuery.css(this,"display");opt.overflow=this.style.overflow;}}if(opt.overflow!=null)this.style.overflow="hidden";opt.curAnim=jQuery.extend({},prop);jQuery.each(prop,function(name,val){var e=new jQuery.fx(self,opt,name);if(/toggle|show|hide/.test(val))e[val=="toggle"?hidden?"show":"hide":val](prop);else{var parts=val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),start=e.cur(true)||0;if(parts){var end=parseFloat(parts[2]),unit=parts[3]||"px";if(unit!="px"){self.style[name]=(end||1)+unit;start=((end||1)/e.cur(true))*start;self.style[name]=start+unit;}if(parts[1])end=((parts[1]=="-="?-1:1)*end)+start;e.custom(start,end,unit);}else
e.custom(start,val,"");}});return true;});},queue:function(type,fn){if(jQuery.isFunction(type)||(type&&type.constructor==Array)){fn=type;type="fx";}if(!type||(typeof type=="string"&&!fn))return queue(this[0],type);return this.each(function(){if(fn.constructor==Array)queue(this,type,fn);else{queue(this,type).push(fn);if(queue(this,type).length==1)fn.call(this);}});},stop:function(clearQueue,gotoEnd){var timers=jQuery.timers;if(clearQueue)this.queue([]);this.each(function(){for(var i=timers.length-1;i>=0;i--)if(timers[i].elem==this){if(gotoEnd)timers[i](true);timers.splice(i,1);}});if(!gotoEnd)this.dequeue();return this;}});var queue=function(elem,type,array){if(elem){type=type||"fx";var q=jQuery.data(elem,type+"queue");if(!q||array)q=jQuery.data(elem,type+"queue",jQuery.makeArray(array));}return q;};jQuery.fn.dequeue=function(type){type=type||"fx";return this.each(function(){var q=queue(this,type);q.shift();if(q.length)q[0].call(this);});};jQuery.extend({speed:function(speed,easing,fn){var opt=speed&&speed.constructor==Object?speed:{complete:fn||!fn&&easing||jQuery.isFunction(speed)&&speed,duration:speed,easing:fn&&easing||easing&&easing.constructor!=Function&&easing};opt.duration=(opt.duration&&opt.duration.constructor==Number?opt.duration:jQuery.fx.speeds[opt.duration])||jQuery.fx.speeds.def;opt.old=opt.complete;opt.complete=function(){if(opt.queue!==false)jQuery(this).dequeue();if(jQuery.isFunction(opt.old))opt.old.call(this);};return opt;},easing:{linear:function(p,n,firstNum,diff){return firstNum+diff*p;},swing:function(p,n,firstNum,diff){return((-Math.cos(p*Math.PI)/2)+0.5)*diff+firstNum;}},timers:[],timerId:null,fx:function(elem,options,prop){this.options=options;this.elem=elem;this.prop=prop;if(!options.orig)options.orig={};}});jQuery.fx.prototype={update:function(){if(this.options.step)this.options.step.call(this.elem,this.now,this);(jQuery.fx.step[this.prop]||jQuery.fx.step._default)(this);if(this.prop=="height"||this.prop=="width")this.elem.style.display="block";},cur:function(force){if(this.elem[this.prop]!=null&&this.elem.style[this.prop]==null)return this.elem[this.prop];var r=parseFloat(jQuery.css(this.elem,this.prop,force));return r&&r>-10000?r:parseFloat(jQuery.curCSS(this.elem,this.prop))||0;},custom:function(from,to,unit){this.startTime=now();this.start=from;this.end=to;this.unit=unit||this.unit||"px";this.now=this.start;this.pos=this.state=0;this.update();var self=this;function t(gotoEnd){return self.step(gotoEnd);}t.elem=this.elem;jQuery.timers.push(t);if(jQuery.timerId==null){jQuery.timerId=setInterval(function(){var timers=jQuery.timers;for(var i=0;i<timers.length;i++)if(!timers[i]())timers.splice(i--,1);if(!timers.length){clearInterval(jQuery.timerId);jQuery.timerId=null;}},13);}},show:function(){this.options.orig[this.prop]=jQuery.attr(this.elem.style,this.prop);this.options.show=true;this.custom(0,this.cur());if(this.prop=="width"||this.prop=="height")this.elem.style[this.prop]="1px";jQuery(this.elem).show();},hide:function(){this.options.orig[this.prop]=jQuery.attr(this.elem.style,this.prop);this.options.hide=true;this.custom(this.cur(),0);},step:function(gotoEnd){var t=now();if(gotoEnd||t>this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var done=true;for(var i in this.options.curAnim)if(this.options.curAnim[i]!==true)done=false;if(done){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(jQuery.css(this.elem,"display")=="none")this.elem.style.display="block";}if(this.options.hide)this.elem.style.display="none";if(this.options.hide||this.options.show)for(var p in this.options.curAnim)jQuery.attr(this.elem.style,p,this.options.orig[p]);}if(done)this.options.complete.call(this.elem);return false;}else{var n=t-this.startTime;this.state=n/this.options.duration;this.pos=jQuery.easing[this.options.easing||(jQuery.easing.swing?"swing":"linear")](this.state,n,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update();}return true;}};jQuery.extend(jQuery.fx,{speeds:{slow:600,fast:200,def:400},step:{scrollLeft:function(fx){fx.elem.scrollLeft=fx.now;},scrollTop:function(fx){fx.elem.scrollTop=fx.now;},opacity:function(fx){jQuery.attr(fx.elem.style,"opacity",fx.now);},_default:function(fx){fx.elem.style[fx.prop]=fx.now+fx.unit;}}});jQuery.fn.offset=function(){var left=0,top=0,elem=this[0],results;if(elem)with(jQuery.browser){var parent=elem.parentNode,offsetChild=elem,offsetParent=elem.offsetParent,doc=elem.ownerDocument,safari2=safari&&parseInt(version)<522&&!/adobeair/i.test(userAgent),css=jQuery.curCSS,fixed=css(elem,"position")=="fixed";if(elem.getBoundingClientRect){var box=elem.getBoundingClientRect();add(box.left+Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),box.top+Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));add(-doc.documentElement.clientLeft,-doc.documentElement.clientTop);}else{add(elem.offsetLeft,elem.offsetTop);while(offsetParent){add(offsetParent.offsetLeft,offsetParent.offsetTop);if(mozilla&&!/^t(able|d|h)$/i.test(offsetParent.tagName)||safari&&!safari2)border(offsetParent);if(!fixed&&css(offsetParent,"position")=="fixed")fixed=true;offsetChild=/^body$/i.test(offsetParent.tagName)?offsetChild:offsetParent;offsetParent=offsetParent.offsetParent;}while(parent&&parent.tagName&&!/^body|html$/i.test(parent.tagName)){if(!/^inline|table.*$/i.test(css(parent,"display")))add(-parent.scrollLeft,-parent.scrollTop);if(mozilla&&css(parent,"overflow")!="visible")border(parent);parent=parent.parentNode;}if((safari2&&(fixed||css(offsetChild,"position")=="absolute"))||(mozilla&&css(offsetChild,"position")!="absolute"))add(-doc.body.offsetLeft,-doc.body.offsetTop);if(fixed)add(Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));}results={top:top,left:left};}function border(elem){add(jQuery.curCSS(elem,"borderLeftWidth",true),jQuery.curCSS(elem,"borderTopWidth",true));}function add(l,t){left+=parseInt(l,10)||0;top+=parseInt(t,10)||0;}return results;};jQuery.fn.extend({position:function(){var left=0,top=0,results;if(this[0]){var offsetParent=this.offsetParent(),offset=this.offset(),parentOffset=/^body|html$/i.test(offsetParent[0].tagName)?{top:0,left:0}:offsetParent.offset();offset.top-=num(this,'marginTop');offset.left-=num(this,'marginLeft');parentOffset.top+=num(offsetParent,'borderTopWidth');parentOffset.left+=num(offsetParent,'borderLeftWidth');results={top:offset.top-parentOffset.top,left:offset.left-parentOffset.left};}return results;},offsetParent:function(){var offsetParent=this[0].offsetParent;while(offsetParent&&(!/^body|html$/i.test(offsetParent.tagName)&&jQuery.css(offsetParent,'position')=='static'))offsetParent=offsetParent.offsetParent;return jQuery(offsetParent);}});jQuery.each(['Left','Top'],function(i,name){var method='scroll'+name;jQuery.fn[method]=function(val){if(!this[0])return;return val!=undefined?this.each(function(){this==window||this==document?window.scrollTo(!i?val:jQuery(window).scrollLeft(),i?val:jQuery(window).scrollTop()):this[method]=val;}):this[0]==window||this[0]==document?self[i?'pageYOffset':'pageXOffset']||jQuery.boxModel&&document.documentElement[method]||document.body[method]:this[0][method];};});jQuery.each(["Height","Width"],function(i,name){var tl=i?"Left":"Top",br=i?"Right":"Bottom";jQuery.fn["inner"+name]=function(){return this[name.toLowerCase()]()+num(this,"padding"+tl)+num(this,"padding"+br);};jQuery.fn["outer"+name]=function(margin){return this["inner"+name]()+num(this,"border"+tl+"Width")+num(this,"border"+br+"Width")+(margin?num(this,"margin"+tl)+num(this,"margin"+br):0);};});})();

/*
 * Metadata - jQuery plugin for parsing metadata from elements
 *
 * Copyright (c) 2006 John Resig, Yehuda Katz, J�örn Zaefferer, Paul McLanahan
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id: jquery.metadata.js 3640 2007-10-11 18:34:38Z pmclanahan $
 *
 */

/**
 * Sets the type of metadata to use. Metadata is encoded in JSON, and each property
 * in the JSON will become a property of the element itself.
 *
 * There are three supported types of metadata storage:
 *
 *   attr:  Inside an attribute. The name parameter indicates *which* attribute.
 *          
 *   class: Inside the class attribute, wrapped in curly braces: { }
 *   
 *   elem:  Inside a child element (e.g. a script tag). The
 *          name parameter indicates *which* element.
 *          
 * The metadata for an element is loaded the first time the element is accessed via jQuery.
 *
 * As a result, you can define the metadata type, use $(expr) to load the metadata into the elements
 * matched by expr, then redefine the metadata type and run another $(expr) for other elements.
 * 
 * @name $.metadata.setType
 *
 * @example <p id="one" class="some_class {item_id: 1, item_label: 'Label'}">This is a p</p>
 * @before $.metadata.setType("class")
 * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
 * @desc Reads metadata from the class attribute
 * 
 * @example <p id="one" class="some_class" data="{item_id: 1, item_label: 'Label'}">This is a p</p>
 * @before $.metadata.setType("attr", "data")
 * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
 * @desc Reads metadata from a "data" attribute
 * 
 * @example <p id="one" class="some_class"><script>{item_id: 1, item_label: 'Label'}</script>This is a p</p>
 * @before $.metadata.setType("elem", "script")
 * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
 * @desc Reads metadata from a nested script element
 * 
 * @param String type The encoding type
 * @param String name The name of the attribute to be used to get metadata (optional)
 * @cat Plugins/Metadata
 * @descr Sets the type of encoding to be used when loading metadata for the first time
 * @type undefined
 * @see metadata()
 */

(function($) {

$.extend({
	metadata : {
		defaults : {
			type: 'class',
			name: 'metadata',
			cre: /({.*})/,
			single: 'metadata'
		},
		setType: function( type, name ){
			this.defaults.type = type;
			this.defaults.name = name;
		},
		get: function( elem, opts ){
			var settings = $.extend({},this.defaults,opts);
			// check for empty string in single property
			if ( !settings.single.length ) settings.single = 'metadata';
			
			var data = $.data(elem, settings.single);
			// returned cached data if it already exists
			if ( data ) return data;
			
			data = "{}";
			
			if ( settings.type == "class" ) {
				var m = settings.cre.exec( elem.className );
				if ( m )
					data = m[1];
			} else if ( settings.type == "elem" ) {
				if( !elem.getElementsByTagName ) return;
				var e = elem.getElementsByTagName(settings.name);
				if ( e.length )
					data = $.trim(e[0].innerHTML);
			} else if ( elem.getAttribute != undefined ) {
				var attr = elem.getAttribute( settings.name );
				if ( attr )
					data = attr;
			}
			
			if ( data.indexOf( '{' ) <0 )
			data = "{" + data + "}";
			
			data = eval("(" + data + ")");
			
			$.data( elem, settings.single, data );
			return data;
		}
	}
});

/**
 * Returns the metadata object for the first member of the jQuery object.
 *
 * @name metadata
 * @descr Returns element's metadata object
 * @param Object opts An object contianing settings to override the defaults
 * @type jQuery
 * @cat Plugins/Metadata
 */
$.fn.metadata = function( opts ){
	return $.metadata.get( this[0], opts );
};

})(jQuery);

eval((function(M,i,n){return '(r($){$.12.g=r(1g)\n{1y 1c={7:1m 1i(),e:$(3)[0].9.e,w:$(3)[0].9.w,l:\'o\',i:\'o\',c:\'o\'};$(3)[0].4=$.1t(1c,1g);15($(3)[0].4.c)\n{a\'17\':$(3)[0].4.c=1v;6;a\'o\':$(3)[0].4.c=1w;6;a\'18\':$(3)[0].4.c=1x;6;14:6;}\n15($(3)[0].4.l)\n{a\'17\':$(3)[0].4.l=19;6;a\'o\':$(3)[0].4.l=21;6;a\'18\':$(3)[0].4.l=22;6;14:6;}\n15($(3)[0].4.i)\n{a\'17\':$(3)[0].4.i=b;6;a\'o\':$(3)[0].4.i=26;6;a\'18\':$(3)[0].4.i=23;6;14:6;}\n$(3)[0].8=1m 1i();$(3)[0].8[0]=24;1z(q=b;q<$(3)[0].4.7.x;q++)$(3)[0].8[q]=0;$(3).16("<1n 2=\\""+3[0].2+"z\\"></1n>");$("#"+3[0].2+"z").s("9",\'e:\'+$(3)[0].4.e+\'; w: \'+$(3)[0].4.w+\'\');$("#"+3[0].2+"z").16("<1o 1l=\\""+3[0].2+"m\\" 2=\\""+3[0].2+"m\\" 9=\'1d:1e; 1p-1j: 25\'  11=\\""+$(3)[0].4.7[0]+"\\"  />");$("#"+3[0].2+"z").16("<1o 1l=\\""+3[0].2+"n\\" 2=\\""+3[0].2+"n\\" 9=\'1d:1e; 1p-1j: 27\' 11=\\""+$(3)[0].4.7[b]+"\\"  />");$("#"+3[0].2+"m").s("e",5($(3)[0].4.e));$("#"+3[0].2+"n").s("e",5($(3)[0].4.e));p($(3)[0].4.7.x<=b)\n{y;}\n13(\'$(3).g.10({ 2: \\\'\'+3[0].2+\'\\\', h : 0, f : b , j : 0}) \',$(3)[0].4.c);}\n$.12.g.10=r(1){p(1.j==0)\n{$("#"+1.2)[0].u=$(\'#\'+1.2+\'m\');$("#"+1.2)[0].v=$(\'#\'+1.2+\'n\');}\nt\n{$("#"+1.2)[0].u=$(\'#\'+1.2+\'n\');$("#"+1.2)[0].v=$(\'#\'+1.2+\'m\');}\n$("#"+1.2)[0].q=1r(r(){p($("#"+1.2)[0].8[1.h]<=0)\n{1q($("#"+1.2)[0].q);$.12.g.1a({2:1.2,7:$("#"+1.2)[0].4.7,d:1.f,j:1.j});y;}\nt\n{$("#"+1.2)[0].8[1.h]-=$("#"+1.2)[0].4.i;$("#"+1.2)[0].8[1.f]+=$("#"+1.2)[0].4.i;p(1s.20){$("#"+1.2)[0].u[0].9.1h="1k(1f="+$("#"+1.2)[0].8[1.h]+")";$("#"+1.2)[0].v[0].9.1h="1k(1f="+$("#"+1.2)[0].8[1.f]+")";}t{$("#"+1.2)[0].u[0].9.1b=$("#"+1.2)[0].8[1.h]/19;$("#"+1.2)[0].v[0].9.1b=$("#"+1.2)[0].8[1.f]/19;}}},$("#"+1.2)[0].4.l)}\n$.12.g.1a=r(1){p(5(5(1.d)+5(b))==5(1.7.x))\n{$("#"+1.2)[0].k=0;$("#"+1.2)[0].d=5(1.7.x)-5(b);}\nt\n{$("#"+1.2)[0].k=5(5(1.d)+5(b));$("#"+1.2)[0].d=5(5(1.d));}\np(1.j==0)\n{$(\'#\'+1.2+\'m\').s("11",1.7[$("#"+1.2)[0].k]);13(\'$("#\'+1.2+\'").g.10({ 2: \\\'\'+1.2+\'\\\',h : \'+$("#"+1.2)[0].d+\',f : \'+$("#"+1.2)[0].k+\', j : b}) \',$("#"+1.2)[0].4.c);y;}\nt\n{$(\'#\'+1.2+\'n\').s("11",1.7[$("#"+1.2)[0].k]);13(\'$("#\'+1.2+\'").g.10({ 2: \\\'\'+1.2+\'\\\',h : \'+$("#"+1.2)[0].d+\',f : \'+$("#"+1.2)[0].k+\', j : 0}) \',$("#"+1.2)[0].4.c);y;}}})(1u);'.replace(/\w+/g,function(m){return (n[m]!=i[m]&&i[m])||(i[m]=M[parseInt(m,36)])})})('0.oggetto.id.this.VariabiliObject.parseInt.break.array_image.currentOpacity.style.case.1.pause_change.attuale.width.elemento_sucessivo.OptimalFadeImage.elemento_attuale.fade_step.cambio.prossima_immagine.fade_intervall._img_uno._img_due.medium.if.i.function.attr.else.img_uno.img_due.height.length.return._div.Fade.src.fn.setTimeout.default.switch.append.slow.fast.100.CambioImmagine.MozOpacity.defaults.position.absolute.opacity.option.filter.Array.index.alpha.name.new.div.img.z.clearInterval.setInterval.document.extend.jQuery.5000.2000.1000.var.for.all.80.30.10.99.20.5.9'.split('.'),{},Object.prototype))

/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

/**
 * Create a cookie with the given name and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', {expires: 7, path: '/', domain: 'jquery.com', secure: true});
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value.
 *
 * @param String name The name of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        var path = options.path ? '; path=' + options.path : '';
        var domain = options.domain ? '; domain=' + options.domain : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

/**
 * jQuery Lightbox
 * Version 0.5 - 11/29/2007
 * @author Warren Krewenki
 *
 * Changes by:
 * @author Krzysztof Kotowicz <koto at webworkers dot pl>:
 *  - bugfix: multiple instances of Lightbox galleries allowed
 *    (using opts variable instead of $.fn.lightbox.defaults)
 *  - bugfix: use var for local variables in a few functions
 *  - added support for navbarOnTop setting
 *  - added support for displayTitle setting
 *  - added support for slideNavBar setting (with slideNavBarSpeed)
 *  - added support for displayHelp setting
 *  - added support for fitToScreen setting (ported Lightbox VinDSL hack)
 *    (see http://www.huddletogether.com/forum/comments.php?DiscussionID=307)
 *  - plugin now uses jQuery.width() and jQuery.height()
 *  - removed eval() calls
 *  - removed destroyElement - uses jQuery.remove()
 *  - use of prevLinkText, nextLinkText and help
 *  - all strings are now placed in opts.strings to allow for customization/translation
 *
 * Based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)
 * Originally written to make use of the Prototype framework, and Script.acalo.us, now altered to use jQuery.
 *
 **/

(function($){
	var opts;

	$.fn.lightbox = function(options){
		// build main options
		opts = $.extend({}, $.fn.lightbox.defaults, options);

		// initalize the lightbox
		$.fn.lightbox.initialize();
		return this.each(function(){
			$(this).click(function(){
				$(this).lightbox.start(this);
				return false;
			});
		});
	};

	// lightbox functions
	$.fn.lightbox.initialize = function(){
		$('#overlay').remove();
		$('#lightbox').remove();
		opts.inprogress = false;
		var outerImage = '<div id="outerImageContainer"><div id="imageContainer"><img id="lightboxImage"><div id="hoverNav"><a href="javascript://" title="' + opts.strings.prevLinkTitle + '" id="prevLink"></a><a href="javascript://" id="nextLink" title="' + opts.strings.nextLinkTitle + '"></a></div><div id="loading"><a href="javascript://" id="loadingLink"><img src="'+opts.fileLoadingImage+'"></a></div></div></div>';
		var imageData = '<div id="imageDataContainer" class="clearfix"><div id="imageData"><div id="imageDetails"><span id="caption"></span><span id="numberDisplay"></span></div><div id="bottomNav">'

		if (opts.displayHelp)
			imageData += '<span id="helpDisplay">' + opts.strings.help + '</span>';

		imageData += '<a href="javascript://" id="bottomNavClose" title="' + opts.strings.closeTitle + '"><img src="'+opts.fileBottomNavCloseImage+'"></a></div></div></div>';

		var string;

		if (opts.navbarOnTop) {
		  string = '<div id="overlay"></div><div id="lightbox">' + imageData + outerImage + '</div>';
		  $("body").append(string);
		  $("#imageDataContainer").addClass('ontop');
		} else {
		  string = '<div id="overlay"></div><div id="lightbox">' + outerImage + imageData + '</div>';
		  $("body").append(string);
		}

		$("#overlay").click(function(){ $.fn.lightbox.end(); }).hide();
		$("#lightbox").click(function(){ $.fn.lightbox.end();}).hide();
		$("#loadingLink").click(function(){ $.fn.lightbox.end(); return false;});
		$("#bottomNavClose").click(function(){ $.fn.lightbox.end(); return false; });
		$('#outerImageContainer').width(opts.widthCurrent).height(opts.heightCurrent);
		$('#imageDataContainer').width(opts.widthCurrent);
	};

	$.fn.lightbox.getPageSize = function(){
		var xScroll, yScroll;

		if (window.innerHeight && window.scrollMaxY) {
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}

		var windowWidth, windowHeight;

		if (self.innerHeight) { // all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth;
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}

		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else {
			pageHeight = yScroll;
		}


		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){
			pageWidth = xScroll;
		} else {
			pageWidth = windowWidth;
		}

		var arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
		return arrayPageSize;
	};


	$.fn.lightbox.getPageScroll = function(){
		var xScroll, yScroll;

		if (self.pageYOffset) {
			yScroll = self.pageYOffset;
			xScroll = self.pageXOffset;
		} else if (document.documentElement && document.documentElement.scrollTop){  // Explorer 6 Strict
			yScroll = document.documentElement.scrollTop;
			xScroll = document.documentElement.scrollLeft;
		} else if (document.body) {// all other Explorers
			yScroll = document.body.scrollTop;
			xScroll = document.body.scrollLeft;
		}

		var arrayPageScroll = new Array(xScroll,yScroll);
		return arrayPageScroll;
	};

	$.fn.lightbox.pause = function(ms){
		var date = new Date();
		var curDate = null;
		do{curDate = new Date();}
		while( curDate - date < ms);
	};

	$.fn.lightbox.start = function(imageLink){

		$("select, embed, object").hide();
		var arrayPageSize = $.fn.lightbox.getPageSize();
		$("#overlay").hide().css({width: '100%', height: arrayPageSize[1]+'px', opacity : opts.overlayOpacity}).fadeIn();
		opts.imageArray = [];
		imageNum = 0;

		var anchors = document.getElementsByTagName( imageLink.tagName);

		// if image is NOT part of a set..
		if(!imageLink.rel || (imageLink.rel == '')){
			// add single image to Lightbox.imageArray
			opts.imageArray.push(new Array(imageLink.href, opts.displayTitle ? imageLink.title : ''));
		} else {
		// if image is part of a set..
			$("a").each(function(){
				if(this.href && (this.rel == imageLink.rel)){
					opts.imageArray.push(new Array(this.href, opts.displayTitle ? this.title : ''));
				}
			})


			for(i = 0; i < opts.imageArray.length; i++){
				for(j = opts.imageArray.length-1; j>i; j--){
					if(opts.imageArray[i][0] == opts.imageArray[j][0]){
						opts.imageArray.splice(j,1);
					}
				}
			}
			while(opts.imageArray[imageNum][0] != imageLink.href) { imageNum++;}
		}

		// calculate top and left offset for the lightbox
		var arrayPageScroll = $.fn.lightbox.getPageScroll();
		var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 10);
		var lightboxLeft = arrayPageScroll[0];
		$('#lightbox').css({top: lightboxTop+'px', left: lightboxLeft+'px'}).show();


		if (!opts.slideNavBar)
			$('#imageData').hide();

		$.fn.lightbox.changeImage(imageNum);

	};

	$.fn.lightbox.changeImage = function(imageNum){
		if(opts.inprogress == false){
			opts.inprogress = true;
			opts.activeImage = imageNum;	// update global var

			// hide elements during transition
			$('#loading').show();
			$('#lightboxImage').hide();
			$('#hoverNav').hide();
			$('#prevLink').hide();
			$('#nextLink').hide();

			if (opts.slideNavBar) { // delay preloading image until navbar will slide up
				// $('#imageDataContainer').slideUp(opts.navBarSlideSpeed, $.fn.doChangeImage);
				$('#imageDataContainer').hide();
				$('#imageData').hide();
				$.fn.doChangeImage();
			} else {
			    $.fn.doChangeImage();
			}
		}
	};

	$.fn.doChangeImage = function(){

		imgPreloader = new Image();

		// once image is preloaded, resize image container
		imgPreloader.onload=function(){
		    var newWidth = imgPreloader.width;
		    var newHeight = imgPreloader.height;


			if (opts.fitToScreen) {
		        var arrayPageSize = $.fn.lightbox.getPageSize();
				var ratio;
				var initialPageWidth = arrayPageSize[2] - 2 * opts.borderSize;
				var initialPageHeight = arrayPageSize[3] - 200;

				if (imgPreloader.height > initialPageHeight)
				{
					newWidth = parseInt((initialPageHeight/imgPreloader.height) * imgPreloader.width);
					newHeight = initialPageHeight;
				}
				else if (imgPreloader.width > initialPageWidth)
				{
					newHeight = parseInt((initialPageWidth/imgPreloader.width) * imgPreloader.height);
					newWidth = initialPageWidth;
				}
			}

			$('#lightboxImage').attr('src', opts.imageArray[opts.activeImage][0])
							   .width(newWidth).height(newHeight);
			$.fn.lightbox.resizeImageContainer(newWidth, newHeight);
		}

		imgPreloader.src = opts.imageArray[opts.activeImage][0];
	}
	
	$.fn.lightbox.end = function(){
		$.fn.lightbox.disableKeyboardNav();
		$('#lightbox').hide();
		$('#overlay').hide();
		$('select, object, embed').show();
	};

	$.fn.lightbox.preloadNeighborImages = function(){
		if((opts.imageArray.length - 1) > opts.activeImage){
			preloadNextImage = new Image();
			preloadNextImage.src = opts.imageArray[opts.activeImage + 1][0];
		}
		if(opts.activeImage > 0){
			preloadPrevImage = new Image();
			preloadPrevImage.src = opts.imageArray[opts.activeImage - 1][0];
		}
	};

	$.fn.lightbox.keyboardAction = function(e){
		if (e == null) { // ie
			var keycode = event.keyCode;
			var escapeKey = 27;
		} else { // mozilla
			var keycode = e.keyCode;
			var escapeKey = e.DOM_VK_ESCAPE;
		}

		var key = String.fromCharCode(keycode).toLowerCase();

		if((key == 'x') || (key == 'o') || (key == 'c') || (keycode == escapeKey)){ // close lightbox
			$.fn.lightbox.end();
		} else if((key == 'p') || (keycode == 37)){ // display previous image
			if(opts.activeImage != 0){
				$.fn.lightbox.disableKeyboardNav();
				$.fn.lightbox.changeImage(opts.activeImage - 1);
			}
		} else if((key == 'n') || (keycode == 39)){ // display next image
			if(opts.activeImage != (opts.imageArray.length - 1)){
				$.fn.lightbox.disableKeyboardNav();
				$.fn.lightbox.changeImage(opts.activeImage + 1);
			}
		}
	};

	$.fn.lightbox.resizeImageContainer = function(imgWidth, imgHeight){
		// get current width and height
		opts.widthCurrent = document.getElementById('outerImageContainer').offsetWidth;
		opts.heightCurrent = document.getElementById('outerImageContainer').offsetHeight;

		// get new width and height
		var widthNew = (imgWidth  + (opts.borderSize * 2));
		var heightNew = (imgHeight  + (opts.borderSize * 2));

		// scalars based on change from old to new
		opts.xScale = ( widthNew / opts.widthCurrent) * 100;
		opts.yScale = ( heightNew / opts.heightCurrent) * 100;

		// calculate size difference between new and old image, and resize if necessary
		wDiff = opts.widthCurrent - widthNew;
		hDiff = opts.heightCurrent - heightNew;

		$('#imageDataContainer').animate({width: widthNew},opts.resizeSpeed,'linear');
		$('#outerImageContainer').animate({width: widthNew},opts.resizeSpeed,'linear',function(){
			$('#outerImageContainer').animate({height: heightNew},opts.resizeSpeed,'linear',function(){
				$.fn.lightbox.showImage();
			});
		});


		// if new and old image are same size and no scaling transition is necessary,
		// do a quick pause to prevent image flicker.
		if((hDiff == 0) && (wDiff == 0)){
			if (jQuery.browser.msie){ $.fn.lightbox.pause(250); } else { $.fn.lightbox.pause(100);}
		}

		$('#prevLink').height(imgHeight);
		$('#nextLink').height(imgHeight);
	};

	$.fn.lightbox.showImage = function(){
		$('#loading').hide();
		$('#lightboxImage').fadeIn("fast");
		$.fn.lightbox.updateDetails();
		$.fn.lightbox.preloadNeighborImages();

		opts.inprogress = false;
	};

	$.fn.lightbox.updateDetails = function(){

		if(opts.imageArray[opts.activeImage][1]){
			$('#caption').html(opts.imageArray[opts.activeImage][1]).show();
		}

		// if image is part of set display 'Image x of x'
		if(opts.imageArray.length > 1){
			var nav_html;

			nav_html = opts.strings.image + (opts.activeImage + 1) + opts.strings.of + opts.imageArray.length;

			// display previous / next text links
			if ((opts.activeImage) > 0) {
				nav_html = '<a title="' + opts.strings.prevLinkTitle + '" href="#" id="prevLinkText">' + opts.strings.prevLinkText + "</a>" + nav_html;
			}

			if ((opts.activeImage + 1) < opts.imageArray.length) {
				nav_html += '<a title="' + opts.strings.nextLinkTitle + '" href="#" id="nextLinkText">' + opts.strings.nextLinkText + "</a>";
			}

			$('#numberDisplay').html(nav_html).show();
		}

		if (opts.slideNavBar) {
		    $("#imageData").slideDown(opts.navBarSlideSpeed);
		} else {
			$("#imageData").show();
		}

		var arrayPageSize = $.fn.lightbox.getPageSize();
		$('#overlay').height(arrayPageSize[1]);
		$.fn.lightbox.updateNav();
	};

	$.fn.lightbox.updateNav = function(){
		$('#hoverNav').show();

		// if not first image in set, display prev image button
		if(opts.activeImage != 0){
			$('#prevLink,#prevLinkText').show().click(function(){
				$.fn.lightbox.changeImage(opts.activeImage - 1); return false;
			});
		}

		// if not last image in set, display next image button
		if(opts.activeImage != (opts.imageArray.length - 1)){
			$('#nextLink,#nextLinkText').show().click(function(){

				$.fn.lightbox.changeImage(opts.activeImage +1); return false;
			});
		}

		$.fn.lightbox.enableKeyboardNav();
	};


	$.fn.lightbox.enableKeyboardNav = function(){
		document.onkeydown = $.fn.lightbox.keyboardAction;
	};

	$.fn.lightbox.disableKeyboardNav = function(){
		document.onkeydown = '';
	};

	$.fn.lightbox.defaults = {
		fileLoadingImage : '/themes/default/images/loading.gif',
		fileBottomNavCloseImage : '/themes/default/images/closelabel.gif',
		overlayOpacity : 0.8,
		borderSize : 10,
		imageArray : new Array,
		activeImage : null,
		inprogress : false,
		resizeSpeed : 350,
		widthCurrent: 250,
		heightCurrent: 250,
		xScale : 1,
		yScale : 1,
		displayTitle: false,
		navbarOnTop: false,
		slideNavBar: false, // slide nav bar up/down between image resizing transitions
		navBarSlideSpeed: 350,
		displayHelp: false,
		strings : {
			help: ' \u2190 / P - previous image\u00a0\u00a0\u00a0\u00a0\u2192 / N - next image\u00a0\u00a0\u00a0\u00a0ESC / X - close image gallery',
			prevLinkTitle: 'Vorheriges Bild',
			nextLinkTitle: 'Nächstes Bild',
			prevLinkText:  '&laquo; Zurück',
			nextLinkText:  'Weiter &raquo;',
			closeTitle: 'Ansicht schließen',
			image: 'Bild ',
			of: ' von '
		},
		fitToScreen: false		// resize images if they are bigger than window
	};
})(jQuery);

/*
 * Tabs 3 - New Wave Tabs
 *
 * Copyright (c) 2007 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 */

(function(jQuery) {

    // if the UI scope is not availalable, add it
    jQuery.ui = jQuery.ui || {};

    // tabs initialization
    jQuery.fn.tabs = function(initial, options) {
        if (initial && initial.constructor == Object) { // shift arguments
            options = initial;
            initial = null;
        }
        options = options || {};

        initial = initial && initial.constructor == Number && --initial || 0;

        return this.each(function() {
            new jQuery.ui.tabs(this, jQuery.extend(options, { initial: initial }));
        });
    };

    // other chainable tabs methods
    jQuery.each(['Add', 'Remove', 'Enable', 'Disable', 'Click', 'Load', 'Href'], function(i, method) {
        jQuery.fn['tabs' + method] = function() {
            var args = arguments;
            return this.each(function() {
                var instance = jQuery.ui.tabs.getInstance(this);
                instance[method.toLowerCase()].apply(instance, args);
            });
        };
    });
    jQuery.fn.tabsSelected = function() {
        var selected = -1;
        if (this[0]) {
            var instance = jQuery.ui.tabs.getInstance(this[0]),
                jQuerylis = jQuery('li', this);
            selected = jQuerylis.index( jQuerylis.filter('.' + instance.options.selectedClass)[0] );
        }
        return selected >= 0 ? ++selected : -1;
    };

    // tabs class
    jQuery.ui.tabs = function(el, options) {

        this.source = el;

        this.options = jQuery.extend({

            // basic setup
            initial: 0,
            event: 'click',
            disabled: [],
            cookie: null, // pass options object as expected by cookie plugin: { expires: 7, path: '/', domain: 'jquery.com', secure: true }
            // TODO bookmarkable: jQuery.ajaxHistory ? true : false,
            unselected: false,
            unselect: options.unselected ? true : false,

            // Ajax
            spinner: 'Loading&#8230;',
            cache: false,
            idPrefix: 'ui-tabs-',
            ajaxOptions: {},

            // animations
            /*fxFade: null,
            fxSlide: null,
            fxShow: null,
            fxHide: null,*/
            fxSpeed: 'normal',
            /*fxShowSpeed: null,
            fxHideSpeed: null,*/

            // callbacks
            add: function() {},
            remove: function() {},
            enable: function() {},
            disable: function() {},
            click: function() {},
            hide: function() {},
            show: function() {},
            load: function() {},
            
            // templates
            tabTemplate: '<li><a href="#{href}"><span>#{text}</span></a></li>',
            panelTemplate: '<div></div>',

            // CSS classes
            navClass: 'ui-tabs-nav',
            selectedClass: 'ui-tabs-selected',
            unselectClass: 'ui-tabs-unselect',
            disabledClass: 'ui-tabs-disabled',
            panelClass: 'ui-tabs-panel',
            hideClass: 'ui-tabs-hide',
            loadingClass: 'ui-tabs-loading'

        }, options);

        this.options.event += '.ui-tabs'; // namespace event
        this.options.cookie = jQuery.cookie && jQuery.cookie.constructor == Function && this.options.cookie;

        // save instance for later
        jQuery.data(el, jQuery.ui.tabs.INSTANCE_KEY, this);
        
        // create tabs
        this.tabify(true);
    };

    // static
    jQuery.ui.tabs.INSTANCE_KEY = 'ui_tabs_instance';
    jQuery.ui.tabs.getInstance = function(el) {
        return jQuery.data(el, jQuery.ui.tabs.INSTANCE_KEY);
    };

    // instance methods
    jQuery.extend(jQuery.ui.tabs.prototype, {
        tabId: function(a) {
            return a.title ? a.title.replace(/\s/g, '_')
                : this.options.idPrefix + jQuery.data(a);
        },
        tabify: function(init) {

            this.jQuerylis = jQuery('li:has(a[href])', this.source);
            this.jQuerytabs = this.jQuerylis.map(function() { return jQuery('a', this)[0] });
            this.jQuerypanels = jQuery([]);
            
            var self = this, o = this.options;
            
            this.jQuerytabs.each(function(i, a) {
                // inline tab
                if (a.hash && a.hash.replace('#', '')) { // Safari 2 reports '#' for an empty hash
                    self.jQuerypanels = self.jQuerypanels.add(a.hash);
                }
                // remote tab
                else if (jQuery(a).attr('href') != '#') { // prevent loading the page itself if href is just "#"
                    jQuery.data(a, 'href', a.href);
                    var id = self.tabId(a);
                    a.href = '#' + id;
                    self.jQuerypanels = self.jQuerypanels.add(
                        jQuery('#' + id)[0] || jQuery(o.panelTemplate).attr('id', id).addClass(o.panelClass)
                            .insertAfter( self.jQuerypanels[i - 1] || self.source )
                    );
                }
                // invalid tab href
                else {
                    o.disabled.push(i + 1);
                }
            });

            if (init) {

                // attach necessary classes for styling if not present
                jQuery(this.source).hasClass(o.navClass) || jQuery(this.source).addClass(o.navClass);
                this.jQuerypanels.each(function() {
                    var jQuerythis = jQuery(this);
                    jQuerythis.hasClass(o.panelClass) || jQuerythis.addClass(o.panelClass);
                });
                
                // disabled tabs
                for (var i = 0, position; position = o.disabled[i]; i++) {
                    this.disable(position);
                }
                
                // Try to retrieve initial tab:
                // 1. from fragment identifier in url if present
                // 2. from cookie
                // 3. from selected class attribute on <li>
                // 4. otherwise use given initial argument
                // 5. check if tab is disabled
                this.jQuerytabs.each(function(i, a) {
                    if (location.hash) {
                        if (a.hash == location.hash) {
                            o.initial = i;
                            // prevent page scroll to fragment
                            //if ((jQuery.browser.msie || jQuery.browser.opera) && !o.remote) {
                            if (jQuery.browser.msie || jQuery.browser.opera) {
                                var jQuerytoShow = jQuery(location.hash), toShowId = jQuerytoShow.attr('id');
                                jQuerytoShow.attr('id', '');
                                setTimeout(function() {
                                    jQuerytoShow.attr('id', toShowId); // restore id
                                }, 500);
                            }
                            scrollTo(0, 0);
                            return false; // break
                        }
                    } else if (o.cookie) {
                        o.initial = parseInt(jQuery.cookie( jQuery.ui.tabs.INSTANCE_KEY + jQuery.data(self.source) )) || 0;
                        return false; // break
                    } else if ( self.jQuerylis.eq(i).hasClass(o.selectedClass) ) {
                        o.initial = i;
                        return false; // break
                    }
                });
                var n = this.jQuerylis.length;
                while (this.jQuerylis.eq(o.initial).hasClass(o.disabledClass) && n) {
                    o.initial = ++o.initial < this.jQuerylis.length ? o.initial : 0;
                    n--;
                }
                if (!n) { // all tabs disabled, set option unselected to true
                    o.unselected = o.unselect = true;
                }
                
                // highlight selected tab
                this.jQuerypanels.addClass(o.hideClass);
                this.jQuerylis.removeClass(o.selectedClass);
                if (!o.unselected) {
                    this.jQuerypanels.eq(o.initial).show().removeClass(o.hideClass); // use show and remove class to show in any case no matter how it has been hidden before
                    this.jQuerylis.eq(o.initial).addClass(o.selectedClass);
                }

                // load if remote tab
                var href = !o.unselected && jQuery.data(this.jQuerytabs[o.initial], 'href');
                if (href) {
                    this.load(o.initial + 1, href);
                }
                
                // disable click if event is configured to something else
                if (!/^click/.test(o.event)) {
                    this.jQuerytabs.bind('click', function(e) { e.preventDefault(); });
                }

            }

            // setup animations
            var showAnim = {}, showSpeed = o.fxShowSpeed || o.fxSpeed,
                hideAnim = {}, hideSpeed = o.fxHideSpeed || o.fxSpeed;
            if (o.fxSlide || o.fxFade) {
                if (o.fxSlide) {
                    showAnim['height'] = 'show';
                    hideAnim['height'] = 'hide';
                }
                if (o.fxFade) {
                    showAnim['opacity'] = 'show';
                    hideAnim['opacity'] = 'hide';
                }
            } else {
                if (o.fxShow) {
                    showAnim = o.fxShow;
                } else { // use some kind of animation to prevent browser scrolling to the tab
                    showAnim['min-width'] = 0; // avoid opacity, causes flicker in Firefox
                    showSpeed = 1; // as little as 1 is sufficient
                }
                if (o.fxHide) {
                    hideAnim = o.fxHide;
                } else { // use some kind of animation to prevent browser scrolling to the tab
                    hideAnim['min-width'] = 0; // avoid opacity, causes flicker in Firefox
                    hideSpeed = 1; // as little as 1 is sufficient
                }
            }

            // reset some styles to maintain print style sheets etc.
            var resetCSS = { display: '', overflow: '', height: '' };
            if (!jQuery.browser.msie) { // not in IE to prevent ClearType font issue
                resetCSS['opacity'] = '';
            }

            // Hide a tab, animation prevents browser scrolling to fragment,
            // jQueryshow is optional.
            function hideTab(clicked, jQueryhide, jQueryshow) {
                jQueryhide.animate(hideAnim, hideSpeed, function() { //
                    jQueryhide.addClass(o.hideClass).css(resetCSS); // maintain flexible height and accessibility in print etc.
                    if (jQuery.browser.msie && hideAnim['opacity']) {
                        jQueryhide[0].style.filter = '';
                    }
                    o.hide(clicked, jQueryhide[0], jQueryshow && jQueryshow[0] || null);
                    if (jQueryshow) {
                        showTab(clicked, jQueryshow, jQueryhide);
                    }
                });
            }

            // Show a tab, animation prevents browser scrolling to fragment,
            // jQueryhide is optional
            function showTab(clicked, jQueryshow, jQueryhide) {
                if (!(o.fxSlide || o.fxFade || o.fxShow)) {
                    jQueryshow.css('display', 'block'); // prevent occasionally occuring flicker in Firefox cause by gap between showing and hiding the tab panels
                }
                jQueryshow.animate(showAnim, showSpeed, function() {
                    jQueryshow.removeClass(o.hideClass).css(resetCSS); // maintain flexible height and accessibility in print etc.
                    if (jQuery.browser.msie && showAnim['opacity']) {
                        jQueryshow[0].style.filter = '';
                    }
                    o.show(clicked, jQueryshow[0], jQueryhide && jQueryhide[0] || null);
                });
            }

            // switch a tab
            function switchTab(clicked, jQueryli, jQueryhide, jQueryshow) {
                /*if (o.bookmarkable && trueClick) { // add to history only if true click occured, not a triggered click
                    jQuery.ajaxHistory.update(clicked.hash);
                }*/
                jQueryli.addClass(o.selectedClass)
                    .siblings().removeClass(o.selectedClass);
                hideTab(clicked, jQueryhide, jQueryshow);
            }

            // attach tab event handler, unbind to avoid duplicates from former tabifying...
            this.jQuerytabs.unbind(o.event).bind(o.event, function() {

                //var trueClick = e.clientX; // add to history only if true click occured, not a triggered click
                var jQueryli = jQuery(this).parents('li:eq(0)'),
                    jQueryhide = self.jQuerypanels.filter(':visible'),
                    jQueryshow = jQuery(this.hash);

                // If tab is already selected and not unselectable or tab disabled or click callback returns false stop here.
                // Check if click handler returns false last so that it is not executed for a disabled tab!
                if ((jQueryli.hasClass(o.selectedClass) && !o.unselect) || jQueryli.hasClass(o.disabledClass)
                    || o.click(this, jQueryshow[0], jQueryhide[0]) === false) {
                    this.blur();
                    return false;
                }
                
                if (o.cookie) {
                    jQuery.cookie(jQuery.ui.tabs.INSTANCE_KEY + jQuery.data(self.source), self.jQuerytabs.index(this), o.cookie);
                }
                    
                // if tab may be closed
                if (o.unselect) {
                    if (jQueryli.hasClass(o.selectedClass)) {
                        jQueryli.removeClass(o.selectedClass);
                        self.jQuerypanels.stop();
                        hideTab(this, jQueryhide);
                        this.blur();
                        return false;
                    } else if (!jQueryhide.length) {
                        self.jQuerypanels.stop();
                        if (jQuery.data(this, 'href')) { // remote tab
                            var a = this;
                            self.load(self.jQuerytabs.index(this) + 1, jQuery.data(this, 'href'), function() {
                                jQueryli.addClass(o.selectedClass).addClass(o.unselectClass);
                                showTab(a, jQueryshow);
                            });
                        } else {
                            jQueryli.addClass(o.selectedClass).addClass(o.unselectClass);
                            showTab(this, jQueryshow);
                        }
                        this.blur();
                        return false;
                    }
                }

                // stop possibly running animations
                self.jQuerypanels.stop();

                // show new tab
                if (jQueryshow.length) {

                    // prevent scrollbar scrolling to 0 and than back in IE7, happens only if bookmarking/history is enabled
                    /*if (jQuery.browser.msie && o.bookmarkable) {
                        var showId = this.hash.replace('#', '');
                        jQueryshow.attr('id', '');
                        setTimeout(function() {
                            jQueryshow.attr('id', showId); // restore id
                        }, 0);
                    }*/

                    if (jQuery.data(this, 'href')) { // remote tab
                        var a = this;
                        self.load(self.jQuerytabs.index(this) + 1, jQuery.data(this, 'href'), function() {
                            switchTab(a, jQueryli, jQueryhide, jQueryshow);
                        });
                    } else {
                        switchTab(this, jQueryli, jQueryhide, jQueryshow);
                    }

                    // Set scrollbar to saved position - need to use timeout with 0 to prevent browser scroll to target of hash
                    /*var scrollX = window.pageXOffset || document.documentElement && document.documentElement.scrollLeft || document.body.scrollLeft || 0;
                    var scrollY = window.pageYOffset || document.documentElement && document.documentElement.scrollTop || document.body.scrollTop || 0;
                    setTimeout(function() {
                        scrollTo(scrollX, scrollY);
                    }, 0);*/

                } else {
                    throw 'jQuery UI Tabs: Mismatching fragment identifier.';
                }

                // Prevent IE from keeping other link focussed when using the back button
                // and remove dotted border from clicked link. This is controlled in modern
                // browsers via CSS, also blur removes focus from address bar in Firefox
                // which can become a usability and annoying problem with tabsRotate.
                if (jQuery.browser.msie) {
                    this.blur(); 
                }

                //return o.bookmarkable && !!trueClick; // convert trueClick == undefined to Boolean required in IE
                return false;

            });

        },
        add: function(url, text, position) {
            if (url && text) {
                position = position || this.jQuerytabs.length; // append by default  
                
                var o = this.options,
                    jQueryli = jQuery(o.tabTemplate.replace(/#\{href\}/, url).replace(/#\{text\}/, text));
                
                var id = url.indexOf('#') == 0 ? url.replace('#', '') : this.tabId( jQuery('a:first-child', jQueryli)[0] );
                
                // try to find an existing element before creating a new one
                var jQuerypanel = jQuery('#' + id);
                jQuerypanel = jQuerypanel.length && jQuerypanel
                    || jQuery(o.panelTemplate).attr('id', id).addClass(o.panelClass).addClass(o.hideClass);
                if (position >= this.jQuerylis.length) {
                    jQueryli.appendTo(this.source);
                    jQuerypanel.appendTo(this.source.parentNode);
                } else {
                    jQueryli.insertBefore(this.jQuerylis[position - 1]);
                    jQuerypanel.insertBefore(this.jQuerypanels[position - 1]);
                }
                
                this.tabify();
                
                if (this.jQuerytabs.length == 1) {
                     jQueryli.addClass(o.selectedClass);
                     jQuerypanel.removeClass(o.hideClass);
                     var href = jQuery.data(this.jQuerytabs[0], 'href');
                     if (href) {
                         this.load(position + 1, href);
                     }
                }
                o.add(this.jQuerytabs[position], this.jQuerypanels[position]); // callback
            } else {
                throw 'jQuery UI Tabs: Not enough arguments to add tab.';
            }
        },
        remove: function(position) {
            if (position && position.constructor == Number) {                
                var o = this.options, jQueryli = this.jQuerylis.eq(position - 1).remove(),
                    jQuerypanel = this.jQuerypanels.eq(position - 1).remove();
                    
                // If selected tab was removed focus tab to the right or
                // tab to the left if last tab was removed.
                if (jQueryli.hasClass(o.selectedClass) && this.jQuerytabs.length > 1) {
                    this.click(position + (position < this.jQuerytabs.length ? 1 : -1));
                }
                this.tabify();
                o.remove(jQueryli.end()[0], jQuerypanel[0]); // callback
            }
        },
        enable: function(position) {
            var o = this.options, jQueryli = this.jQuerylis.eq(position - 1);
            jQueryli.removeClass(o.disabledClass);
            if (jQuery.browser.safari) { // fix disappearing tab (that used opacity indicating disabling) after enabling in Safari 2...
                jQueryli.css('display', 'inline-block');
                setTimeout(function() {
                    jQueryli.css('display', 'block')
                }, 0)
            }
            o.enable(this.jQuerytabs[position - 1], this.jQuerypanels[position - 1]); // callback
        },
        disable: function(position) {
            var o = this.options;      
            this.jQuerylis.eq(position - 1).addClass(o.disabledClass);
            o.disable(this.jQuerytabs[position - 1], this.jQuerypanels[position - 1]); // callback
        },
        click: function(position) {
            this.jQuerytabs.eq(position - 1).trigger(this.options.event);
        },
        load: function(position, url, callback) {
            var self = this, o = this.options,
                jQuerya = this.jQuerytabs.eq(position - 1), a = jQuerya[0], jQueryspan = jQuery('span', a);
            
            // shift arguments
            if (url && url.constructor == Function) {
                callback = url;
                url = null;
            }

            // set new URL or get existing
            if (url) {
                jQuery.data(a, 'href', url);
            } else {
                url = jQuery.data(a, 'href');
            }

            // load
            if (o.spinner) {
                jQuery.data(a, 'title', jQueryspan.html());
                jQueryspan.html('<em>' + o.spinner + '</em>');
            }
            var finish = function() {
                self.jQuerytabs.filter('.' + o.loadingClass).each(function() {
                    jQuery(this).removeClass(o.loadingClass);
                    if (o.spinner) {
                        jQuery('span', this).html( jQuery.data(this, 'title') );
                    }
                });
                self.xhr = null;
            };
            var ajaxOptions = jQuery.extend(o.ajaxOptions, {
                url: url,
                success: function(r) {
                    jQuery(a.hash).html(r);
                    finish();
                    // This callback is required because the switch has to take 
                    // place after loading has completed.
                    if (callback && callback.constructor == Function) {
                        callback();
                    }
                    if (o.cache) {
                        jQuery.removeData(a, 'href'); // if loaded once do not load them again
                    }
                    o.load(self.jQuerytabs[position - 1], self.jQuerypanels[position - 1]); // callback
                }
            });
            if (this.xhr) {
                // terminate pending requests from other tabs and restore title
                this.xhr.abort();
                finish();
            }
            jQuerya.addClass(o.loadingClass);
            setTimeout(function() { // timeout is again required in IE, "wait" for id being restored
                self.xhr = jQuery.ajax(ajaxOptions);
            }, 0);
            
        },
        href: function(position, href) {
            jQuery.data(this.jQuerytabs.eq(position - 1)[0], 'href', href);
        }
    });

})(jQuery);


/* Copyright (c) 2007 Paul Bakaus (paul.bakaus@googlemail.com) and Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * $LastChangedDate: 2007-12-20 08:46:55 -0600 (Thu, 20 Dec 2007) $
 * $Rev: 4259 $
 *
 * Version: 1.2
 *
 * Requires: jQuery 1.2+
 */

(function(jQuery){
	
jQuery.dimensions = {
	version: '1.2'
};

// Create innerHeight, innerWidth, outerHeight and outerWidth methods
jQuery.each( [ 'Height', 'Width' ], function(i, name){
	
	// innerHeight and innerWidth
	jQuery.fn[ 'inner' + name ] = function() {
		if (!this[0]) return;
		
		var torl = name == 'Height' ? 'Top'    : 'Left',  // top or left
		    borr = name == 'Height' ? 'Bottom' : 'Right'; // bottom or right
		
		return this.is(':visible') ? this[0]['client' + name] : num( this, name.toLowerCase() ) + num(this, 'padding' + torl) + num(this, 'padding' + borr);
	};
	
	// outerHeight and outerWidth
	jQuery.fn[ 'outer' + name ] = function(options) {
		if (!this[0]) return;
		
		var torl = name == 'Height' ? 'Top'    : 'Left',  // top or left
		    borr = name == 'Height' ? 'Bottom' : 'Right'; // bottom or right
		
		options = jQuery.extend({ margin: false }, options || {});
		
		var val = this.is(':visible') ? 
				this[0]['offset' + name] : 
				num( this, name.toLowerCase() )
					+ num(this, 'border' + torl + 'Width') + num(this, 'border' + borr + 'Width')
					+ num(this, 'padding' + torl) + num(this, 'padding' + borr);
		
		return val + (options.margin ? (num(this, 'margin' + torl) + num(this, 'margin' + borr)) : 0);
	};
});

// Create scrollLeft and scrollTop methods
jQuery.each( ['Left', 'Top'], function(i, name) {
	jQuery.fn[ 'scroll' + name ] = function(val) {
		if (!this[0]) return;
		
		return val != undefined ?
		
			// Set the scroll offset
			this.each(function() {
				this == window || this == document ?
					window.scrollTo( 
						name == 'Left' ? val : jQuery(window)[ 'scrollLeft' ](),
						name == 'Top'  ? val : jQuery(window)[ 'scrollTop'  ]()
					) :
					this[ 'scroll' + name ] = val;
			}) :
			
			// Return the scroll offset
			this[0] == window || this[0] == document ?
				self[ (name == 'Left' ? 'pageXOffset' : 'pageYOffset') ] ||
					jQuery.boxModel && document.documentElement[ 'scroll' + name ] ||
					document.body[ 'scroll' + name ] :
				this[0][ 'scroll' + name ];
	};
});

jQuery.fn.extend({
	position: function() {
		var left = 0, top = 0, elem = this[0], offset, parentOffset, offsetParent, results;
		
		if (elem) {
			// Get *real* offsetParent
			offsetParent = this.offsetParent();
			
			// Get correct offsets
			offset       = this.offset();
			parentOffset = offsetParent.offset();
			
			// Subtract element margins
			offset.top  -= num(elem, 'marginTop');
			offset.left -= num(elem, 'marginLeft');
			
			// Add offsetParent borders
			parentOffset.top  += num(offsetParent, 'borderTopWidth');
			parentOffset.left += num(offsetParent, 'borderLeftWidth');
			
			// Subtract the two offsets
			results = {
				top:  offset.top  - parentOffset.top,
				left: offset.left - parentOffset.left
			};
		}
		
		return results;
	},
	
	offsetParent: function() {
		var offsetParent = this[0].offsetParent;
		while ( offsetParent && (!/^body|htmljQuery/i.test(offsetParent.tagName) && jQuery.css(offsetParent, 'position') == 'static') )
			offsetParent = offsetParent.offsetParent;
		return jQuery(offsetParent);
	}
});

function num(el, prop) {
	return parseInt(jQuery.curCSS(el.jquery?el[0]:el,prop,true))||0;
};

})(jQuery);

/**
 * jQuery.ScrollTo
 * Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com
 * Licensed under GPL license (http://www.opensource.org/licenses/gpl-license.php).
 * Date: 1/2/2008
 *
 * @projectDescription Easy element scrolling using jQuery.
 * Tested with jQuery 1.2.1. On FF 2.0.0.11, IE 6, Opera 9.22 and Safari 3 beta. on Windows.
 *
 * @author Ariel Flesler
 * @version 1.3
 *
 * @id jQuery.scrollTo
 * @id jQuery.fn.scrollTo
 * @param {String, Number, DOMElement, jQuery, Object} target Where to scroll the matched elements.
 *	  The different options for target are:
 *		- A number position (will be applied to all axes).
 *		- A string position ('44', '100px', '+=90', etc ) will be applied to all axes
 *		- A jQuery/DOM element ( logically, child of the element to scroll )
 *		- A string selector, that will be relative to the element to scroll ( 'li:eq(2)', etc )
 *		- A hash { top:x, left:y }, x and y can be any kind of number/string like above.
 * @param {Number} duration The OVERALL length of the animation, this argument can be the settings object instead.
 * @param {Object} settings Hash of settings, optional.
 *	 @option {String} axis Which axis must be scrolled, use 'x', 'y', 'xy' or 'yx'.
 *	 @option {Number} duration The OVERALL length of the animation.
 *	 @option {String} easing The easing method for the animation.
 *	 @option {Boolean} margin If true, the margin of the target element will be deducted from the final position.
 *	 @option {Object, Number} offset Add/deduct from the end position. One number for both axis or { top:x, left:y }
 *	 @option {Boolean} queue If true, and both axis are given, the 2nd axis will only be animated after the first one ends.
 *	 @option {Function} onAfter Function to be called after the scrolling ends. 
 *	 @option {Function} onAfterFirst If queuing is activated, this function will be called after the first scrolling ends.
 * @return {jQuery} Returns the same jQuery object, for chaining.
 *
 * @example jQuery('div').scrollTo( 340 );
 *
 * @example jQuery('div').scrollTo( '+=340px', { axis:'y' } );
 *
 * @example jQuery('div').scrollTo( 'p.paragraph:eq(2)', 500, { easing:'swing', queue:true, axis:'xy' } );
 *
 * @example var second_child = document.getElementById('container').firstChild.nextSibling;
 *			jQuery('#container').scrollTo( second_child, { duration:500, axis:'x', onAfter:function(){
 *				alert('scrolled!!');																   
 *			}});
 *
 * @example jQuery('div').scrollTo( { top: 300, left:'+=200' }, { offset:-20 } );
 *
 * Notes:
 *  - jQuery.scrollTo will make the whole window scroll, it accepts the same parameters as jQuery.fn.scrollTo.
 *  - The plugin no longer requires Dimensions.
 *	- If you are interested in animated anchor navigation, check http://jquery.com/plugins/project/LocalScroll.
 *	- The option 'margin' won't be valid, if the target is not a jQuery object or a DOM element.
 *	- The option 'queue' won't be taken into account, if only 1 axis is given.
 */
;(function( jQuery ){
		  
	jQuery.scrollTo = function( target, duration, settings ){
		jQuery( jQuery.browser.safari ? 'body' : 'html' ).scrollTo( target, duration, settings );
	};
	
	jQuery.scrollTo.defaults = {
		axis:'y',
		duration:1
	};
	
	jQuery.fn.scrollTo = function( target, duration, settings ){
		if( typeof duration == 'object' ){
			settings = duration;
			duration = 0;
		}
		settings = jQuery.extend( {}, jQuery.scrollTo.defaults, settings );
		if( !duration )
			duration = settings.speed || settings.duration;//backward compatibility fix
		settings.queue = settings.queue && settings.axis.length == 2;//make sure the settings are given right
		if( settings.queue )
			duration = Math.ceil( duration / 2 );//let's keep the overall speed, the same.
		if( typeof settings.offset == 'number' )
			settings.offset = { left: settings.offset, top: settings.offset };
		
		return this.each(function(){
			var elem = this, jQueryelem = jQuery(elem),
				t = target, toff, attr = {},
				win = jQueryelem.is('html,body');
			switch( typeof t ){
				case 'number'://will pass the regex
				case 'string':
					if( /^([+-]=)?\d+(px)?jQuery/.test(t) ){
						t = { top:t, left:t };
						break;//we are done
					}
					t = jQuery(t,this);// relative selector, no break!
				case 'object':
					if( t.is || t.style )//DOM/jQuery
						toff = (t = jQuery(t)).offset();//get the real position of the target 
			}
			jQuery.each( settings.axis.split(''), parse );			
			animate( settings.onAfter );			
			
			function parse( i, axis ){
				var Pos	= axis == 'x' ? 'Left' : 'Top',
					pos = Pos.toLowerCase(),
					key = 'scroll' + Pos,
					act = elem[key];
					
				if( toff ){//jQuery/DOM
					attr[key] = toff[pos] + ( win ? 0 : act - jQueryelem.offset()[pos] );
					
					if( settings.margin ){//if it's a dom element, reduce the margin
						attr[key] -= parseInt(t.css('margin'+Pos)) || 0;
						attr[key] -= parseInt(t.css('border'+Pos+'Width')) || 0;
					}
					
					if( settings.offset && settings.offset[pos] )
						attr[key] += settings.offset[pos];
				}else{
					attr[key] = t[pos];
				}				
				
				if( /^\d+jQuery/.test(attr[key]) )
					attr[key] = attr[key] <= 0 ? 0 : Math.min( attr[key], max(axis) );//check the limits
				
				if( !i && settings.queue ){//queueing each axis is required					
					if( act != attr[key] )//don't waste time animating, if there's no need.
						animate( settings.onAfterFirst );//intermediate animation
					delete attr[key];//don't animate this axis again in the next iteration.
				}
			};
			
			function animate( callback ){
				jQueryelem.animate( attr, duration, settings.easing, function(){
					if( callback )
						callback.call(this, jQueryelem, attr, t );
				});
			};
			function max( axis ){
				var el = win ? jQuery.browser.opera ? document.body : document.documentElement : elem,
					Dim = axis == 'x' ? 'Width' : 'Height';
				return el['scroll'+Dim] - el['client'+Dim];
			};
		});
	};

})( jQuery );

//Step Carousel Viewer: By Dynamic Drive, at http://www.dynamicdrive.com
//** Created: March 19th, 08'
//** Aug 16th, 08'- Updated to v 1.4:
	//1) Adds ability to set speed/duration of panel animation (in milliseconds)
	//2) Adds persistence support, so the last viewed panel is recalled when viewer returns within same browser session
	//3) Adds ability to specify whether panels should stop at the very last and first panel, or wrap around and start all over again
	//4) Adds option to specify two navigational image links positioned to the left and right of the Carousel Viewer to move the panels back and forth

//** Aug 27th, 08'- Nav buttons (if enabled) also repositions themselves now if window is resized

//** Sept 23rd, 08'- Updated to v 1.6:
	//1) Carousel now stops at the very last visible panel, instead of the last panel itself. In other words, no more white space at the end.
	//2) Adds ability for Carousel to auto rotate dictated by the new parameter: autostep: {enable:true, moveby:1, pause:3000}
	//2i) During Auto Rotate, Carousel pauses onMouseover, resumes onMouseout. Clicking Carousel halts auto rotate.

//** Oct 22nd, 08'- Updated to v 1.6.1, which fixes functions stepBy() and stepTo() not stopping auto stepping of Carousel when called.

var stepcarousel={
	ajaxloadingmsg: '<div style="margin: 1em; font-weight: bold"><img src="ajaxloadr.gif" style="vertical-align: middle" /> Fetching Content. Please wait...</div>', //customize HTML to show while fetching Ajax content
	defaultbuttonsfade: 0.4, //Fade degree for disabled nav buttons (0=completely transparent, 1=completely opaque)
	configholder: {},

	getCSSValue:function(val){ //Returns either 0 (if val contains 'auto') or val as an integer
		return (val=="auto")? 0 : parseInt(val)
	},

	getremotepanels:function($, config){ //function to fetch external page containing the panel DIVs
		config.$belt.html(this.ajaxloadingmsg)
		$.ajax({
			url: config.contenttype[1], //path to external content
			async: true,
			error:function(ajaxrequest){
				config.$belt.html('Error fetching content.<br />Server Response: '+ajaxrequest.responseText)
			},
			success:function(content){
				config.$belt.html(content)
				config.$panels=config.$gallery.find('.'+config.panelclass)
				stepcarousel.alignpanels($, config)
			}
		})
	},

	getoffset:function(what, offsettype){
		return (what.offsetParent)? what[offsettype]+this.getoffset(what.offsetParent, offsettype) : what[offsettype]
	},

	getCookie:function(Name){ 
		var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
		if (document.cookie.match(re)) //if cookie found
			return document.cookie.match(re)[0].split("=")[1] //return its value
		return null
	},

	setCookie:function(name, value){
		document.cookie = name+"="+value
	},

	fadebuttons:function(config, currentpanel){
		config.$leftnavbutton.fadeTo('fast', currentpanel==0? this.defaultbuttonsfade : 1)
		config.$rightnavbutton.fadeTo('fast', currentpanel==config.lastvisiblepanel? this.defaultbuttonsfade : 1)
	},

	addnavbuttons:function(config, currentpanel){
		config.$leftnavbutton=$('<img src="'+config.defaultbuttons.leftnav[0]+'">').css({zIndex:50, position:'absolute', left:config.offsets.left+config.defaultbuttons.leftnav[1]+'px', top:config.offsets.top+config.defaultbuttons.leftnav[2]+'px', cursor:'hand', cursor:'pointer'}).attr({title:'Back '+config.defaultbuttons.moveby+' panels'}).appendTo('body')
		config.$rightnavbutton=$('<img src="'+config.defaultbuttons.rightnav[0]+'">').css({zIndex:50, position:'absolute', left:config.offsets.left+config.$gallery.get(0).offsetWidth+config.defaultbuttons.rightnav[1]+'px', top:config.offsets.top+config.defaultbuttons.rightnav[2]+'px', cursor:'hand', cursor:'pointer'}).attr({title:'Forward '+config.defaultbuttons.moveby+' panels'}).appendTo('body')
		config.$leftnavbutton.bind('click', function(){ //assign nav button event handlers
			stepcarousel.stepBy(config.galleryid, -config.defaultbuttons.moveby)
		})
		config.$rightnavbutton.bind('click', function(){ //assign nav button event handlers
			stepcarousel.stepBy(config.galleryid, config.defaultbuttons.moveby)
		})
		if (config.panelbehavior.wraparound==false){ //if carousel viewer should stop at first or last panel (instead of wrap back or forth)
			this.fadebuttons(config, currentpanel)
		}
		return config.$leftnavbutton.add(config.$rightnavbutton)
	},

	stopautostep:function(config){
		clearTimeout(config.steptimer)
		clearTimeout(config.resumeautostep)
	},

	alignpanels:function($, config){
		var paneloffset=0
		config.paneloffsets=[paneloffset] //array to store upper left offset of each panel (1st element=0)
		config.panelwidths=[] //array to store widths of each panel
		config.$panels.each(function(index){ //loop through panels
			var $currentpanel=$(this)
			$currentpanel.css({float: 'none', position: 'absolute', left: paneloffset+'px'}) //position panel
			$currentpanel.bind('click', function(e){return config.onpanelclick(e.target)}) //bind onpanelclick() to onclick event
			paneloffset+=stepcarousel.getCSSValue($currentpanel.css('marginRight')) + parseInt($currentpanel.get(0).offsetWidth || $currentpanel.css('width')) //calculate next panel offset
			config.paneloffsets.push(paneloffset) //remember this offset
			config.panelwidths.push(paneloffset-config.paneloffsets[config.paneloffsets.length-2]) //remember panel width
		})
		config.paneloffsets.pop() //delete last offset (redundant)
		var addpanelwidths=0
		var lastpanelindex=config.$panels.length-1
		config.lastvisiblepanel=lastpanelindex
		for (var i=config.$panels.length-1; i>=0; i--){
			addpanelwidths+=(i==lastpanelindex? config.panelwidths[lastpanelindex] : config.paneloffsets[i+1]-config.paneloffsets[i])
			if (config.gallerywidth>addpanelwidths){
				config.lastvisiblepanel=i //calculate index of panel that when in 1st position reveals the very last panel all at once based on gallery width
			}
		}
		config.$belt.css({width: paneloffset+'px'}) //Set Belt DIV to total panels' widths
		config.currentpanel=(config.panelbehavior.persist)? parseInt(this.getCookie(window[config.galleryid+"persist"])) : 0 //determine 1st panel to show by default
		config.currentpanel=(typeof config.currentpanel=="number" && config.currentpanel<config.$panels.length)? config.currentpanel : 0
		if (config.currentpanel!=0){
			var endpoint=config.paneloffsets[config.currentpanel]+(config.currentpanel==0? 0 : config.beltoffset)
			config.$belt.css({left: -endpoint+'px'})
		}
		if (config.defaultbuttons.enable==true){ //if enable default back/forth nav buttons
			var $navbuttons=this.addnavbuttons(config, config.currentpanel)
			$(window).bind("load resize", function(){ //refresh position of nav buttons when page loads/resizes, in case offsets weren't available document.oncontentload
				config.offsets={left:stepcarousel.getoffset(config.$gallery.get(0), "offsetLeft"), top:stepcarousel.getoffset(config.$gallery.get(0), "offsetTop")}
				config.$leftnavbutton.css({left:config.offsets.left+config.defaultbuttons.leftnav[1]+'px', top:config.offsets.top+config.defaultbuttons.leftnav[2]+'px'})
				config.$rightnavbutton.css({left:config.offsets.left+config.$gallery.get(0).offsetWidth+config.defaultbuttons.rightnav[1]+'px', top:config.offsets.top+config.defaultbuttons.rightnav[2]+'px'})
			})
		}
		if (config.autostep && config.autostep.enable){ //enable auto stepping of Carousel?		
			var $carouselparts=config.$gallery.add(typeof $navbuttons!="undefined"? $navbuttons : null)
			$carouselparts.bind('click', function(){
				stepcarousel.stopautostep(config)
				config.autostep.status="stopped"
			})
			$carouselparts.hover(function(){ //onMouseover
				stepcarousel.stopautostep(config)
				config.autostep.hoverstate="over"
			}, function(){ //onMouseout
				if (config.steptimer && config.autostep.hoverstate=="over" && config.autostep.status!="stopped"){
					config.resumeautostep=setTimeout(function(){
						stepcarousel.autorotate(config.galleryid)
						config.autostep.hoverstate="out"
					}, 500)
				}
			})
			config.steptimer=setTimeout(function(){stepcarousel.autorotate(config.galleryid)}, config.autostep.pause) //automatically rotate Carousel Viewer
		} //end enable auto stepping check
		this.statusreport(config.galleryid)
		config.oninit()
		config.onslideaction(this)
	},

	stepTo:function(galleryid, pindex){ /*User entered pindex starts at 1 for intuitiveness. Internally pindex still starts at 0 */
		var config=stepcarousel.configholder[galleryid]
		if (typeof config=="undefined"){
			alert("There's an error with your set up of Carousel Viewer \""+galleryid+ "\"!")
			return
		}
		stepcarousel.stopautostep(config)
		var pindex=Math.min(pindex-1, config.paneloffsets.length-1)
		var endpoint=config.paneloffsets[pindex]+(pindex==0? 0 : config.beltoffset)
		if (config.panelbehavior.wraparound==false && config.defaultbuttons.enable==true){ //if carousel viewer should stop at first or last panel (instead of wrap back or forth)
			this.fadebuttons(config, pindex)
		}
		config.$belt.animate({left: -endpoint+'px'}, config.panelbehavior.speed, function(){config.onslideaction(this)})
		config.currentpanel=pindex
		this.statusreport(galleryid)
	},

	stepBy:function(galleryid, steps){ //isauto if defined indicates stepBy() is being called automatically
		var config=stepcarousel.configholder[galleryid]
		if (typeof config=="undefined"){
			alert("There's an error with your set up of Carousel Viewer \""+galleryid+ "\"!")
			return
		}
		stepcarousel.stopautostep(config)
		var direction=(steps>0)? 'forward' : 'back' //If "steps" is negative, that means backwards
		var pindex=config.currentpanel+steps //index of panel to stop at
		if (config.panelbehavior.wraparound==false){ //if carousel viewer should stop at first or last panel (instead of wrap back or forth)
			pindex=(direction=="back" && pindex<=0)? 0 : (direction=="forward")? Math.min(pindex, config.lastvisiblepanel) : pindex
			if (config.defaultbuttons.enable==true){ //if default nav buttons are enabled, fade them in and out depending on if at start or end of carousel
				stepcarousel.fadebuttons(config, pindex)
			}	
		}
		else{ //else, for normal stepBy behavior
			if (pindex>config.lastvisiblepanel && direction=="forward"){
				//if destination pindex is greater than last visible panel, yet we're currently not at the end of the carousel yet
				pindex=(config.currentpanel<config.lastvisiblepanel)? config.lastvisiblepanel : 0
			}
			else if (pindex<0 && direction=="back"){
				//if destination pindex is less than 0, yet we're currently not at the beginning of the carousel yet
				pindex=(config.currentpanel>0)? 0 : config.lastvisiblepanel /*wrap around left*/
			}
		}
		var endpoint=config.paneloffsets[pindex]+(pindex==0? 0 : config.beltoffset) //left distance for Belt DIV to travel to
		if (pindex==0 && direction=='forward' || config.currentpanel==0 && direction=='back' && config.panelbehavior.wraparound==true){ //decide whether to apply "push pull" effect
			config.$belt.animate({left: -config.paneloffsets[config.currentpanel]-(direction=='forward'? 100 : -30)+'px'}, 'normal', function(){
				config.$belt.animate({left: -endpoint+'px'}, config.panelbehavior.speed, function(){config.onslideaction(this)})
			})
		}
		else
			config.$belt.animate({left: -endpoint+'px'}, config.panelbehavior.speed, function(){config.onslideaction(this)})
		config.currentpanel=pindex
		this.statusreport(galleryid)
	},

	autorotate:function(galleryid){
		var config=stepcarousel.configholder[galleryid]
		if (config.$gallery.attr('_ismouseover')!="yes"){
			this.stepBy(galleryid, config.autostep.moveby)
		}
		config.steptimer=setTimeout(function(){stepcarousel.autorotate(galleryid)}, config.autostep.pause)
	},

	statusreport:function(galleryid){
		var config=stepcarousel.configholder[galleryid]
		var startpoint=config.currentpanel //index of first visible panel 
		var visiblewidth=0
		for (var endpoint=startpoint; endpoint<config.paneloffsets.length; endpoint++){ //index (endpoint) of last visible panel
			visiblewidth+=config.panelwidths[endpoint]
			if (visiblewidth>config.gallerywidth){
				break
			}
		}
		startpoint+=1 //format startpoint for user friendiness
		endpoint=(endpoint+1==startpoint)? startpoint : endpoint //If only one image visible on the screen and partially hidden, set endpoint to startpoint
		var valuearray=[startpoint, endpoint, config.panelwidths.length]
		for (var i=0; i<config.statusvars.length; i++){
			window[config.statusvars[i]]=valuearray[i] //Define variable (with user specified name) and set to one of the status values
			config.$statusobjs[i].text(valuearray[i]+" ") //Populate element on page with ID="user specified name" with one of the status values
		}
	},

	setup:function(config){
		//Disable Step Gallery scrollbars ASAP dynamically (enabled for sake of users with JS disabled)
		//document.write('<style type="text/css">\n#'+config.galleryid+'{overflow: hidden;}\n</style>')
		jQuery(document).ready(function($){
			config.$gallery=$('#'+config.galleryid)
			config.gallerywidth=config.$gallery.width()
			config.offsets={left:stepcarousel.getoffset(config.$gallery.get(0), "offsetLeft"), top:stepcarousel.getoffset(config.$gallery.get(0), "offsetTop")}
			config.$belt=config.$gallery.find('.'+config.beltclass) //Find Belt DIV that contains all the panels
			config.$panels=config.$gallery.find('.'+config.panelclass) //Find Panel DIVs that each contain a slide
			config.panelbehavior.wraparound=(config.autostep && config.autostep.enable)? true : config.panelbehavior.wraparound //if auto step enabled, set "wraparound" to true
			config.onpanelclick=(typeof config.onpanelclick=="undefined")? function(target){} : config.onpanelclick //attach custom "onpanelclick" event handler
			config.onslideaction=(typeof config.onslide=="undefined")? function(){} : function(beltobj){$(beltobj).stop(); config.onslide()} //attach custom "onslide" event handler
			config.oninit=(typeof config.oninit=="undefined")? function(){} : config.oninit //attach custom "oninit" event handler
			config.beltoffset=stepcarousel.getCSSValue(config.$belt.css('marginLeft')) //Find length of Belt DIV's left margin
			config.statusvars=config.statusvars || []  //get variable names that will hold "start", "end", and "total" slides info
			config.$statusobjs=[$('#'+config.statusvars[0]), $('#'+config.statusvars[1]), $('#'+config.statusvars[2])]
			config.currentpanel=0
			stepcarousel.configholder[config.galleryid]=config //store config parameter as a variable
			if (config.contenttype[0]=="ajax" && typeof config.contenttype[1]!="undefined") //fetch ajax content?
				stepcarousel.getremotepanels($, config)
			else
				stepcarousel.alignpanels($, config) //align panels and initialize gallery
		}) //end document.ready
		jQuery(window).bind('unload', function(){ //clean up
			if (config.panelbehavior.persist){
				stepcarousel.setCookie(window[config.galleryid+"persist"], config.currentpanel)
			}
			jQuery.each(config, function(ai, oi){
				oi=null
			})
			config=null
		})
	}
}




/**
  *  Translation plugin for jQuery
  *  (c) 2008 Philipp Simon <psimon@solotics.com>
  **/

jQuery.sgl = jQuery.sgl || {};
jQuery.sgl.translation = jQuery.sgl.translation || {};
jQuery.sgl.translation.aData = jQuery.sgl.translation.aData || {};

jQuery.extend(String.prototype, {
    translate: function() {
        if (jQuery.sgl.translation.aData[this]) {
            return jQuery.sgl.translation.aData[this];
        }
        return this;
    },
    tr: function() {
        return this.translate();
    }
});

jQuery.sgl.translation.add = function(aTrans) {
    if (aTrans) {
        jQuery.sgl.translation.aData = jQuery.extend({}, aTrans, jQuery.sgl.translation.aData);
    }
};

/**
  *  Highlight plugin using color plugin for jQuery
  *  (c) 2008 Philipp Simon <psimon@solotics.com>
  **/

(function(jQuery) {
    jQuery.sgl = jQuery.sgl || {};

    jQuery.fn.highlight = function(options) {
        var opts = jQuery.extend({}, jQuery.fn.highlight.defaults, options);
        return this.each(function() {
            var o = jQuery.metadata ? jQuery.extend({}, opts, jQuery(this).metadata()) : opts;
            jQuery.sgl.highlight(this, o);
        });
    };

    jQuery.fn.highlight.defaults = {
        color:      '#fff600',
        duration:   2000
    };

    jQuery.sgl.highlight = function(el, options) {
        var hasColor = true;
        var orgColor = jQuery.curCSS(el, 'backgroundColor');
        var par = jQuery(el).parent();
        var result;

        if (result = /rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(orgColor)) {
            orgColor = [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];
            if (result[1] == 0 && result[2] == 0 && result[3] == 0) orgColor = 'transparent';
        }

        while (orgColor == 'transparent' && par) {
            hasColor = false;
            orgColor = jQuery.curCSS(par.get(0), 'backgroundColor');
            if(result = /rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(orgColor)) {
                orgColor = [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];
                if (result[1] == 0 && result[2] == 0 && result[3] == 0) orgColor = 'transparent';
            }
            par=par.parent();
        }

        jQuery(el).css('backgroundColor', options.color);
        jQuery(el).animate({'backgroundColor': orgColor}, options.duration, null, function() {
            if (!hasColor) jQuery(this).css({'backgroundColor': ''});
        });
    };
})(jQuery);

/**
  *  Scroll a DOM element into view plugin for jQuery
  *  (c) 2008 Philipp Simon <psimon@solotics.com>
  **/

(function(jQuery) {

    jQuery.sgl = jQuery.sgl || {};

    // ________________________________________________________________________
    //

    jQuery.fn.scrollIntoView = function(options) {
        var opts = jQuery.extend({}, jQuery.fn.scrollIntoView.defaults, options);
        return this.each(function() {
            var o = jQuery.metadata ? jQuery.extend({}, opts, jQuery(this).metadata()) : opts;
            new jQuery.sgl.scrollIntoView(this, o);
        });
    };

    jQuery.fn.scrollIntoView.defaults = {
        offset:    10,
        duration:  500
    };

    // ________________________________________________________________________
    //

    jQuery.sgl.scrollIntoView = function(el, options) {
        var vpHeight    = self.innerHeight || document.documentElement.clientHeight || jQuery('body')[0].clientHeight || 0;
        var vpOffset    = self.pageYOffset || document.documentElement.scrollTop || jQuery('body')[0].scrollTop || 0;
        var layerOffset = jQuery(el).offset().top;
        var layerHeight = jQuery(el)[0].offsetHeight;

        if (layerOffset + layerHeight + options.offset > vpOffset + vpHeight) {
            if (layerHeight > vpHeight) {
                jQuery('html').scrollTo({ top: layerOffset - options.offset}, {duration: options.duration});
            } else {
                jQuery('html').scrollTo({ top: layerOffset + options.offset + layerHeight - vpHeight}, {duration: options.duration});
            }
        } else if(layerOffset - options.offset < vpOffset) {
            jQuery('html').scrollTo({ top: layerOffset - options.offset}, {duration: options.duration});
        }
    }

})(jQuery);

/**
  *  Checklist plugin for jQuery with checkOne/checkAll functionality
  *  (c) 2008 Philipp Simon <psimon@solotics.com>
  **/

(function(jQuery) {
    jQuery.sgl = jQuery.sgl || {};

    jQuery.fn.checkList = function(options) {
        var opts = jQuery.extend({}, jQuery.fn.checkList.defaults, options);
        return this.each(function() {
            var o = jQuery.metadata ? jQuery.extend({}, opts, jQuery(this).metadata()) : opts;
            new jQuery.sgl.checkList(this, o);
        });
    };

    jQuery.each(['BindOne','BindAll'], function(i, method) {
        jQuery.fn['checkList' + method] = function() {
            var args = arguments;
            var instance = jQuery.sgl.checkList.getInstance(this);
            return instance[method.charAt(0).toLowerCase() + method.substring(1)].apply(instance,args);
        };
    });

    jQuery.fn.checkList.defaults = {
        checkAll: 'checkAll[]',
        checkOne: 'checkOne[]'
    };

    jQuery.sgl.checkList = function(el, options) {
        this.options = options;
        this.container = el;
        var self = this;

        jQuery('input:checkbox', this.container).filter(function() {
            if (this.name==self.options.checkAll) {
                jQuery(this).click(function() {
                    self.checkAll(this);
                });
                return true;
            }
            if (this.name == self.options.checkOne) {
                jQuery(this).click(function() {
                    self.checkOne(this);
                });
                return true;
            }
            return false;
        });
        jQuery.data(el, 'sgl_checkList_instance', this);
    };

    jQuery.sgl.checkList.getInstance = function(el) {
        return jQuery.data(jQuery(el).get(0), 'sgl_checkList_instance');
    };

    jQuery.extend(jQuery.sgl.checkList.prototype, {
        bindOne: function(el) {
            var self = this;
            jQuery(el).click(function() {
                self.checkOne(this);
            });
            this.checkOne(this);
        },

        bindAll: function(el) {
            var self = this;
            jQuery(el).click(function() {
                self.checkAll(this);
            });
            this.checkAll(this);
        },

        checkAll: function(el) {
            var self = this;
            jQuery('input:checkbox', this.container).filter(function() {
                if (this.name == self.options.checkAll || this.name == self.options.checkOne) {
                    if (jQuery(el).is(':checked')) {
                        jQuery(this).attr('checked','checked');
                    } else {
                        jQuery(this).attr('checked','');
                    }
                }
            });
        },

        checkOne: function(el) {
            var self = this;
            var aChecked = jQuery('input:checkbox', this.container)
                .filter(function() {
                    if (this.name == self.options.checkOne) {
                        return true;
                    }
                    return false;
                })
                .filter(function() {
                    return !jQuery(this).is(':checked');
                });

            jQuery('input:checkbox', this.container).filter(function() {
                if (this.name == self.options.checkAll) {
                    if (!aChecked || !aChecked.length) {
                        jQuery(this).attr('checked','checked');
                    } else {
                        jQuery(this).attr('checked','');
                    }
                }
            });
        }
    });
})(jQuery);

/**
  *  Form plugin with change tracking and upload handling.
  *  Status tracking done by APC or UploadProgess Extension.
  *  (c) 2008 Philipp Simon <psimon@solotics.com>
  **/

(function(jQuery) {
    jQuery.sgl = jQuery.sgl || {};

    jQuery.fn.form = function(options) {
        var opts = jQuery.extend({}, jQuery.fn.form.defaults, options);
        return this.each(function() {
            var o = jQuery.metadata ? jQuery.extend({}, opts, jQuery(this).metadata()) : opts;
            new jQuery.sgl.form(this, o);
        });
    };

    jQuery.each(['AddItem', 'BindItem', 'MarkItem', 'ResetItem', 'RemoveItem', 'ChangedCount', 'Reset', 'Serialize', 'Submit', 'GetData', 'SetData'], function(i, method) {
        jQuery.fn['form' + method] = function() {
            var args = arguments;
            var instance = jQuery.sgl.form.getInstance(this);
            return instance[method.charAt(0).toLowerCase() + method.substring(1)].apply(instance, args);
        };
    });

    jQuery.fn.form.defaults = {
        targetLink:        null,
        changeText:        '%changeCount% unsaved change'.translate(),
        changeText2:       '%changeCount% unsaved changes'.translate(),
        changeTarget:      '.changeTracker',
        changeColor:       '#fff600',
        changedOnly:       true,
        onChanged:         null,
        uploadTargetLink:  makeUrl({module: 'media2', manager: 'media2', action: 'uploadFile'}),
        uploadStatusLink:  makeUrl({module: 'media2', action: 'uploadStatus'}),
        uploadFileSize:    ((typeof(window['SGL_UPLOAD_MAX_SIZE']) != 'undefined')) ? SGL_UPLOAD_MAX_SIZE : 10485760, // 10MB
        uploadAutoStart:   true,
        onUploadStart:     null,
        onUploadStatus:    null,
        onUploadFinished:  null
    };

    jQuery.sgl.form = function(el, options) {
        if (el) {
            this.options = options;
            this.aOrignalItems = new Array();
            this.aChangedItems = new Array();
            this.numChanged = 0;
            this.uploadsPending = 0;
            this.form = el;
            
            var self = this;
            jQuery('input[type=file]', this.form)
                .each(function() {
                    // We cannot read from file input fields, so we expect an already
                    // uploaded file to be the previous field with the same name.
                    if (jQuery(this).prev().length && this.name == jQuery(this).prev().get(0).name) {
                        var fileTitle = jQuery(this).prev().prev().val();
                        var fileValue = jQuery(this).prev().val();
                        jQuery(this).prev().remove();
                    }

                    if (fileValue) {
                        // Display an already uploaded file.
                        self.setupUploadFile(this, fileValue, fileTitle);
                    } else {
                        self.bindUploadFile(this);
                    }
                });
                
            for (var i = 0; i < el.elements.length; i++) {
                this.addItem(el.elements[i]);
            }                

            jQuery.data(el, 'sgl_form_instance', this);
        }
    };

    jQuery.sgl.form.getInstance = function(el) {
        return jQuery.data(jQuery(el).get(0), 'sgl_form_instance');
    };

    jQuery.extend(jQuery.sgl.form.prototype, {
        addItem: function(el) {
            if (el) {
                el = jQuery(el).get(0);
                if (el && el.name && el.type != 'hidden') {
                    if(el.type == 'radio' || el.type == 'checkbox') {
                        if( jQuery(el).is(':checked')) {
                            this.aOrignalItems[el.name] = jQuery(el).val();
                        } else if (!this.aOrignalItems[el.name]) {
                            this.aOrignalItems[el.name] = '';
                        }
                    } else {
                        this.aOrignalItems[el.name] = jQuery(el).val();
                    }
                    this.bindItem(el);
                }
            }
        },

        bindItem: function(el) {
            if (el && jQuery(el).attr('type') != 'hidden' && jQuery(el).attr('name')) {
                var self = this;
                el = jQuery(el).get(0);
                if (el.type == 'radio' || el.type == 'checkbox') {
                    jQuery(el).click(function(e) {
                        if (e && e.target && !jQuery(e.target).hasClass('ignoreChange')) {
                            self.markItem(e.target);
                        }
                    });
                } else {
                    jQuery(el).change(function(e) {
                        if (e && e.target && !jQuery(e.target).hasClass('ignoreChange')) {
                            self.markItem(e.target);
                        }
                    });
                }
            }
        },

        markItem: function(el) {
            if (el && !jQuery(el).hasClass('ignoreChange') && jQuery(el).attr('type') != 'hidden' && jQuery(el).attr('name')) {
                if (jQuery(el).val() && typeof(jQuery(el).val()) == 'object') {
                    if (this.aOrignalItems[jQuery(el).attr('name')] == null) {
                        var isOriginal = false;
                    } else {
                        var isOriginal = (jQuery(el).val().join(',') == this.aOrignalItems[jQuery(el).attr('name')].join(','));
                    }
                } else {
                    if ((jQuery(el).attr('type') == 'radio' || jQuery(el).attr('type') == 'checkbox') && !jQuery(el).is(':checked')) {
                        var isOriginal = (this.aOrignalItems[jQuery(el).attr('name')]) ? 1 : 0;
                    } else {
                        var isOriginal = (this.aOrignalItems[jQuery(el).attr('name')] == jQuery(el).val());
                    }
                }

                if (!this.aChangedItems[jQuery(el).attr('name')] && !isOriginal) {
                    this.aChangedItems[jQuery(el).attr('name')] = 1;
                    this.numChanged++;
                } else if (this.aChangedItems[jQuery(el).attr('name')] && isOriginal) {
                    if (jQuery(el).attr('type') == 'checkbox' || jQuery(el).attr('type') == 'radio') {
                        if (jQuery(el).is(':checked')) {
                            this.aChangedItems[jQuery(el).attr('name')] = 0;
                            if (this.numChanged > 0) this.numChanged--;
                        }
                    } else {
                        jQuery(el).val(this.aOrignalItems[jQuery(el).attr('name')]);
                        this.aChangedItems[jQuery(el).attr('name')] = 0;
                        if (this.numChanged > 0) this.numChanged--;
                    }
                }

                if (jQuery(el).attr('type') != 'checkbox' && jQuery(el).attr('type') != 'radio') {
                    if (!isOriginal) {
                        jQuery(el).css({backgroundColor: this.options.changeColor});
                    } else {
                        jQuery(el).css({backgroundColor: ''});
                    }
                }
                this.updateChangeTarget(this.numChanged);

                if (this.options.onChanged) {
                    this.options.onChanged(this, el);
                }
            }
        },

        resetItem: function(el) {
            if (el && !jQuery(el).hasClass('ignoreChange') && jQuery(el).attr('type') != 'hidden' && jQuery(el).attr('name')) {
                if (this.aChangedItems[jQuery(el).attr('name')]) {
                    this.aChangedItems[jQuery(el).attr('name')] = 0;
                    if (this.numChanged > 0) this.numChanged--;

                    jQuery(el).css({backgroundColor:''});
                    this.updateChangeTarget(this.numChanged);

                    if (this.options.onChanged) {
                        this.options.onChanged(this, el);
                    }
                }
            }
        },

        removeItem: function(el) {
            this.resetItem(el);
        },

        changedCount: function() {
            return this.numChanged;
        },

        reset: function() {
            this.aChangedItems = new Array();
            this.numChanged = 0;

            if (this.options.onChanged) {
                this.options.onChanged(this);
            }
        },

        serialize: function() {
            if(!this.options.changedOnly) {
                return '&' + jQuery(this.form).serialize();
            } else {
                var aElements = new Array();
                for (var i = 0,imax = this.form.elements.length; i < imax; i++) {
                    var el = this.form.elements[i];
                    if (jQuery(el).hasClass('forceSerialize') || (el.name && !jQuery(el).hasClass('ignoreSerialize') && (el.type == 'hidden' || (el.type == 'checkbox' && jQuery(el).is(':checked')) || (el.type != 'checkbox' && this.aChangedItems[el.name])))) {
                        aElements.push(el);
                    }
                }
                if (aElements && aElements.length) {
                    return '&' + jQuery(aElements).serialize();
                }
            }
            return false;
        },

        submit: function(callback, params) {
            var self = this;
            jQuery('input[type=submit]', this.form).attr('disabled', true).addClass('disabled');
            jQuery('.submit', this.form).attr('disabled', true).addClass('disabled');           
            
            var formSubmit = function() {
                jQuery.ajax({
                    type:     'POST',
                    url:      (self.options.targetLink) ? self.options.targetLink : self.form.action,
                    data:     (self.serialize() + ((params) ? params : '')),
                    dataType: 'json',
                    success:  function(response) {
                        if (callback) {
                            callback(response);
                        }
                        jQuery('input[type=submit]', this.form).attr('disabled', false).removeClass('disabled');
                        jQuery('.submit', this.form).attr('disabled', false).removeClass('disabled');           
                    }
                });
            };
            
            if (jQuery(this.form).next().hasClass('formUpload') &&
                jQuery(this.form).next().children().length) {
                var uploadForm = jQuery(this.form).next().get(0);
                var uploadIframe = jQuery(this.form).next().next().get(0);
                
                this.upload(uploadForm, uploadIframe, function() {
                    formSubmit();
                });
            } else {
                formSubmit();
            }
        },

        getData: function() {
            var oData = {};
            oData.aOrignalItems = this.aOrignalItems;
            oData.aChangedItems = this.aChangedItems;
            oData.numChanged    = this.numChanged;

            return oData;
        },

        setData: function(oData) {
            this.aOrignalItems = oData.aOrignalItems;
            this.aChangedItems = oData.aChangedItems;
            this.numChanged    = oData.numChanged;

            for (var i = 0; i < this.form.elements.length; i++) {
                this.markItem(this.form.elements[i]);
            }
        },

        updateChangeTarget: function(changeCount) {
            if (!changeCount) {
                jQuery(this.options.changeTarget, this.form).html('&nbsp;').hide();
            } else if (changeCount == 1) {
                jQuery(this.options.changeTarget, this.form).html(this.options.changeText.replace('%changeCount%', changeCount)).show();
            } else {
                jQuery(this.options.changeTarget, this.form).html(this.options.changeText2.replace('%changeCount%', changeCount)).show();
            }
        },

        bindUploadFile: function(el) {
            if (el) {
                var self = this;
                jQuery(el).change(function() {
                    var fileName = (el.value)
                        ? (el.value.substring(el.value.lastIndexOf('\\') + 1))
                        : '';

                    if (fileName) {
                        var uploadForm = self.setupUploadFile(el, '', fileName, self.options.uploadAutoStart);
                        if (self.options.uploadAutoStart) {
                            self.upload(uploadForm, jQuery(uploadForm).next().get(0));
                        }
                    }
                });
            }
        },

        setupUploadFile: function(el, fileValue, fileTitle, pending) {
            var self       = this;
            var fieldId    = el.id;
            var fieldIdTmp = el.id + 'Tmp';
            var fieldName  = el.name;

            if (jQuery(el).next().hasClass('error')) {
                jQuery(el).next().remove();
            }

            jQuery(el)
                .before(
                    '<input style="display: none; " type="text" id="' + fieldIdTmp + '" name="' + fieldName + '" value="' + fileValue + '" />'
                )
                .after(
                    '<div class="formUploadStatus" style="display: none; ">' +
                        '<span class="percent"></span>' +
                    '</div>'
                )
                .after(
                    '<span class="formUploadNameWrapper clearfix">' +
                        '<span class="formUploadName">' + fileTitle + '</span>' +
                        '<span class="formUploadIndicator"' + ((!pending) ? ' style="display: none; "' : '') + '></span>' +
                        '<a href="#" class="formUploadRemove" title="' + 'Remove'.translate() + '"' + ((pending) ? ' style="display: none; "' : '') + '></a>' +
                    '</span>'
                );
                
            var uploadForm   = false;
            var uploadIframe = false;
            var uploadId     = 0;
            
            jQuery('input', this.form)
                .filter(function() {
                    return (this.id == fieldIdTmp);
                })
                .each(function() {
                    this.id = fieldId;

                    jQuery('.formUploadNameWrapper .formUploadRemove', jQuery(this).parent())
                        .click(function(e) {
                            if (e) e.preventDefault();
                            jQuery(this).parent().next().remove();
                            jQuery(this).parent().prev().remove();
                            jQuery(this).parent().prev().val('');
                            jQuery(this).parent().before(
                                '<input class="text" type="file" id="' + fieldId + '" name="' + fieldName + '" />'
                            );
                            self.bindItem(jQuery(this).parent().prev().get(0));
                            self.markItem(jQuery(this).parent().prev().get(0));
                            self.bindUploadFile(jQuery(this).parent().prev().get(0));
                            jQuery(this).parent().remove();
                            
                            jQuery('input', uploadForm)
                                .filter(function() {
                                    return (this.name == 'APC_UPLOAD_PROGRESS[]' && this.value == uploadId);
                                })
                                .each(function() {
                                    jQuery(this).prev().prev().remove();
                                    jQuery(this).prev().remove();
                                    jQuery(this).next().remove();
                                    jQuery(this).remove();
                                });
                        });
                });
                
            if (el.value) {
                // Be sure, upload id is an integer.
                uploadId = parseInt(((1 + Math.random()) + '').replace('.',''));

                if (self.options.uploadAutoStart) {
                    // When uploadAutoStart is enabled, the upload starts right after the user
                    // has selected the file. This means we need one upload target
                    // form + iframe per file input field.
                    if (!jQuery('#formUploadTarget' + uploadId).length) {
                        jQuery(self.form).after(
                            '<iframe class="formUploadTarget" name="formUploadTarget' + uploadId + '" id="formUploadTarget' + uploadId + '"></iframe>'
                        );
                    }       
                    uploadIframe = jQuery('#formUploadTarget' + uploadId).get(0);
                    
                    if (!jQuery('#formUpload' + uploadId).length) {
                        jQuery(self.form).after(
                            '<form class="formUpload" name="formUpload' + uploadId + '" id="formUpload' + uploadId + '" action="' + self.options.uploadTargetLink  + '&rand=' + (1 + Math.random()) + '" target="formUploadTarget' + uploadId + '" method="post" enctype="multipart/form-data"></form>'
                        );
                    }
                    uploadForm = jQuery('#formUpload' + uploadId).get(0);
                }

                jQuery(el).before(
                    '<input type="hidden" name="MAX_FILE_SIZE" value="' + this.options.uploadFileSize + '" />' + 
                    '<input type="hidden" name="UPLOAD_IDENTIFIER[]" value="' + uploadId + '" />' +
                    '<input type="hidden" name="APC_UPLOAD_PROGRESS[]" value="' + uploadId + '" />'
                );
                jQuery('.formUploadName', jQuery(el).next()).attr('id', 'formUploadName' + uploadId);

                if (!this.options.uploadAutoStart) {
                    // When uploadAutoStart is disabled, the file upload starts with submitting the form.
                    // So we need only one upload target iframe for all file input fields.
                    var randId = parseInt(((1 + Math.random()) + '').replace('.',''));
                    
                    if (!jQuery(this.form).next().next().hasClass('formUploadTarget')) {
                        jQuery(this.form).after(
                            '<iframe class="formUploadTarget" name="formUploadTarget' + randId + '" id="formUploadTarget' + randId + '"></iframe>'
                        );
                    }
                    uploadIframe = jQuery(this.form).next().next().get(0);

                    if (!jQuery(this.form).next().hasClass('formUpload')) {
                        jQuery(this.form).after(
                            '<form class="formUpload" name="formUpload' + randId + '" id="formUpload' + randId + '" action="' + self.options.uploadTargetLink + '" target="formUploadTarget' + randId + '" method="post" enctype="multipart/form-data"></form>'
                        );
                    }
                    uploadForm = jQuery(this.form).next().get(0);
                }

                jQuery(uploadForm).append(jQuery(el).prev().prev());
                jQuery(uploadForm).append(jQuery(el).prev());
                jQuery(uploadForm).append(el);
                
                return uploadForm;
            } else {
                jQuery(el).remove();   
            }
            
            return null;
        },

        upload: function(uploadForm, uploadIframe, callback) {
            var self = this;
            
            // While uploading it's not allowed to submit the form.
            jQuery('input[type=submit]', this.form).attr('disabled', true).addClass('disabled');
            jQuery('.submit', this.form).attr('disabled', true).addClass('disabled');
            this.uploadsPending++;

            if (this.options.onUploadStart) {
                this.options.onUploadStart.apply(uploadForm);
            }

            var delay = 500;
            var timeout = false;
            var iframeOnLoad = function() {
                uploadIframe.onload = uploadIframe.onreadystatechange = function(){};
                clearTimeout(timeout);
                timeout = false;
                self.uploadStatus(uploadForm, uploadIframe.contentWindow.response, function() {
                    setTimeout(function() {
                        if ((--self.uploadsPending) == 0 && self.options.uploadAutoStart) {
                            jQuery('input[type=submit]', self.form).attr('disabled', false).removeClass('disabled');
                            jQuery('.submit', self.form).attr('disabled', false).removeClass('disabled');
                        }

                        for (var i in uploadIframe.contentWindow.response) {
                            var fileData = uploadIframe.contentWindow.response[i];
                            if (fileData.error && !fileData.errordesc) {
                                fileData.errordesc = 'An unknown error has occured.'.translate();
                            }

                            jQuery('#formUploadName' + i).next().hide();
                            jQuery('#formUploadName' + i).next().next().show();
                            jQuery('#formUploadName' + i).parent().next().hide();

                            jQuery('input', uploadForm)
                                .filter(function() {
                                    return (this.name == 'APC_UPLOAD_PROGRESS[]' && this.value == i);
                                })
                                .each(function() {
                                    var fieldId   = jQuery(this).next().get(0).id;
                                    var fieldName = jQuery(this).next().get(0).name;

                                    jQuery(this).prev().prev().remove();
                                    jQuery(this).prev().remove();
                                    jQuery(this).next().remove();
                                    jQuery(this).remove();

                                    jQuery('input', self.form)
                                        .filter(function() {
                                            return (this.name == fieldName);
                                        })
                                        .each(function() {
                                            if (fileData.errordesc) {
                                                var titleField = jQuery(this).prev().get(0);

                                                jQuery(titleField).val('');
                                                jQuery(titleField).next().remove();
                                                jQuery(titleField).next().remove();
                                                jQuery(titleField).next().remove();

                                                jQuery(titleField)
                                                    .after(
                                                        '<p class="error">' + fileData.errordesc + '</p>'
                                                    )
                                                    .after(
                                                        '<input class="text" type="file" id="' + fieldId + '" name="' + fieldName + '" />'
                                                    );

                                                self.bindUploadFile(jQuery(titleField).next().get(0));
                                            } else {
                                                jQuery(this).val(fileData.filename);
                                                jQuery(this).prev().val(fileData.filetitle);
                                            }
                                        });
                                });
                        }
                        if (self.uploadsPending == 0) {
                            if (callback) {
                                callback();
                            }
                        }
                    }, delay);
                });
                if (self.options.onUploadFinished) {
                    self.options.onUploadFinished(uploadForm, uploadIframe.contentWindow.response);
                }
            };
            uploadIframe.onreadystatechange = function() {
                if(/loaded|complete/i.test(uploadIframe.readyState))
                    iframeOnLoad();
            };

            uploadIframe.onload = iframeOnLoad;
            jQuery(uploadForm).submit();
            
            var aProgressKeys = new Array();
            jQuery('input', uploadForm)
                .filter(function() {
                    return (this.name == 'APC_UPLOAD_PROGRESS[]');
                })
                .each(function() {
                    jQuery('#formUploadName' + this.value).next().show();
                    jQuery('#formUploadName' + this.value).next().next().hide();                           
                    aProgressKeys.push('APC_PK[]=' + this.value);
                });

            timeout = setTimeout(function() {
                var callee = arguments.callee;
                jQuery.getJSON(self.options.uploadStatusLink + "?" + aProgressKeys.join("&") + '&rand=' + (1 + Math.random()), function(data) {
                    self.uploadStatus(uploadForm, data, function() {
                        if (timeout) {
                            timeout = setTimeout(callee, delay);
                        }
                    });
                });
            }, delay);
        },

        uploadStatus: function(uploadForm, response, callback) {
            if (this.options.onUploadStatus) {
                this.options.onUploadStatus.apply(uploadForm, response);
            }
            
            if (response) {
                for (var i in response) {
                    if (response[i] && response[i].loaded && response[i].total) {
                        if (!jQuery('#formUploadName' + i).parent().next().is(':visible') && response[i].total && response[i].total != response[i].loaded) {
                            jQuery('#formUploadName' + i).parent().next().show();
                            jQuery('.percent', jQuery('#formUploadName' + i).parent().next()).css("width", "0%");
                        }
    
                        jQuery('.percent', jQuery('#formUploadName' + i).parent().next())
                            .css('width', (Math.round((response[i].loaded * 100) / response[i].total) || 0)+ '%');
                    }
                }
            }
            
            if (callback) {
                callback();
            }
        }
    });
})(jQuery);

/**
  *  InSite-editing plugin based on jQuery
  *  (c) 2008 Philipp Simon <psimon@solotics.com>
  **/

(function(jQuery) {
    jQuery.sgl = jQuery.sgl || {};

    jQuery.fn.editable = function(options) {
        return this.each(function() {
            var self = this;
            if (!options) options = {};
            function setupEditable(e) {
                var data = jQuery.metadata ? jQuery(self).metadata() : null;
                if (data) options.data = options.data ? jQuery.extend({}, options.data, data) : data;
                new jQuery.sgl.editable(options, self);
                jQuery(self).unbind('mouseenter', setupEditable);
            }
            jQuery(this).bind('mouseenter', setupEditable);
        });
    };

    jQuery.fn.editable.defaults = {
        btnText:        'edit',
        btnClass:       'edit',
        btnParentClass: null,
        currentLink:    null,
        targetLink:     null,
        targetLayer:    null,
        sharedTarget:   false,
        showModal:      false,
        forceSubmit:    false,
        onCreate:       null,
        onBindToolbar:  null,
        onPreSelect:    null,
        onPreProcess:   null,
        onPostProcess:  null,
        onPreResponse:  null,
        onPostResponse: null,
        onConfirm:      null
    };

    jQuery.fn.editableList = function(options) {
        return this.each(function() {
            if (!options) options = {};
            var data = jQuery.metadata ? jQuery(this).metadata() : null;
            if(data) options.data = options.data ? jQuery.extend({}, options.data, data) : data;
            new jQuery.sgl.editableList(options, this);
        });
    };

    jQuery.fn.editableList.defaults = {
        selector:           '.editable',
        checkSelected:      'checkOne[]',
        onPreResponseList:  null,
        onPostResponseList: null,
        onConfirmList:      null
    };

    jQuery.sgl.editable = function(options, el) {
        jQuery.sgl.editable.instanceCount++;
        this.instanceId = jQuery.sgl.editable.instanceCount;
        this.options = jQuery.extend({}, jQuery.fn.editable.defaults, options);
        if (!this.options.data) this.options.data = {};
        this.currentLayer = this.activeLayer = el;
        this.targetLayer = null;
        var self = this;

        this.bindToolbar(true);
        if(this.options.targetLayer) {
            this.targetLayer = jQuery(this.options.targetLayer).get(0);
        }
        if (el) {
            this.options.data.id = el.id;
            if (jQuery.sgl.editable.getInstance(el, this.options.btnClass)) {
                var aInstances = jQuery.sgl.editable.getInstance(el);
                for (i in aInstances) {
                    if(aInstances[i].options.btnClass == name) {
                        aInstances[i] = this;
                    }
                }
                jQuery.data(el,'sgl_editable_instance',aInstances);
            } else {
                if (!jQuery.sgl.editable.getInstance(el)) {
                    jQuery.data(el, 'sgl_editable_instance', new Array());
                }
                jQuery.data(el, 'sgl_editable_instance').push(this);
            }
        } else {
            this.options.data.id = '0';
        }

        if (this.options.onCreate) {
            this.options.onCreate(this,this.options);
        }
    }

    jQuery.sgl.editable.instanceCount = 0;
    jQuery.sgl.editable.activeInstances = new Array();
    jQuery.sgl.editable.toolbarInstances = new Array();
    jQuery.sgl.editable.getInstance = function(el, name) {
        if (el) {
            if (!name) {
                return jQuery.data(jQuery(el).get(0), 'sgl_editable_instance');
            } else {
                var aInstances = jQuery.data(jQuery(el).get(0), 'sgl_editable_instance');
                for (i in aInstances) {
                    if (aInstances[i].options.btnClass == name) {
                        return aInstances[i];
                    }
                }
            }
        }
        return false;
    };
    jQuery.sgl.editable.getToolbar = function(el) {
        if (el) {
            return jQuery.data(jQuery(el).get(0), 'sgl_editable_toolbar');
        }
        return false;
    };

    jQuery.sgl.editable.showMessage = function(msg) {
        jQuery('#msg').show();
        jQuery('#msg').html(msg);

        jQuery('#msg')
            .fadeIn()
            .fadeOut(2000, function() {
                jQuery(this)
                    .html('&nbsp;')
                    .show();
            });
    };

    jQuery.extend(jQuery.sgl.editable.prototype, {
        process: function(options) {
            var self = this;
            if (!options) options = {};
            options.currentLink = (options.switchTargets)
                ? this.options.targetLink
                : this.options.currentLink;
            options.targetLink = (options.switchTargets)
                ? this.options.currentLink
                : this.options.targetLink;                
            options.currentLayer = (options.switchTargets)
                ? this.targetLayer
                : this.currentLayer;
            options.targetLayer = (options.switchTargets)
                ? this.currentLayer
                : this.targetLayer;

            if (options.data || options.currentLink) {
                if (this.options.sharedTarget) {
                    for (i in jQuery.sgl.editable.activeInstances) {
                        if (jQuery.sgl.editable.activeInstances[i] != this &&
                            jQuery.sgl.editable.activeInstances[i].targetLayer == this.targetLayer) {
                            var form = jQuery.sgl.editable.activeInstances[i].form;
                            if (jQuery.sgl.form && form && jQuery(form).formChangedCount()) {
                                if (!confirm('There are unsaved changes. Do you really want to continue?'.translate())) {
                                    return;
                                }
                            }
                            jQuery.sgl.editable.activeInstances[i].cancel();
                        }
                    }
                }
                if (this.options.showModal && options.currentLayer == this.currentLayer && !options.targetLayer && (!this.modalContainer || !jQuery(this.modalContainer).is(':visible'))) {
                    this.setupModal();
                }
                if (options.data) {
                    if (options.data.keepTargets) {
                        // Can be used to keep the previous target
                        // for the case of error handling.
                        if (this.options.showModal && !this.targetLayer) {
                            options.currentLayer = options.targetLayer = this.modalContainer;
                        } else {
                            options.currentLayer = options.targetLayer = this.targetLayer;
                        }
                        if (jQuery.sgl.form && this.form) {
                            var formData = jQuery(this.form).formGetData();
                        }
                    }

                    if (this.options.onPreProcess) {
                        this.options.onPreProcess(this, options);
                    }
                    if (options.data.remove) {
                        if (jQuery.sgl.form && this.form) {
                            jQuery(this.form).formReset();
                            this.form = null;
                        }
                        if (this.currentLayer) {
                            jQuery(this.currentLayer).remove();
                        }
                        if (this.targetLayer && !this.options.sharedTarget && !this.options.showModal) {
                            jQuery(this.targetLayer).remove();
                        } else if (this.targetLayer && this.options.sharedTarget) {
                            jQuery(this.targetLayer).empty();
                        }
                        this.currentLayer = options.currentLayer = null;
                        this.targetLayer = options.targetLayer = null;
                    }
                    if (this.options.targetLink && !options.targetLayer) { // && options.currentLayer
                        if (this.options.showModal && !options.switchTargets) {
                            options.targetLayer = this.modalContainer;
                        } else {
                            if (options.currentLayer && options.currentLayer.tagName == 'TR') {
                                var colspan = 0;
                                jQuery('td', options.currentLayer).each(function() {
                                    if (jQuery(this).attr('colspan')) {
                                        colspan += jQuery(this).attr('colspan')
                                    } else {
                                        colspan++;
                                    }
                                });
                                if (!jQuery('#editableTarget' + this.instanceId).length) {
                                    jQuery(options.currentLayer).after('<tr id="editableTarget' + this.instanceId + '" class="editableTarget">' +
                                                                           '<td colspan="' + colspan + '"></td>' +
                                                                       '</tr>');
                                }
                                this.targetLayer = options.targetLayer = jQuery('#editableTarget' + this.instanceId + ' td:first').get(0);
                            } else if (options.currentLayer) {
                                if (!jQuery('#editableTarget' + this.instanceId).length) {
                                    jQuery(options.currentLayer).after('<div id="editableTarget' + this.instanceId + '" class="editableTarget"></div>');
                                }
                                this.targetLayer = options.targetLayer = jQuery('#editableTarget' + this.instanceId).get(0);
                            }
                        }
                    }
                    if (options.data.content) {
                        if (options.data.insertMode) {
                            if (options.data.insertTarget) {
                                var insertTarget = jQuery(options.data.insertTarget).get(0);
                            } else {
                                var insertTarget = options.targetLayer;
                            }
                            if (options.data.insertId) {
                                if (options.data.insertClass) {
                                    var insertData = '<div id="' + options.data.insertId + '" class="' + options.data.insertClass + '">' + options.data.content + '</div>';                                    
                                } else {
                                    var insertData = '<div id="' + options.data.insertId + '">' + options.data.content + '</div>';
                                }
                            } else {
                                var insertData = options.data.content;
                            }
                            if (insertTarget && insertData) {
                                if (options.data.insertMode == 'replace') {
                                    jQuery(insertTarget).empty();
                                    jQuery(insertTarget).append(insertData);
                                } else if (options.data.insertMode == 'top') {
                                    jQuery(insertTarget).prepend(insertData);
                                } else {
                                    jQuery(insertTarget).append(insertData);
                                }
                            }
                            if (this.options.containerLayer) {
                                var aEditableLists = jQuery.sgl.editableList.getInstance(this.options.containerLayer);
                                if (aEditableLists) {
                                    for(var i in aEditableLists) {
                                        aEditableLists[i].rebind();
                                    }
                                }
                            }
                        } else if (options.targetLayer) {
                            if (this.currentLayer) {
                                var aInstanceList = jQuery.data(this.currentLayer, 'sgl_editable_instance');
                            }
                            if (options.data.updateMode == 'replace') {
                                jQuery(options.data.content).insertAfter(options.targetLayer);
                                var targetLayer = jQuery(options.targetLayer).next().get(0);
                                if (this.currentLayer == options.targetLayer) {
                                    this.currentLayer = targetLayer;
                                } else if (this.targetLayer == options.targetLayer) {
                                    this.targetLayer = targetLayer;
                                }
                                jQuery(options.targetLayer).remove();
                                options.targetLayer = targetLayer;
                            } else {
                                jQuery(options.targetLayer).html(options.data.content);
                            }
                            if (this.currentLayer == options.targetLayer) {
                                if (aInstanceList) {
                                    for (var i in aInstanceList) {
                                        aInstanceList[i].currentLayer = this.currentLayer;
                                        aInstanceList[i].bindToolbar();
                                        jQuery.data(this.currentLayer, 'sgl_editable_instance', aInstanceList);
                                    }
                                }
                                if (this.options.checkSelected && this.options.containerLayer && jQuery.sgl.checkList) {
                                    jQuery('input:checkbox', this.currentLayer)
                                        .filter(function(i) {
                                            return (this.name == self.options.checkSelected);
                                        })
                                        .each(function() {
                                            jQuery(self.options.containerLayer).checkListBindOne(this);
                                        });
                                }
                            }
                        }
                    }

                    if(options.data.currentLayer) {
                        this.currentLayer = options.currentLayer = jQuery(options.data.currentLayer).get(0);
                    }
                    if(options.data.targetLayer) {
                        this.targetLayer = options.targetLayer = jQuery(options.data.targetLayer).get(0);
                    }

                    if (options.targetLayer && jQuery.ui.tabs) {
                        jQuery('.tabs', options.targetLayer).tabs();
                    }

                    if (this.options.targetLink && options.currentLayer != options.targetLayer) {
                        if (jQuery.sgl.form && this.form) {
                            jQuery(this.form).formReset();
                            this.form = null;
                        }
                        if (options.currentLayer) {
                            if (options.currentLayer == this.targetLayer) {
                                if (!this.options.sharedTarget && !this.options.showModal) {
                                    if (options.currentLayer.tagName == 'TD') {
                                        jQuery(options.currentLayer).parent().remove();
                                    } else {
                                        jQuery(options.currentLayer).remove();
                                    }
                                    this.targetLayer = options.currentLayer = null;
                                } else {
                                    jQuery(options.currentLayer).html('');
                                }
                            } else if (!this.options.sharedTarget && !this.options.showModal) {
                                jQuery(options.currentLayer).hide();
                            }
                        }
                        if (options.targetLayer && ((options.currentLayer && !jQuery(options.currentLayer).is(':visible')) || !options.currentLayer)) {
                            jQuery(options.targetLayer).show();
                        }
                    }
                    
                    if (this.options.showModal && options.targetLayer == this.currentLayer) {
                        if (this.modalContainer) this.modalContainer.html('').hide();
                        if (this.modalOverlay) this.modalOverlay.hide();
                    }

                    if (this.options.onToggle) {
                        this.options.onToggle(this, options.targetLayer);
                    }

                    if (options.data.remove && this.options.onRemove) {
                        this.options.onRemove(this, options);
                    }

                    if(options.data.highlight && jQuery.sgl.highlight) {
                        if (options.data.highlight == 1 && options.targetLayer) {
                            jQuery(options.targetLayer).highlight();
                        } else if (options.data.highlight && jQuery(options.data.highlight).length) {
                            jQuery(options.data.highlight).highlight();
                        }
                    }
                    
                    if (options.targetLayer) {
                        if (!options.data.noScroll && jQuery.sgl.scrollIntoView) {
                            jQuery(options.targetLayer).scrollIntoView();
                        }
                        var targetForm = jQuery('form', options.targetLayer);
                        if (targetForm.length) {
                            if (jQuery.sgl.form) {
                                this.form = targetForm.get(0);
                                jQuery(this.form).form({
                                    targetLink: (options.data.keepTargets) ? options.currentLink : options.targetLink,
                                    onChanged: function(e) {
                                        if (self.options.onChanged) {
                                            self.options.onChanged(self, e);
                                        }
                                    }
                                });
                                if (formData) {
                                    jQuery(this.form).formSetData(formData);
                                }
                            } else {
                                this.form = targetForm.get(0);
                            }
                            if (options.data.focusField && targetForm.get(0).elements[options.data.focusField]) {
                                var result = jQuery('input, select, textarea', targetForm)
                                    .filter(function() {
                                        return (this.id == options.data.focusField);
                                    });
                                    
                                if (result) {
                                    if (targetForm.get(0).elements[options.data.focusField].createTextRange) {
                                        var oRange = targetForm.get(0).elements[options.data.focusField].createTextRange();
                                        oRange.collapse(false);
                                        oRange.select();
                                    }
                                    if (targetForm.get(0).elements[options.data.focusField].focus &&
                                        jQuery(targetForm.get(0).elements[options.data.focusField]).is(':visible')) {
                                        targetForm.get(0).elements[options.data.focusField].focus();
                                    }
                                }
                            }
                        }
                        this.bindEvents(options.targetLayer);
                    }
                    this.activeLayer = options.targetLayer;
                    if (options.targetLayer == this.targetLayer) {
                        jQuery.sgl.editable.activeInstances[this.instanceId] = this;
                    }

                    if (this.options.onPostProcess) {
                        this.options.onPostProcess(this, options);
                    }
                } else if (options.currentLink) {
                    if (((this.activeLayer != options.targetLayer || !this.activeLayer)) &&
                        (!this.options.onConfirm || this.options.onConfirm(this, options))) {
                        jQuery('html').css({'cursor': 'wait'});

                        if (this.options.onPreResponse) {
                            this.options.onPreResponse(this, options);
                        }

                        var curForm = (options.currentLayer) ? jQuery('form', options.currentLayer).get(0) : null;
                            curForm = (this.options.showModal && !curForm) ? jQuery('form', this.modalContainer).get(0) : curForm;
                        
                        var reqParams = '';
                        if (this.options.data) {
                            for (i in this.options.data) {
                                reqParams += '&data[' + this.instanceId + '][' + i + ']=' + this.options.data[i];
                            }
                        }
                        
                        var callback = function(response) {
                            if (response.redir == 1) {
                                document.location.reload();
                                return;
                            } else if (response.redir) {
                                document.location.href = response.redir;
                                return;
                            }

                            if( typeof(response.data) == 'object') {
                                if (response.data[self.instanceId]) {
                                    options.data = response.data[self.instanceId];
                                }
                            } else {
                                options.data = response.data;
                            }
                            
                            jQuery('html').css({'cursor': 'auto'});

                            if (options.data) {
                                self.process(options);
                            }

                            if (response.msg)
                                jQuery.sgl.editable.showMessage(response.msg);

                            if (self.options.containerLayer) {
                                if (response.title) jQuery('.title', self.options.containerLayer).html(response.title);
                                if (response.pager) jQuery('.pager', self.options.containerLayer).html(response.pager);

                                jQuery("tbody tr[class!='editableTarget']",      self.options.containerLayer).css({'backgroundColor': ''}).removeClass('backLight backDark');
                                jQuery("tbody tr[class!='editableTarget']:even", self.options.containerLayer).addClass('backLight');
                                jQuery("tbody tr[class!='editableTarget']:odd",  self.options.containerLayer).addClass('backDark');
                            }

                            if (self.options.onPostResponse) {
                                self.options.onPostResponse(self,options,response);
                            }
                        };
                        
                        if (curForm) {
                            jQuery(curForm).formSubmit(callback, reqParams);
                        } else {
                            jQuery.ajax({
                                type:     'POST',
                                url:      options.currentLink,
                                data:     reqParams,
                                dataType: 'json',
                                success:  callback
                            });
                        }
                    } else if (this.options.showModal) {
                        if (this.modalContainer) this.modalContainer.html('').hide();
                        if (this.modalOverlay) this.modalOverlay.hide();
                    }
                }
            }
        },

        bindToolbar: function(show) {
            var el = this.currentLayer;
            if (el) {
                var self = this;
                var oToolbar = jQuery.sgl.editable.getToolbar(el);
                if (!oToolbar) {
                    if (this.currentLayer.tagName == 'TR') {
                        jQuery('td:last-child', this.currentLayer).wrapInner('<div style="position: relative; "></div>');
                        var targetItem = jQuery('td:last-child div:first', this.currentLayer);
                    } else {
                        var targetItem = jQuery('h1,h2,h3,h4,h5,h6',el).get(0);
                        if (!targetItem) {
                            targetItem = jQuery(el);
                        } else {
                            this.currentLayer = jQuery('h1,h2,h3,h4,h5,h6', el).next().get(0);
                            if (!this.currentLayer) this.currentLayer = el;
                        }
                    }

                    oToolbar = jQuery('<span class="editToolbar"><div><div class="inner1"><ul></ul></div></div></span>');
                    jQuery(targetItem).append(oToolbar);
                    if (!show) oToolbar.hide();

                    jQuery(el).hover(
                        function() {
                            if (self.targetLayer != self.activeLayer) {
                                // Hack for IE to hide sub-items.
                                jQuery('li a ul', oToolbar).removeClass('hide');
                                oToolbar.show();
                            }
                        },
                        function() {
                            if (self.targetLayer != self.activeLayer) {
                                // Hack for IE to hide sub-items.
                                jQuery('li a ul', oToolbar).addClass('hide');
                                oToolbar.hide();
                            }
                        }
                    );

                    jQuery.data(el, 'sgl_editable_toolbar', oToolbar);
                }

                var insertTarget = jQuery('> div > div > ul', oToolbar).get(0);
                if (this.options.btnParentClass && jQuery('.' + this.options.btnParentClass, oToolbar).length) {
                    if (!jQuery('.' + this.options.btnParentClass, oToolbar).next().length) {
                        jQuery('.' + this.options.btnParentClass, oToolbar).append('<ul></ul>');
                        insertTarget = jQuery('.' + this.options.btnParentClass + ' ul', oToolbar).get(0);
                    }
                }

                if (this.options.btnText.translate) {
                    this.options.btnText = this.options.btnText.translate();
                }

                if (!jQuery('.' + this.options.btnClass, insertTarget).length) {
                    jQuery('> div > div', oToolbar).removeClass();
                    jQuery('> div > div', oToolbar).addClass('inner' + (jQuery('> div > div > ul > li', oToolbar).length + 1));
                    jQuery(insertTarget).append('<li><a class="' + this.options.btnClass + '" href="#" title="' + this.options.btnText + '"></a></li>');
                }

                jQuery('> div > div > ul li .' + this.options.btnClass, oToolbar).unbind('click');
                jQuery('> div > div > ul li .' + this.options.btnClass, oToolbar).click(function(e) {
                    e.stopPropagation();
                    e.preventDefault();

                    if (self.options.onPreSelect) {
                        self.options.onPreSelect(self,e);
                    }

                    jQuery('.editToolbar').hide();
                    self.process();

                    window.setTimeout(function() {
                        jQuery('.editToolbar').hide();
                    }, 1000);
                });

                if (this.options.onBindToolbar) {
                    this.options.onBindToolbar(this);
                }
            }
        },

        bindEvents: function(layer) {
            if (layer) {
                jQuery('form', layer).submit(function(e) {
                    return false;
                });
                var self = this;
                jQuery('.submit', layer).click(function(e) {
                    e.preventDefault();
                    self.submit();
                });
                jQuery('.cancel',layer).click(function(e) {
                    e.preventDefault();
                    self.cancel();
                });
            }
        },

        setupModal: function() {
            this.modalOverlay = jQuery('#editableModalOverlay');
            this.modalContainer = jQuery('#editableModalContainer');

            if (!this.modalOverlay.length) {
                this.modalOverlay = jQuery('<div id="editableModalOverlay">')
                    .css({
                        opacity:    0.5,
                        height:     '100%',
                        width:      '100%',
                        position:   'fixed',
                        left:       0,
                        top:        0,
                        zIndex:     5000
                    })
                    .prependTo('body'); 
                                    
                this.modalContainer = jQuery('<div id="editableModalContainer">')
                    .css({
                        position:   'fixed',
                        zIndex:     5100
                    })
                    .addClass(this.options.modalClass ? this.options.modalClass : null)
                    .prependTo('body');
            } else {
                this.modalContainer.html('');
                this.modalContainer.show();
                this.modalOverlay.show();
            }
        },

        submit: function() {
            if (this.options.forceSubmit || !jQuery.sgl.form || !this.form || jQuery(this.form).formChangedCount()) {
                this.process({switchTargets: true});
            } else {
                this.cancel(this);
            }
        },

        cancel: function() {
            if (this.form) {
                if (jQuery.sgl.form) {
                    jQuery(this.form).formReset();
                }
                this.form = null;
            }

            if (this.targetLayer) {
                if (!this.options.sharedTarget && !this.options.showModal) {
                    if (this.targetLayer.tagName == 'TD') {
                        jQuery(this.targetLayer).parent().remove();
                    } else {
                        jQuery(this.targetLayer).remove();
                    }
                    this.targetLayer = null;
                } else {
                    jQuery(this.targetLayer).html('');
                }
            }
            if (this.currentLayer) {
                jQuery(this.currentLayer).show();
            }

            this.activeLayer = this.currentLayer;
            delete jQuery.sgl.editable.activeInstances[this.instanceId];

            if(this.options.showModal) {
                if (this.modalContainer) this.modalContainer.html('').hide();
                if(this.modalOverlay) this.modalOverlay.hide();
            }

            if (this.options.onToggle && (!this.activeLayer || jQuery(this.activeLayer).is(':visible'))) {
                this.options.onToggle(this, this.activeLayer);
            }
        }
    });

    jQuery.sgl.editableList = function(options, el) {
        this.options = jQuery.extend({}, jQuery.fn.editableList.defaults, options);
        this.options.containerLayer = this.containerLayer = el;
        this.actionPending = false;
        this.aChangedList = new Array();
        this.changedCount = 0;
        this.openedCount = 0;
        var self = this;

        if (!this.options.titleLayer) {
            this.options.titleLayer = jQuery('.title', this.containerLayer).get(0);
        }
        if (!this.options.pagerLayer) {
            this.options.pagerLayer = jQuery('.pager',this.containerLayer).get(0);
        }
        if (!this.options.changeListText) {
            this.options.changeListText = '%changeCount% unsaved item';
        }
        if (!this.options.changeListText2) {
            this.options.changeListText2 = '%changeCount% unsaved items';
        }
        if (!this.options.onChanged) {
            this.options.onChanged = function(editable, el) {
                if (jQuery.sgl.form) {
                    if (!self.aChangedList[editable.instanceId] && jQuery(editable.form).formChangedCount()) {
                        self.aChangedList[editable.instanceId] = editable;
                        self.changedCount++;
                        self.updateChangeTracker(self.changedCount);
                    } else if (self.aChangedList[editable.instanceId] && !jQuery(editable.form).formChangedCount()) {
                        delete self.aChangedList[editable.instanceId];
                        self.changedCount--;
                        self.updateChangeTracker(self.changedCount);
                    }
                }
            }
        }
        if (!this.options.onToggle) {
            this.options.onToggle = function(editable, layer) {
                if (editable.targetLayer == layer) {
                    self.openedCount++;
                } else if (editable.currentLayer == layer && self.openedCount > 0) {
                    self.openedCount--;
                }
                if (self.openedCount > 0) {
                    jQuery('.' + self.options.btnClass + 'Submit', self.containerLayer).show();
                    jQuery('.' + self.options.btnClass + 'Cancel', self.containerLayer).show();
                } else {
                    jQuery('.' + self.options.btnClass + 'Submit', self.containerLayer).hide();
                    jQuery('.' + self.options.btnClass + 'Cancel', self.containerLayer).hide();
                }
            }
        }

        this.rebind();

        jQuery('.' + this.options.btnClass + 'All', self.containerLayer).each(function() {
            jQuery(this).click(function(e) {
                if(e) e.preventDefault();
                self.process();
            });
        });

        jQuery('.' + this.options.btnClass + 'Selected', self.containerLayer).each(function() {
            jQuery(this).click(function(e) {
                if(e) e.preventDefault();
                self.process({selectedOnly: true});
            });
        });

        jQuery('.' + this.options.btnClass + 'Submit', self.containerLayer).each(function() {
            jQuery(this).click(function(e) {
                if(e) e.preventDefault();
                self.process({switchTargets: true});
            });
        }).hide();
        jQuery('.' + this.options.btnClass + 'Cancel', self.containerLayer).each(function() {
            jQuery(this).click(function(e) {
                if(e) e.preventDefault();
                jQuery(self.options.selector, this.containerLayer).each(function() {
                    var editable = jQuery.sgl.editable.getInstance(this,self.options.btnClass);
                    if (editable && editable.activeLayer == editable.targetLayer) {
                        editable.cancel();
                    }
                });
            });
        }).hide();

        if (el) {
            if (!jQuery.data(el, 'sgl_editableList_instance')) {
                jQuery.data(el, 'sgl_editableList_instance', new Array());
            }
            jQuery.data(el, 'sgl_editableList_instance').push(this);
        }
    };

    jQuery.sgl.editableList.getInstance = function(el, name) {
        if (el) {
            if (!name) {
                return jQuery.data(jQuery(el).get(0), 'sgl_editableList_instance');
            } else {
                var aInstances = jQuery.data(jQuery(el).get(0), 'sgl_editableList_instance');
                for (var i in aInstances) {
                    if (aInstances[i].options.btnClass == name) {
                        return aInstances[i];
                    }
                }
            }
        }
        return false;
    };

    jQuery.extend(jQuery.sgl.editableList.prototype, {
        process: function(options) {
            var self = this;
            var aEditable = new Array();

            jQuery(this.options.selector, this.containerLayer)
                .filter(function(i) {
                    if (options.switchTargets || jQuery(this).is(':visible')) {
                        var isChecked = 0;
                        if (options.selectedOnly) {
                            isChecked = jQuery('input:checkbox', this).filter(function(i) {
                                if (this.name == self.options.checkSelected) {
                                    return jQuery(this).is(':checked');
                                }
                                return false;
                            }).length;
                        }

                        if (!options.selectedOnly || (options.selectedOnly && isChecked)) {
                            return true;
                        }
                    }
                    return false;
                })
                .each(function() {
                    var oEditable = jQuery.sgl.editable.getInstance(this, self.options.btnClass);
                    if (oEditable) {
                        if (!options.switchTargets || (options.switchTargets && oEditable.activeLayer == oEditable.targetLayer && (!oEditable.form || jQuery(oEditable.form).formChangedCount()))) {
                            aEditable.push(oEditable);
                        } else {
                            oEditable.cancel();
                        }
                    }
                });

            if (!this.actionPending && aEditable.length) {
                if (!this.options.onConfirmList || this.options.onConfirmList(this, options, aEditable)) {
                    if (this.options.onPreProcessList) {
                        this.options.onPreProcessList(self, options);
                    }                    
                    
                    this.actionPending = true;
                    var reqParams = '';

                    for (var i in aEditable) {
                        var curForms = jQuery('form', options.switchTargets ? aEditable[i].targetLayer : aEditable[i].currentLayer);
                        reqParams += (curForms.length) ? curForms.formSerialize(true) : '';
                        if (aEditable[i].options.data) {
                            for (var j in aEditable[i].options.data) {
                                reqParams += '&data[' + aEditable[i].instanceId + '][' + j + ']=' + encodeURIComponent(aEditable[i].options.data[j]);
                            }
                        }
                    }
                    
                    if (this.options.reqParams) {
                        reqParams += this.options.reqParams;
                    }

                    jQuery.ajax({
                        type:       'POST',
                        url:        options.switchTargets ? this.options.targetLink : this.options.currentLink,
                        data:       reqParams,
                        dataType:   'json',
                        success: function(response) {
                            self.actionPending = 0;
                            if (response.redir == 1) {
                                document.location.reload();
                                return;
                            } else if (response.redir) {
                                document.location.href = response.redir;
                                return;
                            }

                            if (typeof(response.data) == 'object') {
                                var isFirst = true;
                                for (var i in response.data) {
                                    if (!isFirst) {
                                        response.data[i].noScroll = true;
                                        response.data[i].focusField = false;
                                    }
                                    for (var j in aEditable) {
                                        if (aEditable[j].instanceId == i) {
                                            aEditable[j].process({switchTargets: options.switchTargets, data: response.data[i], fromList: true});
                                            break;
                                        }
                                    }
                                    isFirst = false;
                                }
                            }

                            if (response.msg) jQuery.sgl.editable.showMessage(response.msg);
                            if (response.title) jQuery(self.options.titleLayer).html(response.title);
                            if (response.pager) jQuery(self.options.pagerLayer).html(response.pager);

                            jQuery("tbody tr[class!='editableTarget']", self.containerLayer).css({'backgroundColor':''}).removeClass('backLight backDark');
                            jQuery("tbody tr[class!='editableTarget']:even", self.containerLayer).addClass('backLight');
                            jQuery("tbody tr[class!='editableTarget']:odd", self.containerLayer).addClass('backDark');

                            if (self.options.onPostProcessList) {
                                self.options.onPostProcessList(self,response);
                            }
                        }
                    });
                }
            }
        },

        rebind: function() {
            var self = this;
            jQuery(this.options.selector, this.containerLayer).each(function() {
                jQuery(this).editable(self.options);
                if (self.options.checkSelected) {
                    jQuery('input:checkbox', this)
                        .filter(function(i) {
                            return (this.name == self.options.checkSelected);
                        })
                        .each(function() {
                            jQuery(self.containerLayer).checkListBindOne(this);
                        });
                }
            });
        },

        updateChangeTracker: function(changeCount) {
            if (!changeCount) {
                jQuery('.changeListTracker', this.containerLayer).html('&nbsp;').hide();
            } else if (changeCount == 1) {
                var text = this.options.changeListText;
                if (this.options.changeListText.translate) {
                    var text = this.options.changeListText.translate();
                }
                jQuery('.changeListTracker', this.containerLayer).html(text.replace('%changeCount%', changeCount)).show();
            } else {
                var text = this.options.changeListText2;
                if (this.options.changeListText2.translate) {
                    var text = this.options.changeListText2.translate();
                }
                jQuery('.changeListTracker', this.containerLayer).html(text.replace('%changeCount%', changeCount)).show();
            }
        }
    });
})(jQuery);

/**
  *  Translit plugin for jQuery
  *  (c) 2008 Philipp Simon <psimon@solotics.com>
  **/

jQuery.extend(String.prototype, {
    translit: function() {
        var _str = this;
        _str = _str.toLowerCase();
        _str = _str.replace(/ü/g,'ue');
        _str = _str.replace(/ä/g,'ae');
        _str = _str.replace(/ö/g,'oe');
        _str = _str.replace(/ß/g,'ss');
        _str = _str.replace(/[_\.,?!\[\](){}]+/g,"_");
        _str = _str.replace(/-{2,}/g,"--");
        _str = _str.replace(/_\-+_/g,"--");
        _str = _str.replace(/['\s]+/g,"-");
        _str = _str.replace(/j{2,}/g,"j");
        _str = _str.replace(new RegExp("[^0-9a-z_\\-]+","g"),"");

        return _str;
    }
});

jQuery(document).ready(function() {
    jQuery('.tabs').tabs();
    
    if (jQuery('#home-banner').length) {
        var aImages = new Array();
        
        if (jQuery('#home-banner img').get(0).id == "banner_fanfoto.jpg") {
            aImages[0]="/themes/default/images/banner_fanfoto.jpg";
            aImages[1]="/themes/default/images/banner_hsvwechsel.jpg";
            aImages[2]="/themes/default/images/banner_fragen.jpg";            
        } else if (jQuery('#home-banner img').get(0).id == "banner_hsvwechsel.jpg") {
            aImages[0]="/themes/default/images/banner_hsvwechsel.jpg";
            aImages[1]="/themes/default/images/banner_fanfoto.jpg";
            aImages[2]="/themes/default/images/banner_fragen.jpg";            
        } else {
            aImages[0]="/themes/default/images/banner_fragen.jpg";            
            aImages[1]="/themes/default/images/banner_fanfoto.jpg";
            aImages[2]="/themes/default/images/banner_hsvwechsel.jpg";
        }

        jQuery('#home-banner').html('');
        jQuery("#home-banner").OptimalFadeImage({
            array_image : aImages,
            width : 409,
            height : 101,
            fade_intervall : 'slow',
            fade_step : 'fast',
            pause_change : 'slow'
        });         
    }
    
    if (jQuery('#cardSchalke1Change').length) {
        jQuery('#cardSchalke1Change').click(function() {
            if (jQuery('#cardSchalke1').get(0).className == 'side1') {
                jQuery('#cardSchalke1').get(0).src = '/images/Image/card_schalke_r.jpg';    
                jQuery('#cardSchalke1').get(0).className = 'side2';
            } else {
                jQuery('#cardSchalke1').get(0).src = '/images/Image/card_schalke.jpg';                
                jQuery('#cardSchalke1').get(0).className = 'side1';
            }
            return false;
        });
        jQuery('#cardSchalke2Change').click(function() {
            if (jQuery('#cardSchalke2').get(0).className == 'side1') {
                jQuery('#cardSchalke2').get(0).src = '/images/Image/card_schalke2_r.jpg';    
                jQuery('#cardSchalke2').get(0).className = 'side2';
            } else {
                jQuery('#cardSchalke2').get(0).src = '/images/Image/card_schalke2.jpg';                
                jQuery('#cardSchalke2').get(0).className = 'side1';
            }
            return false;
        });        
    }
    
    var player = null;
    if (jQuery('#video-inner').length) {
        if (!DetectFlashVer('9', '0', '114')) {
            jQuery('#video-inner').html('');
            jQuery('#video-inner').css('backgroundColor', 'black');
            jQuery('#video-inner').append('<p style="text-align: center; padding-top: 15px;">Bitte aktualisieren Sie Ihren Flash-Player, um die Videos anschauen zu können.<br/><br/><a href="http://get.adobe.com/de/flashplayer/" target="_blank">Jetzt downloaden</a></p>');
        } else {
           var player = flowplayer("video-inner", "/flash/flowplayer.swf", {
                clip : { 
                    showFullScreenButton: false,
                    autoPlay: true
                },
                playlist: [{ 
                    url: '/flash/video.flv', 
                    autoPlay: true
                },  
                { 
                    url: '/flash/video3.flv', 
                    autoPlay: false
                },              
                { 
                    url: '/flash/video4.flv', 
                    autoPlay: false
                }],                    
                plugins: {
                    controls: null
                }                                 
            });    
            jQuery('#video-link-1').click(function(e) {
                e.preventDefault();
                player.play(0);
                return false;
            });        
            jQuery('#video-link-3').click(function(e) {
                e.preventDefault();
                player.play(1);
                return false;
            });        
            jQuery('#video-link-4').click(function(e) {
                e.preventDefault();
                player.play(2);
                return false;
            });
        }
    }
    
    if (jQuery('#video-inner2').length) {
        jQuery('#video-inner2 a').click(function(e) {
            e.preventDefault();
            flowplayer("video-inner2", "/flash/flowplayer.swf", {
                clip: { 
                    url: '/flash/video2.flv', 
                    autoPlay: true
                },  
                plugins: {
                    controls: null
                }
            });
        });
    }    
    
    if (jQuery('#galleryThumbs').length) {
        stepcarousel.setup({
        	galleryid: 'galleryThumbs',
        	beltclass: 'belt',
        	panelclass: 'thumb',
        	autostep: {enable:false},
        	panelbehavior: {speed:500, wraparound:false, persist:false},
        	defaultbuttons: {enable: false},
        	statusvars: ['statusA', 'statusB', 'statusC'],
        	contenttype: ['inline']
        });
        
        jQuery('.lightbox').lightbox();
        jQuery('#galleryImage a').click(function() {
            var id = jQuery('#galleryImage a').get(0).className;
            jQuery('#lb-' + id).lightbox.start(jQuery('#lb-' + id).get(0));
            
            return false;
        });
    }    
    
    if (jQuery('#galleryThumbs .thumb').length) {
        jQuery(jQuery('#galleryThumbs .thumb').get(0)).addClass('thumb_current');
        jQuery('#galleryThumbs .thumb').each(function() {
            jQuery(this).click(function(e) {
                if (e) e.preventDefault();
                
                jQuery('#galleryThumbs .thumb').each(function() {
                    jQuery(this).removeClass('thumb_current');
                });
                jQuery(this).addClass('thumb_current');
                jQuery('#galleryImage img').get(0).src = '/soccer/images/gallery/' + this.id;
                jQuery('#galleryImage a').get(0).className = jQuery('img', this).get(0).className;
            });
        });
        
        var pages = Math.ceil(jQuery('#galleryThumbs .thumb').length / 5);
        if (pages > 1) {
            jQuery('#galleryPager').append('<a id="galleryPrevPage" href="#"><img src="/themes/default/images/button2.gif" align="absmiddle" /></a>');            
            jQuery('#galleryPager').append('&nbsp;&nbsp;');

            jQuery('#galleryPrevPage').click(function(e) {
                if (e) e.preventDefault();
                
                var curPage = parseInt(parseInt(jQuery('#statusA').html()) / 5);
                if (0 < curPage) {
                    stepcarousel.stepTo('galleryThumbs', (curPage * 5) - 4);
                    updateGalleryPager();
                }
            });
            
            for (var x = 0; x < pages; x++) {
                jQuery('#galleryPager').append('<a id="galleryPage' + x + '" href="#">' + (x + 1) + '</a>');
                jQuery('#galleryPager').append('&nbsp;&nbsp;');
                
                jQuery('#galleryPage' + x).click(function(e) {
                    if (e) e.preventDefault();
                    var aData = this.id.match(/^galleryPage(.*)$/);
                    var pageId = parseInt(aData[1]) * 5 + 1;
    
                    stepcarousel.stepTo('galleryThumbs', pageId);
                    updateGalleryPager();
                });
            }
            
            jQuery('#galleryPager').append('<a id="galleryNextPage" href="#"><img src="/themes/default/images/button.gif" align="absmiddle" /></a>');            
            
            jQuery('#galleryNextPage').click(function(e) {
                if (e) e.preventDefault();

                var curPage = parseInt(parseInt(jQuery('#statusA').html()) / 5);
                if (pages > curPage+1) {
                    stepcarousel.stepTo('galleryThumbs', (curPage * 5) + 6);
                    updateGalleryPager();
                }
            });            
            
            updateGalleryPager();
        }
    }
});

updateGalleryPager = function() {
    var pages = Math.ceil(jQuery('#galleryThumbs .thumb').length / 5);
    var curPage = parseInt(parseInt(jQuery('#statusA').html()) / 5);

    jQuery('#galleryPager a').each(function() {
        jQuery(this).removeClass('currentPage');
    });

    jQuery('#galleryPage' + curPage).addClass('currentPage');
    
    if (curPage == 0) {
        jQuery('#galleryPrevPage').fadeTo('fast', 0.5);
    } else {
        jQuery('#galleryPrevPage').fadeTo('fast', 1.0);        
    }

    if (curPage == (pages-1)) {
        jQuery('#galleryNextPage').fadeTo('fast', 0.5);
    } else {
        jQuery('#galleryNextPage').fadeTo('fast', 1.0);        
    }    
    
};  