//===============================================
// OVER LABELS
//===============================================
function initOverLabels() {
	if (!document.getElementById) return;

	var labels, id, field;

	// Set focus and blur handlers to hide and show labels with 'overlabel' class names.
	labels = document.getElementsByTagName('label');
	for (var i = 0; i < labels.length; i++) {

		if (labels[i].className == 'overlabel') {
			// Skip labels that do not have a named association with another field.
			id = labels[i].htmlFor || labels[i].getAttribute('for');

			if (!id || !(field = document.getElementById(id))) {
				continue;
			}

			// Change the applied class to hover the label over the form field.
			labels[i].className = 'overlabel-apply';

			// Hide any fields having an initial value.
			if (field.value !== '') {
				hideLabel(field.getAttribute('id'), true);
			}

			// Set handlers to show and hide labels.
			field.onfocus = function () {
				hideLabel(this.getAttribute('id'), true);
			};

			field.onblur = function () {
				if (this.value === '') {
					hideLabel(this.getAttribute('id'), false);
				}
			};

			// Handle clicks to label elements (for Safari).
			labels[i].onclick = function () {
				var id, field;
				id = this.getAttribute('for');

				if (id && (field = document.getElementById(id))) {
					field.focus();
				}
			};
		}
	}
};

function hideLabel (field_id, hide) {
	var field_for;
	var labels = document.getElementsByTagName('label');

	for (var i = 0; i < labels.length; i++) {
		field_for = labels[i].htmlFor || labels[i].getAttribute('for');

		if (field_for == field_id) {
			labels[i].style.textIndent = (hide) ? '-9999px' : '0px';
			return true;
		}
	}
}

window.onload = function () {
	setTimeout(initOverLabels, 50);
};

// jQuery Upload Crop images
jQuery.imgAreaSelect=function(img,options){var $area=jQuery('<div></div>'),$border1=jQuery('<div></div>'),$border2=jQuery('<div></div>'),imgOfs,imgWidth,imgHeight,startX,startY,moveX,moveY,resizeMargin=10,resize=[],V=0,H=1,d,aspectRatio,x1,x2,y1,y2,x,y,selection={x1:0,y1:0,x2:0,y2:0,width:0,height:0};var $a=$area.add($border1).add($border2);function areaMouseMove(event){x=event.pageX-selection.x1-imgOfs.left;y=event.pageY-selection.y1-imgOfs.top;resize=[];if(options.resizable){if(y<=resizeMargin)resize[V]='n';else if(y>=selection.height-resizeMargin)resize[V]='s';if(x<=resizeMargin)resize[H]='w';else if(x>=selection.width-resizeMargin)resize[H]='e'}$border2.css('cursor',resize.length?resize.join('')+'-resize':options.movable?'move':'')}function areaMouseDown(event){if(event.which!=1)return false;if(options.resizable&&resize.length>0){$('body').css('cursor',resize.join('')+'-resize');x1=(resize[H]=='w'?selection.x2:selection.x1)+imgOfs.left;y1=(resize[V]=='n'?selection.y2:selection.y1)+imgOfs.top;jQuery(document).mousemove(selectingMouseMove);$border2.unbind('mousemove',areaMouseMove);jQuery(document).one('mouseup',function(){resize=[];$('body').css('cursor','');if(options.autoHide)$a.hide();options.onSelectEnd(img,selection);jQuery(document).unbind('mousemove',selectingMouseMove);$border2.mousemove(areaMouseMove)})}else if(options.movable){moveX=selection.x1+imgOfs.left;moveY=selection.y1+imgOfs.top;startX=event.pageX;startY=event.pageY;jQuery(document).mousemove(movingMouseMove).one('mouseup',function(){options.onSelectEnd(img,selection);jQuery(document).unbind('mousemove',movingMouseMove)})}else jQuery(img).mousedown(event);return false}function aspectRatioXY(){x2=Math.max(imgOfs.left,Math.min(imgOfs.left+imgWidth,x1+Math.abs(y2-y1)*aspectRatio*(x2>x1?1:-1)));y2=Math.round(Math.max(imgOfs.top,Math.min(imgOfs.top+imgHeight,y1+Math.abs(x2-x1)/aspectRatio*(y2>y1?1:-1))));x2=Math.round(x2)}function aspectRatioYX(){y2=Math.max(imgOfs.top,Math.min(imgOfs.top+imgHeight,y1+Math.abs(x2-x1)/aspectRatio*(y2>y1?1:-1)));x2=Math.round(Math.max(imgOfs.left,Math.min(imgOfs.left+imgWidth,x1+Math.abs(y2-y1)*aspectRatio*(x2>x1?1:-1))));y2=Math.round(y2)}function selectingMouseMove(event){x2=!resize.length||resize[H]||aspectRatio?event.pageX:selection.x2+imgOfs.left;y2=!resize.length||resize[V]||aspectRatio?event.pageY:selection.y2+imgOfs.top;if(options.minWidth&&Math.abs(x2-x1)<options.minWidth){x2=x1-options.minWidth*(x2<x1?1:-1);if(x2<imgOfs.left)x1=imgOfs.left+options.minWidth;else if(x2>imgOfs.left+imgWidth)x1=imgOfs.left+imgWidth-options.minWidth}if(options.minHeight&&Math.abs(y2-y1)<options.minHeight){y2=y1-options.minHeight*(y2<y1?1:-1);if(y2<imgOfs.top)y1=imgOfs.top+options.minHeight;else if(y2>imgOfs.top+imgHeight)y1=imgOfs.top+imgHeight-options.minHeight}x2=Math.max(imgOfs.left,Math.min(x2,imgOfs.left+imgWidth));y2=Math.max(imgOfs.top,Math.min(y2,imgOfs.top+imgHeight));if(aspectRatio)if(Math.abs(x2-x1)/aspectRatio>Math.abs(y2-y1))aspectRatioYX();else aspectRatioXY();if(options.maxWidth&&Math.abs(x2-x1)>options.maxWidth){x2=x1-options.maxWidth*(x2<x1?1:-1);if(aspectRatio)aspectRatioYX()}if(options.maxHeight&&Math.abs(y2-y1)>options.maxHeight){y2=y1-options.maxHeight*(y2<y1?1:-1);if(aspectRatio)aspectRatioXY()}selection.x1=Math.min(x1,x2)-imgOfs.left;selection.x2=Math.max(x1,x2)-imgOfs.left;selection.y1=Math.min(y1,y2)-imgOfs.top;selection.y2=Math.max(y1,y2)-imgOfs.top;selection.width=Math.abs(x2-x1);selection.height=Math.abs(y2-y1);$a.css({left:(selection.x1+imgOfs.left)+'px',top:(selection.y1+imgOfs.top)+'px',width:Math.max(selection.width-options.borderWidth*2,0)+'px',height:Math.max(selection.height-options.borderWidth*2,0)+'px'});options.onSelectChange(img,selection);return false}function movingMouseMove(event){x1=Math.max(imgOfs.left,Math.min(moveX+event.pageX-startX,imgOfs.left+imgWidth-selection.width));y1=Math.max(imgOfs.top,Math.min(moveY+event.pageY-startY,imgOfs.top+imgHeight-selection.height));x2=x1+selection.width;y2=y1+selection.height;selection.x1=x1-imgOfs.left;selection.y1=y1-imgOfs.top;selection.x2=x2-imgOfs.left;selection.y2=y2-imgOfs.top;$a.css({left:x1+'px',top:y1+'px',width:Math.max(x2-x1-options.borderWidth*2,0)+'px',height:Math.max(y2-y1-options.borderWidth*2,0)+'px'});options.onSelectChange(img,selection);event.preventDefault();return false}this.setOptions=function(newOptions){options=jQuery.extend(options,newOptions);if(newOptions.x1!=null){x1=(selection.x1=newOptions.x1)+imgOfs.left;y1=(selection.y1=newOptions.y1)+imgOfs.top;x2=(selection.x2=newOptions.x2)+imgOfs.left;y2=(selection.y2=newOptions.y2)+imgOfs.top;selection.width=x2-x1;selection.height=y2-y1;$a.show().css({left:x1+'px',top:y1+'px',width:Math.max(x2-x1-options.borderWidth*2,0)+'px',height:Math.max(y2-y1-options.borderWidth*2,0)+'px'});options.onSelectChange(img,selection)}if(newOptions.hide)$a.hide();else if(newOptions.show)$a.show();$a.css({borderWidth:options.borderWidth+'px'});$area.css({backgroundColor:options.selectionColor,opacity:options.selectionOpacity});$border1.css({borderStyle:'solid',borderColor:options.borderColor1});$border2.css({borderStyle:'dashed',borderColor:options.borderColor2});aspectRatio=options.aspectRatio&&(d=options.aspectRatio.split(/:/))?d[0]/d[1]:null};imgWidth=jQuery(img).width();imgHeight=jQuery(img).height();imgOfs=jQuery(img).offset();if(jQuery.browser.msie)jQuery(img).attr('unselectable','on');$a.css({display:'none',position:'absolute',lineHeight:'0px',fontSize:'0px'});$area.css({borderStyle:'solid'});jQuery('body').append($a);initOptions={borderColor1:'#000',borderColor2:'#fff',borderWidth:1,movable:true,resizable:true,selectionColor:'#fff',selectionOpacity:0.2,onSelectStart:function(){},onSelectChange:function(){},onSelectEnd:function(){}};options=jQuery.extend(initOptions,options);this.setOptions(options);if(options.resizable||options.movable)$a.mousemove(areaMouseMove).mousedown(areaMouseDown);jQuery(img).mousedown(function(event){if(event.which!=1)return false;startX=x1=event.pageX;startY=y1=event.pageY;resize=[];$a.show().css({width:'0px',height:'0px',left:x1,top:y1});jQuery(document).mousemove(selectingMouseMove);$border2.unbind('mousemove',areaMouseMove);selection.x1=selection.x2=x1-imgOfs.left;selection.y1=selection.y2=y1-imgOfs.top;options.onSelectStart(img,selection);jQuery(document).one('mouseup',function(){if(options.autoHide)$a.hide();options.onSelectEnd(img,selection);jQuery(document).unbind('mousemove',selectingMouseMove);$border2.mousemove(areaMouseMove)});return false})};jQuery.fn.imgAreaSelect=function(options){options=options||{};this.each(function(){if(jQuery(this).data('imgAreaSelect'))jQuery(this).data('imgAreaSelect').setOptions(options);else jQuery(this).data('imgAreaSelect',new jQuery.imgAreaSelect(this,options))});return this};

// ColorBox v1.3.9 - a full featured, light-weight, customizable lightbox based on jQuery 1.3
// c) 2009 Jack Moore - www.colorpowered.com - jack@colorpowered.com
// Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
// (function(b,gb){var v="none",t="click",N="LoadedContent",d=false,x="resize.",o="y",u="auto",f=true,M="nofollow",q="on",n="x";function e(a,c){a=a?' id="'+k+a+'"':"";c=c?' style="'+c+'"':"";return b("<div"+a+c+"/>")}function p(a,b){b=b===n?m.width():m.height();return typeof a==="string"?Math.round(a.match(/%/)?b/100*parseInt(a,10):parseInt(a,10)):a}function Q(c){c=b.isFunction(c)?c.call(h):c;return a.photo||c.match(/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i)}function cb(){for(var c in a)if(b.isFunction(a[c])&&c.substring(0,2)!==q)a[c]=a[c].call(h);a.rel=a.rel||h.rel||M;a.href=a.href||b(h).attr("href");a.title=a.title||h.title}function db(d){h=d;a=b.extend({},b(h).data(r));cb();if(a.rel!==M){i=b("."+H).filter(function(){return (b(this).data(r).rel||this.rel)===a.rel});g=i.index(h);if(g===-1){i=i.add(h);g=i.length-1}}else{i=b(h);g=0}if(!w){w=F=f;R=h;try{R.blur()}catch(e){}b.event.trigger(hb);a.onOpen&&a.onOpen.call(h);y.css({opacity:+a.opacity,cursor:a.overlayClose?"pointer":u}).show();a.w=p(a.initialWidth,n);a.h=p(a.initialHeight,o);c.position(0);S&&m.bind(x+O+" scroll."+O,function(){y.css({width:m.width(),height:m.height(),top:m.scrollTop(),left:m.scrollLeft()})}).trigger("scroll."+O)}T.add(I).add(J).add(z).add(U).hide();V.html(a.close).show();c.slideshow();c.load()}var eb={transition:"elastic",speed:300,width:d,initialWidth:"600",innerWidth:d,maxWidth:d,height:d,initialHeight:"450",innerHeight:d,maxHeight:d,scalePhotos:f,scrolling:f,inline:d,html:d,iframe:d,photo:d,href:d,title:d,rel:d,opacity:.9,preloading:f,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:d,loop:f,slideshow:d,slideshowAuto:f,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",onOpen:d,onLoad:d,onComplete:d,onCleanup:d,onClosed:d,overlayClose:f,escKey:f,arrowKey:f},r="colorbox",k="cbox",hb=k+"_open",P=k+"_load",W=k+"_complete",X=k+"_cleanup",fb=k+"_closed",G=b.browser.msie&&!b.support.opacity,S=G&&b.browser.version<7,O=k+"_IE6",y,j,E,s,Y,Z,ab,bb,i,m,l,K,L,U,T,z,J,I,V,C,D,A,B,h,R,g,a,w,F,c,H=k+"Element";c=b.fn[r]=b[r]=function(c,d){var a=this;if(!a[0]&&a.selector)return a;c=c||{};if(d)c.onComplete=d;if(!a[0]||a.selector===undefined){a=b("<a/>");c.open=f}a.each(function(){b(this).data(r,b.extend({},b(this).data(r)||eb,c)).addClass(H)});c.open&&db(a[0]);return a};c.init=function(){var h="hover";m=b(gb);j=e().attr({id:r,"class":G?k+"IE":""});y=e("Overlay",S?"position:absolute":"").hide();E=e("Wrapper");s=e("Content").append(l=e(N,"width:0; height:0"),L=e("LoadingOverlay").add(e("LoadingGraphic")),U=e("Title"),T=e("Current"),J=e("Next"),I=e("Previous"),z=e("Slideshow"),V=e("Close"));E.append(e().append(e("TopLeft"),Y=e("TopCenter"),e("TopRight")),e().append(Z=e("MiddleLeft"),s,ab=e("MiddleRight")),e().append(e("BottomLeft"),bb=e("BottomCenter"),e("BottomRight"))).children().children().css({"float":"left"});K=e(d,"position:absolute; width:9999px; visibility:hidden; display:none");b("body").prepend(y,j.append(E,K));s.children().hover(function(){b(this).addClass(h)},function(){b(this).removeClass(h)}).addClass(h);C=Y.height()+bb.height()+s.outerHeight(f)-s.height();D=Z.width()+ab.width()+s.outerWidth(f)-s.width();A=l.outerHeight(f);B=l.outerWidth(f);j.css({"padding-bottom":C,"padding-right":D}).hide();J.click(c.next);I.click(c.prev);V.click(c.close);s.children().removeClass(h);b("."+H).live(t,function(a){if(a.button!==0&&typeof a.button!=="undefined"||a.ctrlKey||a.shiftKey||a.altKey)return f;else{db(this);return d}});y.click(function(){a.overlayClose&&c.close()});b(document).bind("keydown",function(b){if(w&&a.escKey&&b.keyCode===27){b.preventDefault();c.close()}if(w&&a.arrowKey&&!F&&i[1])if(b.keyCode===37&&(g||a.loop)){b.preventDefault();I.click()}else if(b.keyCode===39&&(g<i.length-1||a.loop)){b.preventDefault();J.click()}})};c.remove=function(){j.add(y).remove();b("."+H).die(t).removeData(r).removeClass(H)};c.position=function(f,b){function c(a){Y[0].style.width=bb[0].style.width=s[0].style.width=a.style.width;L[0].style.height=L[1].style.height=s[0].style.height=Z[0].style.height=ab[0].style.height=a.style.height}var e,h=Math.max(m.height()-a.h-A-C,0)/2+m.scrollTop(),g=Math.max(m.width()-a.w-B-D,0)/2+m.scrollLeft();e=j.width()===a.w+B&&j.height()===a.h+A?0:f;E[0].style.width=E[0].style.height="9999px";j.dequeue().animate({width:a.w+B,height:a.h+A,top:h,left:g},{duration:e,complete:function(){c(this);F=d;E[0].style.width=a.w+B+D+"px";E[0].style.height=a.h+A+C+"px";b&&b()},step:function(){c(this)}})};c.resize=function(b){if(w){b=b||{};if(b.width)a.w=p(b.width,n)-B-D;if(b.innerWidth)a.w=p(b.innerWidth,n);l.css({width:a.w});if(b.height)a.h=p(b.height,o)-A-C;if(b.innerHeight)a.h=p(b.innerHeight,o);if(!b.innerHeight&&!b.height){b=l.wrapInner("<div style='overflow:auto'></div>").children();a.h=b.height();b.replaceWith(b.children())}l.css({height:a.h});c.position(a.transition===v?0:a.speed)}};c.prep=function(o){var d="hidden";function n(t){var o,q,s,n,d=i.length,e=a.loop;c.position(t,function(){function t(){G&&j[0].style.removeAttribute("filter")}if(w){G&&p&&l.fadeIn(100);a.iframe&&b("<iframe frameborder=0"+(a.scrolling?"":" scrolling='no'")+(G?" allowtransparency='true'":"")+"/>").attr({src:a.href,name:(new Date).getTime()}).appendTo(l);l.show();U.show().html(a.title);if(d>1){T.html(a.current.replace(/\{current\}/,g+1).replace(/\{total\}/,d)).show();J[e||g<d-1?"show":"hide"]().html(a.next);I[e||g?"show":"hide"]().html(a.previous);o=g?i[g-1]:i[d-1];s=g<d-1?i[g+1]:i[0];if(a.slideshow){z.show();g===d-1&&!e&&j.is("."+k+"Slideshow_on")&&z.click()}if(a.preloading){n=b(s).data(r).href||s.href;q=b(o).data(r).href||o.href;if(Q(n))b("<img/>")[0].src=n;if(Q(q))b("<img/>")[0].src=q}}L.hide();a.transition==="fade"?j.fadeTo(f,1,function(){t()}):t();m.bind(x+k,function(){c.position(0)});b.event.trigger(W);a.onComplete&&a.onComplete.call(h)}})}if(w){var p,f=a.transition===v?0:a.speed;m.unbind(x+k);l.remove();l=e(N).html(o);l.hide().appendTo(K.show()).css({width:function(){a.w=a.w||l.width();a.w=a.mw&&a.mw<a.w?a.mw:a.w;return a.w}(),overflow:a.scrolling?u:d}).css({height:function(){a.h=a.h||l.height();a.h=a.mh&&a.mh<a.h?a.mh:a.h;return a.h}()}).prependTo(s);K.hide();b("#"+k+"Photo").css({cssFloat:v});S&&b("select").not(j.find("select")).filter(function(){return this.style.visibility!==d}).css({visibility:d}).one(X,function(){this.style.visibility="inherit"});a.transition==="fade"?j.fadeTo(f,0,function(){n(0)}):n(f)}};c.load=function(){var j,d,q,m=c.prep;F=f;h=i[g];a=b.extend({},b(h).data(r));cb();b.event.trigger(P);a.onLoad&&a.onLoad.call(h);a.h=a.height?p(a.height,o)-A-C:a.innerHeight&&p(a.innerHeight,o);a.w=a.width?p(a.width,n)-B-D:a.innerWidth&&p(a.innerWidth,n);a.mw=a.w;a.mh=a.h;if(a.maxWidth){a.mw=p(a.maxWidth,n)-B-D;a.mw=a.w&&a.w<a.mw?a.w:a.mw}if(a.maxHeight){a.mh=p(a.maxHeight,o)-A-C;a.mh=a.h&&a.h<a.mh?a.h:a.mh}j=a.href;L.show();if(a.inline){e("InlineTemp").hide().insertBefore(b(j)[0]).bind(P+" "+X,function(){b(this).replaceWith(l.children())});m(b(j))}else if(a.iframe)m(" ");else if(a.html)m(a.html);else if(Q(j)){d=new Image;d.onload=function(){var e;d.onload=null;d.id=k+"Photo";b(d).css({margin:u,border:v,display:"block",cssFloat:"left"});if(a.scalePhotos){q=function(){d.height-=d.height*e;d.width-=d.width*e};if(a.mw&&d.width>a.mw){e=(d.width-a.mw)/d.width;q()}if(a.mh&&d.height>a.mh){e=(d.height-a.mh)/d.height;q()}}if(a.h)d.style.marginTop=Math.max(a.h-d.height,0)/2+"px";setTimeout(function(){m(d)},1);i[1]&&(g<i.length-1||a.loop)&&b(d).css({cursor:"pointer"}).click(c.next);if(G)d.style.msInterpolationMode="bicubic"};d.src=j}else e().appendTo(K).load(j,function(c,a,b){m(a==="error"?"Request unsuccessful: "+b.statusText:this)})};c.next=function(){if(!F){g=g<i.length-1?g+1:0;c.load()}};c.prev=function(){if(!F){g=g?g-1:i.length-1;c.load()}};c.slideshow=function(){function f(){z.text(a.slideshowStop).bind(W,function(){d=setTimeout(c.next,a.slideshowSpeed)}).bind(P,function(){clearTimeout(d)}).one(t,function(){e()});j.removeClass(b+"off").addClass(b+q)}var e,d,b=k+"Slideshow_";z.bind(fb,function(){z.unbind();clearTimeout(d);j.removeClass(b+"off "+b+q)});e=function(){clearTimeout(d);z.text(a.slideshowStart).unbind(W+" "+P).one(t,function(){f();d=setTimeout(c.next,a.slideshowSpeed)});j.removeClass(b+q).addClass(b+"off")};if(a.slideshow&&i[1])a.slideshowAuto?f():e()};c.close=function(){if(w){w=d;b.event.trigger(X);a.onCleanup&&a.onCleanup.call(h);m.unbind("."+k+" ."+O);y.fadeTo("fast",0);j.stop().fadeTo("fast",0,function(){j.find("iframe").attr("src","about:blank");l.remove();j.add(y).css({opacity:1,cursor:u}).hide();try{R.focus()}catch(c){}setTimeout(function(){b.event.trigger(fb);a.onClosed&&a.onClosed.call(h)},1)})}};c.element=function(){return b(h)};c.settings=eb;b(c.init)})(jQuery,this)

// ColorBox v1.3.16 - a full featured, light-weight, customizable lightbox based on jQuery 1.3+
// Copyright (c) 2011 Jack Moore - jack@colorpowered.com
// Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
(function(a,b,c){function ba(b){if(!T){O=b,Z(a.extend(J,a.data(O,e))),x=a(O),P=0,J.rel!=="nofollow"&&(x=a("."+V).filter(function(){var b=a.data(this,e).rel||this.rel;return b===J.rel}),P=x.index(O),P===-1&&(x=x.add(O),P=x.length-1));if(!R){R=S=!0,q.show();if(J.returnFocus)try{O.blur(),a(O).one(k,function(){try{this.focus()}catch(a){}})}catch(c){}p.css({opacity:+J.opacity,cursor:J.overlayClose?"pointer":"auto"}).show(),J.w=X(J.initialWidth,"x"),J.h=X(J.initialHeight,"y"),U.position(0),n&&y.bind("resize."+o+" scroll."+o,function(){p.css({width:y.width(),height:y.height(),top:y.scrollTop(),left:y.scrollLeft()})}).trigger("resize."+o),$(g,J.onOpen),I.add(C).hide(),H.html(J.close).show()}U.load(!0)}}function _(){var a,b=f+"Slideshow_",c="click."+f,d,e,g;J.slideshow&&x[1]&&(d=function(){E.text(J.slideshowStop).unbind(c).bind(i,function(){if(P<x.length-1||J.loop)a=setTimeout(U.next,J.slideshowSpeed)}).bind(h,function(){clearTimeout(a)}).one(c+" "+j,e),q.removeClass(b+"off").addClass(b+"on"),a=setTimeout(U.next,J.slideshowSpeed)},e=function(){clearTimeout(a),E.text(J.slideshowStart).unbind([i,h,j,c].join(" ")).one(c,d),q.removeClass(b+"on").addClass(b+"off")},J.slideshowAuto?d():e())}function $(b,c){c&&c.call(O),a.event.trigger(b)}function Z(b){for(var c in b)a.isFunction(b[c])&&c.substring(0,2)!=="on"&&(b[c]=b[c].call(O));b.rel=b.rel||O.rel||"nofollow",b.href=a.trim(b.href||a(O).attr("href")),b.title=b.title||O.title}function Y(a){return J.photo||/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i.test(a)}function X(a,b){b=b==="x"?y.width():y.height();return typeof a=="string"?Math.round(/%/.test(a)?b/100*parseInt(a,10):parseInt(a,10)):a}function W(c,d){var e=b.createElement("div");c&&(e.id=f+c),e.style.cssText=d||!1;return a(e)}var d={transition:"none",speed:300,width:!1,initialWidth:"455",innerWidth:!1,maxWidth:!1,height:!1,initialHeight:"382",innerHeight:!1,maxHeight:!1,scalePhotos:!0,scrolling:!0,inline:!1,html:!1,iframe:!1,fastIframe:!0,photo:!1,href:!1,title:!1,rel:!1,opacity:.9,preloading:!0,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:!1,returnFocus:!0,loop:!0,slideshow:!1,slideshowAuto:!0,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",onOpen:!1,onLoad:!1,onComplete:!1,onCleanup:!1,onClosed:!1,overlayClose:!0,escKey:!0,arrowKey:!0},e="colorbox",f="cbox",g=f+"_open",h=f+"_load",i=f+"_complete",j=f+"_cleanup",k=f+"_closed",l=f+"_purge",m=a.browser.msie&&!a.support.opacity,n=m&&a.browser.version<7,o=f+"_IE6",p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J={},K,L,M,N,O,P,Q,R,S,T=!1,U,V=f+"Element";U=a.fn[e]=a[e]=function(b,c){var f=this,g;if(!f[0]&&f.selector)return f;b=b||{},c&&(b.onComplete=c);if(!f[0]||f.selector===undefined)f=a("<a/>"),b.open=!0;f.each(function(){a.data(this,e,a.extend({},a.data(this,e)||d,b)),a(this).addClass(V)}),g=b.open,a.isFunction(g)&&(g=g.call(f)),g&&ba(f[0]);return f},U.init=function(){y=a(c),q=W().attr({id:e,"class":m?f+(n?"IE6":"IE"):""}),p=W("Overlay",n?"position:absolute":"").hide(),r=W("Wrapper"),s=W("Content").append(z=W("LoadedContent","width:0; height:0; overflow:hidden"),B=W("LoadingOverlay").add(W("LoadingGraphic")),C=W("Title"),D=W("Current"),F=W("Next"),G=W("Previous"),E=W("Slideshow").bind(g,_),H=W("Close")),r.append(W().append(W("TopLeft"),t=W("TopCenter"),W("TopRight")),W(!1,"clear:left").append(u=W("MiddleLeft"),s,v=W("MiddleRight")),W(!1,"clear:left").append(W("BottomLeft"),w=W("BottomCenter"),W("BottomRight"))).children().children().css({"float":"left"}),A=W(!1,"position:absolute; width:9999px; visibility:hidden; display:none"),a("body").prepend(p,q.append(r,A)),s.children().hover(function(){a(this).addClass("hover")},function(){a(this).removeClass("hover")}).addClass("hover"),K=t.height()+w.height()+s.outerHeight(!0)-s.height(),L=u.width()+v.width()+s.outerWidth(!0)-s.width(),M=z.outerHeight(!0),N=z.outerWidth(!0),q.css({"padding-bottom":K,"padding-right":L}).hide(),F.click(function(){U.next()}),G.click(function(){U.prev()}),H.click(function(){U.close()}),I=F.add(G).add(D).add(E),s.children().removeClass("hover"),a("."+V).live("click",function(a){a.button!==0&&typeof a.button!="undefined"||a.ctrlKey||a.shiftKey||a.altKey||(a.preventDefault(),ba(this))}),p.click(function(){J.overlayClose&&U.close()}),a(b).bind("keydown."+f,function(a){var b=a.keyCode;R&&J.escKey&&b===27&&(a.preventDefault(),U.close()),R&&J.arrowKey&&x[1]&&(b===37?(a.preventDefault(),G.click()):b===39&&(a.preventDefault(),F.click()))})},U.remove=function(){q.add(p).remove(),a("."+V).die("click").removeData(e).removeClass(V)},U.position=function(a,c){function g(a){t[0].style.width=w[0].style.width=s[0].style.width=a.style.width,B[0].style.height=B[1].style.height=s[0].style.height=u[0].style.height=v[0].style.height=a.style.height}var d,e=Math.max(b.documentElement.clientHeight-J.h-M-K,0)/2+y.scrollTop(),f=Math.max(y.width()-J.w-N-L,0)/2+y.scrollLeft();d=q.width()===J.w+N&&q.height()===J.h+M?0:a,r[0].style.width=r[0].style.height="9999px",q.dequeue().animate({width:J.w+N,height:J.h+M,top:e,left:f},{duration:d,complete:function(){g(this),S=!1,r[0].style.width=J.w+N+L+"px",r[0].style.height=J.h+M+K+"px",c&&c()},step:function(){g(this)}})},U.resize=function(a){if(R){a=a||{},a.width&&(J.w=X(a.width,"x")-N-L),a.innerWidth&&(J.w=X(a.innerWidth,"x")),z.css({width:J.w}),a.height&&(J.h=X(a.height,"y")-M-K),a.innerHeight&&(J.h=X(a.innerHeight,"y"));if(!a.innerHeight&&!a.height){var b=z.wrapInner("<div style='overflow:auto'></div>").children();J.h=b.height(),b.replaceWith(b.children())}z.css({height:J.h}),U.position(J.transition==="none"?0:J.speed)}},U.prep=function(b){function h(b){U.position(b,function(){var b,d,g,h,j=x.length,k,n;!R||(n=function(){B.hide(),$(i,J.onComplete)},m&&Q&&z.fadeIn(100),C.html(J.title).add(z).show(),j>1?(typeof J.current=="string"&&D.html(J.current.replace(/\{current\}/,P+1).replace(/\{total\}/,j)).show(),F[J.loop||P<j-1?"show":"hide"]().html(J.next),G[J.loop||P?"show":"hide"]().html(J.previous),b=P?x[P-1]:x[j-1],g=P<j-1?x[P+1]:x[0],J.slideshow&&E.show(),J.preloading&&(h=a.data(g,e).href||g.href,d=a.data(b,e).href||b.href,h=a.isFunction(h)?h.call(g):h,d=a.isFunction(d)?d.call(b):d,Y(h)&&(a("<img/>")[0].src=h),Y(d)&&(a("<img/>")[0].src=d))):I.hide(),J.iframe?(k=a("<iframe/>").addClass(f+"Iframe")[0],J.fastIframe?n():a(k).load(n),k.name=f+ +(new Date),k.src=J.href,J.scrolling||(k.scrolling="no"),m&&(k.frameBorder=0,k.allowTransparency="true"),a(k).appendTo(z).one(l,function(){k.src="//about:blank"})):n(),J.transition==="fade"?q.fadeTo(c,1,function(){q[0].style.filter=""}):q[0].style.filter="",y.bind("resize."+f,function(){U.position(0)}))})}function g(){J.h=J.h||z.height(),J.h=J.mh&&J.mh<J.h?J.mh:J.h;return J.h}function d(){J.w=J.w||z.width(),J.w=J.mw&&J.mw<J.w?J.mw:J.w;return J.w}if(!!R){var c=J.transition==="none"?0:J.speed;y.unbind("resize."+f),z.remove(),z=W("LoadedContent").html(b),z.hide().appendTo(A.show()).css({width:d(),overflow:J.scrolling?"auto":"hidden"}).css({height:g()}).prependTo(s),A.hide(),a(Q).css({"float":"none"}),n&&a("select").not(q.find("select")).filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one(j,function(){this.style.visibility="inherit"}),J.transition==="fade"?q.fadeTo(c,0,function(){h(0)}):h(c)}},U.load=function(b){var c,d,g=U.prep;S=!0,Q=!1,O=x[P],b||Z(a.extend(J,a.data(O,e))),$(l),$(h,J.onLoad),J.h=J.height?X(J.height,"y")-M-K:J.innerHeight&&X(J.innerHeight,"y"),J.w=J.width?X(J.width,"x")-N-L:J.innerWidth&&X(J.innerWidth,"x"),J.mw=J.w,J.mh=J.h,J.maxWidth&&(J.mw=X(J.maxWidth,"x")-N-L,J.mw=J.w&&J.w<J.mw?J.w:J.mw),J.maxHeight&&(J.mh=X(J.maxHeight,"y")-M-K,J.mh=J.h&&J.h<J.mh?J.h:J.mh),c=J.href,B.show(),J.inline?(W().hide().insertBefore(a(c)[0]).one(l,function(){a(this).replaceWith(z.children())}),g(a(c))):J.iframe?g(" "):J.html?g(J.html):Y(c)?(a(Q=new Image).addClass(f+"Photo").error(function(){J.title=!1,g(W("Error").text("This image could not be loaded"))}).load(function(){var a;Q.onload=null,J.scalePhotos&&(d=function(){Q.height-=Q.height*a,Q.width-=Q.width*a},J.mw&&Q.width>J.mw&&(a=(Q.width-J.mw)/Q.width,d()),J.mh&&Q.height>J.mh&&(a=(Q.height-J.mh)/Q.height,d())),J.h&&(Q.style.marginTop=Math.max(J.h-Q.height,0)/2+"px"),x[1]&&(P<x.length-1||J.loop)&&(Q.style.cursor="pointer",Q.onclick=function(){U.next()}),m&&(Q.style.msInterpolationMode="bicubic"),setTimeout(function(){g(Q)},1)}),setTimeout(function(){Q.src=c},1)):c&&A.load(c,function(b,c,d){g(c==="error"?W("Error").text("Request unsuccessful: "+d.statusText):a(this).contents())})},U.next=function(){!S&&x[1]&&(P<x.length-1||J.loop)&&(P=P<x.length-1?P+1:0,U.load())},U.prev=function(){!S&&x[1]&&(P||J.loop)&&(P=P?P-1:x.length-1,U.load())},U.close=function(){R&&!T&&(T=!0,R=!1,$(j,J.onCleanup),y.unbind("."+f+" ."+o),p.fadeTo(200,0),q.stop().fadeTo(300,0,function(){q.add(p).css({opacity:1,cursor:"auto"}).hide(),$(l),z.remove(),setTimeout(function(){T=!1,$(k,J.onClosed)},1)}))},U.element=function(){return a(O)},U.settings=d,a(U.init)})(jQuery,document,this);

//Elastic Plugin
(function(g){g.fn.extend({elastic:function(){var h=["paddingTop","paddingRight","paddingBottom","paddingLeft","fontSize","lineHeight","fontFamily","width","fontWeight"];return this.each(function(){function i(c,j){curratedHeight=Math.floor(parseInt(c,10));a.height()!=curratedHeight&&a.css({height:curratedHeight+"px",overflow:j})}function k(){var c=a.val().replace(/&/g,"&amp;").replace(/ /g,"&nbsp;").replace(/<|>/g,"&gt;").replace(/\n/g,"<br />"),j=b.html().replace(/<br>/ig,"<br />");if(c+"&nbsp;"!= j){b.html(c+"&nbsp;");if(Math.abs(b.height()+l-a.height())>3){c=b.height()+l;if(c>=d)i(d,"auto");else c<=e?i(e,"hidden"):i(c,"hidden")}}}if(this.type!="textarea")return false;var a=g(this),b=g("<div />").css({position:"absolute",display:"none","word-wrap":"break-word"}),l=parseInt(a.css("line-height"),10)||parseInt(a.css("font-size"),"10"),e=parseInt(a.css("height"),10)||l*3,d=parseInt(a.css("max-height"),10)||Number.MAX_VALUE,f=0;if(d<0)d=Number.MAX_VALUE;b.appendTo(a.parent());for(f=h.length;f--;)b.css(h[f].toString(), a.css(h[f].toString()));a.css({overflow:"hidden"});a.bind("keyup change cut paste",function(){k()});a.bind("blur",function(){if(b.height()<d)b.height()>e?a.height(b.height()):a.height(e)});a.live("input paste",function(){setTimeout(k,250)});k()})}})})(jQuery);

// jQuery functions
$(document).ready(function() {
	$('textarea').elastic();

	// Vote tabs
	var tabContainers = $('#votetabs #tabcon > div');
	tabContainers.hide().filter(':first').show();
	
	$('#votetabs ul.tabnav a').click(function() {
		tabContainers.hide();
		tabContainers.filter(this.hash).show();
		$('#votetabs ul.tabnav a').removeClass('selected');
		$(this).addClass('selected');
		return false;
	}).filter(':first').click();

	// If not logged in stalk button tool-tip
	$('#not-logged-in-stalk').click(function(e) {
		e.stopPropagation();
		$('.stalking-state .tooltip-hover').toggle();
	});
	$(document.body).click(function() {
		$('.stalking-state .tooltip-hover').hide();
	});
	
	// STALKING CAROUSEL TOOLTIP
	$('.stalkingCarousel .wrapper li').hover(function(e) {
		e.stopPropagation();
		$('.tooltip-hover', this).toggle();
	});
	// $(document.body).click(function() {
		// $('.stalking-state .tooltip-hover').hide();
	// });
	
	// PROFILE TABS
	var proContainers = $('.protabs #tabcon > div');
	// proContainers.hide().filter(':first').show();
	
	$('.protabs ul.tabnav a').click(function() {
		proContainers.hide();
		proContainers.filter(this.hash).show();
		// proContainers.fadeOut("fast").animate({opacity:1});
		// proContainers.filter(this.hash).slideDown().animate({opacity:1});
		
		$('.protabs ul.tabnav a').removeClass('selected');
		$(this).addClass('selected');
		return false;
	});
	// END PROFILE TABS

	
	// Drop Down Boxes
	// sign in box
	$("a.signin").click(function(e) {
		e.preventDefault();
		if($("a.signin").hasClass("openToggle")) {
			$("a.signin").removeClass("openToggle");
			$("#signin-form").hide();
		} else {
			$("#signin-form").show();
			$("a.signin").addClass("openToggle");
		}
	});
	$("#signin-form").mouseup(function() { return false; });
	$("a.signin").mouseup(function() { return false; });
	$(document).mouseup(function(e) {
		if($(e.target).parent("a.signin").length==0) {
			$("a.signin").removeClass("openToggle");
			$("#signin-form").hide();
		}
	});
	
	// account settings box
	$("a.account").click(function(e) {
		e.preventDefault();
		if($("a.account").hasClass("openToggle")) {
			$("a.account").removeClass("openToggle");
			$("#accountSettings").hide();
		} else {
			$("#accountSettings").show();
			$("a.account").addClass("openToggle");
		}
	});
	$("#accountSettings").mouseup(function() { return false; });
	$("a.account").mouseup(function() { return false; });
	$(document).mouseup(function(e) {
		if($(e.target).parent("a.account").length==0) {
			$("a.account").removeClass("openToggle");
			$("#accountSettings").hide();
		}
	});
	// end Drop Down Boxes
	
	$("a[name=popup]").colorbox({opacity: .4, title: true});

	//select all the a tag with name equal to modal
	
	// Submit comment
	$("#comment_submit").click(function(){
		$("#submit_comment span.postmsg").fadeOut(50);
		$("#submit_comment .submitbut").attr('disabled', 'disabled');
		// show the spinner
    	$('#submit_comment span.postmsg').append('<img src="../images/loader.gif" alt="Loading" id="loading" />');
		
		//the main ajax request
		var dataString = $("#comment_form").serialize();
		
		$.ajax({
			type: "POST",
			data: dataString,
			url: "/add_comment.php",
			timeout: 2000,
			cache: false,
			success: function(msg)
			{
				$("#loading").remove();
				$("#submit_comment span.postmsg").fadeIn(400);
				$("#submit_comment span.postmsg").html(msg);
				setTimeout("$('#submit_comment .submitbut').removeAttr('disabled', 'disabled');",2000);
				setTimeout("$('#submit_comment span.postmsg').fadeOut();",50000);
			}
		});
	return false;
	});
	
	// Edit post
	$("#uppost_submit").click(function(){
		$("#submit_comment .postmsg").fadeOut(50);
		$("#submit_comment .submitbut").attr('disabled', 'disabled');
		// show the spinner
		$('#submit_comment .postmsg').append('<img src="../images/loader.gif" alt="Loading" id="loading" />');
		
		//the main ajax request
		var dataString = $(".uppost_form").serialize();
		
		$.ajax({
			type: "POST",
			data: dataString,
			url: "/edit_post.php",
			timeout: 2000,
			cache: false,
			success: function(msg)
			{
				$("#loading").remove();
				$("#submit_comment .postmsg").fadeIn(400);
				$("#submit_comment .postmsg").html(msg);
				setTimeout("$('#submit_comment .submitbut').removeAttr('disabled', 'disabled');",2000);
				setTimeout("$('#submit_comment .postmsg').fadeOut();",50000);
			}
		});
	return false;
	});
	
	// Edit comment
	$("#upcomment_submit").click(function(){
		$("#submit_comment .postmsg").fadeOut(50);
		$("#submit_comment .submitbut").attr('disabled', 'disabled');
		// show the spinner
		$('#submit_comment .postmsg').append('<img src="../images/loader.gif" alt="Loading" id="loading" />');
		
		//the main ajax request
		var dataString = $(".upcomment_form").serialize();
		
		$.ajax({
			type: "POST",
			data: dataString,
			url: "/edit_comment.php",
			timeout: 2000,
			cache: false,
			success: function(msg)
			{
				$("#loading").remove();
				$("#submit_comment .postmsg").fadeIn(400);
				$("#submit_comment .postmsg").html(msg);
				setTimeout("$('#submit_comment .submitbut').removeAttr('disabled', 'disabled');",2000);
				setTimeout("$('#submit_comment .postmsg').fadeOut();",50000);
			}
		});
	return false;
	});
	
	$("#cboxClose").click(function(){
		$('.postmsg').slideUp("fast");
	});
	$("#cboxOverlay").click(function(){
		$('.postmsg').slideUp("fast");
	});
	$("#comment_reset").click(function(){
		$('#submit_comment .submitbut').removeAttr('disabled', 'disabled');
	});
	$("#reg_cancel").click(function(){
		$('#submit_register .submitbut').removeAttr('disabled', 'disabled');
	});
});

// Profile CAROUSEL
$.fn.stalkingCarousel = function () {

	// function repeat(str, num) {
		// return new Array( num + 1 ).join( str );
	// }
  
	return this.each(function () {
		var $wrapper = $('.stalkingCarousel .wrapper'),
			$slider = $wrapper.find('> ul'),
			$items = $slider.find('> li'),
			$single = $items.filter(':first'),
			
			singleWidth = $single.outerWidth(), 
			visible = Math.floor($wrapper.innerWidth() / singleWidth), // note: doesn't include padding or border
			currentPage = 1,
			pages = Math.ceil($items.length / visible);            


		// 1. Pad so that 'visible' number will always be seen, otherwise create empty items
		// if (($items.length % visible) != 0) {
			// $slider.append(repeat('<li class="empty" />', visible - ($items.length % visible)));
			// $items = $slider.find('> li');
		// }
		
		// 3. Set the left position to the first 'real' item
		// $wrapper.scrollLeft(singleWidth * visible);
		
		// 4. paging function
		function gotoPage(page) {
			var dir = page < currentPage ? -1 : 1,
					n = Math.abs(page - currentPage),
					left = singleWidth * dir * visible * n;
			
			$wrapper.filter(':not(:animated)').animate({
				scrollLeft : '+=' + left
			}, 500, function () {
				if (page == 0) {
					// $wrapper.scrollLeft(singleWidth * visible * pages);
					page = pages;
				} else if (page > pages) {
					// $wrapper.scrollLeft(singleWidth * visible);
					// reset back to start position
					page = 1;
				}

				currentPage = page;
			});                
			
			// return false;
		}
		
		// $wrapper.after(pages);
		
		if (currentPage == 1) {
			$('a.back', this).addClass('back-none');
		}
		
		if (currentPage == pages) {
			$('a.forward', this).addClass('forward-none');
		}
		
		// 5. Bind to the forward and back buttons
		$('a.back', this).live("click", function () {
			if (currentPage != 1 || currentPages != pages) {
				$('.stalkingCarousel .container a.forward').removeClass('forward-none');
			}
			
			if (currentPage == 2) {
				$(this).addClass('back-none');
				return gotoPage(currentPage - 1);
			} else if (currentPage > 2) {
				$(this).removeClass('back-none');
				return gotoPage(currentPage - 1);
			}
		});
		
		$('a.forward', this).live("click", function () {
			
			if (currentPage == pages) {
				$(this).addClass('forward-none');
			} else if (currentPage == pages - 1){
				$('.stalkingCarousel .container a.back').removeClass('back-none');
				$(this).addClass('forward-none');
				return gotoPage(currentPage + 1);
			} else if (currentPage == 1) {
				$('.stalkingCarousel .container a.back').removeClass('back-none');
				return gotoPage(currentPage + 1);
			}
						
		});
		
		// create a public interface to move to a specific page
		$(this).bind('goto', function (event, page) {
			gotoPage(page);
		});
	});  
};

$(document).ready(function () {
	$('.stalkingCarousel .container').stalkingCarousel();
});
			
