/*IE 6 not supported*/
var msg1 = "Did you know that your Internet Explorer is out of date?";
var msg2 = "To get the best possible experience using our website we recommend that you upgrade to a newer version or other web browser. A list of the most popular web browsers can be found below.";
var msg3 = "Just click on the icons to get to the download page";
var br1 = "Internet Explorer 9";
var br2 = "Firefox 6";
var br3 = "Safari 5";
var br4 = "Opera 11";
var br5 = "Chrome 10";
var url1 = "http://www.microsoft.com/windows/Internet-explorer/default.aspx";
var url2 = "http://www.mozilla.com/firefox/";
var url3 = "http://www.apple.com/safari/download/";
var url4 = "http://www.opera.com/download/";
var url5 = "http://www.google.com/chrome";
var imgPath;

function ie(str) { imgPath = str; var _body = document.getElementsByTagName('body')[0]; var _d = document.createElement('div'); var _l = document.createElement('div'); var _h = document.createElement('h1'); var _p1 = document.createElement('p'); var _p2 = document.createElement('p'); var _ul = document.createElement('ul'); var _li1 = document.createElement('li'); var _li2 = document.createElement('li'); var _li3 = document.createElement('li'); var _li4 = document.createElement('li'); var _li5 = document.createElement('li'); var _ico1 = document.createElement('div'); var _ico2 = document.createElement('div'); var _ico3 = document.createElement('div'); var _ico4 = document.createElement('div'); var _ico5 = document.createElement('div'); var _lit1 = document.createElement('div'); var _lit2 = document.createElement('div'); var _lit3 = document.createElement('div'); var _lit4 = document.createElement('div'); var _lit5 = document.createElement('div'); _body.appendChild(_l); _body.appendChild(_d); _d.appendChild(_h); _d.appendChild(_p1); _d.appendChild(_p2); _d.appendChild(_ul); _ul.appendChild(_li1); _ul.appendChild(_li2); _ul.appendChild(_li3); _ul.appendChild(_li4); _ul.appendChild(_li5); _li1.appendChild(_ico1); _li2.appendChild(_ico2); _li3.appendChild(_ico3); _li4.appendChild(_ico4); _li5.appendChild(_ico5); _li1.appendChild(_lit1); _li2.appendChild(_lit2); _li3.appendChild(_lit3); _li4.appendChild(_lit4); _li5.appendChild(_lit5); _d.setAttribute('id', '_d'); _l.setAttribute('id', '_l'); _h.setAttribute('id', '_h'); _p1.setAttribute('id', '_p1'); _p2.setAttribute('id', '_p2'); _ul.setAttribute('id', '_ul'); _li1.setAttribute('id', '_li1'); _li2.setAttribute('id', '_li2'); _li3.setAttribute('id', '_li3'); _li4.setAttribute('id', '_li4'); _li5.setAttribute('id', '_li5'); _ico1.setAttribute('id', '_ico1'); _ico2.setAttribute('id', '_ico2'); _ico3.setAttribute('id', '_ico3'); _ico4.setAttribute('id', '_ico4'); _ico5.setAttribute('id', '_ico5'); _lit1.setAttribute('id', '_lit1'); _lit2.setAttribute('id', '_lit2'); _lit3.setAttribute('id', '_lit3'); _lit4.setAttribute('id', '_lit4'); _lit5.setAttribute('id', '_lit5'); var _width = document.documentElement.clientWidth; var _height = document.documentElement.clientHeight; var _dl = document.getElementById('_l'); _dl.style.width = _width + "px"; _dl.style.height = _height + "px"; _dl.style.position = "absolute"; _dl.style.top = "0px"; _dl.style.left = "0px"; _dl.style.filter = "alpha(opacity=50)"; _dl.style.background = "#fff"; var _dd = document.getElementById('_d'); _ddw = 650; _ddh = 260; _dd.style.width = _ddw + "px"; _dd.style.height = _ddh + "px"; _dd.style.position = "absolute"; _dd.style.top = ((_height - _ddh) / 2) + "px"; _dd.style.left = ((_width - _ddw) / 2) + "px"; _dd.style.padding = "20px"; _dd.style.background = "#fff"; _dd.style.border = "1px solid #ccc"; _dd.style.fontFamily = "'Lucida Grande','Lucida Sans Unicode',Arial,Verdana,sans-serif"; _dd.style.listStyleType = "none"; _dd.style.color = "#4F4F4F"; _dd.style.fontSize = "12px"; _h.appendChild(document.createTextNode(msg1)); var _hd = document.getElementById('_h'); _hd.style.display = "block"; _hd.style.fontSize = "1.3em"; _hd.style.marginBottom = "0.5em"; _hd.style.color = "#333"; _hd.style.fontFamily = "Helvetica,Arial,sans-serif"; _hd.style.fontWeight = "bold"; _p1.appendChild(document.createTextNode(msg2)); var _p1d = document.getElementById('_p1'); _p1d.style.marginBottom = "1em"; _p2.appendChild(document.createTextNode(msg3)); var _p2d = document.getElementById('_p2'); _p2d.style.marginBottom = "1em"; var _uld = document.getElementById('_ul'); _uld.style.listStyleImage = "none"; _uld.style.listStylePosition = "outside"; _uld.style.listStyleType = "none"; _uld.style.margin = "0 px auto"; _uld.style.padding = "0px"; _uld.style.paddingLeft = "10px"; var _li1d = document.getElementById('_li1'); var _li2d = document.getElementById('_li2'); var _li3d = document.getElementById('_li3'); var _li4d = document.getElementById('_li4'); var _li5d = document.getElementById('_li5'); var _li1ds = _li1d.style; var _li2ds = _li2d.style; var _li3ds = _li3d.style; var _li4ds = _li4d.style; var _li5ds = _li5d.style; _li1ds.background = _li2ds.background = _li3ds.background = _li4ds.background = _li5ds.background = "transparent url('" + imgPath + "background_browser.gif') no-repeat scroll left top"; _li1ds.cursor = _li2ds.cursor = _li3ds.cursor = _li4ds.cursor = _li5ds.cursor = "pointer"; _li1d.onclick = function () { window.location = url1 }; _li2d.onclick = function () { window.location = url2 }; _li3d.onclick = function () { window.location = url3 }; _li4d.onclick = function () { window.location = url4 }; _li5d.onclick = function () { window.location = url5 }; _li1ds.styleFloat = _li2ds.styleFloat = _li3ds.styleFloat = _li4ds.styleFloat = _li5ds.styleFloat = "left"; _li1ds.width = _li2ds.width = _li3ds.width = _li4ds.width = _li5ds.width = "120px"; _li1ds.height = _li2ds.height = _li3ds.height = _li4ds.height = _li5ds.height = "122px"; _li1ds.margin = _li2ds.margin = _li3ds.margin = _li4ds.margin = _li5ds.margin = "0 10px 10px 0"; var _ico1d = document.getElementById('_ico1'); var _ico2d = document.getElementById('_ico2'); var _ico3d = document.getElementById('_ico3'); var _ico4d = document.getElementById('_ico4'); var _ico5d = document.getElementById('_ico5'); var _ico1ds = _ico1d.style; var _ico2ds = _ico2d.style; var _ico3ds = _ico3d.style; var _ico4ds = _ico4d.style; var _ico5ds = _ico5d.style; _ico1ds.width = _ico2ds.width = _ico3ds.width = _ico4ds.width = _ico5ds.width = "100px"; _ico1ds.height = _ico2ds.height = _ico3ds.height = _ico4ds.height = _ico5ds.height = "100px"; _ico1ds.margin = _ico2ds.margin = _ico3ds.margin = _ico4ds.margin = _ico5ds.margin = "1px auto"; _ico1ds.background = "transparent url('" + imgPath + "browser_ie.gif') no-repeat scroll left top"; _ico2ds.background = "transparent url('" + imgPath + "browser_firefox.gif') no-repeat scroll left top"; _ico3ds.background = "transparent url('" + imgPath + "browser_safari.gif') no-repeat scroll left top"; _ico4ds.background = "transparent url('" + imgPath + "browser_opera.gif') no-repeat scroll left top"; _ico5ds.background = "transparent url('" + imgPath + "browser_chrome.gif') no-repeat scroll left top"; _lit1.appendChild(document.createTextNode(br1)); _lit2.appendChild(document.createTextNode(br2)); _lit3.appendChild(document.createTextNode(br3)); _lit4.appendChild(document.createTextNode(br4)); _lit5.appendChild(document.createTextNode(br5)); var _lit1d = document.getElementById('_lit1'); var _lit2d = document.getElementById('_lit2'); var _lit3d = document.getElementById('_lit3'); var _lit4d = document.getElementById('_lit4'); var _lit5d = document.getElementById('_lit5'); var _lit1ds = _lit1d.style; var _lit2ds = _lit2d.style; var _lit3ds = _lit3d.style; var _lit4ds = _lit4d.style; var _lit5ds = _lit5d.style; _lit1ds.color = _lit2ds.color = _lit3ds.color = _lit4ds.color = _lit5ds.color = "#808080"; _lit1ds.fontSize = _lit2ds.fontSize = _lit3ds.fontSize = _lit4ds.fontSize = _lit5ds.fontSize = "0.8em"; _lit1ds.height = _lit2ds.height = _lit3ds.height = _lit4ds.height = _lit5ds.height = "18px"; _lit1ds.lineHeight = _lit2ds.lineHeight = _lit3ds.lineHeight = _lit4ds.lineHeight = _lit5ds.lineHeight = "17px"; _lit1ds.margin = _lit2ds.margin = _lit3ds.margin = _lit4ds.margin = _lit5ds.margin = "1px auto"; _lit1ds.width = _lit2ds.width = _lit3ds.width = _lit4ds.width = _lit5ds.width = "118px"; _lit1ds.textAlign = _lit2ds.textAlign = _lit3ds.textAlign = _lit4ds.textAlign = _lit5ds.textAlign = "center"; }


/*IE 6 hover plagin*/
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('9 u=k(){9 g=/^([^#.>`]*)(#|\\.|\\>|\\`)(.+)$/;k u(a,b){9 c=a.J(/\\s*\\,\\s*/);9 d=[];n(9 i=0;i<c.l;i++){d=d.v(o(c[i],b))};6 d};k o(a,b,c){a=a.z(" ","`");9 d=a.r(g);9 e,5,m,7,i,h;9 f=[];4(d==8){d=[a,a]};4(d[1]==""){d[1]="*"};4(c==8){c="`"};4(b==8){b=E};K(d[2]){w"#":7=d[3].r(g);4(7==8){7=[8,d[3]]};e=E.L(7[1]);4(e==8||(d[1]!="*"&&!x(e,d[1]))){6 f};4(7.l==2){f.A(e);6 f};6 o(7[3],e,7[2]);w".":4(c!=">"){5=p(b,d[1])}y{5=b.B};n(i=0,h=5.l;i<h;i++){e=5[i];4(e.C!=1){q};7=d[3].r(g);4(7!=8){4(e.j==8||e.j.r("(\\\\s|^)"+7[1]+"(\\\\s|$)")==8){q};m=o(7[3],e,7[2]);f=f.v(m)}y 4(e.j!=8&&e.j.r("(\\\\s|^)"+d[3]+"(\\\\s|$)")!=8){f.A(e)}};6 f;w">":4(c!=">"){5=p(b,d[1])}y{5=b.B};n(i=0,h=5.l;i<h;i++){e=5[i];4(e.C!=1){q};4(!x(e,d[1])){q};m=o(d[3],e,">");f=f.v(m)};6 f;w"`":5=p(b,d[1]);n(i=0,h=5.l;i<h;i++){e=5[i];m=o(d[3],e,"`");f=f.v(m)};6 f;M:4(c!=">"){5=p(b,d[1])}y{5=b.B};n(i=0,h=5.l;i<h;i++){e=5[i];4(e.C!=1){q};4(!x(e,d[1])){q};f.A(e)};6 f}};k p(a,b){4(b=="*"&&a.F!=8){6 a.F};6 a.p(b)};k x(a,b){4(b=="*"){6 N};6 a.O.G().z("P:","")==b.G()};6 u}();k Q(a,b){9 c=u(a);n(9 i=0;i<c.l;i++){c[i].R=k(){4(t.j.H(b)==-1){t.j+=" "+b}};c[i].S=k(){4(t.j.H(b)!=-1){t.j=t.j.z(b,"")}}}}4(D.I&&!D.T){D.I("U",V)}',58,58,'||||if|listNodes|return|subselector|null|var||||||||limit||className|function|length|listSubNodes|for|doParse|getElementsByTagName|continue|match||this|parseSelector|concat|case|matchNodeNames|else|replace|push|childNodes|nodeType|window|document|all|toLowerCase|indexOf|attachEvent|split|switch|getElementById|default|true|nodeName|html|hoverForIE6|onmouseover|onmouseout|opera|onload|ieHover'.split('|'),0,{}))
/*parametrs [selector, hover_class]*/
function ieHover() {
	hoverForIE6(".link-bar .social-networks li, .article tr", "hover");
	hoverForIE6(".select-area", "select-hover");
	hoverForIE6(".column-holder .column", "column-hover");
}

function initBrowserDetect()
{
	var u = navigator.userAgent.toLowerCase();
	var _html = document.getElementsByTagName("html")[0];
	
	if(is("win")) addClass("win");
	else if(is("mac")) addClass("mac");
	else if(is("linux") || is("x11")) addClass("linux");

	if (is("msie 9.0")) addClass("ie9");
	else if(is("msie 8.0")) addClass("ie8");
	else if(is("msie 7.0")) addClass("ie7");
	else if(is("msie 6.0")) addClass("ie6");
	else if(is("firefox/2")) addClass("ff2");
	else if (is("firefox/3")) addClass("ff3");
	else if (is("firefox/4")) addClass("ff4");
	else if(is("opera") && is("version/10")) addClass("opera10");
	else if(is("opera/9")) addClass("opera9");
	else if(is("safari") && is("version/3")) addClass("safari3");
	else if(is("safari") && is("version/4")) addClass("safari4");
	else if(is("safari") && is("version/5")) addClass("safari5");
	else if(is("chrome")) addClass("chrome");
	else if(is("safari")) addClass("safari2");
	else if(is("unknown")) addClass("unknown");
	
	if(is("msie")) addClass("trident");
	else if(is("applewebkit")) addClass("webkit");
	else if(is("gecko")) addClass("gecko");
	else if(is("opera")) addClass("presto");

	var isiPad = navigator.userAgent.match(/iPad/i) != null;
	var isiPhone = navigator.userAgent.match(/iPhone/i) != null;
	var isiPod = navigator.userAgent.match(/iPod/i) != null;
	var isAndroid = navigator.userAgent.match(/Android/i) != null;

	if (isiPad || isiPhone || isiPod || isAndroid)
	    addClass("idevice");
    	
	function is(browser)
	{
		if(u.indexOf(browser) !=-1) return true;
	}
	function addClass(_class)
	{
		_html.className += (" " + _class);
	}
}
if (window.addEventListener)
	window.addEventListener("load", initBrowserDetect, false);
else if (window.attachEvent)
	window.attachEvent("onload", initBrowserDetect);


function hideFormText() {
	var _inputs = document.getElementsByTagName('input');
	var _txt = document.getElementsByTagName('textarea');
	var _value = [];
	
	if (_inputs) {
		for(var i=0; i<_inputs.length; i++) {
			if (_inputs[i].type == 'text' || _inputs[i].type == 'password') {
			    if (_inputs[i].id == 'filter-box')
			        return;
				_inputs[i].index = i;
				_value[i] = _inputs[i].value;
				
				_inputs[i].onfocus = function(){
					if (this.value == _value[this.index])
						this.value = '';
				}
				_inputs[i].onblur = function(){
					if (this.value == '')
						this.value = _value[this.index];
				}
			}
		}
	}
	if (_txt) {
		for(var i=0; i<_txt.length; i++) {
			_txt[i].index = i;
			_value['txt'+i] = _txt[i].value;
			
			_txt[i].onfocus = function(){
				if (this.value == _value['txt'+this.index])
					this.value = '';
			}
			_txt[i].onblur = function(){
				if (this.value == '')
					this.value = _value['txt'+this.index];
			}
		}
	}
}
if (window.addEventListener)
	window.addEventListener("load", hideFormText, false);
else if (window.attachEvent)
    window.attachEvent("onload", hideFormText);

/*json2*/
var JSON;if(!JSON){JSON={};}
(function(){"use strict";function f(n){return n<10?'0'+n:n;}
if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+
f(this.getUTCMonth()+1)+'-'+
f(this.getUTCDate())+'T'+
f(this.getUTCHours())+':'+
f(this.getUTCMinutes())+':'+
f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}
var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}
function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}
if(typeof rep==='function'){value=rep.call(holder,key,value);}
switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}
v=partial.length===0?'[]':gap?'[\n'+gap+partial.join(',\n'+gap)+'\n'+mind+']':'['+partial.join(',')+']';gap=mind;return v;}
if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){if(typeof rep[i]==='string'){k=rep[i];v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.prototype.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}
v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}
if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}
rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}
return str('',{'':value});};}
if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.prototype.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}
return reviver.call(holder,key,value);}
text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+
('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}
if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
throw new SyntaxError('JSON.parse');};}}());

/* Socket.IO.min 0.6.2 @author Guillermo Rauch <guillermo@learnboost.com>, @license The MIT license., @copyright Copyright (c) 2010 LearnBoost <dev@learnboost.com> */
var io = this.io = { version: "0.6.2", setPath: function (a) { window.console && console.error && console.error("io.setPath will be removed. Please set the variable WEB_SOCKET_SWF_LOCATION pointing to WebSocketMain.swf"), this.path = /\/$/.test(a) ? a : a + "/", WEB_SOCKET_SWF_LOCATION = a + "lib/vendor/web-socket-js/WebSocketMain.swf" } }; "jQuery" in this && (jQuery.io = this.io), typeof window != "undefined" && typeof WEB_SOCKET_SWF_LOCATION == "undefined" && (WEB_SOCKET_SWF_LOCATION = "/socket.io/lib/vendor/web-socket-js/WebSocketMain.swf"), function () { var a = this.io, b = !1; a.util = { ios: !1, load: function (a) { if (/loaded|complete/.test(document.readyState) || b) return a(); "attachEvent" in window ? window.attachEvent("onload", a) : window.addEventListener("load", a, !1) }, inherit: function (a, b) { for (var c in b.prototype) a.prototype[c] = b.prototype[c] }, indexOf: function (a, b, c) { for (var d = a.length, e = c < 0 ? Math.max(0, d + c) : c || 0; e < d; e++) if (a[e] === b) return e; return -1 }, isArray: function (a) { return Object.prototype.toString.call(a) === "[object Array]" }, merge: function (a, b) { for (var c in b) b.hasOwnProperty(c) && (a[c] = b[c]) } }, a.util.ios = /iphone|ipad/i.test(navigator.userAgent), a.util.android = /android/i.test(navigator.userAgent), a.util.opera = /opera/i.test(navigator.userAgent), a.util.load(function () { b = !0 }) } (), function () { var a = this.io, b = "~m~", c = function (a) { if (Object.prototype.toString.call(a) == "[object Object]") { if (!("JSON" in window)) { "console" in window && console.error && console.error("Trying to encode as JSON, but JSON.stringify is missing."); return '{ "$error": "Invalid message" }' } return "~j~" + JSON.stringify(a) } return String(a) }; Transport = a.Transport = function (b, c) { this.base = b, this.options = { timeout: 15e3 }, a.util.merge(this.options, c) }, Transport.prototype.send = function () { throw new Error("Missing send() implementation") }, Transport.prototype.connect = function () { throw new Error("Missing connect() implementation") }, Transport.prototype.disconnect = function () { throw new Error("Missing disconnect() implementation") }, Transport.prototype._encode = function (d) { var e = "", f, d = a.util.isArray(d) ? d : [d]; for (var g = 0, h = d.length; g < h; g++) f = d[g] === null || d[g] === undefined ? "" : c(d[g]), e += b + f.length + b + f; return e }, Transport.prototype._decode = function (a) { var c = [], d, e; do { if (a.substr(0, 3) !== b) return c; a = a.substr(3), d = "", e = ""; for (var f = 0, g = a.length; f < g; f++) { e = Number(a.substr(f, 1)); if (a.substr(f, 1) == e) d += e; else { a = a.substr(d.length + b.length), d = Number(d); break } } c.push(a.substr(0, d)), a = a.substr(d) } while (a !== ""); return c }, Transport.prototype._onData = function (a) { this._setTimeout(); var b = this._decode(a); if (b && b.length) for (var c = 0, d = b.length; c < d; c++) this._onMessage(b[c]) }, Transport.prototype._setTimeout = function () { var a = this; this._timeout && clearTimeout(this._timeout), this._timeout = setTimeout(function () { a._onTimeout() }, this.options.timeout) }, Transport.prototype._onTimeout = function () { this._onDisconnect() }, Transport.prototype._onMessage = function (a) { this.sessionid ? a.substr(0, 3) == "~h~" ? this._onHeartbeat(a.substr(3)) : a.substr(0, 3) == "~j~" ? this.base._onMessage(JSON.parse(a.substr(3))) : this.base._onMessage(a) : (this.sessionid = a, this._onConnect()) }, Transport.prototype._onHeartbeat = function (a) { this.send("~h~" + a) }, Transport.prototype._onConnect = function () { this.connected = !0, this.connecting = !1, this.base._onConnect(), this._setTimeout() }, Transport.prototype._onDisconnect = function () { this.connecting = !1, this.connected = !1, this.sessionid = null, this.base._onDisconnect() }, Transport.prototype._prepareUrl = function () { return (this.base.options.secure ? "https" : "http") + "://" + this.base.host + ":" + this.base.options.port + "/" + this.base.options.resource + "/" + this.type + (this.sessionid ? "/" + this.sessionid : "/") } } (), function () { var a = this.io, b = new Function, c = function () { if (!("XMLHttpRequest" in window)) return !1; var a = new XMLHttpRequest; return a.withCredentials != undefined } (), d = function (a) { if ("XDomainRequest" in window && a) return new XDomainRequest; if ("XMLHttpRequest" in window && (!a || c)) return new XMLHttpRequest; if (!a) { try { var b = new ActiveXObject("MSXML2.XMLHTTP"); return b } catch (d) { } try { var e = new ActiveXObject("Microsoft.XMLHTTP"); return e } catch (d) { } } return !1 }, e = a.Transport.XHR = function () { a.Transport.apply(this, arguments), this._sendBuffer = [] }; a.util.inherit(e, a.Transport), e.prototype.connect = function () { this._get(); return this }, e.prototype._checkSend = function () { if (!this._posting && this._sendBuffer.length) { var a = this._encode(this._sendBuffer); this._sendBuffer = [], this._send(a) } }, e.prototype.send = function (b) { a.util.isArray(b) ? this._sendBuffer.push.apply(this._sendBuffer, b) : this._sendBuffer.push(b), this._checkSend(); return this }, e.prototype._send = function (a) { var c = this; this._posting = !0, this._sendXhr = this._request("send", "POST"), this._sendXhr.onreadystatechange = function () { var a; if (c._sendXhr.readyState == 4) { c._sendXhr.onreadystatechange = b; try { a = c._sendXhr.status } catch (d) { } c._posting = !1, a == 200 ? c._checkSend() : c._onDisconnect() } }, this._sendXhr.send("data=" + encodeURIComponent(a)) }, e.prototype.disconnect = function () { this._onDisconnect(); return this }, e.prototype._onDisconnect = function () { if (this._xhr) { this._xhr.onreadystatechange = b; try { this._xhr.abort() } catch (c) { } this._xhr = null } if (this._sendXhr) { this._sendXhr.onreadystatechange = b; try { this._sendXhr.abort() } catch (c) { } this._sendXhr = null } this._sendBuffer = [], a.Transport.prototype._onDisconnect.call(this) }, e.prototype._request = function (a, b, c) { var e = d(this.base._isXDomain()); c && (e.multipart = !0), e.open(b || "GET", this._prepareUrl() + (a ? "/" + a : "")), b == "POST" && "setRequestHeader" in e && e.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8"); return e }, e.check = function (a) { try { if (d(a)) return !0 } catch (b) { } return !1 }, e.xdomainCheck = function () { return e.check(!0) }, e.request = d } (), function () { var a = this.io, b = a.Transport.websocket = function () { a.Transport.apply(this, arguments) }; a.util.inherit(b, a.Transport), b.prototype.type = "websocket", b.prototype.connect = function () { var a = this; this.socket = new WebSocket(this._prepareUrl()), this.socket.onmessage = function (b) { a._onData(b.data) }, this.socket.onclose = function (b) { a._onClose() }, this.socket.onerror = function (b) { a._onError(b) }; return this }, b.prototype.send = function (a) { this.socket && this.socket.send(this._encode(a)); return this }, b.prototype.disconnect = function () { this.socket && this.socket.close(); return this }, b.prototype._onClose = function () { this._onDisconnect(); return this }, b.prototype._onError = function (a) { this.base.emit("error", [a]) }, b.prototype._prepareUrl = function () { return (this.base.options.secure ? "wss" : "ws") + "://" + this.base.host + ":" + this.base.options.port + "/" + this.base.options.resource + "/" + this.type + (this.sessionid ? "/" + this.sessionid : "") }, b.check = function () { return "WebSocket" in window && WebSocket.prototype && WebSocket.prototype.send && !!WebSocket.prototype.send.toString().match(/native/i) && typeof WebSocket != "undefined" }, b.xdomainCheck = function () { return !0 } } (), function () { var a = this.io, b = a.Transport.flashsocket = function () { a.Transport.websocket.apply(this, arguments) }; a.util.inherit(b, a.Transport.websocket), b.prototype.type = "flashsocket", b.prototype.connect = function () { var b = this, c = arguments; WebSocket.__addTask(function () { a.Transport.websocket.prototype.connect.apply(b, c) }); return this }, b.prototype.send = function () { var b = this, c = arguments; WebSocket.__addTask(function () { a.Transport.websocket.prototype.send.apply(b, c) }); return this }, b.check = function () { if (typeof WebSocket == "undefined" || !("__addTask" in WebSocket)) return !1; if (a.util.opera) return !1; if ("navigator" in window && "plugins" in navigator && navigator.plugins["Shockwave Flash"]) return !!navigator.plugins["Shockwave Flash"].description; if ("ActiveXObject" in window) try { return !!(new ActiveXObject("ShockwaveFlash.ShockwaveFlash")).GetVariable("$version") } catch (b) { } return !1 }, b.xdomainCheck = function () { return !0 } } (), function () { var a = this.io, b = a.Transport.htmlfile = function () { a.Transport.XHR.apply(this, arguments) }; a.util.inherit(b, a.Transport.XHR), b.prototype.type = "htmlfile", b.prototype._get = function () { var a = this; this._open(), window.attachEvent("onunload", function () { a._destroy() }) }, b.prototype._open = function () { this._doc = new ActiveXObject("htmlfile"), this._doc.open(), this._doc.write("<html></html>"), this._doc.parentWindow.s = this, this._doc.close(); var a = this._doc.createElement("div"); this._doc.body.appendChild(a), this._iframe = this._doc.createElement("iframe"), a.appendChild(this._iframe), this._iframe.src = this._prepareUrl() + "/" + +(new Date) }, b.prototype._ = function (a, b) { this._onData(a); var c = b.getElementsByTagName("script")[0]; c.parentNode.removeChild(c) }, b.prototype._destroy = function () { this._iframe && (this._iframe.src = "about:blank", this._doc = null, CollectGarbage()) }, b.prototype.disconnect = function () { this._destroy(); return a.Transport.XHR.prototype.disconnect.call(this) }, b.check = function () { if ("ActiveXObject" in window) try { var b = new ActiveXObject("htmlfile"); return b && a.Transport.XHR.check() } catch (c) { } return !1 }, b.xdomainCheck = function () { return !1 } } (), function () { var a = this.io, b = a.Transport["xhr-multipart"] = function () { a.Transport.XHR.apply(this, arguments) }; a.util.inherit(b, a.Transport.XHR), b.prototype.type = "xhr-multipart", b.prototype._get = function () { var a = this; this._xhr = this._request("", "GET", !0), this._xhr.onreadystatechange = function () { a._xhr.readyState == 4 && a._onData(a._xhr.responseText) }, this._xhr.send(null) }, b.check = function () { return "XMLHttpRequest" in window && "prototype" in XMLHttpRequest && "multipart" in XMLHttpRequest.prototype }, b.xdomainCheck = function () { return !0 } } (), function () { var a = this.io, b = new Function, c = a.Transport["xhr-polling"] = function () { a.Transport.XHR.apply(this, arguments) }; a.util.inherit(c, a.Transport.XHR), c.prototype.type = "xhr-polling", c.prototype.connect = function () { if (a.util.ios || a.util.android) { var b = this; a.util.load(function () { setTimeout(function () { a.Transport.XHR.prototype.connect.call(b) }, 10) }) } else a.Transport.XHR.prototype.connect.call(this) }, c.prototype._get = function () { var a = this; this._xhr = this._request(+(new Date), "GET"), this._xhr.onreadystatechange = function () { var c; if (a._xhr.readyState == 4) { a._xhr.onreadystatechange = b; try { c = a._xhr.status } catch (d) { } c == 200 ? (a._onData(a._xhr.responseText), a._get()) : a._onDisconnect() } }, this._xhr.send(null) }, c.check = function () { return a.Transport.XHR.check() }, c.xdomainCheck = function () { return a.Transport.XHR.xdomainCheck() } } (), function () { var a = this.io; a.JSONP = [], JSONPPolling = a.Transport["jsonp-polling"] = function () { a.Transport.XHR.apply(this, arguments), this._insertAt = document.getElementsByTagName("script")[0], this._index = a.JSONP.length, a.JSONP.push(this) }, a.util.inherit(JSONPPolling, a.Transport["xhr-polling"]), JSONPPolling.prototype.type = "jsonp-polling", JSONPPolling.prototype._send = function (a) { function h() { b._iframe && b._form.removeChild(b._iframe); try { f = document.createElement('<iframe name="' + b._iframeId + '">') } catch (a) { f = document.createElement("iframe"), f.name = b._iframeId } f.id = b._iframeId, b._form.appendChild(f), b._iframe = f } function g() { h(), b._posting = !1, b._checkSend() } var b = this; if (!("_form" in this)) { var c = document.createElement("FORM"), d = document.createElement("TEXTAREA"), e = this._iframeId = "socket_io_iframe_" + this._index, f; c.style.position = "absolute", c.style.top = "-1000px", c.style.left = "-1000px", c.target = e, c.method = "POST", c.action = this._prepareUrl() + "/" + +(new Date) + "/" + this._index, d.name = "data", c.appendChild(d), this._insertAt.parentNode.insertBefore(c, this._insertAt), document.body.appendChild(c), this._form = c, this._area = d } h(), this._posting = !0, this._area.value = a; try { this._form.submit() } catch (i) { } this._iframe.attachEvent ? f.onreadystatechange = function () { b._iframe.readyState == "complete" && g() } : this._iframe.onload = g }, JSONPPolling.prototype._get = function () { var a = this, b = document.createElement("SCRIPT"); this._script && (this._script.parentNode.removeChild(this._script), this._script = null), b.async = !0, b.src = this._prepareUrl() + "/" + +(new Date) + "/" + this._index, b.onerror = function () { a._onDisconnect() }, this._insertAt.parentNode.insertBefore(b, this._insertAt), this._script = b }, JSONPPolling.prototype._ = function () { this._onData.apply(this, arguments), this._get(); return this }, JSONPPolling.check = function () { return !0 }, JSONPPolling.xdomainCheck = function () { return !0 } } (), function () { var a = this.io, b = a.Socket = function (b, c) { this.host = b || document.domain, this.options = { secure: !1, document: document, port: document.location.port || 80, resource: "socket.io", transports: ["websocket", "flashsocket", "htmlfile", "xhr-multipart", "xhr-polling", "jsonp-polling"], transportOptions: { "xhr-polling": { timeout: 25e3 }, "jsonp-polling": { timeout: 25e3} }, connectTimeout: 5e3, reconnect: !0, reconnectionDelay: 500, maxReconnectionAttempts: 10, tryTransportsOnConnectTimeout: !0, rememberTransport: !0 }, a.util.merge(this.options, c), this.connected = !1, this.connecting = !1, this._events = {}, this.transport = this.getTransport(), !this.transport && "console" in window && console.error("No transport available") }; b.prototype.getTransport = function (b) { var c = b || this.options.transports, d; this.options.rememberTransport && !b && (d = this.options.document.cookie.match("(?:^|;)\\s*socketio=([^;]*)"), d && (this._rememberedTransport = !0, c = [decodeURIComponent(d[1])])); for (var e = 0, f; f = c[e]; e++) if (a.Transport[f] && a.Transport[f].check() && (!this._isXDomain() || a.Transport[f].xdomainCheck())) return new a.Transport[f](this, this.options.transportOptions[f] || {}); return null }, b.prototype.connect = function () { if (this.transport && !this.connected) { this.connecting && this.disconnect(!0), this.connecting = !0, this.emit("connecting", [this.transport.type]), this.transport.connect(); if (this.options.connectTimeout) { var a = this; this.connectTimeoutTimer = setTimeout(function () { if (!a.connected) { a.disconnect(!0); if (a.options.tryTransportsOnConnectTimeout && !a._rememberedTransport) { a._remainingTransports || (a._remainingTransports = a.options.transports.slice(0)); var b = a._remainingTransports; while (b.length > 0 && b.splice(0, 1)[0] != a.transport.type); b.length && (a.transport = a.getTransport(b), a.connect()) } (!a._remainingTransports || a._remainingTransports.length == 0) && a.emit("connect_failed") } a._remainingTransports && a._remainingTransports.length == 0 && delete a._remainingTransports }, this.options.connectTimeout) } } return this }, b.prototype.send = function (a) { if (!this.transport || !this.transport.connected) return this._queue(a); this.transport.send(a); return this }, b.prototype.disconnect = function (a) { this.connectTimeoutTimer && clearTimeout(this.connectTimeoutTimer), a || (this.options.reconnect = !1), this.transport.disconnect(); return this }, b.prototype.on = function (a, b) { a in this._events || (this._events[a] = []), this._events[a].push(b); return this }, b.prototype.emit = function (a, b) { if (a in this._events) { var c = this._events[a].concat(); for (var d = 0, e = c.length; d < e; d++) c[d].apply(this, b === undefined ? [] : b) } return this }, b.prototype.removeEvent = function (a, b) { if (a in this._events) for (var c = 0, d = this._events[a].length; c < d; c++) this._events[a][c] == b && this._events[a].splice(c, 1); return this }, b.prototype._queue = function (a) { "_queueStack" in this || (this._queueStack = []), this._queueStack.push(a); return this }, b.prototype._doQueue = function () { if (!("_queueStack" in this) || !this._queueStack.length) return this; this.transport.send(this._queueStack), this._queueStack = []; return this }, b.prototype._isXDomain = function () { var a = window.location.port || 80; return this.host !== document.domain || this.options.port != a }, b.prototype._onConnect = function () { this.connected = !0, this.connecting = !1, this._doQueue(), this.options.rememberTransport && (this.options.document.cookie = "socketio=" + encodeURIComponent(this.transport.type)), this.emit("connect") }, b.prototype._onMessage = function (a) { this.emit("message", [a]) }, b.prototype._onDisconnect = function () { var a = this.connected; this.connected = !1, this.connecting = !1, this._queueStack = [], a && (this.emit("disconnect"), this.options.reconnect && !this.reconnecting && this._onReconnect()) }, b.prototype._onReconnect = function () { function e() { if (!!a.reconnecting) if (!a.connected) { if (a.connecting && a.reconnecting) return a.reconnectionTimer = setTimeout(e, 1e3); a.reconnectionAttempts++ >= a.options.maxReconnectionAttempts ? a.redoTransports ? (a.emit("reconnect_failed"), d()) : (a.on("connect_failed", e), a.options.tryTransportsOnConnectTimeout = !0, a.transport = a.getTransport(a.options.transports), a.redoTransports = !0, a.connect()) : (a.reconnectionDelay *= 2, a.connect(), a.emit("reconnecting", [a.reconnectionDelay, a.reconnectionAttempts]), a.reconnectionTimer = setTimeout(e, a.reconnectionDelay)) } else d() } function d() { a.connected && a.emit("reconnect", [a.transport.type, a.reconnectionAttempts]), a.removeEvent("connect_failed", e).removeEvent("connect", e), delete a.reconnecting, delete a.reconnectionAttempts, delete a.reconnectionDelay, delete a.reconnectionTimer, delete a.redoTransports, a.options.tryTransportsOnConnectTimeout = b, a.options.rememberTransport = c; return } this.reconnecting = !0, this.reconnectionAttempts = 0, this.reconnectionDelay = this.options.reconnectionDelay; var a = this, b = this.options.tryTransportsOnConnectTimeout, c = this.options.rememberTransport; this.options.tryTransportsOnConnectTimeout = !1, this.reconnectionTimer = setTimeout(e, this.reconnectionDelay), this.on("connect", e) }, b.prototype.fire = b.prototype.emit, b.prototype.addListener = b.prototype.addEvent = b.prototype.addEventListener = b.prototype.on, b.prototype.removeListener = b.prototype.removeEventListener = b.prototype.removeEvent } (); var swfobject = function () { function V(b) { var c = /[\\\"<>\.;]/, d = c.exec(b) != null; return d && typeof encodeURIComponent != a ? encodeURIComponent(b) : b } function U(a, b) { if (!!x) { var c = b ? "visible" : "hidden"; t && P(a) ? P(a).style.visibility = c : T("#" + a, "visibility:" + c) } } function T(c, d, e, f) { if (!y.ie || !y.mac) { var g = i.getElementsByTagName("head")[0]; if (!g) return; var h = e && typeof e == "string" ? e : "screen"; f && (v = null, w = null); if (!v || w != h) { var j = Q("style"); j.setAttribute("type", "text/css"), j.setAttribute("media", h), v = g.appendChild(j), y.ie && y.win && typeof i.styleSheets != a && i.styleSheets.length > 0 && (v = i.styleSheets[i.styleSheets.length - 1]), w = h } y.ie && y.win ? v && typeof v.addRule == b && v.addRule(c, d) : v && typeof i.createTextNode != a && v.appendChild(i.createTextNode(c + " {" + d + "}")) } } function S(a) { var b = y.pv, c = a.split("."); c[0] = parseInt(c[0], 10), c[1] = parseInt(c[1], 10) || 0, c[2] = parseInt(c[2], 10) || 0; return b[0] > c[0] || b[0] == c[0] && b[1] > c[1] || b[0] == c[0] && b[1] == c[1] && b[2] >= c[2] ? !0 : !1 } function R(a, b, c) { a.attachEvent(b, c), o[o.length] = [a, b, c] } function Q(a) { return i.createElement(a) } function P(a) { var b = null; try { b = i.getElementById(a) } catch (c) { } return b } function O(a) { var b = P(a); if (b) { for (var c in b) typeof b[c] == "function" && (b[c] = null); b.parentNode.removeChild(b) } } function N(a) { var b = P(a); b && b.nodeName == "OBJECT" && (y.ie && y.win ? (b.style.display = "none", function () { b.readyState == 4 ? O(a) : setTimeout(arguments.callee, 10) } ()) : b.parentNode.removeChild(b)) } function M(a, b, c) { var d = Q("param"); d.setAttribute("name", b), d.setAttribute("value", c), a.appendChild(d) } function L(c, d, f) { var g, h = P(f); if (y.wk && y.wk < 312) return g; if (h) { typeof c.id == a && (c.id = f); if (y.ie && y.win) { var i = ""; for (var j in c) c[j] != Object.prototype[j] && (j.toLowerCase() == "data" ? d.movie = c[j] : j.toLowerCase() == "styleclass" ? i += ' class="' + c[j] + '"' : j.toLowerCase() != "classid" && (i += " " + j + '="' + c[j] + '"')); var k = ""; for (var l in d) d[l] != Object.prototype[l] && (k += '<param name="' + l + '" value="' + d[l] + '" />'); h.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + i + ">" + k + "</object>", n[n.length] = c.id, g = P(c.id) } else { var m = Q(b); m.setAttribute("type", e); for (var o in c) c[o] != Object.prototype[o] && (o.toLowerCase() == "styleclass" ? m.setAttribute("class", c[o]) : o.toLowerCase() != "classid" && m.setAttribute(o, c[o])); for (var p in d) d[p] != Object.prototype[p] && p.toLowerCase() != "movie" && M(m, p, d[p]); h.parentNode.replaceChild(m, h), g = m } } return g } function K(a) { var c = Q("div"); if (y.win && y.ie) c.innerHTML = a.innerHTML; else { var d = a.getElementsByTagName(b)[0]; if (d) { var e = d.childNodes; if (e) { var f = e.length; for (var g = 0; g < f; g++) (e[g].nodeType != 1 || e[g].nodeName != "PARAM") && e[g].nodeType != 8 && c.appendChild(e[g].cloneNode(!0)) } } } return c } function J(a) { if (y.ie && y.win && a.readyState != 4) { var b = Q("div"); a.parentNode.insertBefore(b, a), b.parentNode.replaceChild(K(a), b), a.style.display = "none", function () { a.readyState == 4 ? a.parentNode.removeChild(a) : setTimeout(arguments.callee, 10) } () } else a.parentNode.replaceChild(K(a), a) } function I(b, c, d, e) { u = !0, r = e || null, s = { success: !1, id: d }; var g = P(d); if (g) { g.nodeName == "OBJECT" ? (p = K(g), q = null) : (p = g, q = d), b.id = f; if (typeof b.width == a || !/%$/.test(b.width) && parseInt(b.width, 10) < 310) b.width = "310"; if (typeof b.height == a || !/%$/.test(b.height) && parseInt(b.height, 10) < 137) b.height = "137"; i.title = i.title.slice(0, 47) + " - Flash Player Installation"; var j = y.ie && y.win ? "ActiveX" : "PlugIn", k = "MMredirectURL=" + h.location.toString().replace(/&/g, "%26") + "&MMplayerType=" + j + "&MMdoctitle=" + i.title; typeof c.flashvars != a ? c.flashvars += "&" + k : c.flashvars = k; if (y.ie && y.win && g.readyState != 4) { var l = Q("div"); d += "SWFObjectNew", l.setAttribute("id", d), g.parentNode.insertBefore(l, g), g.style.display = "none", function () { g.readyState == 4 ? g.parentNode.removeChild(g) : setTimeout(arguments.callee, 10) } () } L(b, c, d) } } function H() { return !u && S("6.0.65") && (y.win || y.mac) && !(y.wk && y.wk < 312) } function G(c) { var d = null, e = P(c); if (e && e.nodeName == "OBJECT") if (typeof e.SetVariable != a) d = e; else { var f = e.getElementsByTagName(b)[0]; f && (d = f) } return d } function F() { var b = m.length; if (b > 0) for (var c = 0; c < b; c++) { var d = m[c].id, e = m[c].callbackFn, f = { success: !1, id: d }; if (y.pv[0] > 0) { var g = P(d); if (g) if (S(m[c].swfVersion) && !(y.wk && y.wk < 312)) U(d, !0), e && (f.success = !0, f.ref = G(d), e(f)); else if (m[c].expressInstall && H()) { var h = {}; h.data = m[c].expressInstall, h.width = g.getAttribute("width") || "0", h.height = g.getAttribute("height") || "0", g.getAttribute("class") && (h.styleclass = g.getAttribute("class")), g.getAttribute("align") && (h.align = g.getAttribute("align")); var i = {}, j = g.getElementsByTagName("param"), k = j.length; for (var l = 0; l < k; l++) j[l].getAttribute("name").toLowerCase() != "movie" && (i[j[l].getAttribute("name")] = j[l].getAttribute("value")); I(h, i, d, e) } else J(g), e && e(f) } else { U(d, !0); if (e) { var n = G(d); n && typeof n.SetVariable != a && (f.success = !0, f.ref = n), e(f) } } } } function E() { var c = i.getElementsByTagName("body")[0], d = Q(b); d.setAttribute("type", e); var f = c.appendChild(d); if (f) { var g = 0; (function () { if (typeof f.GetVariable != a) { var b = f.GetVariable("$version"); b && (b = b.split(" ")[1].split(","), y.pv = [parseInt(b[0], 10), parseInt(b[1], 10), parseInt(b[2], 10)]) } else if (g < 10) { g++, setTimeout(arguments.callee, 10); return } c.removeChild(d), f = null, F() })() } else F() } function D() { k ? E() : F() } function C(b) { if (typeof h.addEventListener != a) h.addEventListener("load", b, !1); else if (typeof i.addEventListener != a) i.addEventListener("load", b, !1); else if (typeof h.attachEvent != a) R(h, "onload", b); else if (typeof h.onload == "function") { var c = h.onload; h.onload = function () { c(), b() } } else h.onload = b } function B(a) { t ? a() : l[l.length] = a } function A() { if (!t) { try { var a = i.getElementsByTagName("body")[0].appendChild(Q("span")); a.parentNode.removeChild(a) } catch (b) { return } t = !0; var c = l.length; for (var d = 0; d < c; d++) l[d]() } } var a = "undefined", b = "object", c = "Shockwave Flash", d = "ShockwaveFlash.ShockwaveFlash", e = "application/x-shockwave-flash", f = "SWFObjectExprInst", g = "onreadystatechange", h = window, i = document, j = navigator, k = !1, l = [D], m = [], n = [], o = [], p, q, r, s, t = !1, u = !1, v, w, x = !0, y = function () { var f = typeof i.getElementById != a && typeof i.getElementsByTagName != a && typeof i.createElement != a, g = j.userAgent.toLowerCase(), l = j.platform.toLowerCase(), m = l ? /win/.test(l) : /win/.test(g), n = l ? /mac/.test(l) : /mac/.test(g), o = /webkit/.test(g) ? parseFloat(g.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : !1, p = !1, q = [0, 0, 0], r = null; if (typeof j.plugins != a && typeof j.plugins[c] == b) r = j.plugins[c].description, r && (typeof j.mimeTypes == a || !j.mimeTypes[e] || !!j.mimeTypes[e].enabledPlugin) && (k = !0, p = !1, r = r.replace(/^.*\s+(\S+\s+\S+$)/, "$1"), q[0] = parseInt(r.replace(/^(.*)\..*$/, "$1"), 10), q[1] = parseInt(r.replace(/^.*\.(.*)\s.*$/, "$1"), 10), q[2] = /[a-zA-Z]/.test(r) ? parseInt(r.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0); else if (typeof h.ActiveXObject != a) try { var s = new ActiveXObject(d); s && (r = s.GetVariable("$version"), r && (p = !0, r = r.split(" ")[1].split(","), q = [parseInt(r[0], 10), parseInt(r[1], 10), parseInt(r[2], 10)])) } catch (t) { } return { w3: f, pv: q, wk: o, ie: p, win: m, mac: n} } (), z = function () { !y.w3 || ((typeof i.readyState != a && i.readyState == "complete" || typeof i.readyState == a && (i.getElementsByTagName("body")[0] || i.body)) && A(), t || (typeof i.addEventListener != a && i.addEventListener("DOMContentLoaded", A, !1), y.ie && y.win && (i.attachEvent(g, function () { i.readyState == "complete" && (i.detachEvent(g, arguments.callee), A()) }), h == top && function () { if (!t) { try { i.documentElement.doScroll("left") } catch (a) { setTimeout(arguments.callee, 0); return } A() } } ()), y.wk && function () { if (!t) { if (!/loaded|complete/.test(i.readyState)) { setTimeout(arguments.callee, 0); return } A() } } (), C(A))) } (), W = function () { y.ie && y.win && window.attachEvent("onunload", function () { var a = o.length; for (var b = 0; b < a; b++) o[b][0].detachEvent(o[b][1], o[b][2]); var c = n.length; for (var d = 0; d < c; d++) N(n[d]); for (var e in y) y[e] = null; y = null; for (var f in swfobject) swfobject[f] = null; swfobject = null }) } (); return { registerObject: function (a, b, c, d) { if (y.w3 && a && b) { var e = {}; e.id = a, e.swfVersion = b, e.expressInstall = c, e.callbackFn = d, m[m.length] = e, U(a, !1) } else d && d({ success: !1, id: a }) }, getObjectById: function (a) { if (y.w3) return G(a) }, embedSWF: function (c, d, e, f, g, h, i, j, k, l) { var m = { success: !1, id: d }; y.w3 && !(y.wk && y.wk < 312) && c && d && e && f && g ? (U(d, !1), B(function () { e += "", f += ""; var n = {}; if (k && typeof k === b) for (var o in k) n[o] = k[o]; n.data = c, n.width = e, n.height = f; var p = {}; if (j && typeof j === b) for (var q in j) p[q] = j[q]; if (i && typeof i === b) for (var r in i) typeof p.flashvars != a ? p.flashvars += "&" + r + "=" + i[r] : p.flashvars = r + "=" + i[r]; if (S(g)) { var s = L(n, p, d); n.id == d && U(d, !0), m.success = !0, m.ref = s } else { if (h && H()) { n.data = h, I(n, p, d, l); return } U(d, !0) } l && l(m) })) : l && l(m) }, switchOffAutoHideShow: function () { x = !1 }, ua: y, getFlashPlayerVersion: function () { return { major: y.pv[0], minor: y.pv[1], release: y.pv[2]} }, hasFlashPlayerVersion: S, createSWF: function (a, b, c) { return y.w3 ? L(a, b, c) : undefined }, showExpressInstall: function (a, b, c, d) { y.w3 && H() && I(a, b, c, d) }, removeSWF: function (a) { y.w3 && N(a) }, createCSS: function (a, b, c, d) { y.w3 && T(a, b, c, d) }, addDomLoadEvent: B, addLoadEvent: C, getQueryParamValue: function (a) { var b = i.location.search || i.location.hash; if (b) { /\?/.test(b) && (b = b.split("?")[1]); if (a == null) return V(b); var c = b.split("&"); for (var d = 0; d < c.length; d++) if (c[d].substring(0, c[d].indexOf("=")) == a) return V(c[d].substring(c[d].indexOf("=") + 1)) } return "" }, expressInstallCallback: function () { if (u) { var a = P(f); a && p && (a.parentNode.replaceChild(p, a), q && (U(q, !0), y.ie && y.win && (p.style.display = "block")), r && r(s)), u = !1 } } } } (); (function () { function b() { } if (!window.WebSocket) { var a = window.console; if (!a || !a.log || !a.error) a = { log: function () { }, error: function () { } }; if (!swfobject.hasFlashPlayerVersion("10.0.0")) { a.error("Flash Player >= 10.0.0 is required."); return } location.protocol == "file:" && a.error("WARNING: web-socket-js doesn't work in file:///... URL unless you set Flash Security Settings properly. Open the page via Web server i.e. http://..."), WebSocket = function (a, b, c, d, e) { var f = this; f.__id = WebSocket.__nextId++, WebSocket.__instances[f.__id] = f, f.readyState = WebSocket.CONNECTING, f.bufferedAmount = 0, setTimeout(function () { WebSocket.__addTask(function () { WebSocket.__flash.create(f.__id, a, b, c || null, d || 0, e || null) }) }, 0) }, WebSocket.prototype.send = function (a) { if (this.readyState == WebSocket.CONNECTING) throw "INVALID_STATE_ERR: Web Socket connection has not been established"; var b = WebSocket.__flash.send(this.__id, encodeURIComponent(a)); if (b < 0) return !0; this.bufferedAmount += b; return !1 }, WebSocket.prototype.close = function () { this.readyState != WebSocket.CLOSED && this.readyState != WebSocket.CLOSING && (this.readyState = WebSocket.CLOSING, WebSocket.__flash.close(this.__id)) }, WebSocket.prototype.addEventListener = function (a, b, c) { "__events" in this || (this.__events = {}), a in this.__events || (this.__events[a] = [], "function" == typeof this["on" + a] && (this.__events[a].defaultHandler = this["on" + a], this["on" + a] = this.__createEventHandler(this, a))), this.__events[a].push(b) }, WebSocket.prototype.removeEventListener = function (a, b, c) { "__events" in this || (this.__events = {}); if (a in this.__events) for (var d = this.__events.length; d > -1; --d) if (b === this.__events[a][d]) { this.__events[a].splice(d, 1); break } }, WebSocket.prototype.dispatchEvent = function (a) { if (!("__events" in this)) throw "UNSPECIFIED_EVENT_TYPE_ERR"; if (!(a.type in this.__events)) throw "UNSPECIFIED_EVENT_TYPE_ERR"; for (var b = 0, c = this.__events[a.type].length; b < c; ++b) { this.__events[a.type][b](a); if (a.cancelBubble) break } !1 !== a.returnValue && "function" == typeof this.__events[a.type].defaultHandler && this.__events[a.type].defaultHandler(a) }, WebSocket.prototype.__handleEvent = function (b) { "readyState" in b && (this.readyState = b.readyState); try { if (b.type == "open") this.onopen && this.onopen(); else if (b.type == "close") this.onclose && this.onclose(); else if (b.type == "error") this.onerror && this.onerror(b); else { if (b.type != "message") throw "unknown event type: " + b.type; if (this.onmessage) { var c = decodeURIComponent(b.message), d; window.MessageEvent && !window.opera ? (d = document.createEvent("MessageEvent"), d.initMessageEvent("message", !1, !1, c, null, null, window, null)) : d = { data: c }, this.onmessage(d) } } } catch (d) { a.error(d.toString()) } }, WebSocket.prototype.__createEventHandler = function (a, c) { return function (d) { var e = new b; e.initEvent(c, !0, !0), e.target = e.currentTarget = a; for (var f in d) e[f] = d[f]; a.dispatchEvent(e, arguments) } }, WebSocket.CONNECTING = 0, WebSocket.OPEN = 1, WebSocket.CLOSING = 2, WebSocket.CLOSED = 3, WebSocket.__flash = null, WebSocket.__instances = {}, WebSocket.__tasks = [], WebSocket.__nextId = 0, WebSocket.__initialize = function () { if (!WebSocket.__flash) { WebSocket.__swfLocation && (window.WEB_SOCKET_SWF_LOCATION = WebSocket.__swfLocation); if (!window.WEB_SOCKET_SWF_LOCATION) { a.error("[WebSocket] set WEB_SOCKET_SWF_LOCATION to location of WebSocketMain.swf"); return } var b = document.createElement("div"); b.id = "webSocketContainer", b.style.position = "absolute", WebSocket.__isFlashLite() ? (b.style.left = "0px", b.style.top = "0px") : (b.style.left = "-100px", b.style.top = "-100px"); var c = document.createElement("div"); c.id = "webSocketFlash", b.appendChild(c), document.body.appendChild(b), swfobject.embedSWF(WEB_SOCKET_SWF_LOCATION, "webSocketFlash", "1", "1", "10.0.0", null, null, { hasPriority: !0, swliveconnect: !0, allowScriptAccess: "always" }, null, function (b) { b.success || a.error("[WebSocket] swfobject.embedSWF failed") }) } }, WebSocket.loadFlashPolicyFile = function (a) { WebSocket.__addTask(function () { WebSocket.__flash.loadManualPolicyFile(a) }) }, WebSocket.__onFlashInitialized = function () { setTimeout(function () { WebSocket.__flash = document.getElementById("webSocketFlash"), WebSocket.__flash.setCallerUrl(location.href), WebSocket.__flash.setDebug(!!window.WEB_SOCKET_DEBUG); for (var a = 0; a < WebSocket.__tasks.length; ++a) WebSocket.__tasks[a](); WebSocket.__tasks = [] }, 0) }, WebSocket.__onFlashEvent = function () { setTimeout(function () { var a = WebSocket.__flash.receiveEvents(); for (var b = 0; b < a.length; ++b) WebSocket.__instances[a[b].webSocketId].__handleEvent(a[b]) }, 0); return !0 }, WebSocket.__log = function (b) { a.log(decodeURIComponent(b)) }, WebSocket.__error = function (b) { a.error(decodeURIComponent(b)) }, WebSocket.__addTask = function (a) { WebSocket.__flash ? a() : WebSocket.__tasks.push(a) }, WebSocket.__isFlashLite = function () { if (!window.navigator || !window.navigator.mimeTypes) return !1; var a = window.navigator.mimeTypes["application/x-shockwave-flash"]; if (!a || !a.enabledPlugin || !a.enabledPlugin.filename) return !1; return a.enabledPlugin.filename.match(/flashlite/i) ? !0 : !1 }, b.prototype.cancelable = !0, b.prototype.cancelBubble = !1, b.prototype.preventDefault = function () { this.cancelable && (this.returnValue = !1) }, b.prototype.stopPropagation = function () { this.cancelBubble = !0 }, b.prototype.initEvent = function (a, b, c) { this.type = a, this.cancelable = c, this.timeStamp = new Date }, window.WEB_SOCKET_DISABLE_AUTO_INITIALIZATION || (window.addEventListener ? window.addEventListener("load", function () { WebSocket.__initialize() }, !1) : window.attachEvent("onload", function () { WebSocket.__initialize() })) } })();

/*template*/
(function (a) { var r = a.fn.domManip, d = "_tmplitem", q = /^[^<]*(<[\w\W]+>)[^>]*$|\{\{\! /, b = {}, f = {}, e, p = { key: 0, data: {} }, h = 0, c = 0, l = []; function g(e, d, g, i) { var c = { data: i || (d ? d.data : {}), _wrap: d ? d._wrap : null, tmpl: null, parent: d || null, nodes: [], calls: u, nest: w, wrap: x, html: v, update: t }; e && a.extend(c, e, { nodes: [], parent: d }); if (g) { c.tmpl = g; c._ctnt = c._ctnt || c.tmpl(a, c); c.key = ++h; (l.length ? f : b)[h] = c } return c } a.each({ appendTo: "append", prependTo: "prepend", insertBefore: "before", insertAfter: "after", replaceAll: "replaceWith" }, function (f, d) { a.fn[f] = function (n) { var g = [], i = a(n), k, h, m, l, j = this.length === 1 && this[0].parentNode; e = b || {}; if (j && j.nodeType === 11 && j.childNodes.length === 1 && i.length === 1) { i[d](this[0]); g = this } else { for (h = 0, m = i.length; h < m; h++) { c = h; k = (h > 0 ? this.clone(true) : this).get(); a.fn[d].apply(a(i[h]), k); g = g.concat(k) } c = 0; g = this.pushStack(g, f, i.selector) } l = e; e = null; a.tmpl.complete(l); return g } }); a.fn.extend({ tmpl: function (d, c, b) { return a.tmpl(this[0], d, c, b) }, tmplItem: function () { return a.tmplItem(this[0]) }, template: function (b) { return a.template(b, this[0]) }, domManip: function (d, l, j) { if (d[0] && d[0].nodeType) { var f = a.makeArray(arguments), g = d.length, i = 0, h; while (i < g && !(h = a.data(d[i++], "tmplItem"))); if (g > 1) f[0] = [a.makeArray(d)]; if (h && c) f[2] = function (b) { a.tmpl.afterManip(this, b, j) }; r.apply(this, f) } else r.apply(this, arguments); c = 0; !e && a.tmpl.complete(b); return this } }); a.extend({ tmpl: function (d, h, e, c) { var j, k = !c; if (k) { c = p; d = a.template[d] || a.template(null, d); f = {} } else if (!d) { d = c.tmpl; b[c.key] = c; c.nodes = []; c.wrapped && n(c, c.wrapped); return a(i(c, null, c.tmpl(a, c))) } if (!d) return []; if (typeof h === "function") h = h.call(c || {}); e && e.wrapped && n(e, e.wrapped); j = a.isArray(h) ? a.map(h, function (a) { return a ? g(e, c, d, a) : null }) : [g(e, c, d, h)]; return k ? a(i(c, null, j)) : j }, tmplItem: function (b) { var c; if (b instanceof a) b = b[0]; while (b && b.nodeType === 1 && !(c = a.data(b, "tmplItem")) && (b = b.parentNode)); return c || p }, template: function (c, b) { if (b) { if (typeof b === "string") b = o(b); else if (b instanceof a) b = b[0] || {}; if (b.nodeType) b = a.data(b, "tmpl") || a.data(b, "tmpl", o(b.innerHTML)); return typeof c === "string" ? (a.template[c] = b) : b } return c ? typeof c !== "string" ? a.template(null, c) : a.template[c] || a.template(null, q.test(c) ? c : a(c)) : null }, encode: function (a) { return ("" + a).split("<").join("&lt;").split(">").join("&gt;").split('"').join("&#34;").split("'").join("&#39;") } }); a.extend(a.tmpl, { tag: { tmpl: { _default: { $2: "null" }, open: "if($notnull_1){_=_.concat($item.nest($1,$2));}" }, wrap: { _default: { $2: "null" }, open: "$item.calls(_,$1,$2);_=[];", close: "call=$item.calls();_=call._.concat($item.wrap(call,_));" }, each: { _default: { $2: "$index, $value" }, open: "if($notnull_1){$.each($1a,function($2){with(this){", close: "}});}" }, "if": { open: "if(($notnull_1) && $1a){", close: "}" }, "else": { _default: { $1: "true" }, open: "}else if(($notnull_1) && $1a){" }, html: { open: "if($notnull_1){_.push($1a);}" }, "=": { _default: { $1: "$data" }, open: "if($notnull_1){_.push($.encode($1a));}" }, "!": { open: ""} }, complete: function () { b = {} }, afterManip: function (f, b, d) { var e = b.nodeType === 11 ? a.makeArray(b.childNodes) : b.nodeType === 1 ? [b] : []; d.call(f, b); m(e); c++ } }); function i(e, g, f) { var b, c = f ? a.map(f, function (a) { return typeof a === "string" ? e.key ? a.replace(/(<\w+)(?=[\s>])(?![^>]*_tmplitem)([^>]*)/g, "$1 " + d + '="' + e.key + '" $2') : a : i(a, e, a._ctnt) }) : e; if (g) return c; c = c.join(""); c.replace(/^\s*([^<\s][^<]*)?(<[\w\W]+>)([^>]*[^>\s])?\s*$/, function (f, c, e, d) { b = a(e).get(); m(b); if (c) b = j(c).concat(b); if (d) b = b.concat(j(d)) }); return b ? b : j(c) } function j(c) { var b = document.createElement("div"); b.innerHTML = c; return a.makeArray(b.childNodes) } function o(b) { return new Function("jQuery", "$item", "var $=jQuery,call,_=[],$data=$item.data;with($data){_.push('" + a.trim(b).replace(/([\\'])/g, "\\$1").replace(/[\r\t\n]/g, " ").replace(/\$\{([^\}]*)\}/g, "{{= $1}}").replace(/\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g, function (m, l, j, d, b, c, e) { var i = a.tmpl.tag[j], h, f, g; if (!i) throw "Template command not found: " + j; h = i._default || []; if (c && !/\w$/.test(b)) { b += c; c = "" } if (b) { b = k(b); e = e ? "," + k(e) + ")" : c ? ")" : ""; f = c ? b.indexOf(".") > -1 ? b + c : "(" + b + ").call($item" + e : b; g = c ? f : "(typeof(" + b + ")==='function'?(" + b + ").call($item):(" + b + "))" } else g = f = h.$1 || "null"; d = k(d); return "');" + i[l ? "close" : "open"].split("$notnull_1").join(b ? "typeof(" + b + ")!=='undefined' && (" + b + ")!=null" : "true").split("$1a").join(g).split("$1").join(f).split("$2").join(d ? d.replace(/\s*([^\(]+)\s*(\((.*?)\))?/g, function (d, c, b, a) { a = a ? "," + a + ")" : b ? ")" : ""; return a ? "(" + c + ").call($item" + a : d }) : h.$2 || "") + "_.push('" }) + "');}return _;") } function n(c, b) { c._wrap = i(c, true, a.isArray(b) ? b : [q.test(b) ? b : a(b).html()]).join("") } function k(a) { return a ? a.replace(/\\'/g, "'").replace(/\\\\/g, "\\") : null } function s(b) { var a = document.createElement("div"); a.appendChild(b.cloneNode(true)); return a.innerHTML } function m(o) { var n = "_" + c, k, j, l = {}, e, p, i; for (e = 0, p = o.length; e < p; e++) { if ((k = o[e]).nodeType !== 1) continue; j = k.getElementsByTagName("*"); for (i = j.length - 1; i >= 0; i--) m(j[i]); m(k) } function m(j) { var p, i = j, k, e, m; if (m = j.getAttribute(d)) { while (i.parentNode && (i = i.parentNode).nodeType === 1 && !(p = i.getAttribute(d))); if (p !== m) { i = i.parentNode ? i.nodeType === 11 ? 0 : i.getAttribute(d) || 0 : 0; if (!(e = b[m])) { e = f[m]; e = g(e, b[i] || f[i], null, true); e.key = ++h; b[h] = e } c && o(m) } j.removeAttribute(d) } else if (c && (e = a.data(j, "tmplItem"))) { o(e.key); b[e.key] = e; i = a.data(j.parentNode, "tmplItem"); i = i ? i.key : 0 } if (e) { k = e; while (k && k.key != i) { k.nodes.push(j); k = k.parent } delete e._ctnt; delete e._wrap; a.data(j, "tmplItem", e) } function o(a) { a = a + n; e = l[a] = l[a] || g(e, b[e.parent.key + n] || e.parent, null, true) } } } function u(a, d, c, b) { if (!a) return l.pop(); l.push({ _: a, tmpl: d, item: this, data: c, options: b }) } function w(d, c, b) { return a.tmpl(a.template(d), c, b, this) } function x(b, d) { var c = b.options || {}; c.wrapped = d; return a.tmpl(a.template(b.tmpl), b.data, c, b.item) } function v(d, c) { var b = this._wrap; return a.map(a(a.isArray(b) ? b.join("") : b).filter(d || "*"), function (a) { return c ? a.innerText || a.textContent : a.outerHTML || s(a) }) } function t() { var b = this.nodes; a.tmpl(null, null, null, this).insertBefore(b[0]); a(b).remove() } })(jQuery);

/*cycle*/
(function ($) { var ver = "2.86"; if ($.support == undefined) { $.support = { opacity: !($.browser.msie) }; } function debug(s) { if ($.fn.cycle.debug) { log(s); } } function log() { if (window.console && window.console.log) { window.console.log("[cycle] " + Array.prototype.join.call(arguments, " ")); } } $.fn.cycle = function (options, arg2) { var o = { s: this.selector, c: this.context }; if (this.length === 0 && options != "stop") { if (!$.isReady && o.s) { log("DOM not ready, queuing slideshow"); $(function () { $(o.s, o.c).cycle(options, arg2); }); return this; } log("terminating; zero elements found by selector" + ($.isReady ? "" : " (DOM not ready)")); return this; } return this.each(function () { var opts = handleArguments(this, options, arg2); if (opts === false) { return; } opts.updateActivePagerLink = opts.updateActivePagerLink || $.fn.cycle.updateActivePagerLink; if (this.cycleTimeout) { clearTimeout(this.cycleTimeout); } this.cycleTimeout = this.cyclePause = 0; var $cont = $(this); var $slides = opts.slideExpr ? $(opts.slideExpr, this) : $cont.children(); var els = $slides.get(); if (els.length < 2) { log("terminating; too few slides: " + els.length); return; } var opts2 = buildOptions($cont, $slides, els, opts, o); if (opts2 === false) { return; } var startTime = opts2.continuous ? 10 : getTimeout(opts2.currSlide, opts2.nextSlide, opts2, !opts2.rev); if (startTime) { startTime += (opts2.delay || 0); if (startTime < 10) { startTime = 10; } debug("first timeout: " + startTime); this.cycleTimeout = setTimeout(function () { go(els, opts2, 0, !opts2.rev); }, startTime); } }); }; function handleArguments(cont, options, arg2) { if (cont.cycleStop == undefined) { cont.cycleStop = 0; } if (options === undefined || options === null) { options = {}; } if (options.constructor == String) { switch (options) { case "destroy": case "stop": var opts = $(cont).data("cycle.opts"); if (!opts) { return false; } cont.cycleStop++; if (cont.cycleTimeout) { clearTimeout(cont.cycleTimeout); } cont.cycleTimeout = 0; $(cont).removeData("cycle.opts"); if (options == "destroy") { destroy(opts); } return false; case "toggle": cont.cyclePause = (cont.cyclePause === 1) ? 0 : 1; checkInstantResume(cont.cyclePause, arg2, cont); return false; case "pause": cont.cyclePause = 1; return false; case "resume": cont.cyclePause = 0; checkInstantResume(false, arg2, cont); return false; case "prev": case "next": var opts = $(cont).data("cycle.opts"); if (!opts) { log('options not found, "prev/next" ignored'); return false; } $.fn.cycle[options](opts); return false; default: options = { fx: options }; } return options; } else { if (options.constructor == Number) { var num = options; options = $(cont).data("cycle.opts"); if (!options) { log("options not found, can not advance slide"); return false; } if (num < 0 || num >= options.elements.length) { log("invalid slide index: " + num); return false; } options.nextSlide = num; if (cont.cycleTimeout) { clearTimeout(cont.cycleTimeout); cont.cycleTimeout = 0; } if (typeof arg2 == "string") { options.oneTimeFx = arg2; } go(options.elements, options, 1, num >= options.currSlide); return false; } } return options; function checkInstantResume(isPaused, arg2, cont) { if (!isPaused && arg2 === true) { var options = $(cont).data("cycle.opts"); if (!options) { log("options not found, can not resume"); return false; } if (cont.cycleTimeout) { clearTimeout(cont.cycleTimeout); cont.cycleTimeout = 0; } go(options.elements, options, 1, 1); } } } function removeFilter(el, opts) { if (!$.support.opacity && opts.cleartype && el.style.filter) { try { el.style.removeAttribute("filter"); } catch (smother) { } } } function destroy(opts) { if (opts.next) { $(opts.next).unbind(opts.prevNextEvent); } if (opts.prev) { $(opts.prev).unbind(opts.prevNextEvent); } if (opts.pager || opts.pagerAnchorBuilder) { $.each(opts.pagerAnchors || [], function () { this.unbind().remove(); }); } opts.pagerAnchors = null; if (opts.destroy) { opts.destroy(opts); } } function buildOptions($cont, $slides, els, options, o) { var opts = $.extend({}, $.fn.cycle.defaults, options || {}, $.metadata ? $cont.metadata() : $.meta ? $cont.data() : {}); if (opts.autostop) { opts.countdown = opts.autostopCount || els.length; } var cont = $cont[0]; $cont.data("cycle.opts", opts); opts.$cont = $cont; opts.stopCount = cont.cycleStop; opts.elements = els; opts.before = opts.before ? [opts.before] : []; opts.after = opts.after ? [opts.after] : []; opts.after.unshift(function () { opts.busy = 0; }); if (!$.support.opacity && opts.cleartype) { opts.after.push(function () { removeFilter(this, opts); }); } if (opts.continuous) { opts.after.push(function () { go(els, opts, 0, !opts.rev); }); } saveOriginalOpts(opts); if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg) { clearTypeFix($slides); } if ($cont.css("position") == "static") { $cont.css("position", "relative"); } if (opts.width) { $cont.width(opts.width); } if (opts.height && opts.height != "auto") { $cont.height(opts.height); } if (opts.startingSlide) { opts.startingSlide = parseInt(opts.startingSlide); } if (opts.random) { opts.randomMap = []; for (var i = 0; i < els.length; i++) { opts.randomMap.push(i); } opts.randomMap.sort(function (a, b) { return Math.random() - 0.5; }); opts.randomIndex = 1; opts.startingSlide = opts.randomMap[1]; } else { if (opts.startingSlide >= els.length) { opts.startingSlide = 0; } } opts.currSlide = opts.startingSlide || 0; var first = opts.startingSlide; $slides.css({ position: "absolute", top: 0, left: 0 }).hide().each(function (i) { var z = first ? i >= first ? els.length - (i - first) : first - i : els.length - i; $(this).css("z-index", z); }); $(els[first]).css("opacity", 1).show(); removeFilter(els[first], opts); if (opts.fit && opts.width) { $slides.width(opts.width); } if (opts.fit && opts.height && opts.height != "auto") { $slides.height(opts.height); } var reshape = opts.containerResize && !$cont.innerHeight(); if (reshape) { var maxw = 0, maxh = 0; for (var j = 0; j < els.length; j++) { var $e = $(els[j]), e = $e[0], w = $e.outerWidth(), h = $e.outerHeight(); if (!w) { w = e.offsetWidth || e.width || $e.attr("width"); } if (!h) { h = e.offsetHeight || e.height || $e.attr("height"); } maxw = w > maxw ? w : maxw; maxh = h > maxh ? h : maxh; } if (maxw > 0 && maxh > 0) { $cont.css({ width: maxw + "px", height: maxh + "px" }); } } if (opts.pause) { $cont.hover(function () { this.cyclePause++; }, function () { this.cyclePause--; }); } if (supportMultiTransitions(opts) === false) { return false; } var requeue = false; options.requeueAttempts = options.requeueAttempts || 0; $slides.each(function () { var $el = $(this); this.cycleH = (opts.fit && opts.height) ? opts.height : ($el.height() || this.offsetHeight || this.height || $el.attr("height") || 0); this.cycleW = (opts.fit && opts.width) ? opts.width : ($el.width() || this.offsetWidth || this.width || $el.attr("width") || 0); if ($el.is("img")) { var loadingIE = ($.browser.msie && this.cycleW == 28 && this.cycleH == 30 && !this.complete); var loadingFF = ($.btrowser.mozilla && this.cycleW == 34 && this.cycleH == 19 && !this.complete); var loadingOp = ($.browser.opera && ((this.cycleW == 42 && this.cycleH == 19) || (this.cycleW == 37 && this.cycleH == 17)) && !this.complete); var loadingOther = (this.cycleH == 0 && this.cycleW == 0 && !this.complete); if (loadingIE || loadingFF || loadingOp || loadingOther) { if (o.s && opts.requeueOnImageNotLoaded && ++options.requeueAttempts < 100) { log(options.requeueAttempts, " - img slide not loaded, requeuing slideshow: ", this.src, this.cycleW, this.cycleH); setTimeout(function () { $(o.s, o.c).cycle(options); }, opts.requeueTimeout); requeue = true; return false; } else { log("could not determine size of image: " + this.src, this.cycleW, this.cycleH); } } } return true; }); if (requeue) { return false; } opts.cssBefore = opts.cssBefore || {}; opts.animIn = opts.animIn || {}; opts.animOut = opts.animOut || {}; $slides.not(":eq(" + first + ")").css(opts.cssBefore); if (opts.cssFirst) { $($slides[first]).css(opts.cssFirst); } if (opts.timeout) { opts.timeout = parseInt(opts.timeout); if (opts.speed.constructor == String) { opts.speed = $.fx.speeds[opts.speed] || parseInt(opts.speed); } if (!opts.sync) { opts.speed = opts.speed / 2; } var buffer = opts.fx == "shuffle" ? 500 : 250; while ((opts.timeout - opts.speed) < buffer) { opts.timeout += opts.speed; } } if (opts.easing) { opts.easeIn = opts.easeOut = opts.easing; } if (!opts.speedIn) { opts.speedIn = opts.speed; } if (!opts.speedOut) { opts.speedOut = opts.speed; } opts.slideCount = els.length; opts.currSlide = opts.lastSlide = first; if (opts.random) { if (++opts.randomIndex == els.length) { opts.randomIndex = 0; } opts.nextSlide = opts.randomMap[opts.randomIndex]; } else { opts.nextSlide = opts.startingSlide >= (els.length - 1) ? 0 : opts.startingSlide + 1; } if (!opts.multiFx) { var init = $.fn.cycle.transitions[opts.fx]; if ($.isFunction(init)) { init($cont, $slides, opts); } else { if (opts.fx != "custom" && !opts.multiFx) { log("unknown transition: " + opts.fx, "; slideshow terminating"); return false; } } } var e0 = $slides[first]; if (opts.before.length) { opts.before[0].apply(e0, [e0, e0, opts, true]); } if (opts.after.length > 1) { opts.after[1].apply(e0, [e0, e0, opts, true]); } if (opts.next) { $(opts.next).bind(opts.prevNextEvent, function () { return advance(opts, opts.rev ? -1 : 1); }); } if (opts.prev) { $(opts.prev).bind(opts.prevNextEvent, function () { return advance(opts, opts.rev ? 1 : -1); }); } if (opts.pager || opts.pagerAnchorBuilder) { buildPager(els, opts); } exposeAddSlide(opts, els); return opts; } function saveOriginalOpts(opts) { opts.original = { before: [], after: [] }; opts.original.cssBefore = $.extend({}, opts.cssBefore); opts.original.cssAfter = $.extend({}, opts.cssAfter); opts.original.animIn = $.extend({}, opts.animIn); opts.original.animOut = $.extend({}, opts.animOut); $.each(opts.before, function () { opts.original.before.push(this); }); $.each(opts.after, function () { opts.original.after.push(this); }); } function supportMultiTransitions(opts) { var i, tx, txs = $.fn.cycle.transitions; if (opts.fx.indexOf(",") > 0) { opts.multiFx = true; opts.fxs = opts.fx.replace(/\s*/g, "").split(","); for (i = 0; i < opts.fxs.length; i++) { var fx = opts.fxs[i]; tx = txs[fx]; if (!tx || !txs.hasOwnProperty(fx) || !$.isFunction(tx)) { log("discarding unknown transition: ", fx); opts.fxs.splice(i, 1); i--; } } if (!opts.fxs.length) { log("No valid transitions named; slideshow terminating."); return false; } } else { if (opts.fx == "all") { opts.multiFx = true; opts.fxs = []; for (p in txs) { tx = txs[p]; if (txs.hasOwnProperty(p) && $.isFunction(tx)) { opts.fxs.push(p); } } } } if (opts.multiFx && opts.randomizeEffects) { var r1 = Math.floor(Math.random() * 20) + 30; for (i = 0; i < r1; i++) { var r2 = Math.floor(Math.random() * opts.fxs.length); opts.fxs.push(opts.fxs.splice(r2, 1)[0]); } debug("randomized fx sequence: ", opts.fxs); } return true; } function exposeAddSlide(opts, els) { opts.addSlide = function (newSlide, prepend) { var $s = $(newSlide), s = $s[0]; if (!opts.autostopCount) { opts.countdown++; } els[prepend ? "unshift" : "push"](s); if (opts.els) { opts.els[prepend ? "unshift" : "push"](s); } opts.slideCount = els.length; $s.css("position", "absolute"); $s[prepend ? "prependTo" : "appendTo"](opts.$cont); if (prepend) { opts.currSlide++; opts.nextSlide++; } if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg) { clearTypeFix($s); } if (opts.fit && opts.width) { $s.width(opts.width); } if (opts.fit && opts.height && opts.height != "auto") { $slides.height(opts.height); } s.cycleH = (opts.fit && opts.height) ? opts.height : $s.height(); s.cycleW = (opts.fit && opts.width) ? opts.width : $s.width(); $s.css(opts.cssBefore); if (opts.pager || opts.pagerAnchorBuilder) { $.fn.cycle.createPagerAnchor(els.length - 1, s, $(opts.pager), els, opts); } if ($.isFunction(opts.onAddSlide)) { opts.onAddSlide($s); } else { $s.hide(); } }; } $.fn.cycle.resetState = function (opts, fx) { fx = fx || opts.fx; opts.before = []; opts.after = []; opts.cssBefore = $.extend({}, opts.original.cssBefore); opts.cssAfter = $.extend({}, opts.original.cssAfter); opts.animIn = $.extend({}, opts.original.animIn); opts.animOut = $.extend({}, opts.original.animOut); opts.fxFn = null; $.each(opts.original.before, function () { opts.before.push(this); }); $.each(opts.original.after, function () { opts.after.push(this); }); var init = $.fn.cycle.transitions[fx]; if ($.isFunction(init)) { init(opts.$cont, $(opts.elements), opts); } }; function go(els, opts, manual, fwd) { if (manual && opts.busy && opts.manualTrump) { debug("manualTrump in go(), stopping active transition"); $(els).stop(true, true); opts.busy = false; } if (opts.busy) { debug("transition active, ignoring new tx request"); return; } var p = opts.$cont[0], curr = els[opts.currSlide], next = els[opts.nextSlide]; if (p.cycleStop != opts.stopCount || p.cycleTimeout === 0 && !manual) { return; } if (!manual && !p.cyclePause && ((opts.autostop && (--opts.countdown <= 0)) || (opts.nowrap && !opts.random && opts.nextSlide < opts.currSlide))) { if (opts.end) { opts.end(opts); } return; } var changed = false; if ((manual || !p.cyclePause) && (opts.nextSlide != opts.currSlide)) { changed = true; var fx = opts.fx; curr.cycleH = curr.cycleH || $(curr).height(); curr.cycleW = curr.cycleW || $(curr).width(); next.cycleH = next.cycleH || $(next).height(); next.cycleW = next.cycleW || $(next).width(); if (opts.multiFx) { if (opts.lastFx == undefined || ++opts.lastFx >= opts.fxs.length) { opts.lastFx = 0; } fx = opts.fxs[opts.lastFx]; opts.currFx = fx; } if (opts.oneTimeFx) { fx = opts.oneTimeFx; opts.oneTimeFx = null; } $.fn.cycle.resetState(opts, fx); if (opts.before.length) { $.each(opts.before, function (i, o) { if (p.cycleStop != opts.stopCount) { return; } o.apply(next, [curr, next, opts, fwd]); }); } var after = function () { $.each(opts.after, function (i, o) { if (p.cycleStop != opts.stopCount) { return; } o.apply(next, [curr, next, opts, fwd]); }); }; debug("tx firing; currSlide: " + opts.currSlide + "; nextSlide: " + opts.nextSlide); opts.busy = 1; if (opts.fxFn) { opts.fxFn(curr, next, opts, after, fwd, manual && opts.fastOnEvent); } else { if ($.isFunction($.fn.cycle[opts.fx])) { $.fn.cycle[opts.fx](curr, next, opts, after, fwd, manual && opts.fastOnEvent); } else { $.fn.cycle.custom(curr, next, opts, after, fwd, manual && opts.fastOnEvent); } } } if (changed || opts.nextSlide == opts.currSlide) { opts.lastSlide = opts.currSlide; if (opts.random) { opts.currSlide = opts.nextSlide; if (++opts.randomIndex == els.length) { opts.randomIndex = 0; } opts.nextSlide = opts.randomMap[opts.randomIndex]; if (opts.nextSlide == opts.currSlide) { opts.nextSlide = (opts.currSlide == opts.slideCount - 1) ? 0 : opts.currSlide + 1; } } else { var roll = (opts.nextSlide + 1) == els.length; opts.nextSlide = roll ? 0 : opts.nextSlide + 1; opts.currSlide = roll ? els.length - 1 : opts.nextSlide - 1; } } if (changed && opts.pager) { opts.updateActivePagerLink(opts.pager, opts.currSlide, opts.activePagerClass); } var ms = 0; if (opts.timeout && !opts.continuous) { ms = getTimeout(curr, next, opts, fwd); } else { if (opts.continuous && p.cyclePause) { ms = 10; } } if (ms > 0) { p.cycleTimeout = setTimeout(function () { go(els, opts, 0, !opts.rev); }, ms); } } $.fn.cycle.updateActivePagerLink = function (pager, currSlide, clsName) { $(pager).each(function () { $(this).children().removeClass(clsName).eq(currSlide).addClass(clsName); }); }; function getTimeout(curr, next, opts, fwd) { if (opts.timeoutFn) { var t = opts.timeoutFn(curr, next, opts, fwd); while ((t - opts.speed) < 250) { t += opts.speed; } debug("calculated timeout: " + t + "; speed: " + opts.speed); if (t !== false) { return t; } } return opts.timeout; } $.fn.cycle.next = function (opts) { advance(opts, opts.rev ? -1 : 1); }; $.fn.cycle.prev = function (opts) { advance(opts, opts.rev ? 1 : -1); }; function advance(opts, val) { var els = opts.elements; var p = opts.$cont[0], timeout = p.cycleTimeout; if (timeout) { clearTimeout(timeout); p.cycleTimeout = 0; } if (opts.random && val < 0) { opts.randomIndex--; if (--opts.randomIndex == -2) { opts.randomIndex = els.length - 2; } else { if (opts.randomIndex == -1) { opts.randomIndex = els.length - 1; } } opts.nextSlide = opts.randomMap[opts.randomIndex]; } else { if (opts.random) { opts.nextSlide = opts.randomMap[opts.randomIndex]; } else { opts.nextSlide = opts.currSlide + val; if (opts.nextSlide < 0) { if (opts.nowrap) { return false; } opts.nextSlide = els.length - 1; } else { if (opts.nextSlide >= els.length) { if (opts.nowrap) { return false; } opts.nextSlide = 0; } } } } var cb = opts.onPrevNextEvent || opts.prevNextClick; if ($.isFunction(cb)) { cb(val > 0, opts.nextSlide, els[opts.nextSlide]); } go(els, opts, 1, val >= 0); return false; } function buildPager(els, opts) { var $p = $(opts.pager); $.each(els, function (i, o) { $.fn.cycle.createPagerAnchor(i, o, $p, els, opts); }); opts.updateActivePagerLink(opts.pager, opts.startingSlide, opts.activePagerClass); } $.fn.cycle.createPagerAnchor = function (i, el, $p, els, opts) { var a; if ($.isFunction(opts.pagerAnchorBuilder)) { a = opts.pagerAnchorBuilder(i, el); debug("pagerAnchorBuilder(" + i + ", el) returned: " + a); } else { a = '<a href="#">' + (i + 1) + "</a>"; } if (!a) { return; } var $a = $(a); if ($a.parents("body").length === 0) { var arr = []; if ($p.length > 1) { $p.each(function () { var $clone = $a.clone(true); $(this).append($clone); arr.push($clone[0]); }); $a = $(arr); } else { $a.appendTo($p); } } opts.pagerAnchors = opts.pagerAnchors || []; opts.pagerAnchors.push($a); $a.bind(opts.pagerEvent, function (e) { e.preventDefault(); opts.nextSlide = i; var p = opts.$cont[0], timeout = p.cycleTimeout; if (timeout) { clearTimeout(timeout); p.cycleTimeout = 0; } var cb = opts.onPagerEvent || opts.pagerClick; if ($.isFunction(cb)) { cb(opts.nextSlide, els[opts.nextSlide]); } go(els, opts, 1, opts.currSlide < i); }); if (!/^click/.test(opts.pagerEvent) && !opts.allowPagerClickBubble) { $a.bind("click.cycle", function () { return false; }); } if (opts.pauseOnPagerHover) { $a.hover(function () { opts.$cont[0].cyclePause++; }, function () { opts.$cont[0].cyclePause--; }); } }; $.fn.cycle.hopsFromLast = function (opts, fwd) { var hops, l = opts.lastSlide, c = opts.currSlide; if (fwd) { hops = c > l ? c - l : opts.slideCount - l; } else { hops = c < l ? l - c : l + opts.slideCount - c; } return hops; }; function clearTypeFix($slides) { debug("applying clearType background-color hack"); function hex(s) { s = parseInt(s).toString(16); return s.length < 2 ? "0" + s : s; } function getBg(e) { for (; e && e.nodeName.toLowerCase() != "html"; e = e.parentNode) { var v = $.css(e, "background-color"); if (v.indexOf("rgb") >= 0) { var rgb = v.match(/\d+/g); return "#" + hex(rgb[0]) + hex(rgb[1]) + hex(rgb[2]); } if (v && v != "transparent") { return v; } } return "#ffffff"; } $slides.each(function () { $(this).css("background-color", getBg(this)); }); } $.fn.cycle.commonReset = function (curr, next, opts, w, h, rev) { $(opts.elements).not(curr).hide(); opts.cssBefore.opacity = 1; opts.cssBefore.display = "block"; if (w !== false && next.cycleW > 0) { opts.cssBefore.width = next.cycleW; } if (h !== false && next.cycleH > 0) { opts.cssBefore.height = next.cycleH; } opts.cssAfter = opts.cssAfter || {}; opts.cssAfter.display = "none"; $(curr).css("zIndex", opts.slideCount + (rev === true ? 1 : 0)); $(next).css("zIndex", opts.slideCount + (rev === true ? 0 : 1)); }; $.fn.cycle.custom = function (curr, next, opts, cb, fwd, speedOverride) { var $l = $(curr), $n = $(next); var speedIn = opts.speedIn, speedOut = opts.speedOut, easeIn = opts.easeIn, easeOut = opts.easeOut; $n.css(opts.cssBefore); if (speedOverride) { if (typeof speedOverride == "number") { speedIn = speedOut = speedOverride; } else { speedIn = speedOut = 1; } easeIn = easeOut = null; } var fn = function () { $n.animate(opts.animIn, speedIn, easeIn, cb); }; $l.animate(opts.animOut, speedOut, easeOut, function () { if (opts.cssAfter) { $l.css(opts.cssAfter); } if (!opts.sync) { fn(); } }); if (opts.sync) { fn(); } }; $.fn.cycle.transitions = { fade: function ($cont, $slides, opts) { $slides.not(":eq(" + opts.currSlide + ")").css("opacity", 0); opts.before.push(function (curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts); opts.cssBefore.opacity = 0; }); opts.animIn = { opacity: 1 }; opts.animOut = { opacity: 0 }; opts.cssBefore = { top: 0, left: 0 }; } }; $.fn.cycle.ver = function () { return ver; }; $.fn.cycle.defaults = { fx: "fade", timeout: 4000, timeoutFn: null, continuous: 0, speed: 1000, speedIn: null, speedOut: null, next: null, prev: null, onPrevNextEvent: null, prevNextEvent: "click.cycle", pager: null, onPagerEvent: null, pagerEvent: "click.cycle", allowPagerClickBubble: false, pagerAnchorBuilder: null, before: null, after: null, end: null, easing: null, easeIn: null, easeOut: null, shuffle: null, animIn: null, animOut: null, cssBefore: null, cssAfter: null, fxFn: null, height: "auto", startingSlide: 0, sync: 1, random: 0, fit: 0, containerResize: 1, pause: 0, pauseOnPagerHover: 0, autostop: 0, autostopCount: 0, delay: 0, slideExpr: null, cleartype: !$.support.opacity, cleartypeNoBg: false, nowrap: 0, fastOnEvent: 0, randomizeEffects: 1, rev: 0, manualTrump: true, requeueOnImageNotLoaded: true, requeueTimeout: 250, activePagerClass: "activeSlide", updateActivePagerLink: null }; })(jQuery);
(function ($) { $.fn.cycle.transitions.none = function ($cont, $slides, opts) { opts.fxFn = function (curr, next, opts, after) { $(next).show(); $(curr).hide(); after(); }; }; $.fn.cycle.transitions.scrollUp = function ($cont, $slides, opts) { $cont.css("overflow", "hidden"); opts.before.push($.fn.cycle.commonReset); var h = $cont.height(); opts.cssBefore = { top: h, left: 0 }; opts.cssFirst = { top: 0 }; opts.animIn = { top: 0 }; opts.animOut = { top: -h }; }; $.fn.cycle.transitions.scrollDown = function ($cont, $slides, opts) { $cont.css("overflow", "hidden"); opts.before.push($.fn.cycle.commonReset); var h = $cont.height(); opts.cssFirst = { top: 0 }; opts.cssBefore = { top: -h, left: 0 }; opts.animIn = { top: 0 }; opts.animOut = { top: h }; }; $.fn.cycle.transitions.scrollLeft = function ($cont, $slides, opts) { $cont.css("overflow", "hidden"); opts.before.push($.fn.cycle.commonReset); var w = $cont.width(); opts.cssFirst = { left: 0 }; opts.cssBefore = { left: w, top: 0 }; opts.animIn = { left: 0 }; opts.animOut = { left: 0 - w }; }; $.fn.cycle.transitions.scrollRight = function ($cont, $slides, opts) { $cont.css("overflow", "hidden"); opts.before.push($.fn.cycle.commonReset); var w = $cont.width(); opts.cssFirst = { left: 0 }; opts.cssBefore = { left: -w, top: 0 }; opts.animIn = { left: 0 }; opts.animOut = { left: w }; }; $.fn.cycle.transitions.scrollHorz = function ($cont, $slides, opts) { $cont.css("overflow", "hidden").width(); opts.before.push(function (curr, next, opts, fwd) { $.fn.cycle.commonReset(curr, next, opts); opts.cssBefore.left = fwd ? (next.cycleW - 1) : (1 - next.cycleW); opts.animOut.left = fwd ? -curr.cycleW : curr.cycleW; }); opts.cssFirst = { left: 0 }; opts.cssBefore = { top: 0 }; opts.animIn = { left: 0 }; opts.animOut = { top: 0 }; }; $.fn.cycle.transitions.scrollVert = function ($cont, $slides, opts) { $cont.css("overflow", "hidden"); opts.before.push(function (curr, next, opts, fwd) { $.fn.cycle.commonReset(curr, next, opts); opts.cssBefore.top = fwd ? (1 - next.cycleH) : (next.cycleH - 1); opts.animOut.top = fwd ? curr.cycleH : -curr.cycleH; }); opts.cssFirst = { top: 0 }; opts.cssBefore = { left: 0 }; opts.animIn = { top: 0 }; opts.animOut = { left: 0 }; }; $.fn.cycle.transitions.slideX = function ($cont, $slides, opts) { opts.before.push(function (curr, next, opts) { $(opts.elements).not(curr).hide(); $.fn.cycle.commonReset(curr, next, opts, false, true); opts.animIn.width = next.cycleW; }); opts.cssBefore = { left: 0, top: 0, width: 0 }; opts.animIn = { width: "show" }; opts.animOut = { width: 0 }; }; $.fn.cycle.transitions.slideY = function ($cont, $slides, opts) { opts.before.push(function (curr, next, opts) { $(opts.elements).not(curr).hide(); $.fn.cycle.commonReset(curr, next, opts, true, false); opts.animIn.height = next.cycleH; }); opts.cssBefore = { left: 0, top: 0, height: 0 }; opts.animIn = { height: "show" }; opts.animOut = { height: 0 }; }; $.fn.cycle.transitions.shuffle = function ($cont, $slides, opts) { var i, w = $cont.css("overflow", "visible").width(); $slides.css({ left: 0, top: 0 }); opts.before.push(function (curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts, true, true, true); }); if (!opts.speedAdjusted) { opts.speed = opts.speed / 2; opts.speedAdjusted = true; } opts.random = 0; opts.shuffle = opts.shuffle || { left: -w, top: 15 }; opts.els = []; for (i = 0; i < $slides.length; i++) { opts.els.push($slides[i]); } for (i = 0; i < opts.currSlide; i++) { opts.els.push(opts.els.shift()); } opts.fxFn = function (curr, next, opts, cb, fwd) { var $el = fwd ? $(curr) : $(next); $(next).css(opts.cssBefore); var count = opts.slideCount; $el.animate(opts.shuffle, opts.speedIn, opts.easeIn, function () { var hops = $.fn.cycle.hopsFromLast(opts, fwd); for (var k = 0; k < hops; k++) { fwd ? opts.els.push(opts.els.shift()) : opts.els.unshift(opts.els.pop()); } if (fwd) { for (var i = 0, len = opts.els.length; i < len; i++) { $(opts.els[i]).css("z-index", len - i + count); } } else { var z = $(curr).css("z-index"); $el.css("z-index", parseInt(z) + 1 + count); } $el.animate({ left: 0, top: 0 }, opts.speedOut, opts.easeOut, function () { $(fwd ? this : curr).hide(); if (cb) { cb(); } }); }); }; opts.cssBefore = { display: "block", opacity: 1, top: 0, left: 0 }; }; $.fn.cycle.transitions.turnUp = function ($cont, $slides, opts) { opts.before.push(function (curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts, true, false); opts.cssBefore.top = next.cycleH; opts.animIn.height = next.cycleH; }); opts.cssFirst = { top: 0 }; opts.cssBefore = { left: 0, height: 0 }; opts.animIn = { top: 0 }; opts.animOut = { height: 0 }; }; $.fn.cycle.transitions.turnDown = function ($cont, $slides, opts) { opts.before.push(function (curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts, true, false); opts.animIn.height = next.cycleH; opts.animOut.top = curr.cycleH; }); opts.cssFirst = { top: 0 }; opts.cssBefore = { left: 0, top: 0, height: 0 }; opts.animOut = { height: 0 }; }; $.fn.cycle.transitions.turnLeft = function ($cont, $slides, opts) { opts.before.push(function (curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts, false, true); opts.cssBefore.left = next.cycleW; opts.animIn.width = next.cycleW; }); opts.cssBefore = { top: 0, width: 0 }; opts.animIn = { left: 0 }; opts.animOut = { width: 0 }; }; $.fn.cycle.transitions.turnRight = function ($cont, $slides, opts) { opts.before.push(function (curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts, false, true); opts.animIn.width = next.cycleW; opts.animOut.left = curr.cycleW; }); opts.cssBefore = { top: 0, left: 0, width: 0 }; opts.animIn = { left: 0 }; opts.animOut = { width: 0 }; }; $.fn.cycle.transitions.zoom = function ($cont, $slides, opts) { opts.before.push(function (curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts, false, false, true); opts.cssBefore.top = next.cycleH / 2; opts.cssBefore.left = next.cycleW / 2; opts.animIn = { top: 0, left: 0, width: next.cycleW, height: next.cycleH }; opts.animOut = { width: 0, height: 0, top: curr.cycleH / 2, left: curr.cycleW / 2 }; }); opts.cssFirst = { top: 0, left: 0 }; opts.cssBefore = { width: 0, height: 0 }; }; $.fn.cycle.transitions.fadeZoom = function ($cont, $slides, opts) { opts.before.push(function (curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts, false, false); opts.cssBefore.left = next.cycleW / 2; opts.cssBefore.top = next.cycleH / 2; opts.animIn = { top: 0, left: 0, width: next.cycleW, height: next.cycleH }; }); opts.cssBefore = { width: 0, height: 0 }; opts.animOut = { opacity: 0 }; }; $.fn.cycle.transitions.blindX = function ($cont, $slides, opts) { var w = $cont.css("overflow", "hidden").width(); opts.before.push(function (curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts); opts.animIn.width = next.cycleW; opts.animOut.left = curr.cycleW; }); opts.cssBefore = { left: w, top: 0 }; opts.animIn = { left: 0 }; opts.animOut = { left: w }; }; $.fn.cycle.transitions.blindY = function ($cont, $slides, opts) { var h = $cont.css("overflow", "hidden").height(); opts.before.push(function (curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts); opts.animIn.height = next.cycleH; opts.animOut.top = curr.cycleH; }); opts.cssBefore = { top: h, left: 0 }; opts.animIn = { top: 0 }; opts.animOut = { top: h }; }; $.fn.cycle.transitions.blindZ = function ($cont, $slides, opts) { var h = $cont.css("overflow", "hidden").height(); var w = $cont.width(); opts.before.push(function (curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts); opts.animIn.height = next.cycleH; opts.animOut.top = curr.cycleH; }); opts.cssBefore = { top: h, left: w }; opts.animIn = { top: 0, left: 0 }; opts.animOut = { top: h, left: w }; }; $.fn.cycle.transitions.growX = function ($cont, $slides, opts) { opts.before.push(function (curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts, false, true); opts.cssBefore.left = this.cycleW / 2; opts.animIn = { left: 0, width: this.cycleW }; opts.animOut = { left: 0 }; }); opts.cssBefore = { width: 0, top: 0 }; }; $.fn.cycle.transitions.growY = function ($cont, $slides, opts) { opts.before.push(function (curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts, true, false); opts.cssBefore.top = this.cycleH / 2; opts.animIn = { top: 0, height: this.cycleH }; opts.animOut = { top: 0 }; }); opts.cssBefore = { height: 0, left: 0 }; }; $.fn.cycle.transitions.curtainX = function ($cont, $slides, opts) { opts.before.push(function (curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts, false, true, true); opts.cssBefore.left = next.cycleW / 2; opts.animIn = { left: 0, width: this.cycleW }; opts.animOut = { left: curr.cycleW / 2, width: 0 }; }); opts.cssBefore = { top: 0, width: 0 }; }; $.fn.cycle.transitions.curtainY = function ($cont, $slides, opts) { opts.before.push(function (curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts, true, false, true); opts.cssBefore.top = next.cycleH / 2; opts.animIn = { top: 0, height: next.cycleH }; opts.animOut = { top: curr.cycleH / 2, height: 0 }; }); opts.cssBefore = { left: 0, height: 0 }; }; $.fn.cycle.transitions.cover = function ($cont, $slides, opts) { var d = opts.direction || "left"; var w = $cont.css("overflow", "hidden").width(); var h = $cont.height(); opts.before.push(function (curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts); if (d == "right") { opts.cssBefore.left = -w; } else { if (d == "up") { opts.cssBefore.top = h; } else { if (d == "down") { opts.cssBefore.top = -h; } else { opts.cssBefore.left = w; } } } }); opts.animIn = { left: 0, top: 0 }; opts.animOut = { opacity: 1 }; opts.cssBefore = { top: 0, left: 0 }; }; $.fn.cycle.transitions.uncover = function ($cont, $slides, opts) { var d = opts.direction || "left"; var w = $cont.css("overflow", "hidden").width(); var h = $cont.height(); opts.before.push(function (curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts, true, true, true); if (d == "right") { opts.animOut.left = w; } else { if (d == "up") { opts.animOut.top = -h; } else { if (d == "down") { opts.animOut.top = h; } else { opts.animOut.left = -w; } } } }); opts.animIn = { left: 0, top: 0 }; opts.animOut = { opacity: 1 }; opts.cssBefore = { top: 0, left: 0 }; }; $.fn.cycle.transitions.toss = function ($cont, $slides, opts) { var w = $cont.css("overflow", "visible").width(); var h = $cont.height(); opts.before.push(function (curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts, true, true, true); if (!opts.animOut.left && !opts.animOut.top) { opts.animOut = { left: w * 2, top: -h / 2, opacity: 0 }; } else { opts.animOut.opacity = 0; } }); opts.cssBefore = { left: 0, top: 0 }; opts.animIn = { left: 0 }; }; $.fn.cycle.transitions.wipe = function ($cont, $slides, opts) { var w = $cont.css("overflow", "hidden").width(); var h = $cont.height(); opts.cssBefore = opts.cssBefore || {}; var clip; if (opts.clip) { if (/l2r/.test(opts.clip)) { clip = "rect(0px 0px " + h + "px 0px)"; } else { if (/r2l/.test(opts.clip)) { clip = "rect(0px " + w + "px " + h + "px " + w + "px)"; } else { if (/t2b/.test(opts.clip)) { clip = "rect(0px " + w + "px 0px 0px)"; } else { if (/b2t/.test(opts.clip)) { clip = "rect(" + h + "px " + w + "px " + h + "px 0px)"; } else { if (/zoom/.test(opts.clip)) { var top = parseInt(h / 2); var left = parseInt(w / 2); clip = "rect(" + top + "px " + left + "px " + top + "px " + left + "px)"; } } } } } } opts.cssBefore.clip = opts.cssBefore.clip || clip || "rect(0px 0px 0px 0px)"; var d = opts.cssBefore.clip.match(/(\d+)/g); var t = parseInt(d[0]), r = parseInt(d[1]), b = parseInt(d[2]), l = parseInt(d[3]); opts.before.push(function (curr, next, opts) { if (curr == next) { return; } var $curr = $(curr), $next = $(next); $.fn.cycle.commonReset(curr, next, opts, true, true, false); opts.cssAfter.display = "block"; var step = 1, count = parseInt((opts.speedIn / 13)) - 1; (function f() { var tt = t ? t - parseInt(step * (t / count)) : 0; var ll = l ? l - parseInt(step * (l / count)) : 0; var bb = b < h ? b + parseInt(step * ((h - b) / count || 1)) : h; var rr = r < w ? r + parseInt(step * ((w - r) / count || 1)) : w; $next.css({ clip: "rect(" + tt + "px " + rr + "px " + bb + "px " + ll + "px)" }); (step++ <= count) ? setTimeout(f, 13) : $curr.css("display", "none"); })(); }); opts.cssBefore = { display: "block", opacity: 1, top: 0, left: 0 }; opts.animIn = { left: 0 }; opts.animOut = { left: 0 }; }; })(jQuery);

/*tableSorter Mod*/
(function ($) {
    $.extend({ tablesorter: new function () {
        var parsers = [], widgets = []; this.defaults = { cssHeader: "header", cssAsc: "headerSortUp", cssDesc: "headerSortDown", sortInitialOrder: "asc", sortMultiSortKey: "shiftKey", sortForce: null, sortAppend: null, textExtraction: "simple", parsers: {}, widgets: [], widgetZebra: { css: ["even", "odd"] }, headers: {}, widthFixed: false, cancelSelection: true, sortList: [], headerList: [], dateFormat: "us", decimal: '.', debug: false }; function benchmark(s, d) { log(s + ": " + (new Date().getTime() - d.getTime()) + "ms"); }
        this.benchmark = benchmark; function log(s) { if (console !== undefined && console.debug !== undefined) { console.log(s); } else { alert(s); } }
        function buildParserCache(table, $headers) {
            if (table.config.debug) { var parsersDebug = ""; }
            var rows = table.tBodies[0].rows; if (table.tBodies[0].rows[0]) {
                var list = [], cells = rows[0].cells, l = cells.length; for (var i = 0; i < l; i++) {
                    var p = false; if ($.metadata && ($($headers[i]).metadata() && $($headers[i]).metadata().sorter)) { p = getParserById($($headers[i]).metadata().sorter); } else if ((table.config.headers[i] && table.config.headers[i].sorter)) { p = getParserById(table.config.headers[i].sorter); }
                    if (!p) { p = detectParserForColumn(table, cells[i]); }
                    if (table.config.debug) { parsersDebug += "column:" + i + " parser:" + p.id + "\n"; }
                    list.push(p);
                }
            }
            if (table.config.debug) { log(parsersDebug); }
            return list;
        }; function detectParserForColumn(table, node) {
            var l = parsers.length; for (var i = 1; i < l; i++) { if (parsers[i].is($.trim(getElementText(table.config, node)), table, node)) { return parsers[i]; } }
            return parsers[0];
        }
        function getParserById(name) {
            var l = parsers.length; for (var i = 0; i < l; i++) { if (parsers[i].id.toLowerCase() == name.toLowerCase()) { return parsers[i]; } }
            return false;
        }
        function buildCache(table) {
            if (table.config.debug) { var cacheTime = new Date(); }
            var totalRows = (table.tBodies[0] && table.tBodies[0].rows.length) || 0, totalCells = (table.tBodies[0].rows[0] && table.tBodies[0].rows[0].cells.length) || 0, parsers = table.config.parsers, cache = { row: [], normalized: [] }; for (var i = 0; i < totalRows; ++i) {
                var c = table.tBodies[0].rows[i], cols = []; cache.row.push($(c)); for (var j = 0; j < totalCells; ++j) { cols.push(parsers[j].format(getElementText(table.config, c.cells[j]), table, c.cells[j])); }
                cols.push(i); cache.normalized.push(cols); cols = null;
            }; if (table.config.debug) { benchmark("Built cache for " + totalRows + " rows", cacheTime); }
            return cache;
        }; function getElementText(config, node) {
            if (!node) return ""; var t = ""; if (config.textExtraction == "simple") { if (node.childNodes[0] && node.childNodes[0].hasChildNodes()) { t = node.childNodes[0].innerHTML; } else { t = node.innerHTML; } } else { if (typeof (config.textExtraction) == "function") { t = config.textExtraction(node); } else { t = $(node).text(); } }
            return t;
        }
        function appendToTable(table, cache) {
            if (table.config.debug) { var appendTime = new Date() }
            var c = cache, r = c.row, n = c.normalized, totalRows = n.length, tableBody = $(table.tBodies[0]), rows = []; if (totalRows > 0) { var checkCell = (n[0].length - 1); for (var i = 0; i < totalRows; i++) { rows.push(r[n[i][checkCell]]); if (!table.config.appender) { var o = r[n[i][checkCell]]; var l = o.length; for (var j = 0; j < l; j++) { tableBody[0].appendChild(o[j]); } } } }
            if (table.config.appender) { table.config.appender(table, rows); }
            rows = null; if (table.config.debug) { benchmark("Rebuilt table", appendTime); }
            applyWidget(table); setTimeout(function () { $(table).trigger("sortEnd"); }, 0);
        }; function buildHeaders(table) {
            if (table.config.debug) { var time = new Date(); }
            var meta = ($.metadata) ? true : false, tableHeadersRows = []; for (var i = 0; i < table.tHead.rows.length; i++) { tableHeadersRows[i] = 0; }; $tableHeaders = $("thead th", table); $tableHeaders.each(function (index) {
                this.count = 0; this.column = index; this.order = formatSortingOrder(table.config.sortInitialOrder); if (checkHeaderMetadata(this) || checkHeaderOptions(table, index)) this.sortDisabled = true; if (!this.sortDisabled) { $(this).addClass(table.config.cssHeader); }
                table.config.headerList[index] = this;
            }); if (table.config.debug) { benchmark("Built headers", time); log($tableHeaders); }
            return $tableHeaders;
        }; function checkCellColSpan(table, rows, row) {
            var arr = [], r = table.tHead.rows, c = r[row].cells; for (var i = 0; i < c.length; i++) { var cell = c[i]; if (cell.colSpan > 1) { arr = arr.concat(checkCellColSpan(table, headerArr, row++)); } else { if (table.tHead.length == 1 || (cell.rowSpan > 1 || !r[row + 1])) { arr.push(cell); } } }
            return arr;
        }; function checkHeaderMetadata(cell) { if (($.metadata) && ($(cell).metadata().sorter === false)) { return true; }; return false; }
        function checkHeaderOptions(table, i) { if ((table.config.headers[i]) && (table.config.headers[i].sorter === false)) { return true; }; return false; }
        function applyWidget(table) { var c = table.config.widgets; var l = c.length; for (var i = 0; i < l; i++) { getWidgetById(c[i]).format(table); } }
        function getWidgetById(name) { var l = widgets.length; for (var i = 0; i < l; i++) { if (widgets[i].id.toLowerCase() == name.toLowerCase()) { return widgets[i]; } } }; function formatSortingOrder(v) {
            if (typeof (v) != "Number") { i = (v.toLowerCase() == "desc") ? 1 : 0; } else { i = (v == (0 || 1)) ? v : 0; }
            return i;
        }
        function isValueInArray(v, a) {
            var l = a.length; for (var i = 0; i < l; i++) { if (a[i][0] == v) { return true; } }
            return false;
        }
        function setHeadersCss(table, $headers, list, css) { $headers.removeClass(css[0]).removeClass(css[1]); var h = []; $headers.each(function (offset) { if (!this.sortDisabled) { h[this.column] = $(this); } }); var l = list.length; for (var i = 0; i < l; i++) { h[list[i][0]].addClass(css[list[i][1]]); } }
        function fixColumnWidth(table, $headers) { var c = table.config; if (c.widthFixed) { var colgroup = $('<colgroup>'); $("tr:first td", table.tBodies[0]).each(function () { colgroup.append($('<col>').css('width', $(this).width())); }); $(table).prepend(colgroup); }; }
        function updateHeaderSortCount(table, sortList) { var c = table.config, l = sortList.length; for (var i = 0; i < l; i++) { var s = sortList[i], o = c.headerList[s[0]]; o.count = s[1]; o.count++; } }
        function multisort(table, sortList, cache) {
            if (table.config.debug) { var sortTime = new Date(); }
            var dynamicExp = "var sortWrapper = function(a,b) {", l = sortList.length; for (var i = 0; i < l; i++) { var c = sortList[i][0]; var order = sortList[i][1]; var s = (getCachedSortType(table.config.parsers, c) == "text") ? ((order == 0) ? "sortText" : "sortTextDesc") : ((order == 0) ? "sortNumeric" : "sortNumericDesc"); var e = "e" + i; dynamicExp += "var " + e + " = " + s + "(a[" + c + "],b[" + c + "]); "; dynamicExp += "if(" + e + ") { return " + e + "; } "; dynamicExp += "else { "; }
            var orgOrderCol = cache.normalized[0].length - 1; dynamicExp += "return a[" + orgOrderCol + "]-b[" + orgOrderCol + "];"; for (var i = 0; i < l; i++) { dynamicExp += "}; "; }
            dynamicExp += "return 0; "; dynamicExp += "}; "; eval(dynamicExp); cache.normalized.sort(sortWrapper); if (table.config.debug) { benchmark("Sorted " + sortList.toString(), sortTime); }
            return cache;
        }; function sortText(a, b) { return ((a < b) ? -1 : ((a > b) ? 1 : 0)); }; function sortTextDesc(a, b) { return ((b < a) ? -1 : ((b > a) ? 1 : 0)); }; function sortNumeric(a, b) { return a - b; }; function sortNumericDesc(a, b) { return b - a; }; function getCachedSortType(parsers, i) { return parsers[i].type; }; this.construct = function (settings) {
            return this.each(function () {
                if (!this.tHead || !this.tBodies) return; var $this, $document, $headers, cache, config, shiftDown = 0, sortOrder; this.config = {}; config = $.extend(this.config, $.tablesorter.defaults, settings); $this = $(this); $headers = buildHeaders(this); this.config.parsers = buildParserCache(this, $headers); cache = buildCache(this); this.config.cache = cache; var sortCSS = [config.cssDesc, config.cssAsc]; fixColumnWidth(this); $headers.click(function (e) {
                    $this.trigger("sortStart"); var totalRows = ($this[0].tBodies[0] && $this[0].tBodies[0].rows.length) || 0; if (!this.sortDisabled && totalRows > 0) {
                        var $cell = $(this); var i = this.column; this.order = this.count++ % 2; if (!e[config.sortMultiSortKey]) {
                            config.sortList = []; if (config.sortForce != null) { var a = config.sortForce; for (var j = 0; j < a.length; j++) { if (a[j][0] != i) { config.sortList.push(a[j]); } } }
                            config.sortList.push([i, this.order]);
                        } else { if (isValueInArray(i, config.sortList)) { for (var j = 0; j < config.sortList.length; j++) { var s = config.sortList[j], o = config.headerList[s[0]]; if (s[0] == i) { o.count = s[1]; o.count++; s[1] = o.count % 2; } } } else { config.sortList.push([i, this.order]); } }; setTimeout(function () { setHeadersCss($this[0], $headers, config.sortList, sortCSS); appendToTable($this[0], multisort($this[0], config.sortList, cache)); }, 1); return false;
                    }
                }).mousedown(function () { if (config.cancelSelection) { this.onselectstart = function () { return false }; return false; } }); $this.bind("update", function () { this.config.parsers = buildParserCache(this, $headers); cache = buildCache(this); }).bind("sorton", function (e, list) { $(this).trigger("sortStart"); config.sortList = list; var sortList = config.sortList; updateHeaderSortCount(this, sortList); setHeadersCss(this, $headers, sortList, sortCSS); appendToTable(this, multisort(this, sortList, cache)); }).bind("appendCache", function () { appendToTable(this, cache); }).bind("applyWidgetId", function (e, id) { getWidgetById(id).format(this); }).bind("applyWidgets", function () { applyWidget(this); }); if ($.metadata && ($(this).metadata() && $(this).metadata().sortlist)) { config.sortList = $(this).metadata().sortlist; }
                if (config.sortList.length > 0) { $this.trigger("sorton", [config.sortList]); }
                applyWidget(this);
            });
        }; this.addParser = function (parser) {
            var l = parsers.length, a = true; for (var i = 0; i < l; i++) { if (parsers[i].id.toLowerCase() == parser.id.toLowerCase()) { a = false; } }
            if (a) { parsers.push(parser); };
        }; this.addWidget = function (widget) { widgets.push(widget); }; this.formatFloat = function (s) { var i = parseFloat(s); return (isNaN(i)) ? 0 : i; }; this.formatInt = function (s) { var i = parseInt(s); return (isNaN(i)) ? 0 : i; }; this.isDigit = function (s, config) { var DECIMAL = '\\' + config.decimal; var exp = '/(^[+]?0(' + DECIMAL + '0+)?$)|(^([-+]?[1-9][0-9]*)$)|(^([-+]?((0?|[1-9][0-9]*)' + DECIMAL + '(0*[1-9][0-9]*)))$)|(^[-+]?[1-9]+[0-9]*' + DECIMAL + '0+$)/'; return RegExp(exp).test($.trim(s)); }; this.clearTableBody = function (table) {
            if ($.browser.msie) {
                function empty() { while (this.firstChild) this.removeChild(this.firstChild); }
                empty.apply(table.tBodies[0]);
            } else { table.tBodies[0].innerHTML = ""; }
        };
    }
    }); $.fn.extend({ tablesorter: $.tablesorter.construct }); var ts = $.tablesorter; ts.addParser({ id: "text", is: function (s) { return true; }, format: function (s) { return $.trim(s.toLowerCase()); }, type: "text" }); ts.addParser({ id: "digit", is: function (s, table) { var c = table.config; return $.tablesorter.isDigit(s, c); }, format: function (s) { return $.tablesorter.formatFloat(s); }, type: "numeric" }); ts.addParser({ id: "currency", is: function (s) { return /^[£$€?.]/.test(s); }, format: function (s) { return $.tablesorter.formatFloat(s.replace(new RegExp(/[^0-9.]/g), "")); }, type: "numeric" }); ts.addParser({ id: "ipAddress", is: function (s) { return /^\d{2,3}[\.]\d{2,3}[\.]\d{2,3}[\.]\d{2,3}$/.test(s); }, format: function (s) {
        var a = s.split("."), r = "", l = a.length; for (var i = 0; i < l; i++) { var item = a[i]; if (item.length == 2) { r += "0" + item; } else { r += item; } }
        return $.tablesorter.formatFloat(r);
    }, type: "numeric"
    }); ts.addParser({ id: "url", is: function (s) { return /^(https?|ftp|file):\/\/$/.test(s); }, format: function (s) { return jQuery.trim(s.replace(new RegExp(/(https?|ftp|file):\/\//), '')); }, type: "text" }); ts.addParser({ id: "isoDate", is: function (s) { return /^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(s); }, format: function (s) { return $.tablesorter.formatFloat((s != "") ? new Date(s.replace(new RegExp(/-/g), "/")).getTime() : "0"); }, type: "numeric" }); ts.addParser({ id: "percent", is: function (s) { return /\%$/.test($.trim(s)); }, format: function (s) { return $.tablesorter.formatFloat(s.replace(new RegExp(/%/g), "")); }, type: "numeric" }); ts.addParser({ id: "usLongDate", is: function (s) { return s.match(new RegExp(/^[A-Za-z]{3,10}\.? [0-9]{1,2}, ([0-9]{4}|'?[0-9]{2}) (([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(AM|PM)))$/)); }, format: function (s) { return $.tablesorter.formatFloat(new Date(s).getTime()); }, type: "numeric" }); ts.addParser({ id: "shortDate", is: function (s) { return /\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/.test(s); }, format: function (s, table) {
        var c = table.config; s = s.replace(/\-/g, "/"); if (c.dateFormat == "us") { s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/, "$3/$1/$2"); } else if (c.dateFormat == "uk") { s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/, "$3/$2/$1"); } else if (c.dateFormat == "dd/mm/yy" || c.dateFormat == "dd-mm-yy") { s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{2})/, "$1/$2/$3"); }
        return $.tablesorter.formatFloat(new Date(s).getTime());
    }, type: "numeric"
    }); ts.addParser({ id: "time", is: function (s) { return /^(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(am|pm)))$/.test(s); }, format: function (s) { return $.tablesorter.formatFloat(new Date("2000/01/01 " + s).getTime()); }, type: "numeric" }); ts.addParser({ id: "metadata", is: function (s) { return false; }, format: function (s, table, cell) { var c = table.config, p = (!c.parserMetadataName) ? 'sortValue' : c.parserMetadataName; return $(cell).metadata()[p]; }, type: "numeric" }); ts.addWidget({ id: "zebra", format: function (table) {
        if (table.config.debug) { var time = new Date(); }
        $("tr:visible", table.tBodies[0]).filter(':even').removeClass(table.config.widgetZebra.css[1]).addClass(table.config.widgetZebra.css[0]).end().filter(':odd').removeClass(table.config.widgetZebra.css[0]).addClass(table.config.widgetZebra.css[1]); if (table.config.debug) { $.tablesorter.benchmark("Applied Zebra widget", time); }
    }
    });
})(jQuery);

/*tableSorterFilter*/
(function ($) {
    $.extend({ tablesorterFilter: new function () {
        function has_words(str, words, caseSensitive) {
            var text = caseSensitive ? str : str.toLowerCase(); for (var i = 0; i < words.length; i++) { if (words[i].charAt(0) == '-') { if (text.indexOf(words[i].substr(1)) != -1) return false; } else if (text.indexOf(words[i]) == -1) return false; }
            return true;
        }
        function doFilter(table) {
            if (table.config.debug) { var cacheTime = new Date(); }
            var filters = []; for (var i = 0; i < table.config.filter.length; i++) { var container = $(table.config.filter[i].filterContainer); var phrase = jQuery.trim(container.val()).replace(/\s+/g, ' '); if (phrase.length != 0) { var caseSensitive = table.config.filter[i].filterCaseSensitive; filters.push({ caseSensitive: caseSensitive, words: caseSensitive ? phrase.split(" ") : phrase.toLowerCase().split(" "), findStr: table.config.filter[i].filterColumns ? "td:eq(" + table.config.filter[i].filterColumns.join("),td:eq(") + ")" : "", filterFunction: table.config.filter[i].filterFunction }); } }
            var filterCount = filters.length; if (filterCount == 0) { var search_text = function () { var elem = jQuery(this); resultRows[resultRows.length] = elem; } } else {
                var search_text = function () {
                    var elem = jQuery(this); for (var i = 0; i < filterCount; i++) { if (!filters[i].filterFunction((filters[i].findStr ? elem.find(filters[i].findStr) : elem).text(), filters[i].words, filters[i].caseSensitive)) { return true; } }
                    resultRows[resultRows.length] = elem;
                }
            }
            var allRows = table.config.cache.row; var resultRows = []; var allRowsCount = allRows.length; for (var i = 0; i < allRowsCount; i++) { allRows[i].each(search_text); }
            $.tablesorter.clearTableBody(table); var resultRowsCount = resultRows.length; for (var i = 0; i < resultRowsCount; i++) { $(table.tBodies[0]).append(resultRows[i]); }
            $(table).trigger("update"); if (resultRows.length) { $(table).trigger("appendCache"); $(table).trigger("sorton", [table.config.sortList]); }
            if (table.config.debug) { $.tablesorter.benchmark("Apply filter:", cacheTime); }
            $(table).trigger("filterEnd");
            //initStaffList();
            return table;
        }; function clearFilter(table) {
            if (table.config.debug) { var cacheTime = new Date(); }
            for (var i = 0; i < table.config.filter.length; i++)
                $(table.config.filter[i].filterContainer).val('').get(0).lastValue = ''; var allRows = table.config.cache.row; $.tablesorter.clearTableBody(table); for (var i = 0; i < allRows.length; i++) { $(table.tBodies[0]).append(allRows[i]); }
            $(table).trigger("update"); $(table).trigger("appendCache"); $(table).trigger("sorton", [table.config.sortList]); if (table.config.debug) { $.tablesorter.benchmark("Clear filter:", cacheTime); }
            $(table).trigger("filterCleared"); return table;
        }; this.defaults = { filterContainer: '#filter-box', filterClearContainer: '#filter-clear-button', filterColumns: null, filterCaseSensitive: false, filterWaitTime: 500, filterFunction: has_words }; this.construct = function () {
            var settings = arguments; return this.each(function () {
                this.config.filter = new Array(settings.length); var config = this.config; config.filter = new Array(settings.length); for (var i = 0; i < settings.length; i++)
                    config.filter[i] = $.extend(this.config.filter[i], $.tablesorterFilter.defaults, settings[i]); var table = this; function checkInputBox(inputBox, override) { var value = inputBox.value; if ((value != inputBox.lastValue) || (override)) { inputBox.lastValue = value; doFilter(table); } }; var timer = new Array(settings.length); for (var i = 0; i < settings.length; i++) {
                    var container = $(config.filter[i].filterContainer); if (container.length)
                        container[0].filterIndex = i; container.keyup(function (e, phrase) {
                            var index = this.filterIndex; if (undefined !== phrase)
                                $(this).val(phrase); var inputBox = this; if (inputBox.keyCode == 13 || undefined !== phrase) { var timerWait = 1; var overrideBool = true; } else { var timerWait = config.filter[index].filterWaitTime || 500; var overrideBool = false; }
                            var timerCallback = function () { checkInputBox(inputBox, overrideBool); }
                            clearTimeout(timer[index]); timer[index] = setTimeout(timerCallback, timerWait); return false;
                        }); if (config.filter[i].filterClearContainer) {
                        var container = $(config.filter[i].filterClearContainer); if (container.length) {
                            container[0].filterIndex = i; container.click(function () {
                                var index = this.filterIndex; var container = $(config.filter[index].filterContainer); container.val(""); container[0].lastValue = ""; doFilter(table); if (container[0].type != 'hidden')
                                    container.focus();
                            });
                        }
                    }
                }
                $(table).bind("doFilter", function () { doFilter(table); }); $(table).bind("clearFilter", function () { clearFilter(table); });
            });
        };
    }
    }); $.fn.extend({ tablesorterFilter: $.tablesorterFilter.construct });
})(jQuery);

/*tableSorterPager*/
(function ($) {
    $.extend({ tablesorterPager: new function () {
        function updatePageDisplay(c) { var s = $(c.cssPageDisplay, c.container).html("Displaying page " + (c.page + 1) + c.seperator + c.totalPages); }
        function setPageSize(table, size) { var c = table.config; c.size = size; c.totalPages = Math.ceil(c.totalRows / c.size); c.pagerPositionSet = false; moveToPage(table); fixPosition(table); }
        function fixPosition(table) {
                var c = table.config;
                if(!c.pagerPositionSet && c.positionFixed) {
                    var c = table.config, o = $(table), r = c.size - (c.totalRows % c.size) ;
                    if(c.totalRows <= c.size)
                    {
                        c.container.hide();
                        o.parent().css({height: "auto"});
                    }
                    if(o.offset && c.page == (c.totalPages - 1)) {
                        c.container.css({
                            'margin-top': '0'//o.find("tbody tr").first().height() * r + 12 + 'px'
                        });
                    }
                    else if(o.offset){
                        c.container.css({
                            'margin-top': '0'
                        });
                    }
                    //c.pagerPositionSet = true;
                }
        }
        function moveToFirstPage(table) { var c = table.config; c.page = 0; moveToPage(table); }
        function moveToLastPage(table) { var c = table.config; c.page = (c.totalPages - 1); moveToPage(table); }
        function moveToNextPage(table) {
            var c = table.config; c.page++; if (c.page >= (c.totalPages - 1)) { c.page = (c.totalPages - 1); }
            moveToPage(table);
        }
        function moveToPrevPage(table) {
            var c = table.config; c.page--; if (c.page <= 0) { c.page = 0; }
            moveToPage(table);
        }
        function moveToPage(table) {
            var c = table.config; if (c.page < 0 || c.page > (c.totalPages - 1)) { c.page = 0; }
            renderTable(table, c.rowsCopy);

        }
        function renderTable(table, rows) {
            var c = table.config; var l = rows.length; var s = (c.page * c.size); var e = (s + c.size); if (e > rows.length) { e = rows.length; }
            var tableBody = $(table.tBodies[0]); $.tablesorter.clearTableBody(table); for (var i = s; i < e; i++) { var o = rows[i]; var l = o.length; for (var j = 0; j < l; j++) { tableBody[0].appendChild(o[j]); } }
            fixPosition(table, tableBody, rows); $(table).trigger("applyWidgets"); if (c.page >= c.totalPages) { moveToLastPage(table); }
            updatePageDisplay(c);
            //initTables();
        }
        this.appender = function (table, rows) { var c = table.config; c.rowsCopy = rows; c.totalRows = rows.length; c.totalPages = Math.ceil(c.totalRows / c.size); renderTable(table, rows); }; 
        this.defaults = { size: 20, offset: 0, page: 0, totalRows: 0, totalPages: 0, container: null, cssNext: '.next', cssPrev: '.prev', cssFirst: '.first', cssLast: '.last', cssPageDisplay: '.pagedisplay', cssPageSize: '.pagesize', seperator: " of ", positionFixed: true, appender: this.appender }; 
        this.construct = function (settings) { return this.each(function () { config = $.extend(this.config, $.tablesorterPager.defaults, settings); var table = this, pager = config.container; $(this).trigger("appendCache"); config.size = settings.size != null ? settings.size : $.tablesorterPager.defaults.size; $(config.cssFirst, pager).click(function () { moveToFirstPage(table); return false; }); $(config.cssNext, pager).click(function () { moveToNextPage(table); return false; }); $(config.cssPrev, pager).click(function () { moveToPrevPage(table); return false; }); $(config.cssLast, pager).click(function () { moveToLastPage(table); return false; }); }); };
    }
    }); $.fn.extend({ tablesorterPager: $.tablesorterPager.construct });
})(jQuery);

jQuery.timer = function (interval, callback) {
    var interval = interval || 100;

    if (!callback)
        return false;

    _timer = function (interval, callback) {
        this.stop = function () {
            clearInterval(self.id);
        };

        this.internalCallback = function () {
            callback(self);
        };

        this.reset = function (val) {
            if (self.id)
                clearInterval(self.id);

            var val = val || 100;
            this.id = setInterval(this.internalCallback, val);
        };

        this.interval = interval;
        this.id = setInterval(this.internalCallback, this.interval);

        var self = this;
    };

    return new _timer(interval, callback);
};

/*cookie plugin*/
jQuery.cookie = function (name, value, options) {
    if (typeof value != 'undefined') {
        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();
        }
        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 {
        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]); if (cookie.substring(0, name.length + 1) == (name + '=')) { cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); break; } } }
        return cookieValue;
    }
};

/*type watch plugin*/
(function (jQuery) {
    jQuery.fn.typeWatch = function (o) {
        // Options
        var options = jQuery.extend({
            wait: 750,
            callback: function () { },
            highlight: true,
            captureLength: 2
        }, o);

        function checkElement(timer, override) {
            var elTxt = jQuery(timer.el).val();

            // Fire if text > options.captureLength AND text != saved txt OR if override AND text > options.captureLength
            if ((elTxt.length > options.captureLength && elTxt.toUpperCase() != timer.text)
			|| (override && elTxt.length > options.captureLength)) {
                timer.text = elTxt.toUpperCase();
                timer.cb(elTxt);
            }
        };

        function watchElement(elem) {
            // Must be text or textarea
            if (elem.type.toUpperCase() == "TEXT" || elem.nodeName.toUpperCase() == "TEXTAREA") {

                // Allocate timer element
                var timer = {
                    timer: null,
                    text: jQuery(elem).val().toUpperCase(),
                    cb: options.callback,
                    el: elem,
                    wait: options.wait
                };

                // Set focus action (highlight)
                if (options.highlight) {
                    jQuery(elem).focus(
						function () {
						    this.select();
						});
                }

                // Key watcher / clear and reset the timer
                var startWatch = function (evt) {
                    evt.preventDefault();
                    var timerWait = timer.wait;
                    var overrideBool = false;
                    var elTxt = jQuery(timer.el).val();

                    if(elTxt.length > options.captureLength)
                    {
                        if(evt.keyCode != 16 && evt.keyCode != 17 && evt.keyCode != 18)
                        {
                            $("#messagec").addClass('loading');
                            $("#messagec").removeClass('info');
                            $("#messagec").removeClass('error');
                            $("#messagec").html("loading...");
                            $("#messagec").show();
                        }
                    }
                    else
                    {
                        $("#messagec").hide();
                    }

                    if (evt.keyCode == 13 && this.type.toUpperCase() == "TEXT") {
                        timerWait = 1;
                        overrideBool = true;
                    }

                    var timerCallbackFx = function () {
                        checkElement(timer, overrideBool)
                    }

                    // Clear timer					
                    clearTimeout(timer.timer);
                    timer.timer = setTimeout(timerCallbackFx, timerWait);

                };

                jQuery(elem).keyup(startWatch);
            }
        };

        // Watch Each Element
        return this.each(function (index) {
            watchElement(this);
        });

    };

})(jQuery);

/*Form to Wizard plugin*/
(function ($) {
    $.fn.formToWizard = function (options) {
        options = $.extend({
            submitButton: ""
        }, options);

        var element = this;

        var steps = $(element).find("fieldset");
        var count = steps.size();
        var submmitButtonName = "#" + options.submitButton;
        $(submmitButtonName).hide();

        // 2
        $(element).before("<ul id='steps'></ul>");

        steps.each(function (i) {
            $(this).wrap("<div id='step" + i + "'></div>");
            $(this).append("<p id='step" + i + "commands'></p>");

            // 2
            var name = $(this).find("legend").html();
            $("#steps").append("<li id='stepDesc" + i + "'>Step " + (i + 1) + "<span>" + name + "</span></li>");

            if (i == 0) {
                createNextButton(i);
                selectStep(i);
            }
            else if (i == count - 1) {
                $("#step" + i).hide();
                createPrevButton(i);
            }
            else {
                $("#step" + i).hide();
                createPrevButton(i);
                createNextButton(i);
            }
        });

        function createPrevButton(i) {
            var stepName = "step" + i;
            $("#" + stepName + "commands").append("<a href='#' id='" + stepName + "Prev' class='link rev'>Back</a>");

            $("#" + stepName + "Prev").bind("click", function (e) {
                $("#" + stepName).hide();
                $("#step" + (i - 1)).show();
                $(submmitButtonName).hide();
                selectStep(i - 1);
            });
        }

        function createNextButton(i) {
            var stepName = "step" + i;
            $("#" + stepName + "commands").append("<a href='#' id='" + stepName + "Next' class='link forward'>Next </a>");

            $("#" + stepName + "Next").bind("click", function (e) {
                $("#" + stepName).hide();
                $("#step" + (i + 1)).show();
                if (i + 2 == count)
                    $(submmitButtonName).show();
                selectStep(i + 1);
            });
        }

        function selectStep(i) {
            $("#steps li").removeClass("current");
            $("#stepDesc" + i).addClass("current");
        }

    }
})(jQuery);

/*Countdown*/
(function ($) {

    $.fn.countDown = function (options) {

        config = {};

        $.extend(config, options);

        diffSecs = this.setCountDown(config);

        if (config.onComplete) {
            $.data($(this)[0], 'callback', config.onComplete);
        }
        if (config.omitWeeks) {
            $.data($(this)[0], 'omitWeeks', config.omitWeeks);
        }

        $('#' + $(this).attr('id') + ' .digit').html('<div class="top"></div><div class="bottom"></div>');
        $(this).doCountDown($(this).attr('id'), diffSecs, 500);

        return this;

    };

    $.fn.stopCountDown = function () {
        clearTimeout($.data(this[0], 'timer'));
    };

    $.fn.startCountDown = function () {
        this.doCountDown($(this).attr('id'), $.data(this[0], 'diffSecs'), 500);
    };

    $.fn.setCountDown = function (options) {
        var targetTime = new Date();

        if (options.targetDate) {
            targetTime = new Date(options.targetDate.month + '/' + options.targetDate.day + '/' + options.targetDate.year + ' ' + options.targetDate.hour + ':' + options.targetDate.min + ':' + options.targetDate.sec + (options.targetDate.utc ? ' UTC' : ''));
        }
        else if (options.targetOffset) {
            targetTime.setFullYear(options.targetOffset.year + targetTime.getFullYear());
            targetTime.setMonth(options.targetOffset.month + targetTime.getMonth());
            targetTime.setDate(options.targetOffset.day + targetTime.getDate());
            targetTime.setHours(options.targetOffset.hour + targetTime.getHours());
            targetTime.setMinutes(options.targetOffset.min + targetTime.getMinutes());
            targetTime.setSeconds(options.targetOffset.sec + targetTime.getSeconds());
        }

        var nowTime;
        if (options.serverStartTime)
        {
            nowTime = new Date(options.serverStartTime.month + '/' + options.serverStartTime.day + '/' + options.serverStartTime.year + ' ' + options.serverStartTime.hour + ':' + options.serverStartTime.min + ':' + options.serverStartTime.sec + (options.serverStartTime.utc ? ' UTC' : ''));
        }
        else
        {
            nowTime = new Date();
        }

        diffSecs = Math.floor((targetTime.valueOf() - nowTime.valueOf()) / 1000);

        $.data(this[0], 'diffSecs', diffSecs);

        return diffSecs;
    };

    $.fn.doCountDown = function (id, diffSecs, duration) {
        $this = $('#' + id);
        if (diffSecs <= 0) {
            diffSecs = 0;
            if ($.data($this[0], 'timer')) {
                clearTimeout($.data($this[0], 'timer'));
            }
        }

        secs = diffSecs % 60;
        mins = Math.floor(diffSecs / 60) % 60;
        hours = Math.floor(diffSecs / 60 / 60) % 24;
        if ($.data($this[0], 'omitWeeks') == true) {
            days = Math.floor(diffSecs / 60 / 60 / 24);
            weeks = Math.floor(diffSecs / 60 / 60 / 24 / 7);
        }
        else {
            days = Math.floor(diffSecs / 60 / 60 / 24) % 7;
            weeks = Math.floor(diffSecs / 60 / 60 / 24 / 7);
        }

        $this.dashChangeTo(id, 'seconds_dash', secs, duration ? duration : 800);
        $this.dashChangeTo(id, 'minutes_dash', mins, duration ? duration : 1200);
        $this.dashChangeTo(id, 'hours_dash', hours, duration ? duration : 1200);
        $this.dashChangeTo(id, 'days_dash', days, duration ? duration : 1200);
        $this.dashChangeTo(id, 'weeks_dash', weeks, duration ? duration : 1200);

        $.data($this[0], 'diffSecs', diffSecs);
        if (diffSecs > 0) {
            e = $this;
            t = setTimeout(function () { e.doCountDown(id, diffSecs - 1); }, 1000);
            $.data(e[0], 'timer', t);
        }
        else if (cb = $.data($this[0], 'callback')) {
            $.data($this[0], 'callback')();
        }

    };

    $.fn.dashChangeTo = function (id, dash, n, duration) {
        $this = $('#' + id);

        for (var i = ($this.find('.' + dash + ' .digit').length - 1); i >= 0; i--) {
            var d = n % 10;
            n = (n - d) / 10;
            $this.digitChangeTo('#' + $this.attr('id') + ' .' + dash + ' .digit:eq(' + i + ')', d, duration);
        }
    };

    $.fn.digitChangeTo = function (digit, n, duration) {
        if (!duration) {
            duration = 800;
        }
        if ($(digit + ' div.top').html() != n + '') {

            $(digit + ' div.top').css({ 'display': 'none' });
            $(digit + ' div.top').html((n ? n : '0')).slideDown(duration);

            $(digit + ' div.bottom').animate({ 'height': '' }, duration, function () {
                $(digit + ' div.bottom').html($(digit + ' div.top').html());
                $(digit + ' div.bottom').css({ 'display': 'block', 'height': '' });
                $(digit + ' div.top').hide().slideUp(10);


            });
        }
    };

})(jQuery);

/*Max Length*/
(function ($) {

$.fn.maxlength = function (settings) {

    if (typeof settings == 'string') {
        settings = { feedback : settings };
    }

    settings = $.extend({}, $.fn.maxlength.defaults, settings);

    function length(el) {
    	var parts = el.value;
    	if ( settings.words )
    		parts = el.value.length ? parts.split(/\s+/) : { length : 0 };
    	return parts.length;
    }
    
    return this.each(function () {
        var field = this,
        	$field = $(field),
        	$form = $(field.form),
        	limit = settings.useInput ? $form.find('input[name=maxlength]').val() : $field.attr('maxlength'),
        	$charsLeft = $form.find(settings.feedback);

    	function limitCheck(event) {
        	var len = length(this),
        	    exceeded = len >= limit,
        		code = event.keyCode;

        	if ( !exceeded )
        		return;

            switch (code) {
                case 8:  // allow delete
                case 9:
                case 17:
                case 36: // and cursor keys
                case 35:
                case 37: 
                case 38:
                case 39:
                case 40:
                case 46:
                case 65:
                    return;

                default:
                    return settings.words && code != 32 && code != 13 && len == limit;
            }
        }


        var updateCount = function () {
            var len = length(field),
            	diff = limit - len;

            $charsLeft.html( diff || "0" );

            // truncation code
            if (settings.hardLimit && diff < 0) {
            	field.value = settings.words ? 
            	    // split by white space, capturing it in the result, then glue them back
            		field.value.split(/(\s+)/, (limit*2)-1).join('') :
            		field.value.substr(0, limit);

                updateCount();
            }
        };

        $field.keyup(updateCount).change(updateCount);
        if (settings.hardLimit) {
            $field.keydown(limitCheck);
        }

        updateCount();
    });
};

$.fn.maxlength.defaults = {
    useInput : false,
    hardLimit : true,
    feedback : '.charsLeft',
    words : false
};

})(jQuery);

$(document).ready(function () {

    if ($('div.status').get(0)) {
        var noThanks = $.cookie("close_service");
        if (noThanks != "yes") {
            getServiceTime(null);
            $.timer(45000, function (timer) {
                getServiceTime(timer);
            });
        }

        $('.noteclose').click(function () {
            $.cookie("close_service", "yes");
            $('div.status').hide('slow');
        });
    }

    if ($('#notify').get(0)) {
        var isNotified = $.cookie("notify");
        if (isNotified != "yes") {
            //get modal
            $("#notify").reveal({
                animation: 'fadeAndPop',                   //fade, fadeAndPop, none
                animationspeed: 300,                       //how fast animtions are
                closeonbackgroundclick: true,              //if you click background will modal close?
                dismissmodalclass: 'close-modal'    //the class of a button or element that will close an open modal
            });
            $.cookie("notify", "yes");
        }

        $('#notify a.link').click(function(e) {
            $("#notify").close();
            e.preventDefault();
        });
    }

    if ($('#content ul.sf_newsList').get(0)) {

        $('#content ul.sf_newsList li').css("cursor", "pointer");

        $("#content ul.sf_newsList li").hover(function () {
            $(this).css("background-color", "#d6eef3");
        },
	    function () {
	        $(this).css("background-color", "transparent");
	    });

        $("#content ul.sf_newsList li").click(function () {
            window.location = $(this).find("a").attr("href"); return false;
        });
    }

    if ($("#campus-select").get(0)) {

        $("#campus-select .column").css("cursor", "pointer");

        //melbourne
        $("#campus-select .column.blue").hover(function () {
            $(this).css("background-color", "#CFF8FF");
        },
	    function () {
	        $(this).css("background-color", "transparent");
	    });

        //viera
        $("#campus-select .column.light-green").hover(function () {
            $(this).css("background-color", "#DBDF99");
        },
	    function () {
	        $(this).css("background-color", "transparent");
	    });

        //seba
        $("#campus-select .column.red").hover(function () {
            $(this).css("background-color", "#FFC2AF");
        },
	    function () {
	        $(this).css("background-color", "transparent");
	    });

        //otown
        $("#campus-select .column.orange").hover(function () {
            $(this).css("background-color", "#FFD3AF");
        },
	    function () {
	        $(this).css("background-color", "transparent");
	    });

        $("#campus-select .column").click(function () {
            window.location = $(this).find("a").attr("href"); return false;
        });

    }

if ($(".four-column").get(0)) {
 
        $(".four-column .column").css("cursor", "pointer");
 
        $(".four-column .column.dark-blue").hover(function () {
            $(this).css("background-color", "#CFF8FF");
        },
           function () {
               $(this).css("background-color", "transparent");
           });
 
        $(".four-column .column").click(function () {
            window.location = $(this).find("a").attr("href"); return false;
        });
 
    }

    if ($("#slideshow").get(0)) {
        $('#slideshow').cycle({
            fx: 'fade',
            timeout: 7000,
            next: '#next',
            prev: '#prev'
        });
        $('.player-frame').hover(
            function () { $('#prev').fadeIn(); $('#next').fadeIn();},
            function () { $('#prev').fadeOut(); $('#next').fadeOut();
        });
    }

    if ($("#teachings").get(0)) {
        $(".a").click(function () {
            window.location = $(this).find("a").attr("href"); return false;
        });

        $("#teachings").tablesorter({
            headers: {
                0: { sorter: false },
                2: { sorter: "usLongDate" }
            }
        })
             .tablesorterPager({ container: $("#pager"), positionFixed: false});

    }

    if ($("#dailydevos").get(0)) {

        $(".a").click(function () {
            window.location = $(this).find("a").attr("href"); return false;
        });

        $("#dailydevos").tablesorter()
                         .tablesorterPager({ container: $("#pager"), positionFixed: false })
                         .tablesorterFilter({ filterContainer: $("#filter-box"),
                             filterClearContainer: $("#filter-clear-button"),
                             filterCaseSensitive: false
                         });

        $("#filter-box").keypress(function (e) {
            if (e.which == 13) {
                return false;
            }
        });

    }

    if ($("#staffcontacts").get(0)) {

        $(".a").click(function () {
            $('#emailmodal').remove();
            $('body').append('<div id="emailmodal" class="reveal-modal large"><iframe id="frame1" scrolling="no" FRAMEBORDER="0" style="width:600px; border:0;  height:510px; overflow:hidden; background:#eee;" src="' + $(this).find("a").attr("href") + '" /><a class="close-reveal-modal">&#215;</a></div>"');
            $('#emailmodal').reveal({
                animation: 'fadeAndPop',                   //fade, fadeAndPop, none
                animationspeed: 300,                       //how fast animtions are
                closeonbackgroundclick: true,              //if you click background will modal close?
                dismissmodalclass: 'close-reveal-modal'    //the class of a button or element that will close an open modal
            });
            return false;
        });

        $("#staffcontacts").tablesorter()
                         .tablesorterPager({ container: $("#pager"), positionFixed: false })
                         .tablesorterFilter({ filterContainer: $("#filter-box"),
                             filterClearContainer: $("#filter-clear-button"),
                             filterCaseSensitive: false
                         });

        $("#filter-box").keypress(function (e) {
            if (e.which == 13) {
                return false;
            }
        });

    }

    if ($("#ministries").get(0)) {

        $(".a").click(function () {
            window.location = $(this).find("a").attr("href"); return false;
        });

        $("#ministries").tablesorter()
                         .tablesorterPager({ container: $("#pager"), positionFixed: false })
                         .tablesorterFilter({ filterContainer: $("#filter-box"),
                             filterClearContainer: $("#filter-clear-button"),
                             filterCaseSensitive: false
                         });

        $("#filter-box").keypress(function (e) {
            if (e.which == 13) {
                return false;
            }
        });

    }

    if ($(".missions-table").get(0)) {

        $(".a").click(function () {
            window.location = $(this).find("a").attr("href"); return false;
        });


        $(".c").click(function () {
            $('#emailmodal').remove();
            $('body').append('<div id="emailmodal" class="reveal-modal large"><iframe id="frame1" scrolling="no" FRAMEBORDER="0" style="width:600px; border:0;  height:510px; overflow:hidden; background:#eee;" src="' + $(this).find("a").attr("href") + '" /><a class="close-reveal-modal">&#215;</a></div>"');
            $('#emailmodal').reveal({
                animation: 'fadeAndPop',                   //fade, fadeAndPop, none
                animationspeed: 300,                       //how fast animtions are
                closeonbackgroundclick: true,              //if you click background will modal close?
                dismissmodalclass: 'close-reveal-modal'    //the class of a button or element that will close an open modal
            });
            return false;
        });

        $(".missions-table").tablesorter();
    }

    if ($("#buttonbox, #buttonbox2").get(0)) {

        $("#buttonbox, #buttonbox2").css("cursor", "pointer");

        //melbourne
        $("#buttonbox, #buttonbox2").hover(function () {
            $(this).css("background-color", "#CFF8FF");
        },
	    function () {
	        $(this).css("background-color", "transparent");
	    });

        $("#buttonbox, #buttonbox2").click(function () {
            window.location = $(this).find("a").attr("href"); return false;
        });

    }

    if ($(".bluehighlight").get(0)) {

        $(".bluehighlight").css("cursor", "pointer");

        $(".bluehighlight").hover(function () {
            $(this).css("background-color", "#CFF8FF");
        },
	    function () {
	        $(this).css("background-color", "transparent");
	    });

        $(".bluehighlight").click(function () {
            window.location = $(this).find("a").attr("href"); return false;
        });

    }


    if ($(".teachingSeries").get(0)) {

        $(".teachingSeries").css("cursor", "pointer");

        $(".teachingSeries").hover(function () {
            $(this).css("background-color", "#CFF8FF");
        },
	    function () {
	        $(this).css("background-color", "transparent");
	    });

        $(".teachingSeries").click(function () {
            window.location = $(this).find("a").attr("href"); return false;
        });

    }

    if ($("#yellowpages").get(0)) {

        $(".a").click(function () {
            window.location = $(this).find("a").attr("href"); return false;
        });

        $("#yellowpages").tablesorter()
                         .tablesorterPager({ container: $("#pager"), positionFixed: false })
                         .tablesorterFilter({ filterContainer: $("#filter-box"),
                             filterClearContainer: $("#filter-clear-button"),
                             filterCaseSensitive: false
                         });

        $("#filter-box").keypress(function (e) {
            if (e.which == 13) {
                return false;
            }
        });
    }

    if ($("#smallGroups").get(0)) {

        $(".a").click(function () {
            window.location = $(this).find("a").attr("href"); return false;
        });

        $("#smallGroups").tablesorter()
                         .tablesorterPager({ container: $("#pager"), positionFixed: false })
                         .tablesorterFilter({ filterContainer: $("#filter-box"),
                             filterClearContainer: $("#filter-clear-button"),
                             filterCaseSensitive: false
                         });

        $("#filter-box").keypress(function (e) {
            if (e.which == 13) {
                return false;
            }
        });
    }

    if($("#gmap").get(0)){
        var latlng = new google.maps.LatLng($("#lat").val(),$("#long").val());
        var myOptions = {
          zoom: 12,
          center: latlng,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };

        var map = new google.maps.Map(document.getElementById("gmap"), myOptions);
        var image = 'http://www.calvaryccm.com/images/logos/small-icon.png';

        var marker1 = new google.maps.Marker({
            map: map,
            position: latlng,
            icon: image
        });

        if($("#address").val() != "" || $("#address").val() != null)
        {
            var geocoder = new google.maps.Geocoder();
            geocoder.geocode( { 'address': $("#address").val()}, function(results, status) {
              if (status == google.maps.GeocoderStatus.OK) {
                map.setCenter(results[0].geometry.location);
                var marker2 = new google.maps.Marker({
                    map: map,
                    position: results[0].geometry.location
                });
                var infowindow = new google.maps.InfoWindow({
                    content: "<h3 style=\"margin: 0;\">" + $("h1").text() + "</h3><a href=\"http://maps.google.com/maps?q=" + $("#address").val().replace(/ /ig, "+") + "\">Get Directions</a>",
                    maxWidth: 100
                });
                google.maps.event.addListener(marker2, 'click', function() {
                  infowindow.open(map,marker2);
                });
              } 
            });
        }
    }

    if ($("#livepoll").get(0)) {
        WEB_SOCKET_SWF_LOCATION = 'http://resources.calvaryccm.com/socket.io/WebSocketMainInsecure.swf';
        var socket = new io.Socket("livepoll.calvaryccm.com", { port: 8080 });
        socket.connect();
        socket.on("connect", function () {
            socket.send('{"join":"event1","listen":["event1"]}');
        });
        socket.on("message", function (data) {
            if (data.event1 == 1)
                $("#livepoll").html("1 person is currently watching");
            else if (data.event < 0)
                $("#livepoll").html("");
            else
                $("#livepoll").html(data.event1 + " people are currently watching");
        });
    }

    SetModalClick();

    if ($("#mediaplayer_jwplayer_display_image").get(0)) {

        $("#mediaplayer_jwplayer_display_image").css("cursor", "pointer");
        $("#mediaplayer_jwplayer_display_image").click(function () {
            window.location = "http://get.adobe.com/flashplayer/"; return false;
        });
    }

    //"Instant" search
    if ($("#teachings").get(0)) {
        if (typeof Array.prototype.map !== 'function') {
            Array.prototype.map = function (fn) {
                for (i = 0, r = [], l = this.length; i < l; r.push(fn(this[i++])));
                return r;
            };
        }


        var prevquery = "WDMrclYmwBsloFdmWA3g7g910Uob1ajb4b5s7kWheas";

        //if it's not empty on page load
        if ($("#filter-box").val() != '')
            GetTeachingsSearch($("#filter-box").val());


        $("#filter-box").typeWatch({
            callback: function () { GetTeachingsSearch($("#filter-box").val()) },
            wait: 400,
            highlight: false,
            captureLength: 1
        });

        $('#filter-box').keydown(function (e) {
            if (e.keyCode == 13)
                e.preventDefault();
        });

        //Identify the typing action
        $('#filter-box').keyup(function (e) {
            e.preventDefault();

            //switch back to original table if search box is empty.
            if ($("#filter-box").val() == '') {
                if (!$("#teachings").is(":visible"))
                    SwitchTables();
                if ($("#none").get(0))
                    $("#none").remove();
                $("#pager").show();
                $("#messagec").hide();
                return false;
            }


        });

        $(".book").change(function () {
            if ($(".book option:selected").val() > 0) {
                $("#filter-box").val($(".book option:selected").text()).trigger("keyup");
                $(".tag").val("-1");
            }
        });

        $(".tag").change(function () {
            if ($(".tag option:selected").val() > 0) {
                $("#filter-box").val($(".tag option:selected").text()).trigger("keyup");
                $(".book").val("-1");
            }
        });
    }

    if ($("#mq_form").get(0)) {
        $("#SignupForm").formToWizard();
        $("#statement").click(function () {
            $('#statementmodal').remove();
            $('body').append('<div id="statementmodal" class="reveal-modal large">Statement goes here<a class="close-reveal-modal">&#215;</a></div>"');
            $('#statementmodal').reveal({
                animation: 'fadeAndPop',                   //fade, fadeAndPop, none
                animationspeed: 300,                       //how fast animtions are
                closeonbackgroundclick: true,              //if you click background will modal close?
                dismissmodalclass: 'close-reveal-modal'    //the class of a button or element that will close an open modal
            });
            return false;
        });
    }

    if ($("#countdown_dashboard").get(0)) {

        $('#countdown_dashboard').countDown({
            targetDate: jQuery.parseJSON($("#targetdate").val()),
            omitWeeks: true,
            onComplete: function(){window.location.reload(true);},
            serverStartTime: jQuery.parseJSON($("#start").val())

        });
    }

   if ($("#volunteersSmall").get(0)) {

        $(".a").click(function () {
            window.location = $(this).find("a").attr("href"); return false;
        });

        $("#volunteersSmall").tablesorter()
                         .tablesorterPager({ container: $("#pager"), size: 4 });
    }

   if ($("#smallGroupsSmall").get(0)) {

        $(".a").click(function () {
            window.location = $(this).find("a").attr("href"); return false;
        });

        $("#smallGroupsSmall").tablesorter()
                         .tablesorterPager({ container: $("#pager2"), size: 4 });

    }
	// Displays information about buildings for the campus maps
	$('#buildings li').click(function(){
		// Hides the full map
		$(".fullMap").hide();
		$(".building-desc").hide();
		// Shows building description
		var prefix = $(this).find("a:first").attr("rel");
		$("#building-holder").html('<h2>' + $(this).find("a:first").text() + '</h2>  <div id="' + prefix + 'Id" class="buildingImage" ></div>  <div class="buildingText"> ' + $("#" + prefix + "Content").html() + '</div>').show();
		return false;
        });

    $('#back').click(function(){
		$("#building-holder").html("");
		$("#building-holder").hide();
		$(".fullMap").show();
		return false;	
	});

    if($("#iprayrequest").get(0)) {
        $("textarea.limited").maxlength({
            'feedback': '.charsLeft',
            'useInput': true
      });
    }
});

function getServiceTime(timer) {
    //$('#watchlive').remove();
    //$("#header strong.slogan").after("<div id=\"watchlive\" class=\"loadingWatchLive\" style=\"display: none;\"></div>");
    //$("#watchlive").fadeIn('slow');
    $.ajax({
        type: "POST",
        url: "/ServiceTimes.asmx/IsServiceTime",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        error: function (xhr, status, error) {
            //$('#watchlive').removeClass('loadingWatchLive');
            var err = eval("(" + xhr.responseText + ")");
            $('#watchlive').html(err.Message);
        },

        success: function (msg) {
            setTimeout(function () {

                //$("#watchlive").fadeOut('slow', function () { $('#watchlive').removeClass('loadingWatchLive'); });

                if (msg.d) {
                    //$(".slogan").after("<div id=\"watchlive\" class=\"watch\" style=\"display: none;\"></div>");
                    $('div.status').show('slow');
                    //$('#watchlive').css("display", "inline");
                    //$('#watchlive').html("<h3>Watch Worship Service Live!</h3><a href=\"/teachings/livestreaming.aspx\">Click here to see more</a>");
                    initWatchLiveLink();
                    if (timer != null)
                        timer.stop();
                }
            }, 2000
                    )
        }
    });
}

function initWatchLiveLink() {
    var $a = $('div.status').find('a:first');
    if ($a != null) {
        var href = $a.attr('href');

        $("div.watch").hover(
			function () {
			    $(this).css({ 'cursor': 'pointer' });
			},
			function () {
			    $(this).css({ 'cursor': 'default' });
			}
		).click(
			function () {
			    window.location = href;
			}
		);
    }

}

function ToLower(item) {
    return item.toLowerCase();
}

function GetTeachingsSearch(prevquery) {
    //abort duplicate requests
    //if (prevquery == $("#filter-box").val())
    //    return;

    $.ajax({
        type: "POST",
        url: "/Teachings.asmx/GetTeachingsBySearch",
        data: "{'archiveID': '" + $('#a12 input[type="hidden"]').val() + "', 'searchval': '" + $("#filter-box").val() + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        error: function (xhr, status, error) {
            //$('#watchlive').removeClass('loadingWatchLive');
            var err = jQuery.parseJSON(xhr.responseText);
            $("#messagec").html(err.Message);
            $("#messagec").removeClass("loading");
            $("#messagec").addClass("error");
            $("#messagec").show();
        },

        success: function (msg) {
            $("#teachings-alt tr").unbind('click');
            if (msg == null) return;
            if (msg.d == null) return;
            if ($("#none").get(0))
                $("#none").remove();
            if ($("#teachings").is(":visible"))
                SwitchTables();
            if (msg.d.Teachings.length > 0) {
                $("#pager").hide();
                $("#teachings-alt").tablesorter();//.tablesorterPager({ container: $("#pager-alt") });
                $("#teachings-alt > tbody:last").empty();
                //$("#teachings-alt").append("<thead><tr><th><strong>Title</strong></th><th><strong>Msg #</strong></th><th><strong>Speaker</strong></th><th><strong>Scripture</strong></th><th><strong>Date</strong></th><th><strong>Series</strong></th><th><strong>Tags</strong></th></tr></thead><tbody></tbody>");
                var res = $("#teachTemplate").tmpl(msg.d); //.appendTo("#teachings tbody");
                $("#teachings-alt > tbody:last").append(res);
                $("#teachings-alt tbody tr").click(function () {
                    window.location = $(this).attr("rel");
                });
                $("#teachings-alt").trigger("update");
                $("#messagec").removeClass("loading");
                $("#messagec").addClass("info");
                $("#messagec").html(msg.d.Message + ". <a href=\"/pages/search-help.html\" class=\"emailmodal\">Need search tips?</a>");
                $("#messagec").show();
            }
            else {
                //$("#messagec").hide();
                $("#teachings-alt > tbody:last").empty();
                $("#pager").hide();
                $("#messagec").removeClass("loading");
                $("#messagec").addClass("info");
                $("#messagec").html("Your search <strong>'" + $("#filter-box").val() + "'</strong> did not match any teachings. <a href=\"/pages/search-help.html\" class=\"emailmodal\">Need Help?</a>");
            }
            SetModalClick();
            prevquery = $("#filter-box").val();
        }
    });
}


function SwitchTables() {
    $("#teachings").toggle();
    //$("#pager").toggle();
    $("#teachings-alt").toggle();
    //$("#pager-alt").toggle();
}

function ArrayToCommaSepString(arr)
{
    return arr.join(", ");
}

function SetModalClick(scrollbars){
    $(".emailmodal").unbind('click');
    $(".emailmodal").click(function () {
        $('#emailmodal').remove();
        $('body').append('<div id="emailmodal" class="reveal-modal large"><iframe id="frame1" scrolling="no" FRAMEBORDER="0" style="width:595px; border:0;  height:530px; overflow:hidden; background:#eee;" src="' + $(this).attr("href") + '" /><a class="close-reveal-modal">&#215;</a></div>"');
        $('#emailmodal').reveal({
            animation: 'fadeAndPop',                   //fade, fadeAndPop, none
            animationspeed: 300,                       //how fast animtions are
            closeonbackgroundclick: true,              //if you click background will modal close?
            dismissmodalclass: 'close-reveal-modal'    //the class of a button or element that will close an open modal
        });
        return false;
    });

    $(".mediamodal").unbind('click');
    $(".mediamodal").click(function () {
        $('.reveal-modal-bg').unbind('click');
        $('.close-reveal-modal').unbind('click');
        $('#mediamodal').remove();
        $('body').append('<div id="mediamodal" class="reveal-modal large" style="width:675px; margin-left:-415px;"><div id="mediaplayer"><script type="text/javascript">SetupMediaPlayer("' + $(this).attr('rel').toLowerCase() + '");</script></div><div id="livepoll_min" style="padding-top:20px;"></div><a class="close-reveal-modal">&#215;</a></div>"');
        $('#mediamodal').reveal({
            animation: 'fadeAndPop',                   //fade, fadeAndPop, none
            animationspeed: 300,                       //how fast animtions are
            closeonbackgroundclick: true,              //if you click background will modal close?
            dismissmodalclass: 'close-reveal-modal'    //the class of a button or element that will close an open modal
        });
        var socket;
           if ($("#livepoll_min").get(0)) {
                var num = -1;
                var media_array = document.URL.split("/");
                var msgnum = "ministries_" + media_array[media_array.length - 2];
                WEB_SOCKET_SWF_LOCATION = 'http://resources.calvaryccm.com/socket.io/WebSocketMainInsecure.swf';
                socket = new io.Socket("livepoll.calvaryccm.com", { port: 8080 });
                socket.connect();
                socket.on("connect", function () {
                    socket.send('{"join":"' + msgnum + '","listen":["' + msgnum + '"]}');
                });
                socket.on("message", function (data) {
                    if (!$("#livepoll_min").get(0)) {
                        socket.disconnect();
                        return;
                    }
                    for (var prop in data) {
                        if (data.hasOwnProperty(prop))
                            num = data[prop];
                    }

                    if (num < 1) {
                        $("#livepoll_min").hide("slow");
                        return;
                    }

                    if (num == 1) {
                        $("#livepoll_min").show("slow").html("1 person is currently watching or listening");
                        return;
                    }

                    $("#livepoll_min").show("slow").html(num + " people are currently watching or listening");
                });
        }

        $('.reveal-modal-bg').click(function(){
            $("#mediaplayer").remove();
            $("#livepoll_min").remove();
            socket.disconnect();
        });

        $('.close-reveal-modal').click(function(){
            $("#mediaplayer").remove();
            $("#livepoll_min").remove();
            socket.disconnect();
        });
        return false;
    });
}

//menu
$(function () {
    $("ul.nav li").hover(function () {
        $(this).addClass("hover");
        $('ul:first', this).css('visibility', 'visible');
    }, function () {
        $(this).removeClass("hover");
        $('ul:first', this).css('visibility', 'hidden');
    });
    $("ul.nav li ul li:has(ul)").find("a:first").append(" &raquo; ");
});

//Campus menu with arrows
$(function () {
    $('#slideshow').hover(
        function () { $('#controls').fadeIn(); },
        function () { $('#controls').fadeOut(); }
    );

    $('#slides').cycle({
        fx: 'fade',
        speed: 400,
        timeout: 3000,
        next: '#next',
        prev: '#prev'
    });
});
