

// jQuery tableSorter 2.0.3. - http://tablesorter.com/docs/
(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(typeof console!="undefined"&&typeof 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("Building 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,checkCell=(n[0].length-1),tableBody=$(table.tBodies[0]),rows=[];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("Sorting on "+sortList.toString()+" and dir "+order+" time:",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);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("Applying Zebra widget",time);}}});})(jQuery);

// * jQuery.ScrollTo - Easy element scrolling using jQuery. * @version 1.3.3 
;(function($){var o=$.scrollTo=function(a,b,c){o.window().scrollTo(a,b,c)};o.defaults={axis:'y',duration:0};o.window=function(){return $($.browser.safari?'body':'html')};$.fn.scrollTo=function(l,m,n){if(typeof m=='object'){n=m;m=0}n=$.extend({},o.defaults,n);m=m||n.speed||n.duration;n.queue=n.queue&&n.axis.length>1;if(n.queue)m/=2;n.offset=j(n.offset);n.over=j(n.over);return this.each(function(){var a=this,b=$(a),t=l,c,d={},w=b.is('html,body');switch(typeof t){case'number':case'string':if(/^([+-]=)?\d+(px)?$/.test(t)){t=j(t);break}t=$(t,this);case'object':if(t.is||t.style)c=(t=$(t)).offset()}$.each(n.axis.split(''),function(i,f){var P=f=='x'?'Left':'Top',p=P.toLowerCase(),k='scroll'+P,e=a[k],D=f=='x'?'Width':'Height';if(c){d[k]=c[p]+(w?0:e-b.offset()[p]);if(n.margin){d[k]-=parseInt(t.css('margin'+P))||0;d[k]-=parseInt(t.css('border'+P+'Width'))||0}d[k]+=n.offset[p]||0;if(n.over[p])d[k]+=t[D.toLowerCase()]()*n.over[p]}else d[k]=t[p];if(/^\d+$/.test(d[k]))d[k]=d[k]<=0?0:Math.min(d[k],h(D));if(!i&&n.queue){if(e!=d[k])g(n.onAfterFirst);delete d[k]}});g(n.onAfter);function g(a){b.animate(d,m,n.easing,a&&function(){a.call(this,l)})};function h(D){var b=w?$.browser.opera?document.body:document.documentElement:a;return b['scroll'+D]-b['client'+D]}})};function j(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);

// jquery conrer 1.9.9: * For more details see: http://methvin.com/jquery/jq-corner.html 
;(function(c){var e=(function(){if(!c.browser.msie){return false}var h=document.createElement("div");try{h.style.setExpression("width","0+0")}catch(g){return false}return true})();function d(g,h){return parseInt(c.css(g,h))||0}function b(g){var g=parseInt(g).toString(16);return(g.length<2)?"0"+g:g}function f(i){for(;i&&i.nodeName.toLowerCase()!="html";i=i.parentNode){var g=c.css(i,"backgroundColor");if(g=="rgba(0, 0, 0, 0)"){continue}if(g.indexOf("rgb")>=0){var h=g.match(/\d+/g);return"#"+b(h[0])+b(h[1])+b(h[2])}if(g&&g!="transparent"){return g}}return"#ffffff"}function a(j,g,h){switch(j){case"round":return Math.round(h*(1-Math.cos(Math.asin(g/h))));case"cool":return Math.round(h*(1+Math.cos(Math.asin(g/h))));case"sharp":return Math.round(h*(1-Math.cos(Math.acos(g/h))));case"bite":return Math.round(h*(Math.cos(Math.asin((h-g-1)/h))));case"slide":return Math.round(h*(Math.atan2(g,h/g)));case"jut":return Math.round(h*(Math.atan2(h,(h-g-1))));case"curl":return Math.round(h*(Math.atan(g)));case"tear":return Math.round(h*(Math.cos(g)));case"wicked":return Math.round(h*(Math.tan(g)));case"long":return Math.round(h*(Math.sqrt(g)));case"sculpt":return Math.round(h*(Math.log((h-g-1),h)));case"dog":return(g&1)?(g+1):h;case"dog2":return(g&2)?(g+1):h;case"dog3":return(g&3)?(g+1):h;case"fray":return(g%2)*h;case"notch":return h;case"bevel":return g+1}}c.fn.corner=function(k){if(this.length==0){if(!c.isReady&&this.selector){var t=this.selector,p=this.context;c(function(){c(t,p).corner(k)})}return this}k=(k||"").toLowerCase();var h=/keep/.test(k);var l=((k.match(/cc:(#[0-9a-f]+)/)||[])[1]);var q=((k.match(/sc:(#[0-9a-f]+)/)||[])[1]);var j=parseInt((k.match(/(\d+)px/)||[])[1])||10;var r=/round|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dog/;var m=((k.match(r)||["round"])[0]);var n={T:0,B:1};var g={TL:/top|tl/.test(k),TR:/top|tr/.test(k),BL:/bottom|bl/.test(k),BR:/bottom|br/.test(k)};if(!g.TL&&!g.TR&&!g.BL&&!g.BR){g={TL:1,TR:1,BL:1,BR:1}}var i=document.createElement("div");i.style.overflow="hidden";i.style.height="1px";i.style.backgroundColor=q||"transparent";i.style.borderStyle="solid";return this.each(function(x){var s={T:parseInt(c.css(this,"paddingTop"))||0,R:parseInt(c.css(this,"paddingRight"))||0,B:parseInt(c.css(this,"paddingBottom"))||0,L:parseInt(c.css(this,"paddingLeft"))||0};if(typeof this.style.zoom!=undefined){this.style.zoom=1}if(!h){this.style.border="none"}i.style.borderColor=l||f(this.parentNode);var z=c.curCSS(this,"height");for(var u in n){var A=n[u];if((A&&(g.BL||g.BR))||(!A&&(g.TL||g.TR))){i.style.borderStyle="none "+(g[u+"R"]?"solid":"none")+" none "+(g[u+"L"]?"solid":"none");var B=document.createElement("div");c(B).addClass("jquery-corner");var o=B.style;A?this.appendChild(B):this.insertBefore(B,this.firstChild);if(A&&z!="auto"){if(c.css(this,"position")=="static"){this.style.position="relative"}o.position="absolute";o.bottom=o.left=o.padding=o.margin="0";if(e){o.setExpression("width","this.parentNode.offsetWidth")}else{o.width="100%"}}else{if(!A&&c.browser.msie){if(c.css(this,"position")=="static"){this.style.position="relative"}o.position="absolute";o.top=o.left=o.right=o.padding=o.margin="0";if(e){var C=d(this,"borderLeftWidth")+d(this,"borderRightWidth");o.setExpression("width","this.parentNode.offsetWidth - "+C+'+ "px"')}else{o.width="100%"}}else{o.position="relative";o.margin=!A?"-"+s.T+"px -"+s.R+"px "+(s.T-j)+"px -"+s.L+"px":(s.B-j)+"px -"+s.R+"px -"+s.B+"px -"+s.L+"px"}}for(var v=0;v<j;v++){var D=Math.max(0,a(m,v,j));var y=i.cloneNode(false);y.style.borderWidth="0 "+(g[u+"R"]?D:0)+"px 0 "+(g[u+"L"]?D:0)+"px";A?B.appendChild(y):B.insertBefore(y,B.firstChild)}}}})};c.fn.uncorner=function(){c("div.jquery-corner",this).remove();return this}})(jQuery);

// jQuery clueTip plugin - Version 0.9.8  (05/22/2008)
;(function(e){var i,h,g,d,f,j,c;e.fn.cluetip=function(l,k){if(typeof l=="object"){k=l;l=null}return this.each(function(I){var u=e(this);var F=e.extend(false,{},e.fn.cluetip.defaults,k||{},e.metadata?u.metadata():e.meta?u.data():{});var o=false;var y=parseInt(F.cluezIndex,10)-1;var Q=false,P=0;if(!e("#cluetip").length){h=e('<div id="cluetip-inner"></div>');d=e('<h3 id="cluetip-title"></h3>');g=e('<div id="cluetip-outer"></div>').append(h).prepend(d);i=e('<div id="cluetip"></div>').css({zIndex:F.cluezIndex}).append(g).append('<div id="cluetip-extra"></div>')[b](a).hide();e('<div id="cluetip-waitimage"></div>').css({position:"absolute",zIndex:y-1}).insertBefore("#cluetip").hide();i.css({position:"absolute",zIndex:y});g.css({position:"relative",zIndex:y+1});f=e('<div id="cluetip-arrows" class="cluetip-arrows"></div>').css({zIndex:y+1}).appendTo("#cluetip")}var H=(F.dropShadow)?+F.dropShadowSteps:0;if(!j){j=e([]);for(var T=0;T<H;T++){j=j.add(e("<div></div>").css({zIndex:y-T-1,opacity:0.1,top:1+T,left:1+T}))}j.css({position:"absolute",backgroundColor:"#000"}).prependTo(i)}var D=u.attr(F.attribute),r=F.cluetipClass;if(!D&&!F.splitTitle&&!l){return true}if(F.local&&F.hideLocal){e(D+":first").hide()}var E=parseInt(F.topOffset,10),A=parseInt(F.leftOffset,10);var z,R;var w=isNaN(parseInt(F.height,10))?"auto":(/\D/g).test(F.height)?F.height:F.height+"px";var m,s,J,W,L,S;var x=isNaN(parseInt(F.width,10))?275:parseInt(F.width,10);var U=x+(parseInt(i.css("paddingLeft"))||0)+(parseInt(i.css("paddingRight"))||0)+H;var B=this.offsetWidth;var t,K,X,M,n;var O;var G=(F.attribute!="title")?u.attr(F.titleAttribute):"";if(F.splitTitle){if(G==undefined){G=""}O=G.split(F.splitTitle);G=O.shift()}var q;var v=function(ac){if(!F.onActivate(u)){return false}Q=true;i.removeClass().css({width:x});if(D==u.attr("href")){u.css("cursor",F.cursor)}u.attr("title","");if(F.hoverClass){u.addClass(F.hoverClass)}s=J=u.offset().top;t=u.offset().left;M=ac.pageX;L=ac.pageY;if(u[0].tagName.toLowerCase()!="area"){m=e(document).scrollTop();n=e(window).width()}if(F.positionBy=="fixed"){K=B+t+A;i.css({left:K})}else{K=(B>t&&t>U)||t+B+U+A>n?t-U-A:B+t+A;if(u[0].tagName.toLowerCase()=="area"||F.positionBy=="mouse"||B+U>n){if(M+20+U>n){i.addClass(" cluetip-"+r);K=(M-U-A)>=0?M-U-A-parseInt(i.css("marginLeft"),10)+parseInt(h.css("marginRight"),10):M-(U/2)}else{K=M+A}}var Z=K<0?ac.pageY+E:ac.pageY;i.css({left:(K>0&&F.positionBy!="bottomTop")?K:(M+(U/2)>n)?n/2-U/2:Math.max(M-(U/2),0)})}R=e(window).height();if(l){h.html(l);N(Z)}else{if(O){var aa=O.length;for(var ab=0;ab<aa;ab++){if(ab==0){h.html(O[ab])}else{h.append('<div class="split-body">'+O[ab]+"</div>")}}N(Z)}else{if(!F.local&&D.indexOf("#")!=0){if(o&&F.ajaxCache){h.html(o);N(Z)}else{var ad=F.ajaxSettings;ad.url=D;ad.beforeSend=function(){g.children().empty();if(F.waitImage){e("#cluetip-waitimage").css({top:L+20,left:M+20}).show()}};ad.error=function(){if(Q){h.html("<i>sorry, the contents could not be loaded</i>")}};ad.success=function(af){o=F.ajaxProcess(af);if(Q){h.html(o)}};ad.complete=function(){c=e("#cluetip-inner img").length;if(c&&!e.browser.opera){e("#cluetip-inner img").load(function(){c--;if(c<1){e("#cluetip-waitimage").hide();if(Q){N(Z)}}})}else{e("#cluetip-waitimage").hide();if(Q){N(Z)}}};e.ajax(ad)}}else{if(F.local){var ae=e(D+":first");var Y=e.fn.wrapInner?ae.wrapInner("<div></div>").children().clone(true):ae.html();e.fn.wrapInner?h.empty().append(Y):h.html(Y);N(Z)}}}}};var N=function(aa){i.addClass("cluetip-"+r);if(F.truncate){var ab=h.text().slice(0,F.truncate)+"...";h.html(ab)}function Y(){}G?d.show().html(G):(F.showTitle)?d.show().html("&nbsp;"):d.hide();if(F.sticky){var Z=e('<div id="cluetip-close"><a href="#">'+F.closeText+"</a></div>");(F.closePosition=="bottom")?Z.appendTo(h):(F.closePosition=="title")?Z.prependTo(d):Z.prependTo(h);Z.click(function(){C();return false});if(F.mouseOutClose){if(e.fn.hoverIntent&&F.hoverIntent){i.hoverIntent({over:Y,timeout:F.hoverIntent.timeout,out:function(){Z.trigger("click")}})}else{i.hover(Y,function(){Z.trigger("click")})}}else{i.unbind("mouseout")}}var ac="";g.css({overflow:w=="auto"?"visible":"auto",height:w});z=w=="auto"?Math.max(i.outerHeight(),i.height()):parseInt(w,10);W=J;S=m+R;if(F.positionBy=="fixed"){W=J-F.dropShadowSteps+E}else{if((K<M&&Math.max(K,0)+U>M)||F.positionBy=="bottomTop"){if(J+z+E>S&&L-m>z+E){W=L-z-E;ac="top"}else{W=L+E;ac="bottom"}}else{if(J+z+E>S){W=(z>=R)?m:S-z-E}else{if(u.css("display")=="block"||u[0].tagName.toLowerCase()=="area"||F.positionBy=="mouse"){W=aa-E}else{W=J-F.dropShadowSteps}}}}if(ac==""){K<t?ac="left":ac="right"}i.css({top:W+"px"}).removeClass().addClass("clue-"+ac+"-"+r).addClass(" cluetip-"+r);if(F.arrows){var ad=(J-W-F.dropShadowSteps);f.css({top:(/(left|right)/.test(ac)&&K>=0&&ad>0)?ad+"px":/(left|right)/.test(ac)?0:""}).show()}else{f.hide()}j.hide();i.hide()[F.fx.open](F.fx.open!="show"&&F.fx.openSpeed);if(F.dropShadow){j.css({height:z,width:x}).show()}if(e.fn.bgiframe){i.bgiframe()}if(F.delayedClose>0){P=setTimeout(C,F.delayedClose)}F.onShow(i,h)};var V=function(){Q=false;e("#cluetip-waitimage").hide();if(!F.sticky||(/click|toggle/).test(F.activation)){C();clearTimeout(P)}if(F.hoverClass){u.removeClass(F.hoverClass)}e(".cluetip-clicked").removeClass("cluetip-clicked")};var C=function(){g.parent().hide().removeClass().end().children().empty();if(G){u.attr(F.titleAttribute,G)}u.css("cursor","");if(F.arrows){f.css({top:""})}};if((/click|toggle/).test(F.activation)){u.click(function(Y){if(i.is(":hidden")||!u.is(".cluetip-clicked")){v(Y);e(".cluetip-clicked").removeClass("cluetip-clicked");u.addClass("cluetip-clicked")}else{V(Y)}this.blur();return false})}else{if(F.activation=="focus"){u.focus(function(Y){v(Y)});u.blur(function(Y){V(Y)})}else{u.click(function(){if(u.attr("href")&&u.attr("href")==D&&!F.clickThrough){return false}});var p=function(Y){if(F.tracking==true){var aa=K-Y.pageX;var Z=W?W-Y.pageY:J-Y.pageY;u.mousemove(function(ab){i.css({left:ab.pageX+aa,top:ab.pageY+Z})})}};if(e.fn.hoverIntent&&F.hoverIntent){u.mouseover(function(){u.attr("title","")}).hoverIntent({sensitivity:F.hoverIntent.sensitivity,interval:F.hoverIntent.interval,over:function(Y){v(Y);p(Y)},timeout:F.hoverIntent.timeout,out:function(Y){V(Y);u.unbind("mousemove")}})}else{u.hover(function(Y){v(Y);p(Y)},function(Y){V(Y);u.unbind("mousemove")})}}}})};e.fn.cluetip.defaults={width:275,height:"auto",cluezIndex:97,positionBy:"auto",topOffset:15,leftOffset:15,local:false,hideLocal:true,attribute:"rel",titleAttribute:"title",splitTitle:"",showTitle:true,cluetipClass:"default",hoverClass:"",waitImage:true,cursor:"help",arrows:false,dropShadow:true,dropShadowSteps:6,sticky:false,mouseOutClose:false,activation:"hover",clickThrough:false,tracking:false,delayedClose:0,closePosition:"top",closeText:"Close",truncate:0,fx:{open:"show",openSpeed:""},hoverIntent:{sensitivity:3,interval:50,timeout:0},onActivate:function(k){return true},onShow:function(k,l){},ajaxCache:true,ajaxProcess:function(k){k=k.replace(/<s(cript|tyle)(.|\s)*?\/s(cript|tyle)>/g,"").replace(/<(link|title)(.|\s)*?\/(link|title)>/g,"");return k},ajaxSettings:{dataType:"html"},debug:false};var b="appendTo",a="body";e.cluetip={};e.cluetip.setup=function(k){if(k&&k.insertionType&&(k.insertionType).match(/appendTo|prependTo|insertBefore|insertAfter/)){b=k.insertionType}if(k&&k.insertionElement){a=k.insertionElement}}})(jQuery);

// jQuery TipTip plugin - code.drewwilson.com/entry/tiptip-jquery-plugin
;(function($){$.fn.tipTip=function(options){var defaults={activation:"hover",keepAlive:false,maxWidth:"200px",edgeOffset:3,defaultPosition:"bottom",delay:400,fadeIn:200,fadeOut:200,attribute:"title",content:false,enter:function(){},exit:function(){}};var opts=$.extend(defaults,options);if($("#tiptip_holder").length<=0){var tiptip_holder=$('<div id="tiptip_holder" style="max-width:'+opts.maxWidth+';"></div>');var tiptip_content=$('<div id="tiptip_content"></div>');var tiptip_arrow=$('<div id="tiptip_arrow"></div>');$("body").append(tiptip_holder.html(tiptip_content).prepend(tiptip_arrow.html('<div id="tiptip_arrow_inner"></div>')))}else{var tiptip_holder=$("#tiptip_holder");var tiptip_content=$("#tiptip_content");var tiptip_arrow=$("#tiptip_arrow")}return this.each(function(){var org_elem=$(this);if(opts.content){var org_title=opts.content}else{var org_title=org_elem.attr(opts.attribute)}if(org_title!=""){if(!opts.content){org_elem.removeAttr(opts.attribute)}var timeout=false;if(opts.activation=="hover"){org_elem.hover(function(){active_tiptip()},function(){if(!opts.keepAlive){deactive_tiptip()}});if(opts.keepAlive){tiptip_holder.hover(function(){},function(){deactive_tiptip()})}}else if(opts.activation=="focus"){org_elem.focus(function(){active_tiptip()}).blur(function(){deactive_tiptip()})}else if(opts.activation=="click"){org_elem.click(function(){active_tiptip();return false}).hover(function(){},function(){if(!opts.keepAlive){deactive_tiptip()}});if(opts.keepAlive){tiptip_holder.hover(function(){},function(){deactive_tiptip()})}}function active_tiptip(){opts.enter.call(this);tiptip_content.html(org_title);tiptip_holder.hide().removeAttr("class").css("margin","0");tiptip_arrow.removeAttr("style");var top=parseInt(org_elem.offset()['top']);var left=parseInt(org_elem.offset()['left']);var org_width=parseInt(org_elem.outerWidth());var org_height=parseInt(org_elem.outerHeight());var tip_w=tiptip_holder.outerWidth();var tip_h=tiptip_holder.outerHeight();var w_compare=Math.round((org_width-tip_w)/2);var h_compare=Math.round((org_height-tip_h)/2);var marg_left=Math.round(left+w_compare);var marg_top=Math.round(top+org_height+opts.edgeOffset);var t_class="";var arrow_top="";var arrow_left=Math.round(tip_w-12)/2;if(opts.defaultPosition=="bottom"){t_class="_bottom"}else if(opts.defaultPosition=="top"){t_class="_top"}else if(opts.defaultPosition=="left"){t_class="_left"}else if(opts.defaultPosition=="right"){t_class="_right"}var right_compare=(w_compare+left)<parseInt($(window).scrollLeft());var left_compare=(tip_w+left)>parseInt($(window).width());if((right_compare&&w_compare<0)||(t_class=="_right"&&!left_compare)||(t_class=="_left"&&left<(tip_w+opts.edgeOffset+5))){t_class="_right";arrow_top=Math.round(tip_h-13)/2;arrow_left=-12;marg_left=Math.round(left+org_width+opts.edgeOffset);marg_top=Math.round(top+h_compare)}else if((left_compare&&w_compare<0)||(t_class=="_left"&&!right_compare)){t_class="_left";arrow_top=Math.round(tip_h-13)/2;arrow_left=Math.round(tip_w);marg_left=Math.round(left-(tip_w+opts.edgeOffset+5));marg_top=Math.round(top+h_compare)}var top_compare=(top+org_height+opts.edgeOffset+tip_h+8)>parseInt($(window).height()+$(window).scrollTop());var bottom_compare=((top+org_height)-(opts.edgeOffset+tip_h+8))<0;if(top_compare||(t_class=="_bottom"&&top_compare)||(t_class=="_top"&&!bottom_compare)){if(t_class=="_top"||t_class=="_bottom"){t_class="_top"}else{t_class=t_class+"_top"}arrow_top=tip_h;marg_top=Math.round(top-(tip_h+5+opts.edgeOffset))}else if(bottom_compare|(t_class=="_top"&&bottom_compare)||(t_class=="_bottom"&&!top_compare)){if(t_class=="_top"||t_class=="_bottom"){t_class="_bottom"}else{t_class=t_class+"_bottom"}arrow_top=-12;marg_top=Math.round(top+org_height+opts.edgeOffset)}if(t_class=="_right_top"||t_class=="_left_top"){marg_top=marg_top+5}else if(t_class=="_right_bottom"||t_class=="_left_bottom"){marg_top=marg_top-5}if(t_class=="_left_top"||t_class=="_left_bottom"){marg_left=marg_left+5}tiptip_arrow.css({"margin-left":arrow_left+"px","margin-top":arrow_top+"px"});tiptip_holder.css({"margin-left":marg_left+"px","margin-top":marg_top+"px"}).attr("class","tip"+t_class);if(timeout){clearTimeout(timeout)}timeout=setTimeout(function(){tiptip_holder.stop(true,true).fadeIn(opts.fadeIn)},opts.delay)}function deactive_tiptip(){opts.exit.call(this);if(timeout){clearTimeout(timeout)}tiptip_holder.fadeOut(opts.fadeOut)}}})}})(jQuery);

// jQuery.LocalScroll - http://flesler.blogspot.com * @version 1.2.6 
;(function($){var g=location.href.replace(/#.*/,''),h=$.localScroll=function(a){$('body').localScroll(a)};h.defaults={duration:1e3,axis:'y',event:'click',stop:1};h.hash=function(a){a=$.extend({},h.defaults,a);a.hash=0;if(location.hash)setTimeout(function(){i(0,location,a)},0)};$.fn.localScroll=function(b){b=$.extend({},h.defaults,b);return(b.persistent||b.lazy)?this.bind(b.event,function(e){var a=$([e.target,e.target.parentNode]).filter(c)[0];a&&i(e,a,b)}):this.find('a,area').filter(c).bind(b.event,function(e){i(e,this,b)}).end().end();function c(){var a=this;return!!a.href&&!!a.hash&&a.href.replace(a.hash,'')==g&&(!b.filter||$(a).is(b.filter))}};function i(e,a,b){var c=a.hash.slice(1),d=document.getElementById(c)||document.getElementsByName(c)[0],f;if(d){e&&e.preventDefault();f=$(b.target||$.scrollTo.window());if(b.lock&&f.is(':animated')||b.onBefore&&b.onBefore.call(a,e,d,f)===!1)return;if(b.stop)f.queue('fx',[]).stop();f.scrollTo(d,b).trigger('notify.serialScroll',[d]);if(b.hash)f.queue(function(){location=a.hash;$(this).dequeue()})}}})(jQuery);

// jQuery Context Menu v1.00 - http://abeautifulsite.net/notebook/80 
;if(jQuery){(function(){$.extend($.fn,{contextMenu:function(a,b){if(a.menu==undefined){return false}if(a.inSpeed==undefined){a.inSpeed=150}if(a.outSpeed==undefined){a.outSpeed=75}if(a.inSpeed==0){a.inSpeed=-1}if(a.outSpeed==0){a.outSpeed=-1}$(this).each(function(){var c=$(this);var d=$(c).offset();$("#"+a.menu).addClass("contextMenu");$(this).mousedown(function(g){var f=g;$(this).mouseup(function(j){var i=$(this);$(this).unbind("mouseup");if(f.button==2){$(".contextMenu").hide();var l=$("#"+a.menu);if($(c).hasClass("disabled")){return false}var k={},h,m;if(self.innerHeight){k.pageYOffset=self.pageYOffset;k.pageXOffset=self.pageXOffset;k.innerHeight=self.innerHeight;k.innerWidth=self.innerWidth}else{if(document.documentElement&&document.documentElement.clientHeight){k.pageYOffset=document.documentElement.scrollTop;k.pageXOffset=document.documentElement.scrollLeft;k.innerHeight=document.documentElement.clientHeight;k.innerWidth=document.documentElement.clientWidth}else{if(document.body){k.pageYOffset=document.body.scrollTop;k.pageXOffset=document.body.scrollLeft;k.innerHeight=document.body.clientHeight;k.innerWidth=document.body.clientWidth}}}(j.pageX)?h=j.pageX:h=j.clientX+k.scrollLeft;(j.pageY)?m=j.pageY:h=j.clientY+k.scrollTop;$(document).unbind("click");$(l).css({top:m,left:h}).fadeIn(a.inSpeed);$(l).find("A").mouseover(function(){$(l).find("LI.hover").removeClass("hover");$(this).parent().addClass("hover")}).mouseout(function(){$(l).find("LI.hover").removeClass("hover")});$(document).keypress(function(n){switch(n.keyCode){case 38:if($(l).find("LI.hover").size()==0){$(l).find("LI:last").addClass("hover")}else{$(l).find("LI.hover").removeClass("hover").prevAll("LI:not(.disabled)").eq(0).addClass("hover");if($(l).find("LI.hover").size()==0){$(l).find("LI:last").addClass("hover")}}break;case 40:if($(l).find("LI.hover").size()==0){$(l).find("LI:first").addClass("hover")}else{$(l).find("LI.hover").removeClass("hover").nextAll("LI:not(.disabled)").eq(0).addClass("hover");if($(l).find("LI.hover").size()==0){$(l).find("LI:first").addClass("hover")}}break;case 13:$(l).find("LI.hover A").trigger("click");break;case 27:$(document).trigger("click");break}});$("#"+a.menu).find("A").unbind("click");$("#"+a.menu).find("LI:not(.disabled) A").click(function(){$(document).unbind("click").unbind("keypress");$(".contextMenu").hide();if(b){b($(this).attr("href").substr(1),$(i),{x:h-d.left,y:m-d.top,docX:h,docY:m})}return false});setTimeout(function(){$(document).click(function(){$(document).unbind("click").unbind("keypress");$(l).fadeOut(a.outSpeed);return false})},0)}})});if($.browser.mozilla){$("#"+a.menu).each(function(){$(this).css({MozUserSelect:"none"})})}else{if($.browser.msie){$("#"+a.menu).each(function(){$(this).bind("selectstart.disableTextSelect",function(){return false})})}else{$("#"+a.menu).each(function(){$(this).bind("mousedown.disableTextSelect",function(){return false})})}}$(c).add("UL.contextMenu").bind("contextmenu",function(){return false})});return $(this)},disableContextMenuItems:function(a){if(a==undefined){$(this).find("LI").addClass("disabled");return($(this))}$(this).each(function(){if(a!=undefined){var c=a.split(",");for(var b=0;b<c.length;b++){$(this).find('A[href="'+c[b]+'"]').parent().addClass("disabled")}}});return($(this))},enableContextMenuItems:function(a){if(a==undefined){$(this).find("LI.disabled").removeClass("disabled");return($(this))}$(this).each(function(){if(a!=undefined){var c=a.split(",");for(var b=0;b<c.length;b++){$(this).find('A[href="'+c[b]+'"]').parent().removeClass("disabled")}}});return($(this))},disableContextMenu:function(){$(this).each(function(){$(this).addClass("disabled")});return($(this))},enableContextMenu:function(){$(this).each(function(){$(this).removeClass("disabled")});return($(this))},destroyContextMenu:function(){$(this).each(function(){$(this).unbind("mousedown").unbind("mouseup")});return($(this))}})})(jQuery)};

// jquery addon: urlParams v2.1, from: http://hinnerk.ruemenapf.de/
// usage: @example value = $(document).getUrlParam("paramName");
;jQuery.fn.extend({getUrlParam:function(f){f=escape(unescape(f));var e=new Array();var b=null;if($(this).attr("nodeName")=="#document"){if(window.location.search.search(f)>-1){b=window.location.search.substr(1,window.location.search.length).split("&")}}else{if($(this).attr("src")!="undefined"){var d=$(this).attr("src");if(d.indexOf("?")>-1){var a=d.substr(d.indexOf("?")+1);b=a.split("&")}}else{if($(this).attr("href")!="undefined"){var d=$(this).attr("href");if(d.indexOf("?")>-1){var a=d.substr(d.indexOf("?")+1);b=a.split("&")}}else{return null}}}if(b==null){return null}for(var c=0;c<b.length;c++){if(escape(unescape(b[c].split("=")[0]))==f){e.push(b[c].split("=")[1])}}if(e.length==0){return null}else{if(e.length==1){return e[0]}else{return e}}}});

// Revision: $Id: jquery.autocomplete.js 15 2009-08-22 10:30:27Z joern.zaefferer    - http://jquery.bassistance.de/autocomplete/   
/*
;(function($){$.fn.extend({autocomplete:function(urlOrData,options){var isUrl=typeof urlOrData=="string";options=$.extend({},$.Autocompleter.defaults,{url:isUrl?urlOrData:null,data:isUrl?null:urlOrData,delay:isUrl?$.Autocompleter.defaults.delay:10,max:options&&!options.scroll?10:150},options);options.highlight=options.highlight||function(value){return value;};options.formatMatch=options.formatMatch||options.formatItem;return this.each(function(){new $.Autocompleter(this,options);});},result:function(handler){return this.bind("result",handler);},search:function(handler){return this.trigger("search",[handler]);},flushCache:function(){return this.trigger("flushCache");},setOptions:function(options){return this.trigger("setOptions",[options]);},unautocomplete:function(){return this.trigger("unautocomplete");}});$.Autocompleter=function(input,options){var KEY={UP:38,DOWN:40,DEL:46,TAB:9,RETURN:13,ESC:27,COMMA:188,PAGEUP:33,PAGEDOWN:34,BACKSPACE:8};var $input=$(input).attr("autocomplete","off").addClass(options.inputClass);var timeout;var previousValue="";var cache=$.Autocompleter.Cache(options);var hasFocus=0;var lastKeyPressCode;var config={mouseDownOnSelect:false};var select=$.Autocompleter.Select(options,input,selectCurrent,config);var blockSubmit;$.browser.opera&&$(input.form).bind("submit.autocomplete",function(){if(blockSubmit){blockSubmit=false;return false;}});$input.bind(($.browser.opera?"keypress":"keydown")+".autocomplete",function(event){hasFocus=1;lastKeyPressCode=event.keyCode;switch(event.keyCode){case KEY.UP:event.preventDefault();if(select.visible()){select.prev();}else{onChange(0,true);}break;case KEY.DOWN:event.preventDefault();if(select.visible()){select.next();}else{onChange(0,true);}break;case KEY.PAGEUP:event.preventDefault();if(select.visible()){select.pageUp();}else{onChange(0,true);}break;case KEY.PAGEDOWN:event.preventDefault();if(select.visible()){select.pageDown();}else{onChange(0,true);}break;case options.multiple&&$.trim(options.multipleSeparator)==","&&KEY.COMMA:case KEY.TAB:case KEY.RETURN:if(selectCurrent()){event.preventDefault();blockSubmit=true;return false;}break;case KEY.ESC:select.hide();break;default:clearTimeout(timeout);timeout=setTimeout(onChange,options.delay);break;}}).focus(function(){hasFocus++;}).blur(function(){hasFocus=0;if(!config.mouseDownOnSelect){hideResults();}}).click(function(){if(hasFocus++>1&&!select.visible()){onChange(0,true);}}).bind("search",function(){var fn=(arguments.length>1)?arguments[1]:null;function findValueCallback(q,data){var result;if(data&&data.length){for(var i=0;i<data.length;i++){if(data[i].result.toLowerCase()==q.toLowerCase()){result=data[i];break;}}}if(typeof fn=="function")fn(result);else $input.trigger("result",result&&[result.data,result.value]);}$.each(trimWords($input.val()),function(i,value){request(value,findValueCallback,findValueCallback);});}).bind("flushCache",function(){cache.flush();}).bind("setOptions",function(){$.extend(options,arguments[1]);if("data"in arguments[1])cache.populate();}).bind("unautocomplete",function(){select.unbind();$input.unbind();$(input.form).unbind(".autocomplete");});function selectCurrent(){var selected=select.selected();if(!selected)return false;var v=selected.result;previousValue=v;if(options.multiple){var words=trimWords($input.val());if(words.length>1){var seperator=options.multipleSeparator.length;var cursorAt=$(input).selection().start;var wordAt,progress=0;$.each(words,function(i,word){progress+=word.length;if(cursorAt<=progress){wordAt=i;return false;}progress+=seperator;});words[wordAt]=v;v=words.join(options.multipleSeparator);}v+=options.multipleSeparator;}$input.val(v);hideResultsNow();$input.trigger("result",[selected.data,selected.value]);return true;}function onChange(crap,skipPrevCheck){if(lastKeyPressCode==KEY.DEL){select.hide();return;}var currentValue=$input.val();if(!skipPrevCheck&&currentValue==previousValue)return;previousValue=currentValue;currentValue=lastWord(currentValue);if(currentValue.length>=options.minChars){$input.addClass(options.loadingClass);if(!options.matchCase)currentValue=currentValue.toLowerCase();request(currentValue,receiveData,hideResultsNow);}else{stopLoading();select.hide();}};function trimWords(value){if(!value)return[""];if(!options.multiple)return[$.trim(value)];return $.map(value.split(options.multipleSeparator),function(word){return $.trim(value).length?$.trim(word):null;});}function lastWord(value){if(!options.multiple)return value;var words=trimWords(value);if(words.length==1)return words[0];var cursorAt=$(input).selection().start;if(cursorAt==value.length){words=trimWords(value)}else{words=trimWords(value.replace(value.substring(cursorAt),""));}return words[words.length-1];}function autoFill(q,sValue){if(options.autoFill&&(lastWord($input.val()).toLowerCase()==q.toLowerCase())&&lastKeyPressCode!=KEY.BACKSPACE){$input.val($input.val()+sValue.substring(lastWord(previousValue).length));$(input).selection(previousValue.length,previousValue.length+sValue.length);}};function hideResults(){clearTimeout(timeout);timeout=setTimeout(hideResultsNow,200);};function hideResultsNow(){var wasVisible=select.visible();select.hide();clearTimeout(timeout);stopLoading();if(options.mustMatch){$input.search(function(result){if(!result){if(options.multiple){var words=trimWords($input.val()).slice(0,-1);$input.val(words.join(options.multipleSeparator)+(words.length?options.multipleSeparator:""));}else{$input.val("");$input.trigger("result",null);}}});}};function receiveData(q,data){if(data&&data.length&&hasFocus){stopLoading();select.display(data,q);autoFill(q,data[0].value);select.show();}else{hideResultsNow();}};function request(term,success,failure){if(!options.matchCase)term=term.toLowerCase();var data=cache.load(term);if(data&&data.length){success(term,data);}else if((typeof options.url=="string")&&(options.url.length>0)){var extraParams={timestamp:+new Date()};$.each(options.extraParams,function(key,param){extraParams[key]=typeof param=="function"?param():param;});$.ajax({mode:"abort",port:"autocomplete"+input.name,dataType:options.dataType,url:options.url,data:$.extend({q:lastWord(term),limit:options.max},extraParams),success:function(data){var parsed=options.parse&&options.parse(data)||parse(data);cache.add(term,parsed);success(term,parsed);}});}else{select.emptyList();failure(term);}};function parse(data){var parsed=[];var rows=data.split("\n");for(var i=0;i<rows.length;i++){var row=$.trim(rows[i]);if(row){row=row.split("|");parsed[parsed.length]={data:row,value:row[0],result:options.formatResult&&options.formatResult(row,row[0])||row[0]};}}return parsed;};function stopLoading(){$input.removeClass(options.loadingClass);};};$.Autocompleter.defaults={inputClass:"ac_input",resultsClass:"ac_results",loadingClass:"ac_loading",minChars:1,delay:400,matchCase:false,matchSubset:true,matchContains:false,cacheLength:10,max:100,mustMatch:false,extraParams:{},selectFirst:true,formatItem:function(row){return row[0];},formatMatch:null,autoFill:false,width:0,multiple:false,multipleSeparator:", ",highlight:function(value,term){return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)","gi"),"<strong>$1</strong>");},scroll:true,scrollHeight:180};$.Autocompleter.Cache=function(options){var data={};var length=0;function matchSubset(s,sub){if(!options.matchCase)s=s.toLowerCase();var i=s.indexOf(sub);if(options.matchContains=="word"){i=s.toLowerCase().search("\\b"+sub.toLowerCase());}if(i==-1)return false;return i==0||options.matchContains;};function add(q,value){if(length>options.cacheLength){flush();}if(!data[q]){length++;}data[q]=value;}function populate(){if(!options.data)return false;var stMatchSets={},nullData=0;if(!options.url)options.cacheLength=1;stMatchSets[""]=[];for(var i=0,ol=options.data.length;i<ol;i++){var rawValue=options.data[i];rawValue=(typeof rawValue=="string")?[rawValue]:rawValue;var value=options.formatMatch(rawValue,i+1,options.data.length);if(value===false)continue;var firstChar=value.charAt(0).toLowerCase();if(!stMatchSets[firstChar])stMatchSets[firstChar]=[];var row={value:value,data:rawValue,result:options.formatResult&&options.formatResult(rawValue)||value};stMatchSets[firstChar].push(row);if(nullData++<options.max){stMatchSets[""].push(row);}};$.each(stMatchSets,function(i,value){options.cacheLength++;add(i,value);});}setTimeout(populate,25);function flush(){data={};length=0;}return{flush:flush,add:add,populate:populate,load:function(q){if(!options.cacheLength||!length)return null;if(!options.url&&options.matchContains){var csub=[];for(var k in data){if(k.length>0){var c=data[k];$.each(c,function(i,x){if(matchSubset(x.value,q)){csub.push(x);}});}}return csub;}else
if(data[q]){return data[q];}else
if(options.matchSubset){for(var i=q.length-1;i>=options.minChars;i--){var c=data[q.substr(0,i)];if(c){var csub=[];$.each(c,function(i,x){if(matchSubset(x.value,q)){csub[csub.length]=x;}});return csub;}}}return null;}};};$.Autocompleter.Select=function(options,input,select,config){var CLASSES={ACTIVE:"ac_over"};var listItems,active=-1,data,term="",needsInit=true,element,list;function init(){if(!needsInit)return;element=$("<div/>").hide().addClass(options.resultsClass).css("position","absolute").appendTo(document.body);list=$("<ul/>").appendTo(element).mouseover(function(event){if(target(event).nodeName&&target(event).nodeName.toUpperCase()=='LI'){active=$("li",list).removeClass(CLASSES.ACTIVE).index(target(event));$(target(event)).addClass(CLASSES.ACTIVE);}}).click(function(event){$(target(event)).addClass(CLASSES.ACTIVE);select();input.focus();return false;}).mousedown(function(){config.mouseDownOnSelect=true;}).mouseup(function(){config.mouseDownOnSelect=false;});if(options.width>0)element.css("width",options.width);needsInit=false;}function target(event){var element=event.target;while(element&&element.tagName!="LI")element=element.parentNode;if(!element)return[];return element;}function moveSelect(step){listItems.slice(active,active+1).removeClass(CLASSES.ACTIVE);movePosition(step);var activeItem=listItems.slice(active,active+1).addClass(CLASSES.ACTIVE);if(options.scroll){var offset=0;listItems.slice(0,active).each(function(){offset+=this.offsetHeight;});if((offset+activeItem[0].offsetHeight-list.scrollTop())>list[0].clientHeight){list.scrollTop(offset+activeItem[0].offsetHeight-list.innerHeight());}else if(offset<list.scrollTop()){list.scrollTop(offset);}}};function movePosition(step){active+=step;if(active<0){active=listItems.size()-1;}else if(active>=listItems.size()){active=0;}}function limitNumberOfItems(available){return options.max&&options.max<available?options.max:available;}function fillList(){list.empty();var max=limitNumberOfItems(data.length);for(var i=0;i<max;i++){if(!data[i])continue;var formatted=options.formatItem(data[i].data,i+1,max,data[i].value,term);if(formatted===false)continue;var li=$("<li/>").html(options.highlight(formatted,term)).addClass(i%2==0?"ac_even":"ac_odd").appendTo(list)[0];$.data(li,"ac_data",data[i]);}listItems=list.find("li");if(options.selectFirst){listItems.slice(0,1).addClass(CLASSES.ACTIVE);active=0;}if($.fn.bgiframe)list.bgiframe();}return{display:function(d,q){init();data=d;term=q;fillList();},next:function(){moveSelect(1);},prev:function(){moveSelect(-1);},pageUp:function(){if(active!=0&&active-8<0){moveSelect(-active);}else{moveSelect(-8);}},pageDown:function(){if(active!=listItems.size()-1&&active+8>listItems.size()){moveSelect(listItems.size()-1-active);}else{moveSelect(8);}},hide:function(){element&&element.hide();listItems&&listItems.removeClass(CLASSES.ACTIVE);active=-1;},visible:function(){return element&&element.is(":visible");},current:function(){return this.visible()&&(listItems.filter("."+CLASSES.ACTIVE)[0]||options.selectFirst&&listItems[0]);},show:function(){var offset=$(input).offset();element.css({width:typeof options.width=="string"||options.width>0?options.width:$(input).width(),top:offset.top+input.offsetHeight,left:offset.left}).show();if(options.scroll){list.scrollTop(0);list.css({maxHeight:options.scrollHeight,overflow:'auto'});if($.browser.msie&&typeof document.body.style.maxHeight==="undefined"){var listHeight=0;listItems.each(function(){listHeight+=this.offsetHeight;});var scrollbarsVisible=listHeight>options.scrollHeight;list.css('height',scrollbarsVisible?options.scrollHeight:listHeight);if(!scrollbarsVisible){listItems.width(list.width()-parseInt(listItems.css("padding-left"))-parseInt(listItems.css("padding-right")));}}}},selected:function(){var selected=listItems&&listItems.filter("."+CLASSES.ACTIVE).removeClass(CLASSES.ACTIVE);return selected&&selected.length&&$.data(selected[0],"ac_data");},emptyList:function(){list&&list.empty();},unbind:function(){element&&element.remove();}};};$.fn.selection=function(start,end){if(start!==undefined){return this.each(function(){if(this.createTextRange){var selRange=this.createTextRange();if(end===undefined||start==end){selRange.move("character",start);selRange.select();}else{selRange.collapse(true);selRange.moveStart("character",start);selRange.moveEnd("character",end);selRange.select();}}else if(this.setSelectionRange){this.setSelectionRange(start,end);}else if(this.selectionStart){this.selectionStart=start;this.selectionEnd=end;}});}var field=this[0];if(field.createTextRange){var range=document.selection.createRange(),orig=field.value,teststring="<->",textLength=range.text.length;range.text=teststring;var caretAt=field.value.indexOf(teststring);field.value=orig;this.selection(caretAt,caretAt+textLength);return{start:caretAt,end:caretAt+textLength}}else if(field.selectionStart!==undefined){return{start:field.selectionStart,end:field.selectionEnd}}};})(jQuery);
*/

// jquery.autocomplete.js : http://code.google.com/p/jquery-autocomplete/
;(function(a){a.Autocompleter=function(b,c){this.cacheData_={};this.cacheLength_=0;this.selectClass_="jquery-autocomplete-selected-item";this.keyTimeout_=null;this.lastKeyPressed_=null;this.lastProcessedValue_=null;this.lastSelectedValue_=null;this.active_=false;this.finishOnBlur_=true;if(!b||!(b instanceof jQuery)||b.length!==1||b.get(0).tagName.toUpperCase()!=="INPUT"){alert("Invalid parameter for jquery.Autocompleter, jQuery object with one element with INPUT tag expected");return}if(typeof c==="string"){this.options={url:c}}else{this.options=c}this.options.maxCacheLength=parseInt(this.options.maxCacheLength,10);if(isNaN(this.options.maxCacheLength)||this.options.maxCacheLength<1){this.options.maxCacheLength=1}this.options.minChars=parseInt(this.options.minChars,10);if(isNaN(this.options.minChars)||this.options.minChars<1){this.options.minChars=1}this.dom={};this.dom.$elem=b;if(this.options.inputClass){this.dom.$elem.addClass(this.options.inputClass)}this.dom.$results=a("<div></div>").hide();if(this.options.resultsClass){this.dom.$results.addClass(this.options.resultsClass)}this.dom.$results.css({position:"absolute"});a("body").append(this.dom.$results);var d=this;b.keydown(function(a){d.lastKeyPressed_=a.keyCode;switch(d.lastKeyPressed_){case 38:a.preventDefault();if(d.active_){d.focusPrev()}else{d.activate()}return false;break;case 40:a.preventDefault();if(d.active_){d.focusNext()}else{d.activate()}return false;break;case 9:case 13:if(d.active_){a.preventDefault();d.selectCurrent();return false}break;case 27:if(d.active_){a.preventDefault();d.finish();return false}break;default:d.activate()}});b.blur(function(){if(d.finishOnBlur_){setTimeout(function(){d.finish()},200)}})};a.Autocompleter.prototype.position=function(){var a=this.dom.$elem.offset();this.dom.$results.css({top:a.top+this.dom.$elem.outerHeight(),left:a.left})};a.Autocompleter.prototype.cacheRead=function(a){var b,c,d,e,f;if(this.options.useCache){a=String(a);b=a.length;if(this.options.matchSubset){c=1}else{c=b}while(c<=b){if(this.options.matchInside){e=b-c}else{e=0}f=0;while(f<=e){d=a.substr(0,c);if(this.cacheData_[d]!==undefined){return this.cacheData_[d]}f++}c++}}return false};a.Autocompleter.prototype.cacheWrite=function(a,b){if(this.options.useCache){if(this.cacheLength_>=this.options.maxCacheLength){this.cacheFlush()}a=String(a);if(this.cacheData_[a]!==undefined){this.cacheLength_++}return this.cacheData_[a]=b}return false};a.Autocompleter.prototype.cacheFlush=function(){this.cacheData_={};this.cacheLength_=0};a.Autocompleter.prototype.callHook=function(b,c){var d=this.options[b];if(d&&a.isFunction(d)){return d(c,this)}return false};a.Autocompleter.prototype.activate=function(){var a=this;var b=function(){a.activateNow()};var c=parseInt(this.options.delay,10);if(isNaN(c)||c<=0){c=250}if(this.keyTimeout_){clearTimeout(this.keyTimeout_)}this.keyTimeout_=setTimeout(b,c)};a.Autocompleter.prototype.activateNow=function(){var a=this.dom.$elem.val();if(a!==this.lastProcessedValue_&&a!==this.lastSelectedValue_){if(a.length>=this.options.minChars){this.active_=true;this.lastProcessedValue_=a;this.fetchData(a)}}};a.Autocompleter.prototype.fetchData=function(a){if(this.options.data){this.filterAndShowResults(this.options.data,a)}else{var b=this;this.fetchRemoteData(a,function(c){b.filterAndShowResults(c,a)})}};a.Autocompleter.prototype.fetchRemoteData=function(b,c){var d=this.cacheRead(b);if(d){c(d)}else{var e=this;this.dom.$elem.addClass(this.options.loadingClass);var f=function(a){var d=false;if(a!==false){d=e.parseRemoteData(a);e.cacheWrite(b,d)}e.dom.$elem.removeClass(e.options.loadingClass);c(d)};a.ajax({url:this.makeUrl(b),success:f,error:function(){f(false)}})}};a.Autocompleter.prototype.setExtraParam=function(b,c){var d=a.trim(String(b));if(d){if(!this.options.extraParams){this.options.extraParams={}}if(this.options.extraParams[d]!==c){this.options.extraParams[d]=c;this.cacheFlush()}}};a.Autocompleter.prototype.makeUrl=function(b){var c=this;var d=this.options.paramName||"q";var e=this.options.url;var f=a.extend({},this.options.extraParams);if(this.options.paramName===false){e+=encodeURIComponent(b)}else{f[d]=b}var g=[];a.each(f,function(a,b){g.push(c.makeUrlParam(a,b))});if(g.length){e+=e.indexOf("?")==-1?"?":"&";e+=g.join("&")}return e};a.Autocompleter.prototype.makeUrlParam=function(a,b){return String(a)+"="+encodeURIComponent(b)};a.Autocompleter.prototype.parseRemoteData=function(a){var b=[];var c=String(a).replace("\r\n","\n");var d,e,f,g,h=c.split("\n");var i;for(d=0;d<h.length;d++){g=h[d].split("|");f=[];for(e=0;e<g.length;e++){f.push(unescape(g[e]))}i=f.shift();b.push({value:unescape(i),data:f})}return b};a.Autocompleter.prototype.filterAndShowResults=function(a,b){this.showResults(this.filterResults(a,b),b)};a.Autocompleter.prototype.filterResults=function(b,c){var d=[];var e,f,g,h,i,j;var k,l,m="";var n=new RegExp("[.*+?|()\\[\\]{}\\\\]","g");for(g=0;g<b.length;g++){h=b[g];i=typeof h;if(i==="string"){e=h;f={}}else if(a.isArray(h)){e=h[0];f=h.slice(1)}else if(i==="object"){e=h.value;f=h.data}e=String(e);if(e>""){if(typeof f!=="object"){f={}}j=!this.options.filterResults;if(!j){l=String(c);l=l.replace(n,"\\$&");if(!this.options.matchInside){l="^"+l}if(!this.options.matchCase){m="i"}k=new RegExp(l,m);j=k.test(e)}if(j){d.push({value:e,data:f})}}}if(this.options.sortResults){d=this.sortResults(d,c)}if(this.options.maxItemsToShow>0&&this.options.maxItemsToShow<d.length){d.length=this.options.maxItemsToShow}return d};a.Autocompleter.prototype.sortResults=function(b,c){var d=this;var e=this.options.sortFunction;if(!a.isFunction(e)){e=function(a,b,c){return d.sortValueAlpha(a,b,c)}}b.sort(function(a,b){return e(a,b,c)});return b};a.Autocompleter.prototype.sortValueAlpha=function(a,b,c){a=String(a.value);b=String(b.value);if(!this.options.matchCase){a=a.toLowerCase();b=b.toLowerCase()}if(a>b){return 1}if(a<b){return-1}return 0};a.Autocompleter.prototype.showResults=function(b,c){var d=this;var e=a("<ul></ul>");var f,g,h,i,j=false,k=false;var l=b.length;for(f=0;f<l;f++){g=b[f];h=a("<li>"+this.showResult(g.value,g.data)+"</li>");h.data("value",g.value);h.data("data",g.data);h.click(function(){var b=a(this);d.selectItem(b)}).mousedown(function(){d.finishOnBlur_=false}).mouseup(function(){d.finishOnBlur_=true});e.append(h);if(j===false){j=String(g.value);k=h;h.addClass(this.options.firstItemClass)}if(f==l-1){h.addClass(this.options.lastItemClass)}}this.position();this.dom.$results.html(e).show();i=this.dom.$results.outerWidth()-this.dom.$results.width();this.dom.$results.width(this.dom.$elem.outerWidth()-i);a("li",this.dom.$results).hover(function(){d.focusItem(this)},function(){});if(this.autoFill(j,c)){this.focusItem(k)}};a.Autocompleter.prototype.showResult=function(b,c){if(a.isFunction(this.options.showResult)){return this.options.showResult(b,c)}else{return b}};a.Autocompleter.prototype.autoFill=function(a,b){var c,d,e,f;if(this.options.autoFill&&this.lastKeyPressed_!=8){c=String(a).toLowerCase();d=String(b).toLowerCase();e=a.length;f=b.length;if(c.substr(0,f)===d){this.dom.$elem.val(a);this.selectRange(f,e);return true}}return false};a.Autocompleter.prototype.focusNext=function(){this.focusMove(+1)};a.Autocompleter.prototype.focusPrev=function(){this.focusMove(-1)};a.Autocompleter.prototype.focusMove=function(b){var c,d=a("li",this.dom.$results);b=parseInt(b,10);for(var c=0;c<d.length;c++){if(a(d[c]).hasClass(this.selectClass_)){this.focusItem(c+b);return}}this.focusItem(0)};a.Autocompleter.prototype.focusItem=function(b){var c,d=a("li",this.dom.$results);if(d.length){d.removeClass(this.selectClass_).removeClass(this.options.selectClass);if(typeof b==="number"){b=parseInt(b,10);if(b<0){b=0}else if(b>=d.length){b=d.length-1}c=a(d[b])}else{c=a(b)}if(c){c.addClass(this.selectClass_).addClass(this.options.selectClass)}}};a.Autocompleter.prototype.selectCurrent=function(){var b=a("li."+this.selectClass_,this.dom.$results);if(b.length==1){this.selectItem(b)}else{this.finish()}};a.Autocompleter.prototype.selectItem=function(a){var b=a.data("value");var c=a.data("data");var d=this.displayValue(b,c);this.lastProcessedValue_=d;this.lastSelectedValue_=d;this.dom.$elem.val(d).focus();this.setCaret(d.length);this.callHook("onItemSelect",{value:b,data:c});this.finish()};a.Autocompleter.prototype.displayValue=function(b,c){if(a.isFunction(this.options.displayValue)){return this.options.displayValue(b,c)}else{return b}};a.Autocompleter.prototype.finish=function(){if(this.keyTimeout_){clearTimeout(this.keyTimeout_)}if(this.dom.$elem.val()!==this.lastSelectedValue_){if(this.options.mustMatch){this.dom.$elem.val("")}this.callHook("onNoMatch")}this.dom.$results.hide();this.lastKeyPressed_=null;this.lastProcessedValue_=null;if(this.active_){this.callHook("onFinish")}this.active_=false};a.Autocompleter.prototype.selectRange=function(a,b){var c=this.dom.$elem.get(0);if(c.setSelectionRange){c.focus();c.setSelectionRange(a,b)}else if(this.createTextRange){var d=this.createTextRange();d.collapse(true);d.moveEnd("character",b);d.moveStart("character",a);d.select()}};a.Autocompleter.prototype.setCaret=function(a){this.selectRange(a,a)};a.fn.autocomplete=function(b){if(typeof b==="string"){b={url:b}}var c=a.extend({},a.fn.autocomplete.defaults,b);return this.each(function(){var b=a(this);var d=new a.Autocompleter(b,c);b.data("autocompleter",d)})};a.fn.autocomplete.defaults={paramName:"q",minChars:1,loadingClass:"acLoading",resultsClass:"acResults",inputClass:"acInput",selectClass:"acSelect",mustMatch:false,matchCase:false,matchInside:true,matchSubset:true,useCache:true,maxCacheLength:10,autoFill:false,filterResults:true,sortResults:true,sortFunction:false,onItemSelect:false,onNoMatch:false,maxItemsToShow:-1}})(jQuery)


// json2 for parsing, in case older browser needs it 
;if(!this.JSON){this.JSON={}};(function(){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){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v)}}}}else{for(k in value){if(Object.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.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v}else{delete value[k]}}}}return reviver.call(holder,key,value)};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')}}}());

 $.fn.delay = function(time, callback){ jQuery.fx.step.delay = function(){}; return this.animate({delay:1}, time, callback); }




jQuery.fn.center = function () {
    //this.css("position","fixed");
    this.css("top", "100px");
    this.css("left", ( $(window).width() - this.outerWidth() ) / 2+$(window).scrollLeft() + "px");
    return this;
}


//gb_modal:

function gb_modal_show( url, called_from_div ){

  gb_modal_terminate(); // perform mendatory cleanup first...

  $('body').append('<div id="gbm-modal-wrap"></div>'
          ).append('<div id="gbm-overlay"></div>');
          
  $('#gbm-overlay').show();
  
  $('html').addClass('freeze-html-scroll'); // prevent outer document scrolling...
  
  $('#gbm-modal-wrap').append('<div id="gbm-modal-content"></div>');
  
  //$.scrollTo('#gbm-modal-content', 500);
  
  $('#gbm-modal-content').load( url, function(){
        
        $('.html-editor').css('height', '250px'); // allow a bigger win
        $('#gbm-modal-wrap').show('fast');
        $('.gb-editor').find('td').css('padding', '0px');
        
        edit_as_modal_functionality();
    });
}



function gb_modal_terminate(){

  
  if( $('#gbm-overlay') )
    $('#gbm-overlay').remove();
  
  if( $('#gbm-modal-wrap'))
    $('#gbm-modal-wrap').remove();


  $('html').removeClass('freeze-html-scroll'); // restore outer document scrolling...
  
}

//fake "delay" before the passed function src: http://james.padolsey.com/javascript/jquery-delay-plugin/
/*
$('a').delay(1000, function(){
    $(this).css({
        background: 'red'
    });
});
*/
//$.fn.delay = function(time, callback){jQuery.fx.step.delay = function(){};eturn this.animate({delay:1}, time, callback);}


// cross site functions (some shared w/admin):
//-------------------------------------------------

var _jtracker_force_url =   ''; // used only for overrides
var _jtracker_mask_rf   =   ''; // used only for overrides                             
var host_name           =   host_detect();
var base_path_url       =   get_base_path();



function uniqid(){
    
    return Math.floor((Math.random())*10000);
}

function host_detect(){
    
    return top.location.host;
}

function get_base_path(){

    var base_path = '';
    
    var secure = (document.location.protocol=="https:") ? true : false;
    
    switch( host_name )
    {
        case    'localhost'     :base_path = 'http://localhost/jungo/';break;
        case    'yes3'          :base_path = 'http://yes3/root/home/yanay/site/www/';break;
        
        case    'www.jungo.com' :
        case    'jungo.com'     :
                                  base_path = 'http://www.jungo.com/';
                                  if( secure )
                                    base_path = base_path.replace('http','https');
                                  break;        
    }   
    
    return base_path;
  
}
function get_scripts_path(){
   
    return ( get_base_path() + 'st/do/' );
}   


function js_bypass(){  /* for overrides */ }

function is_dev_mode(){

    if( host_name=='yes3' || host_name=='localhost'  )
        return true;
    else
        return false;
}

function is_production(){

    if( is_dev_mode() ) 
        return false;
    else
        return true;

}

function st_script( tag, redirect, id_param ){

  var link    = base_path_url+'st/';
  var fname   = '';
    
  switch( tag ){
  
    case 'events'   :fname = 'news/events.php';break;
    case 'index'   :fname = 'index.php';break;
    default         :fname = 'index.php';break;
  
  }

  link += fname;
  
  if( id_param )
    link += '?id=' + id_param;
  
  if( redirect )
    location.href = link;
  else
    return link;

}

function st_index(){
// a shortcut for js clicks to index.php:

  st_script( 'index', true);
  //location.href  = base_path_url + 'st/index.html';  // temp: only while HTP version is in use!

  return false;
}




function submit_form( form_name ){

  document.getElementById(form_name).submit();
}




function check_opt_out_email(){

  var error='';
  
  
  error += checkEmail( document.opt_out_form.email_field );
  
  
  if( error!='' )  
  {
    // errors notice:
    form_error_msg( '#form-edit-comments', 'Email address invalid. Please check again...');
    return false;
  }  
  
  else
  {
    // wait notice:
    $('#form-edit-comments').html( "<div class='ajax-box'><img src='../../images/ajax_load.gif' border='0'></div> " +
                                     "Please wait while processing information...");
    $('#form-edit-comments').show();
    
    document.opt_out_form.submit();
    
    return true;
  
  }

}



function google_track_as( virtual_page ){

    // re-enforce domain relation (Urchin bug??)
    if( is_production() )
      pageTracker._trackPageview( virtual_page ); 
}

function run_conversion_code(){   // same code as the PHP version by this name

    
    if( !is_production() ) return; 
    
    div_id = 'gconversion' + (new Date().getTime());
    
    conversion_script = base_path_url+'st/_run_adwords_conversion.php';
    
    
    $( 'body' ).append("<div id='"+div_id+"' style='display:none;'></div>");
    
    $( '#'+div_id ).load( base_path_url+'st/_run_adwords_conversion.php');
    
    
    
}



function update_checkbox_selection( form_name, result_field, checkboxes_arr, add_extra_field ){
    
     
     var form_handler       = document[ ''+form_name+'' ];
     var checkboxes_count   = form_handler[ ''+checkboxes_arr+''].length;
     var addition           = '';
     
     var final_result = '';
     
     
     for (i=0; i < checkboxes_count; i++)
     {
        //console.log( 'i: '+i+' value: '+ checkboxes_arr[i].value );
        
        if( form_handler[ ''+checkboxes_arr+''][i].checked == true )
         final_result = final_result + form_handler[''+checkboxes_arr+''][i].value + ', ';
     }
     
     if( add_extra_field && $('#'+add_extra_field).val() ){
        addition = $('#'+add_extra_field).val();
    }
     
    $( '#'+result_field ).val( final_result + addition );
}




function redirect_to_download_down(){

  location.href  = base_path_url + 'downloads_maintenance.html';
  
}



function redirect_to_download( product_name, custom_tag, language ){
  
  var download_path =  get_scripts_path() + "download_new.php?product=" + product_name;
  
  if( custom_tag )  
    download_path += "&tag=" + custom_tag;
  else
    download_path += "&tag=" + location.pathname;  // default tag is referring page

  if( language ){
   download_path += "&lang=" + language;
  }
  
  location.href = download_path; 

}





function redirect_to_contact( contact_subject, custom_tag, language ){

  var contact_path =  get_scripts_path() + "contact_form.php?subject=" + contact_subject;
    
  if( custom_tag )  
    contact_path += "&tag=" + custom_tag;
  else
    contact_path += "&tag=" + location.pathname;  // default tag is referring page

  if( language ){
   contact_path += "&lang=" + language;
  }

    
  location.href = contact_path;                               
  
}


function redirect_to_st_store( product_id ){

  var store_path =  get_scripts_path() + "store/index.php";
  
  if( product_id ) store_path += "?pid=" + product_id; 
  
  location.href = store_path;
  
}


function launch_wd_usb_demo(){

  window.open( base_path_url + 'st/images/viewlet/WinDriverUSB.swf','MyWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=807,height=624,left=20,top=20'); 
  return false;
}

function launch_wd_pci_demo(){

  window.open( base_path_url + 'st/images/viewlet/WinDriverPCI.swf','MyWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=807,height=624,left=20,top=20'); 
  return false;
}

function launch_usb_host_tester_demo(){

  window.open( base_path_url + 'st/images/viewlet/usb_tester_demo.swf','MyWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=807,height=624,left=20,top=20'); 
  return false;
}



    
function JTracker( forced_mask ){
    
 var params = {};
    
    params.current_url          = location.href;
    
    // url masking:
        
        // a masking can come from a content page (HTP/PHP), where a param is embedded into the page ( _jtracker_mask_url ),
        // or from an action, where JTracker() is fed with param 'forced_mask' :

        params.current_url_mask     = ( typeof _jtracker_mask_url != "undefined" && _jtracker_mask_url!='' ) ? _jtracker_mask_url : '';
        
        //console.log( 'got explicit forced_mask: '+forced_mask);
        
        if( forced_mask )           // more powerful: actions overwrite page's internal param. (usually this is used for ACTIONS, not pages)
        params.current_url_mask     = forced_mask;                      
    
    params.prev_url             = document.referrer;
    params.fr_src_mask          = $(document).getUrlParam("fr") ? $(document).getUrlParam("fr") : '';    // reads the '?fr=...' used to tag foreign sources of interest

    // if injected referrer url from js, use it:
    if( _jtracker_mask_rf )
      params.fr_src_mask = _jtracker_mask_rf; 
    
    sending_url = get_scripts_path() + 'tools/track_page.php?jsoncallback=?';
    
    $.getJSON( sending_url, params, function(data){});
 

}


function loading_msg( msg ){
    
    if(!msg) msg='loading...';
    
    return "<div style='float: left;' class='loading-img'>" + msg + "</div>";
    
}


function submit_news_join(){

    var email= $('#email_field').val();

    $('#news-join-form').html( loading_msg('sending request...') );

    $.ajax( { url : get_scripts_path()+'email_stat.php',
              data : { email_field : email, src : 'Join_news_page', stat : '2' },
              
              success: function(){
                          $('#news-join-form').html('<b><br/>Great!<br/>We will now keep you updated... </b> <br/>');
                        }
              });
            
}



