
/* jquery.positionBy */
(function($){var A=function(a,b,c,d){this.x1=a;this.x2=c;this.y1=b;this.y2=d;};A.prototype.contains=function(a){return(this.x1<=a.x1&&a.x2<=this.x2)&&(this.y1<=a.y1&&a.y2<=this.y2);};A.prototype.transform=function(x,y){return new A(this.x1+x,this.y1+y,this.x2+x,this.y2+y);};$.fn.positionBy=function(q){var r=new Date();if(this.length==0){return this;}var q=$.extend({target:null,targetPos:null,elementPos:null,x:null,y:null,positions:null,addClass:false,force:false,container:window},q);if(q.x!=null){var s=q.x;var t=q.y;var u=0;var v=0;}else{var w=$($(q.target)[0]);var u=w.outerWidth();var v=w.outerHeight();var x=w.offset();var s=x.left;var t=x.top;}var y=s+u;var z=t+v;return this.each(function(){var c=$(this);if(!c.is(':visible')){c.css({left:-3000,top:-3000}).show();}var d=c.outerWidth();var e=c.outerHeight();var f=[];var g=[];f[0]=new A(y,t,y+d,t+e);g[0]=[1,7,4];f[1]=new A(y,z-e,y+d,z);g[1]=[0,6,4];f[2]=new A(y,z,y+d,z+e);g[2]=[1,3,10];f[3]=new A(y-d,z,y,z+e);g[3]=[1,6,10];f[4]=new A(s,z,s+d,z+e);g[4]=[1,6,9];f[5]=new A(s-d,z,s,z+e);g[5]=[6,4,9];f[6]=new A(s-d,z-e,s,z);g[6]=[7,1,4];f[7]=new A(s-d,t,s,t+e);g[7]=[6,0,4];f[8]=new A(s-d,t-e,s,t);g[8]=[7,9,4];f[9]=new A(s,t-e,s+d,t);g[9]=[0,7,4];f[10]=new A(y-d,t-e,y,t);g[10]=[0,7,3];f[11]=new A(y,t-e,y+d,t);g[11]=[0,10,3];f[12]=new A(y-d,t,y,t+e);g[12]=[13,7,10];f[13]=new A(y-d,z-e,y,z);g[13]=[12,6,3];f[14]=new A(s,z-e,s+d,z);g[14]=[15,1,4];f[15]=new A(s,t,s+d,t+e);g[15]=[14,0,9];if(q.positions!==null){var h=q.positions[0];}else if(q.targetPos!=null&&q.elementPos!=null){var h=[];h[0]=[];h[0][0]=15;h[0][1]=7;h[0][2]=8;h[0][3]=9;h[1]=[];h[1][0]=0;h[1][1]=12;h[1][2]=10;h[1][3]=11;h[2]=[];h[2][0]=2;h[2][1]=3;h[2][2]=13;h[2][3]=1;h[3]=[];h[3][0]=4;h[3][1]=5;h[3][2]=6;h[3][3]=14;var h=h[q.targetPos][q.elementPos];}var i=f[h];var j=h;if(!q.force){$window=$(window);var k=$window.scrollLeft();var l=$window.scrollTop();var m=new A(k,l,k+$window.width(),l+$window.height());var n;if(q.positions){n=q.positions;}else{n=[h];}var o=[];while(n.length>0){var p=n.shift();if(o[p]){continue;}o[p]=true;if(!m.contains(f[p])){if(q.positions===null){n=jQuery.merge(n,g[p]);}}else{i=f[p];break;}}}c.parents().each(function(){var a=$(this);if(a.css('position')!='static'){var b=a.offset();i=i.transform(-b.left,-b.top);return false;}});c.css({left:i.x1,top:i.y1});if(q.addClass){c.removeClass('positionBy0 positionBy1 positionBy2 positionBy3 positionBy4 positionBy5 '+'positionBy6 positionBy7 positionBy8 positionBy9 positionBy10 positionBy11 '+'positionBy12 positionBy13 positionBy14 positionBy15').addClass('positionBy'+p);}});};})(jQuery);

/* jquery.bgiframe */
(function($){$.fn.bgIframe=$.fn.bgiframe=function(s){if($.browser.msie && parseFloat($.browser.version) < 7){s=$.extend({top:'auto',left:'auto',width:'auto',height:'auto',opacity:true,src:'javascript:false;'},s||{});var prop=function(n){return n&&n.constructor==Number?n+'px':n;},html='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+'style="display:block;position:absolute;z-index:-1;'+(s.opacity!==false?'filter:Alpha(Opacity=\'0\');':'')+'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+'"/>';return this.each(function(){if($('> iframe.bgiframe',this).length==0)this.insertBefore(document.createElement(html),this.firstChild);});}return this;};})(jQuery);

/* jQuery.fn.pngFi */
(function(A){jQuery.fn.pngFix=function(D){D=jQuery.extend({blankgif:"blank.gif"},D);var C=(navigator.appName=="Microsoft Internet Explorer"&&parseInt(navigator.appVersion)==4&&navigator.appVersion.indexOf("MSIE 5.5")!=-1);var B=(navigator.appName=="Microsoft Internet Explorer"&&parseInt(navigator.appVersion)==4&&navigator.appVersion.indexOf("MSIE 6.0")!=-1);if(jQuery.browser.msie&&(C||B)){jQuery(this).find("img[@src$=.png]").each(function(){jQuery(this).attr("width",jQuery(this).width());jQuery(this).attr("height",jQuery(this).height());var L="";var G="";var F=(jQuery(this).attr("id"))?'id="'+jQuery(this).attr("id")+'" ':"";var M=(jQuery(this).attr("class"))?'class="'+jQuery(this).attr("class")+'" ':"";var I=(jQuery(this).attr("title"))?'title="'+jQuery(this).attr("title")+'" ':"";var J=(jQuery(this).attr("alt"))?'alt="'+jQuery(this).attr("alt")+'" ':"";var H=(jQuery(this).attr("align"))?"float:"+jQuery(this).attr("align")+";":"";var E=(jQuery(this).parent().attr("href"))?"cursor:hand;":"";if(this.style.border){L+="border:"+this.style.border+";";this.style.border="";};if(this.style.padding){L+="padding:"+this.style.padding+";";this.style.padding="";}if(this.style.margin){L+="margin:"+this.style.margin+";";this.style.margin="";};var K=(this.style.cssText);G+="<span "+F+M+I+J;G+='style="position:relative;white-space:pre-line;display:inline-block;background:transparent;'+H+E;G+="width:"+jQuery(this).width()+"px;height:"+jQuery(this).height()+"px;";G+="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+jQuery(this).attr("src")+"', sizingMethod='scale');";G+=K+'"></span>';if(L!=""){G='<span style="position:relative;display:inline-block;'+L+E+"width:"+jQuery(this).width()+"px;height:"+jQuery(this).height()+'px;">'+G+"</span>";}jQuery(this).hide();jQuery(this).after(G);});jQuery(this).find("*").each(function(){var F=jQuery(this).css("background-image");if(F.indexOf(".png")!=-1){var E=F.split('url("')[1].split('")')[0];jQuery(this).css("background-image","none");jQuery(this).get(0).runtimeStyle.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+E+"',sizingMethod='scale')";}});jQuery(this).find("input[@src$=.png]").each(function(){var E=jQuery(this).attr("src");jQuery(this).get(0).runtimeStyle.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+E+"', sizingMethod='scale');";jQuery(this).attr("src",D.blankgif);});}return jQuery;};})(jQuery);

/* jdMenu */
(function(D){function C(E){var F=D.data(D(E).parents().andSelf().filter("ul.jd_menu")[0],"jdMenuSettings");D("> li",E).bind("mouseenter.jdmenu mouseleave.jdmenu",function(G){D(this).toggleClass("jdm_hover");var H=D("> ul",this);if(H.length==1){clearTimeout(this.$jdTimer);var J=(G.type=="mouseenter");var I=(J?B:A);this.$jdTimer=setTimeout(function(){I(H[0],F.onAnimate,F.isVertical);},J?F.showDelay:F.hideDelay);}}).bind("click.jdmenu",function(H){var I=D("> ul",this);if(I.length==1&&(F.disableLinks==true||D(this).hasClass("accessible"))){B(I,F.onAnimate,F.isVertical);return false;}if(H.target==this){var J=D("> a",H.target).not(".accessible");if(J.length>0){var G=J[0];if(!G.onclick){window.open(G.href,G.target||"_self");}else{D(G).trigger("click");}}}if(F.disableLinks||(!F.disableLinks&&!D(this).parent().hasClass("jd_menu"))){D(this).parent().jdMenuHide();H.stopPropagation();}}).find("> a").bind("focus.jdmenu blur.jdmenu",function(G){var H=D(this).parents("li:eq(0)");if(G.type=="focus"){H.addClass("jdm_hover");}else{H.removeClass("jdm_hover");}}).filter(".accessible").bind("click.jdmenu",function(G){G.preventDefault();});}function B(H,G,F){var H=D(H);if(H.is(":visible")){return; }H.bgiframe();var E=H.parent();H.trigger("jdMenuShow").positionBy({target:E[0],targetPos:(F===true||!E.parent().hasClass("jd_menu")?1:3),elementPos:0,hideAfterPosition:true});if(!H.hasClass("jdm_events")){H.addClass("jdm_events");C(H);}E.addClass("jdm_active").siblings("li").find("> ul:eq(0):visible").each(function(){A(this);});if(G===undefined){H.show();}else{G.apply(H[0],[true]);}}function A(F,E){var F=D(F);D(".bgiframe",F).remove();F.filter(":not(.jd_menu)").find("> li > ul:eq(0):visible").each(function(){A(this);}).end();if(E===undefined){F.hide();}else{E.apply(F[0],[false]);}F.trigger("jdMenuHide").parents("li:eq(0)").removeClass("jdm_active jdm_hover").end().find("> li").removeClass("jdm_active jdm_hover");}D.fn.jdMenu=function(E){var E=D.extend({showDelay:200,hideDelay:500,disableLinks:true},E);if(!D.isFunction(E.onAnimate)){E.onAnimate=undefined;}return this.filter("ul.jd_menu").each(function(){D.data(this,"jdMenuSettings",D.extend({isVertical:D(this).hasClass("jd_menu_vertical")},E));C(this);});};D.fn.jdMenuUnbind=function(){D("ul.jdm_events",this).unbind(".jdmenu").find("> a").unbind(".jdmenu");};D.fn.jdMenuHide=function(){return this.filter("ul").each(function(){A(this);});};D(window).bind("click.jdmenu",function(){D("ul.jd_menu ul:visible").jdMenuHide();});})(jQuery);

/* jquery.selectboxes */
;(function(h){h.fn.addOption=function(){var j=function(a,f,c,g){var d=document.createElement("option");d.value=f,d.text=c;var b=a.options;var e=b.length;if(!a.cache){a.cache={};for(var i=0;i<e;i++){a.cache[b[i].value]=i}}if(typeof a.cache[f]=="undefined")a.cache[f]=e;a.options[a.cache[f]]=d;if(g){d.selected=true}};var k=arguments;if(k.length==0)return this;var l=true;var m=false;var n,o,p;if(typeof(k[0])=="object"){m=true;n=k[0]}if(k.length>=2){if(typeof(k[1])=="boolean")l=k[1];else if(typeof(k[2])=="boolean")l=k[2];if(!m){o=k[0];p=k[1]}}this.each(function(){if(this.nodeName.toLowerCase()!="select")return;if(m){for(var a in n){j(this,a,n[a],l)}}else{j(this,o,p,l)}});return this};h.fn.ajaxAddOption=function(c,g,d,b,e){if(typeof(c)!="string")return this;if(typeof(g)!="object")g={};if(typeof(d)!="boolean")d=true;this.each(function(){var f=this;h.getJSON(c,g,function(a){h(f).addOption(a,d);if(typeof b=="function"){if(typeof e=="object"){b.apply(f,e)}else{b.call(f)}}})});return this};h.fn.removeOption=function(){var d=arguments;if(d.length==0)return this;var b=typeof(d[0]);var e,i;if(b=="string"||b=="object"||b=="function"){e=d[0];if(e.constructor==Array){var j=e.length;for(var k=0;k<j;k++){this.removeOption(e[k],d[1])}return this}}else if(b=="number")i=d[0];else return this;this.each(function(){if(this.nodeName.toLowerCase()!="select")return;if(this.cache)this.cache=null;var a=false;var f=this.options;if(!!e){var c=f.length;for(var g=c-1;g>=0;g--){if(e.constructor==RegExp){if(f[g].value.match(e)){a=true}}else if(f[g].value==e){a=true}if(a&&d[1]===true)a=f[g].selected;if(a){f[g]=null}a=false}}else{if(d[1]===true){a=f[i].selected}else{a=true}if(a){this.remove(i)}}});return this};h.fn.sortOptions=function(e){var i=h(this).selectedValues();var j=typeof(e)=="undefined"?true:!!e;this.each(function(){if(this.nodeName.toLowerCase()!="select")return;var c=this.options;var g=c.length;var d=[];for(var b=0;b<g;b++){d[b]={v:c[b].value,t:c[b].text}}d.sort(function(a,f){o1t=a.t.toLowerCase(),o2t=f.t.toLowerCase();if(o1t==o2t)return 0;if(j){return o1t<o2t?-1:1}else{return o1t>o2t?-1:1}});for(var b=0;b<g;b++){c[b].text=d[b].t;c[b].value=d[b].v}}).selectOptions(i,true);return this};h.fn.selectOptions=function(g,d){var b=g;var e=typeof(g);if(e=="object"&&b.constructor==Array){var i=this;h.each(b,function(){i.selectOptions(this,d)})};var j=d||false;if(e!="string"&&e!="function"&&e!="object")return this;this.each(function(){if(this.nodeName.toLowerCase()!="select")return this;var a=this.options;var f=a.length;for(var c=0;c<f;c++){if(b.constructor==RegExp){if(a[c].value.match(b)){a[c].selected=true}else if(j){a[c].selected=false}}else{if(a[c].value==b){a[c].selected=true}else if(j){a[c].selected=false}}}});return this};h.fn.copyOptions=function(g,d){var b=d||"selected";if(h(g).size()==0)return this;this.each(function(){if(this.nodeName.toLowerCase()!="select")return this;var a=this.options;var f=a.length;for(var c=0;c<f;c++){if(b=="all"||(b=="selected"&&a[c].selected)){h(g).addOption(a[c].value,a[c].text)}}});return this};h.fn.containsOption=function(g,d){var b=false;var e=g;var i=typeof(e);var j=typeof(d);if(i!="string"&&i!="function"&&i!="object")return j=="function"?this:b;this.each(function(){if(this.nodeName.toLowerCase()!="select")return this;if(b&&j!="function")return false;var a=this.options;var f=a.length;for(var c=0;c<f;c++){if(e.constructor==RegExp){if(a[c].value.match(e)){b=true;if(j=="function")d.call(a[c],c)}}else{if(a[c].value==e){b=true;if(j=="function")d.call(a[c],c)}}}});return j=="function"?this:b};h.fn.selectedValues=function(){var a=[];this.selectedOptions().each(function(){a[a.length]=this.value});return a};h.fn.selectedTexts=function(){var a=[];this.selectedOptions().each(function(){a[a.length]=this.text});return a};h.fn.selectedOptions=function(){return this.find("option:selected")}})(jQuery);

/* jquery.checkboxes */
;(function(d){d.fn.toggleCheckboxes=function(a,b){a=a||"*";b=b||false;var c=d([]);this.each(function(){var e=d("input[type=checkbox]",this).filter(a).each(function(){this.checked=!this.checked}).filter(":checked");c=e});if(!b){c=this}return c};d.fn.checkCheckboxes=function(a,b){a=a||"*";b=b||false;var c=d([]);this.each(function(){var e=d("input[type=checkbox]",this).filter(a).each(function(){this.checked=true}).filter(":checked");c=e});if(!b){c=this}return c};d.fn.unCheckCheckboxes=function(a,b){a=a||"*";b=b||false;var c=d([]);this.each(function(){var e=d("input[type=checkbox]",this).filter(a).each(function(){this.checked=false}).filter(":not(:checked)");c=e});if(!b){c=this}return c};d.radioCheckboxGroup=function(e,a){a=a||"*";var b="input[type=checkbox]";if(e){b+="[name="+e+"]"}var c=d(b).filter(a);c.click(function(){c.not(this).each(function(){this.checked=false}).end()})}})(jQuery);

//jquery.md5.js
(function(E){var Q=function(G,F){return(G<<F)|(G>>>(32-F));};var A=function(S,G){var U,F,I,T,H;I=(S&2147483648);T=(G&2147483648);U=(S&1073741824);F=(G&1073741824);H=(S&1073741823)+(G&1073741823);if(U&F){return(H^2147483648^I^T)}if(U|F){if(H&1073741824){return(H^3221225472^I^T)}else{return(H^1073741824^I^T)}}else{return(H^I^T)}};var R=function(F,H,G){return(F&H)|((~F)&G)};var P=function(F,H,G){return(F&G)|(H&(~G))};var N=function(F,H,G){return(F^H^G)};var M=function(F,H,G){return(H^(F|(~G)))};var K=function(H,G,U,T,F,I,S){H=A(H,A(A(R(G,U,T),F),S));return A(Q(H,I),G)};var C=function(H,G,U,T,F,I,S){H=A(H,A(A(P(G,U,T),F),S));return A(Q(H,I),G)};var L=function(H,G,U,T,F,I,S){H=A(H,A(A(N(G,U,T),F),S));return A(Q(H,I),G)};var D=function(H,G,U,T,F,I,S){H=A(H,A(A(M(G,U,T),F),S));return A(Q(H,I),G)};var J=function(I){var V;var H=I.length;var G=H+8;var U=(G-(G%64))/64;var T=(U+1)*16;var W=Array(T-1);var F=0;var S=0;while(S<H){V=(S-(S%4))/4;F=(S%4)*8;W[V]=(W[V]|(I.charCodeAt(S)<<F));S++}V=(S-(S%4))/4;F=(S%4)*8;W[V]=W[V]|(128<<F);W[T-2]=H<<3;W[T-1]=H>>>29;return W};var B=function(I){var H="",F="",S,G;for(G=0;G<=3;G++){S=(I>>>(G*8))&255;F="0"+S.toString(16);H=H+F.substr(F.length-2,2)}return H};var O=function(G){G=G.replace(/\x0d\x0a/g,"\x0a");var F="";for(var I=0;I<G.length;I++){var H=G.charCodeAt(I);if(H<128){F+=String.fromCharCode(H)}else{if((H>127)&&(H<2048)){F+=String.fromCharCode((H>>6)|192);F+=String.fromCharCode((H&63)|128)}else{F+=String.fromCharCode((H>>12)|224);F+=String.fromCharCode(((H>>6)&63)|128);F+=String.fromCharCode((H&63)|128)}}}return F};E.extend({md5:function(F){var V=Array();var j,l,G,U,i,u,t,r,o;var g=7,e=12,Y=17,W=22;var s=5,p=9,n=14,m=20;var T=4,S=11,I=16,H=23;var h=6,f=10,Z=15,X=21;F=O(F);V=J(F);u=1732584193;t=4023233417;r=2562383102;o=271733878;for(j=0;j<V.length;j+=16){l=u;G=t;U=r;i=o;u=K(u,t,r,o,V[j+0],g,3614090360);o=K(o,u,t,r,V[j+1],e,3905402710);r=K(r,o,u,t,V[j+2],Y,606105819);t=K(t,r,o,u,V[j+3],W,3250441966);u=K(u,t,r,o,V[j+4],g,4118548399);o=K(o,u,t,r,V[j+5],e,1200080426);r=K(r,o,u,t,V[j+6],Y,2821735955);t=K(t,r,o,u,V[j+7],W,4249261313);u=K(u,t,r,o,V[j+8],g,1770035416);o=K(o,u,t,r,V[j+9],e,2336552879);r=K(r,o,u,t,V[j+10],Y,4294925233);t=K(t,r,o,u,V[j+11],W,2304563134);u=K(u,t,r,o,V[j+12],g,1804603682);o=K(o,u,t,r,V[j+13],e,4254626195);r=K(r,o,u,t,V[j+14],Y,2792965006);t=K(t,r,o,u,V[j+15],W,1236535329);u=C(u,t,r,o,V[j+1],s,4129170786);o=C(o,u,t,r,V[j+6],p,3225465664);r=C(r,o,u,t,V[j+11],n,643717713);t=C(t,r,o,u,V[j+0],m,3921069994);u=C(u,t,r,o,V[j+5],s,3593408605);o=C(o,u,t,r,V[j+10],p,38016083);r=C(r,o,u,t,V[j+15],n,3634488961);t=C(t,r,o,u,V[j+4],m,3889429448);u=C(u,t,r,o,V[j+9],s,568446438);o=C(o,u,t,r,V[j+14],p,3275163606);r=C(r,o,u,t,V[j+3],n,4107603335);t=C(t,r,o,u,V[j+8],m,1163531501);u=C(u,t,r,o,V[j+13],s,2850285829);o=C(o,u,t,r,V[j+2],p,4243563512);r=C(r,o,u,t,V[j+7],n,1735328473);t=C(t,r,o,u,V[j+12],m,2368359562);u=L(u,t,r,o,V[j+5],T,4294588738);o=L(o,u,t,r,V[j+8],S,2272392833);r=L(r,o,u,t,V[j+11],I,1839030562);t=L(t,r,o,u,V[j+14],H,4259657740);u=L(u,t,r,o,V[j+1],T,2763975236);o=L(o,u,t,r,V[j+4],S,1272893353);r=L(r,o,u,t,V[j+7],I,4139469664);t=L(t,r,o,u,V[j+10],H,3200236656);u=L(u,t,r,o,V[j+13],T,681279174);o=L(o,u,t,r,V[j+0],S,3936430074);r=L(r,o,u,t,V[j+3],I,3572445317);t=L(t,r,o,u,V[j+6],H,76029189);u=L(u,t,r,o,V[j+9],T,3654602809);o=L(o,u,t,r,V[j+12],S,3873151461);r=L(r,o,u,t,V[j+15],I,530742520);t=L(t,r,o,u,V[j+2],H,3299628645);u=D(u,t,r,o,V[j+0],h,4096336452);o=D(o,u,t,r,V[j+7],f,1126891415);r=D(r,o,u,t,V[j+14],Z,2878612391);t=D(t,r,o,u,V[j+5],X,4237533241);u=D(u,t,r,o,V[j+12],h,1700485571);o=D(o,u,t,r,V[j+3],f,2399980690);r=D(r,o,u,t,V[j+10],Z,4293915773);t=D(t,r,o,u,V[j+1],X,2240044497);u=D(u,t,r,o,V[j+8],h,1873313359);o=D(o,u,t,r,V[j+15],f,4264355552);r=D(r,o,u,t,V[j+6],Z,2734768916);t=D(t,r,o,u,V[j+13],X,1309151649);u=D(u,t,r,o,V[j+4],h,4149444226);o=D(o,u,t,r,V[j+11],f,3174756917);r=D(r,o,u,t,V[j+2],Z,718787259);t=D(t,r,o,u,V[j+9],X,3951481745);u=A(u,l);t=A(t,G);r=A(r,U);o=A(o,i)}var q=B(u)+B(t)+B(r)+B(o);return q.toLowerCase()}})})(jQuery);

//jquery.cycle.lite.js version 1.3
(function(D){var A="Lite-1.3";D.fn.cycle=function(E){return this.each(function(){E=E||{};if(this.cycleTimeout){clearTimeout(this.cycleTimeout)}this.cycleTimeout=0;this.cyclePause=0;var L=D(this);var I=E.slideExpr?D(E.slideExpr,this):L.children();var G=I.get();if(G.length<2){window.console&&console.log("terminating; too few slides: "+G.length);return }var F=D.extend({},D.fn.cycle.defaults,E||{},D.metadata?L.metadata():D.meta?L.data():{});var M=D.isFunction(L.data)?L.data(F.metaAttr):null;if(M){F=D.extend(F,M)}F.before=F.before?[F.before]:[];F.after=F.after?[F.after]:[];F.after.unshift(function(){F.busy=0});var N=this.className;F.width=parseInt((N.match(/w:(\d+)/)||[])[1])||F.width;F.height=parseInt((N.match(/h:(\d+)/)||[])[1])||F.height;F.timeout=parseInt((N.match(/t:(\d+)/)||[])[1])||F.timeout;if(L.css("position")=="static"){L.css("position","relative")}if(F.width){L.width(F.width)}if(F.height&&F.height!="auto"){L.height(F.height)}var H=0;I.css({position:"absolute",top:0,left:0}).each(function(O){D(this).css("z-index",G.length-O)});D(G[H]).css("opacity",1).show();if(D.browser.msie){G[H].style.removeAttribute("filter")}if(F.fit&&F.width){I.width(F.width)}if(F.fit&&F.height&&F.height!="auto"){I.height(F.height)}if(F.pause){L.hover(function(){this.cyclePause=1},function(){this.cyclePause=0})}var J=D.fn.cycle.transitions[F.fx];J&&J(L,I,F);I.each(function(){var O=D(this);this.cycleH=(F.fit&&F.height)?F.height:O.height();this.cycleW=(F.fit&&F.width)?F.width:O.width()});if(F.cssFirst){D(I[H]).css(F.cssFirst)}if(F.timeout){if(F.speed.constructor==String){F.speed={slow:600,fast:200}[F.speed]||400}if(!F.sync){F.speed=F.speed/2}while((F.timeout-F.speed)<250){F.timeout+=F.speed}}F.speedIn=F.speed;F.speedOut=F.speed;F.slideCount=G.length;F.currSlide=H;F.nextSlide=1;var K=I[H];if(F.before.length){F.before[0].apply(K,[K,K,F,true])}if(F.after.length>1){F.after[1].apply(K,[K,K,F,true])}if(F.click&&!F.next){F.next=F.click}if(F.next){D(F.next).bind("click",function(){return C(G,F,F.rev?-1:1)})}if(F.prev){D(F.prev).bind("click",function(){return C(G,F,F.rev?1:-1)})}if(F.timeout){this.cycleTimeout=setTimeout(function(){B(G,F,0,!F.rev)},F.timeout+(F.delay||0))}})};function B(J,E,I,K){if(E.busy){return }var H=J[0].parentNode,M=J[E.currSlide],L=J[E.nextSlide];if(H.cycleTimeout===0&&!I){return }if(I||!H.cyclePause){if(E.before.length){D.each(E.before,function(N,O){O.apply(L,[M,L,E,K])})}var F=function(){if(D.browser.msie){this.style.removeAttribute("filter")}D.each(E.after,function(N,O){O.apply(L,[M,L,E,K])})};if(E.nextSlide!=E.currSlide){E.busy=1;D.fn.cycle.custom(M,L,E,F)}var G=(E.nextSlide+1)==J.length;E.nextSlide=G?0:E.nextSlide+1;E.currSlide=G?J.length-1:E.nextSlide-1}if(E.timeout){H.cycleTimeout=setTimeout(function(){B(J,E,0,!E.rev)},E.timeout)}}function C(E,F,I){var H=E[0].parentNode,G=H.cycleTimeout;if(G){clearTimeout(G);H.cycleTimeout=0}F.nextSlide=F.currSlide+I;if(F.nextSlide<0){F.nextSlide=E.length-1}else{if(F.nextSlide>=E.length){F.nextSlide=0}}B(E,F,1,I>=0);return false}D.fn.cycle.custom=function(K,H,I,E){var J=D(K),G=D(H);G.css(I.cssBefore);var F=function(){G.animate(I.animIn,I.speedIn,I.easeIn,E)};J.animate(I.animOut,I.speedOut,I.easeOut,function(){J.css(I.cssAfter);if(!I.sync){F()}});if(I.sync){F()}};D.fn.cycle.transitions={fade:function(F,G,E){G.not(":eq(0)").hide();E.cssBefore={opacity:0,display:"block"};E.cssAfter={display:"none"};E.animOut={opacity:0};E.animIn={opacity:1}},fadeout:function(F,G,E){E.before.push(function(K,I,J,H){D(K).css("zIndex",J.slideCount+(H===true?1:0));D(I).css("zIndex",J.slideCount+(H===true?0:1))});G.not(":eq(0)").hide();E.cssBefore={opacity:1,display:"block",zIndex:1};E.cssAfter={display:"none",zIndex:0};E.animOut={opacity:0}}};D.fn.cycle.ver=function(){return A};D.fn.cycle.defaults={animIn:{},animOut:{},fx:"fade",after:null,before:null,cssBefore:{},cssAfter:{},delay:0,fit:0,height:"auto",metaAttr:"cycle",next:null,pause:0,prev:null,speed:1000,slideExpr:null,sync:1,timeout:4000}})(jQuery);

// NEW PMM APPLICATION OBJECT //
var _app = {

		/*
		 * Extending Objects
		 * These objects will be extended by additional included code
		 */
		
		_pmm:{},

		
		/* Properties
		 * 
		 */
		
		qstrParams:{},
		
		/* 
		 * Functions & Objects
		 */
		
		init:function()
		{
			this.qstr_parse();
		},
		
		prepareQueryString: function(v)
		{
		    if(typeof(v) == 'object'){
		        var q = '';
		        for ( var k in v ) {
		            if(v[k] !== ''){
		                q += k + '=' + v[k] + '&';
		            }
		        }
		
		        return q.substring(0,(q.length-1));
		    }
		    else{
		        return false;
		    }
		},
		
		qstr_parse: function (qs,rv) 
		{
		    this.qstrParams = {};
		
		    if (qs === null){
		       qs=location.search.substring(1,location.search.length);
		    }
		
		    if((typeof qs === 'undefined') || (qs.length === 0)){
		        return;
		    }
		
		    // Turn <plus> back to <space>
		    // See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
		    qs = qs.replace(/\+/g, ' ');
		    var args = qs.split('&'); // parse out name/value pairs separated via &
		
		    // split out each name=value pair
		    for (var i=0;i<args.length;i++) {
		        var value;
		        var pair = args[i].split('=');
		        var name = unescape(pair[0]);
		
		        if (pair.length == 2){
		           value = unescape(pair[1]);
		        }
		        else{
		           value = name;
		        }
		
		        this.qstrParams[name] = value;
		    }
		
		    if(rv){
		        return this.qstrParams;
		    }
		},

		qstr_get: function(key, default_)
		{
		    // This silly looking line changes UNDEFINED to NULL
		    if (default_ === null) {default_ = null;}
		
		    var value = this.qstrParams[key];
		    if (value === null){ value = default_; }
		
		    return value;
		},
		
		flushEmptyKeys: function(v)
		{
		    var o = {};
		    for ( var k in v ) {
		        if(v[k] !== ''){
		            o[k] = v[k];
		        }
		    }
		
		    return o;
		}
};

_app._pmm = {

		/*
		 * Extending Objects
		 * These objects will be extended by additional included code
		 */
		_hasConsole:false,
		_googleAnalytics:{},
		_ga:this._googleAnalytics,
		
		/*
		 * Properties
		 */
		
		/*
		 * Functions & Objects
		 */
		init: function(options)
		{
			this.setRequest();
		},
    	
		setRequest: function(){
		    var reqPath = location.href.substring(7);
		    siteData.req.path  = reqPath;
		    siteData.req.route = reqPath.split('/');
		},

		getIfSetProperty: function(obj, path){
		    var p = path.split('.');
		    var o = obj;
		    
		    for (var i in p) {
		    	if(p.hasOwnProperty(i)){ 
		        	var oo = eval('o.' + p[i]);
		            switch (typeof oo) {
		                case 'object':
		                    //continue
		                    o = oo;
		                    break;
		                    
		                case 'string':
		                case 'int':
		                case 'array':
		                    return oo;
		                    
		                case 'undefined':
		                    return false;
		            }
		    	}
		    }
		},

		getSiteProfileByLotToken: function(lotToken)
		{
			var p;
			var r;
			
		    if(lotToken != ''){
		        if(lotToken.indexOf('|') > -1){
		            p = lotToken.split('|');
		            r = Math.floor(Math.random()*p.length);
		            return this.getSiteProfileByLotToken(p[r]);
		        }
		        else{
		            if(typeof siteData.profiles.profiles != 'undefined'){
		                p = siteData.profiles.profiles;
		                if(p){
		                    for (var i in p.profile) {
		                        if(p.profile[i].sitetoken == lotToken){
		                            return p.profile[i];
		                        }
		                    }
		                }
		            }
		        }
		    }
		    
		    return false;
		},

		goToSearch: function()
		{
			toConsole('Called $.PMM.goToSearch()');
			
			var doNewFormat = true;
			var req = (arguments[0]) ? arguments[0] : false;
		
			if(req === 'search'){
				var v = {};
				v.status = (arguments[1]) ? arguments[1] : false;
				v.make   = (arguments[2]) ? arguments[2] : false;
				v.model  = (arguments[3]) ? arguments[3] : false;
		
				var trim = (arguments[4]) ? arguments[4] : false;
				
				toConsole('Make: ' + v.make);
				toConsole('Model: ' + v.model);
				toConsole('Trim: ' + trim);
				
				var qs = '';
		
				var href;
				if(doNewFormat){
					href = '/vehicle/search/';
					for ( var idx in v ) {
						if(v[idx]){
							href += v[idx] + '/';
						}
					}
		
					if(qs.length !== 0){
						href += '?' + qs;
					}
				}
				else{
					href = '/inv_new.php?vStatus=1&vMake=' + v.make + '&vModel=' + v.model;
		
					if(qs.length !== 0){
						href += qs;
					}
				}
		
				window.location.href = href;
			}
		}
};

_app._pmm._googleAnalytics = { // mimic GA object schema so that we can do local qualification before invocation
	vo:{
	    linkerUrl:null,
	    opt_pageURL:''
	},
	
	pageTracker:{
		_link: function(href){
		    if(typeof pageTracker == 'object'){ // then _gat is loaded and assigned
		    	toConsole('SUCCESS running pageTracker._link');
		        pageTracker._link(href);
		    }
		    else{
		    	toConsole('FAILED to run pageTracker._link');
		    }
	    },
	    
	    _trackPageview: function(){
	    	pageTracker._trackPageview(this.opt_pageURL);
	    }
	},
	
	prepare:function(settings)
	{
		for(var i in settings){
			if(settings.hasOwnProperty(i)){ 
		        this.vo.i = settings[i];
			}
		}	
	},
	
	prepareLink:function(href){  
		toConsole('Preparing link');
	    this.vo.linkerUrl = pageTracker._getLinkerUrl(href);
	}
	
};

function toConsole(msg){
    if((window.console && siteData.isENM) || (_app._pmm._hasConsole)) {
        if(($.browser.mozilla) || ($.browser.webkit)){
            console.info(msg);
        }
    }
}

/* Collect Google Analytics Event Calls */
function doTrackEvent(trackerToken){
	if(siteData.siteToken == 'cerritosautosquare'){
		var c = trackerToken.split('-');
		_gaq.push([c[0], c[1].replace(/_/g,' '), c[2], c[3]]);
	}
}

function clearCookie (cookie)
{
    if($.cookie){
        $.cookie(cookie,null);
        toConsole('Cookie Removed: ' + cookie);
    }
}

function clone(o){
    if(typeof(o) != 'object') return o;
    if(o == null) return o;

    var O = new Object();

    for(var i in o){
    	if(o.hasOwnProperty(i)){
            O[i] = clone(o[i]);
    	}
    }

    return O;
}

function isNumber(n) {
  return !isNaN(parseFloat(n)) && isFinite(n);
}


function getdigits (s) {
    return s.replace (/[^\d]/g, "");
}

if(typeof String.prototype.trim !== 'function') {
  String.prototype.trim = function() {
    //return this.replace(/^\s+|\s+$/g, '');
    return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
  }
}


$(document).ready(function(){
	if((window.console && siteData.isENM) || (window.console && ($('body').hasClass('staging')))) {
	    _app._pmm._hasConsole = true;
	}
	
    _app._pmm.init();
    
    if($('ul.jd_menu').length > 0){
    	toConsole('Main Nav Loaded');
    	if(_IS_TOUCH){
    		$('ul.jd_menu').jdMenu({disableLinks:true});
    	}
    	else{
    		$('ul.jd_menu').jdMenu({disableLinks:false});
    	}
    }
    
    $('a.print').bind('click',function(){
		window.print();
		return false;
    });
    
    var isAlt = false; 
    var key   = {"alt":18,"a":65};
    $(document).bind('keyup',function (e) { 
        if(e.which == key['alt']) isAlt=false; 
    });
    
    $(document).bind('keydown',function (e) {
        if(e.which == key['alt']){
        	isAlt=true;
        } 
        if(e.which == key['a'] && isAlt == true) { 
        	$('#adminLogin').triggerHandler('click');
        	return false; 
        } 
    });
    
    
});



