// jQuery Alert Dialogs Plugin
// jQuery.ScrollTo - Easy element scrolling using jQuery.
// FancyBox 1.3.1
// Auto-growing textareas
// FCBKcomplete 2.7.6
// auto fill input
// feed writer 1.2
// form validate 0.2
// swfobject
// jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
// jQuery Alert Dialogs Plugin
//
// Version 1.1
//
// Cory S.N. LaViska
// A Beautiful Site (http://abeautifulsite.net/)
// 14 May 2009
//
// Visit http://abeautifulsite.net/notebook/87 for more information
//
// Usage:
//		jAlert( message, [title, callback] )
//		jConfirm( message, [title, callback] )
//		jPrompt( message, [value, title, callback] )
// 
// History:
//
//		1.00 - Released (29 December 2008)
//
//		1.01 - Fixed bug where unbinding would destroy all resize events
//
// License:
// 
// This plugin is dual-licensed under the GNU General Public License and the MIT License and
// is copyright 2008 A Beautiful Site, LLC. 
//
(function($) {
	
	$.alerts = {
		
		// These properties can be read/written by accessing $.alerts.propertyName from your scripts at any time
		
		verticalOffset: -75,                // vertical offset of the dialog from center screen, in pixels
		horizontalOffset: 0,                // horizontal offset of the dialog from center screen, in pixels/
		repositionOnResize: true,           // re-centers the dialog on window resize
		overlayOpacity: .6,                // transparency level of overlay
		overlayColor: '#ccc',               // base color of overlay
		draggable: true,                    // make the dialogs draggable (requires UI Draggables plugin)
		okButton: '&nbsp;OK&nbsp;',         // text for the OK button
		cancelButton: '&nbsp;Cancel&nbsp;', // text for the Cancel button
		dialogClass: null,                  // if specified, this class will be applied to all dialogs
		
		// Public methods
		
		alert: function(message, title, callback) {
			if( title == null ) title = 'Alert';
			$.alerts._show(title, message, null, 'alert', function(result) {
				if( callback ) callback(result);
			});
		},
		
		confirm: function(message, title, callback) {
			if( title == null ) title = 'Confirm';
			$.alerts._show(title, message, null, 'confirm', function(result) {
				if( callback ) callback(result);
			});
		},
			
		prompt: function(message, value, title, callback) {
			if( title == null ) title = 'Prompt';
			$.alerts._show(title, message, value, 'prompt', function(result) {
				if( callback ) callback(result);
			});
		},
		
		// Private methods
		
		_show: function(title, msg, value, type, callback) {
			
			$.alerts._hide();
			$.alerts._overlay('show');
			
			$("BODY").append(
			  '<div id="popup_container">' +
			    '<div id="popup_content">' +
			      '<div id="popup_message"></div>' +
				'</div>' +
			  '</div>');
			
			if( $.alerts.dialogClass ) $("#popup_container").addClass($.alerts.dialogClass);
			
			// IE6 Fix
			var pos = ($.browser.msie && parseInt($.browser.version) <= 6 ) ? 'absolute' : 'fixed'; 
			
			$("#popup_container").css({
				position: pos,
				zIndex: 99999,
				padding: 0,
				margin: 0
			});
			
			$("#popup_title").text(title);
			$("#popup_content").addClass(type);
			$("#popup_message").text(msg);
			$("#popup_message").html( $("#popup_message").text().replace(/\n/g, '<br />') );
			
			$("#popup_container").css({
				minWidth: $("#popup_container").outerWidth(),
				maxWidth: $("#popup_container").outerWidth(),
				display : 'none'
			});
			
			$.alerts._reposition();
			$.alerts._maintainPosition(true);
			
			$("#popup_container").fadeIn(400);
			
			switch( type ) {
				case 'alert':
					$("#popup_message").after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton + '" id="popup_ok" /></div>');
					$("#popup_ok").click( function() {
						$.alerts._hide();
						callback(true);
					});
					$("#popup_ok").focus().keypress( function(e) {
						if( e.keyCode == 13 || e.keyCode == 27 ) $("#popup_ok").trigger('click');
					});
				break;
				case 'confirm':
					$("#popup_message").after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton + '" id="popup_ok" /> <input type="button" value="' + $.alerts.cancelButton + '" id="popup_cancel" /></div>');
					$("#popup_ok").click( function() {
						$.alerts._hide();
						if( callback ) callback(true);
					});
					$("#popup_cancel").click( function() {
						$.alerts._hide();
						if( callback ) callback(false);
					});
					$("#popup_ok").focus();
					$("#popup_ok, #popup_cancel").keypress( function(e) {
						if( e.keyCode == 13 ) $("#popup_ok").trigger('click');
						if( e.keyCode == 27 ) $("#popup_cancel").trigger('click');
					});
				break;
				case 'prompt':
					$("#popup_message").append('<br /><input type="text" size="30" id="popup_prompt" />').after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton + '" id="popup_ok" /> <input type="button" value="' + $.alerts.cancelButton + '" id="popup_cancel" /></div>');
					$("#popup_prompt").width( $("#popup_message").width() );
					$("#popup_ok").click( function() {
						var val = $("#popup_prompt").val();
						$.alerts._hide();
						if( callback ) callback( val );
					});
					$("#popup_cancel").click( function() {
						$.alerts._hide();
						if( callback ) callback( null );
					});
					$("#popup_prompt, #popup_ok, #popup_cancel").keypress( function(e) {
						if( e.keyCode == 13 ) $("#popup_ok").trigger('click');
						if( e.keyCode == 27 ) $("#popup_cancel").trigger('click');
					});
					if( value ) $("#popup_prompt").val(value);
					$("#popup_prompt").focus().select();
				break;
			}
			
			// Make draggable
			if( $.alerts.draggable ) {
				try {
					$("#popup_container").draggable({ handle: $("#popup_title") });
					$("#popup_title").css({ cursor: 'move' });
				} catch(e) { /* requires jQuery UI draggables */ }
			}
		},
		
		_hide: function() {
			$("#popup_container").fadeOut(500, function(){ $(this).remove(); });
			$.alerts._overlay('hide');
			$.alerts._maintainPosition(false);
		},
		
		_overlay: function(status) {
			switch( status ) {
				case 'show':
					$.alerts._overlay('hide');
					$("BODY").append('<div id="popup_overlay"></div>');
					$("#popup_overlay").css({
						position: 'absolute',
						zIndex: 99998,
						top: '0px',
						left: '0px',
						width: '100%',
						height: $(document).height(),
						background: $.alerts.overlayColor,
						opacity: 0
					}).animate({ opacity : $.alerts.overlayOpacity });
				break;
				case 'hide':
					$("#popup_overlay").fadeOut(500, function(){ $(this).remove(); });
				break;
			}
		},
		
		_reposition: function() {
			var top = (($(window).height() / 2) - ($("#popup_container").outerHeight() / 2)) + $.alerts.verticalOffset;
			var left = (($(window).width() / 2) - ($("#popup_container").outerWidth() / 2)) + $.alerts.horizontalOffset;
			if( top < 0 ) top = 0;
			if( left < 0 ) left = 0;
			
			// IE6 fix
			if( $.browser.msie && parseInt($.browser.version) <= 6 ) top = top + $(window).scrollTop();
			
			$("#popup_container").css({
				top: top + 'px',
				left: left + 'px'
			});
			$("#popup_overlay").height( $(document).height() );
		},
		
		_maintainPosition: function(status) {
			if( $.alerts.repositionOnResize ) {
				switch(status) {
					case true:
						$(window).bind('resize', $.alerts._reposition);
					break;
					case false:
						$(window).unbind('resize', $.alerts._reposition);
					break;
				}
			}
		}
		
	};
	
	// Shortuct functions
	jAlert = function(message, title, callback) {
		$.alerts.alert(message, title, callback);
	};
	
	jConfirm = function(message, title, callback) {
		$.alerts.confirm(message, title, callback);
	};
		
	jPrompt = function(message, value, title, callback) {
		$.alerts.prompt(message, value, title, callback);
	};
	
})(jQuery);

/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);

/*
 * FancyBox - jQuery Plugin
 * Simple and fancy lightbox alternative
 *
 * Examples and documentation at: http://fancybox.net
 * 
 * Copyright (c) 2008 - 2010 Janis Skarnelis
 *
 * Version: 1.3.1 (05/03/2010)
 * Requires: jQuery v1.3+
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */

(function(b){var m,u,x,g,D,i,z,A,B,p=0,e={},q=[],n=0,c={},j=[],E=null,s=new Image,G=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,S=/[^\.]\.(swf)\s*$/i,H,I=1,k,l,h=false,y=b.extend(b("<div/>")[0],{prop:0}),v=0,O=!b.support.opacity&&!window.XMLHttpRequest,J=function(){u.hide();s.onerror=s.onload=null;E&&E.abort();m.empty()},P=function(){b.fancybox('<p id="fancybox_error">The requested content cannot be loaded.<br />Please try again later.</p>',{scrolling:"no",padding:20,transitionIn:"none",transitionOut:"none"})},
K=function(){return[b(window).width(),b(window).height(),b(document).scrollLeft(),b(document).scrollTop()]},T=function(){var a=K(),d={},f=c.margin,o=c.autoScale,t=(20+f)*2,w=(20+f)*2,r=c.padding*2;if(c.width.toString().indexOf("%")>-1){d.width=a[0]*parseFloat(c.width)/100-40;o=false}else d.width=c.width+r;if(c.height.toString().indexOf("%")>-1){d.height=a[1]*parseFloat(c.height)/100-40;o=false}else d.height=c.height+r;if(o&&(d.width>a[0]-t||d.height>a[1]-w))if(e.type=="image"||e.type=="swf"){t+=r;
w+=r;o=Math.min(Math.min(a[0]-t,c.width)/c.width,Math.min(a[1]-w,c.height)/c.height);d.width=Math.round(o*(d.width-r))+r;d.height=Math.round(o*(d.height-r))+r}else{d.width=Math.min(d.width,a[0]-t);d.height=Math.min(d.height,a[1]-w)}d.top=a[3]+(a[1]-(d.height+40))*0.5;d.left=a[2]+(a[0]-(d.width+40))*0.5;if(c.autoScale===false){d.top=Math.max(a[3]+f,d.top);d.left=Math.max(a[2]+f,d.left)}return d},U=function(a){if(a&&a.length)switch(c.titlePosition){case "inside":return a;case "over":return'<span id="fancybox-title-over">'+
a+"</span>";default:return'<span id="fancybox-title-wrap"><span id="fancybox-title-left"></span><span id="fancybox-title-main">'+a+'</span><span id="fancybox-title-right"></span></span>'}return false},V=function(){var a=c.title,d=l.width-c.padding*2,f="fancybox-title-"+c.titlePosition;b("#fancybox-title").remove();v=0;if(c.titleShow!==false){a=b.isFunction(c.titleFormat)?c.titleFormat(a,j,n,c):U(a);if(!(!a||a==="")){b('<div id="fancybox-title" class="'+f+'" />').css({width:d,paddingLeft:c.padding,
paddingRight:c.padding}).html(a).appendTo("body");switch(c.titlePosition){case "inside":v=b("#fancybox-title").outerHeight(true)-c.padding;l.height+=v;break;case "over":b("#fancybox-title").css("bottom",c.padding);break;default:b("#fancybox-title").css("bottom",b("#fancybox-title").outerHeight(true)*-1);break}b("#fancybox-title").appendTo(D).hide()}}},W=function(){b(document).unbind("keydown.fb").bind("keydown.fb",function(a){if(a.keyCode==27&&c.enableEscapeButton){a.preventDefault();b.fancybox.close()}else if(a.keyCode==
37){a.preventDefault();b.fancybox.prev()}else if(a.keyCode==39){a.preventDefault();b.fancybox.next()}});if(b.fn.mousewheel){g.unbind("mousewheel.fb");j.length>1&&g.bind("mousewheel.fb",function(a,d){a.preventDefault();h||d===0||(d>0?b.fancybox.prev():b.fancybox.next())})}if(c.showNavArrows){if(c.cyclic&&j.length>1||n!==0)A.show();if(c.cyclic&&j.length>1||n!=j.length-1)B.show()}},X=function(){var a,d;if(j.length-1>n){a=j[n+1].href;if(typeof a!=="undefined"&&a.match(G)){d=new Image;d.src=a}}if(n>0){a=
j[n-1].href;if(typeof a!=="undefined"&&a.match(G)){d=new Image;d.src=a}}},L=function(){i.css("overflow",c.scrolling=="auto"?c.type=="image"||c.type=="iframe"||c.type=="swf"?"hidden":"auto":c.scrolling=="yes"?"auto":"visible");if(!b.support.opacity){i.get(0).style.removeAttribute("filter");g.get(0).style.removeAttribute("filter")}b("#fancybox-title").show();c.hideOnContentClick&&i.one("click",b.fancybox.close);c.hideOnOverlayClick&&x.one("click",b.fancybox.close);c.showCloseButton&&z.show();W();b(window).bind("resize.fb",
b.fancybox.center);c.centerOnScroll?b(window).bind("scroll.fb",b.fancybox.center):b(window).unbind("scroll.fb");b.isFunction(c.onComplete)&&c.onComplete(j,n,c);h=false;X()},M=function(a){var d=Math.round(k.width+(l.width-k.width)*a),f=Math.round(k.height+(l.height-k.height)*a),o=Math.round(k.top+(l.top-k.top)*a),t=Math.round(k.left+(l.left-k.left)*a);g.css({width:d+"px",height:f+"px",top:o+"px",left:t+"px"});d=Math.max(d-c.padding*2,0);f=Math.max(f-(c.padding*2+v*a),0);i.css({width:d+"px",height:f+
"px"});if(typeof l.opacity!=="undefined")g.css("opacity",a<0.5?0.5:a)},Y=function(a){var d=a.offset();d.top+=parseFloat(a.css("paddingTop"))||0;d.left+=parseFloat(a.css("paddingLeft"))||0;d.top+=parseFloat(a.css("border-top-width"))||0;d.left+=parseFloat(a.css("border-left-width"))||0;d.width=a.width();d.height=a.height();return d},Q=function(){var a=e.orig?b(e.orig):false,d={};if(a&&a.length){a=Y(a);d={width:a.width+c.padding*2,height:a.height+c.padding*2,top:a.top-c.padding-20,left:a.left-c.padding-
20}}else{a=K();d={width:1,height:1,top:a[3]+a[1]*0.5,left:a[2]+a[0]*0.5}}return d},N=function(){u.hide();if(g.is(":visible")&&b.isFunction(c.onCleanup))if(c.onCleanup(j,n,c)===false){b.event.trigger("fancybox-cancel");h=false;return}j=q;n=p;c=e;i.get(0).scrollTop=0;i.get(0).scrollLeft=0;if(c.overlayShow){O&&b("select:not(#fancybox-tmp select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one("fancybox-cleanup",function(){this.style.visibility="inherit"});
x.css({"background-color":c.overlayColor,opacity:c.overlayOpacity}).unbind().show()}l=T();V();if(g.is(":visible")){b(z.add(A).add(B)).hide();var a=g.position(),d;k={top:a.top,left:a.left,width:g.width(),height:g.height()};d=k.width==l.width&&k.height==l.height;i.fadeOut(c.changeFade,function(){var f=function(){i.html(m.contents()).fadeIn(c.changeFade,L)};b.event.trigger("fancybox-change");i.empty().css("overflow","hidden");if(d){i.css({top:c.padding,left:c.padding,width:Math.max(l.width-c.padding*
2,1),height:Math.max(l.height-c.padding*2-v,1)});f()}else{i.css({top:c.padding,left:c.padding,width:Math.max(k.width-c.padding*2,1),height:Math.max(k.height-c.padding*2,1)});y.prop=0;b(y).animate({prop:1},{duration:c.changeSpeed,easing:c.easingChange,step:M,complete:f})}})}else{g.css("opacity",1);if(c.transitionIn=="elastic"){k=Q();i.css({top:c.padding,left:c.padding,width:Math.max(k.width-c.padding*2,1),height:Math.max(k.height-c.padding*2,1)}).html(m.contents());g.css(k).show();if(c.opacity)l.opacity=
0;y.prop=0;b(y).animate({prop:1},{duration:c.speedIn,easing:c.easingIn,step:M,complete:L})}else{i.css({top:c.padding,left:c.padding,width:Math.max(l.width-c.padding*2,1),height:Math.max(l.height-c.padding*2-v,1)}).html(m.contents());g.css(l).fadeIn(c.transitionIn=="none"?0:c.speedIn,L)}}},F=function(){m.width(e.width);m.height(e.height);if(e.width=="auto")e.width=m.width();if(e.height=="auto")e.height=m.height();N()},Z=function(){h=true;e.width=s.width;e.height=s.height;b("<img />").attr({id:"fancybox-img",
src:s.src,alt:e.title}).appendTo(m);N()},C=function(){J();var a=q[p],d,f,o,t,w;e=b.extend({},b.fn.fancybox.defaults,typeof b(a).data("fancybox")=="undefined"?e:b(a).data("fancybox"));o=a.title||b(a).title||e.title||"";if(a.nodeName&&!e.orig)e.orig=b(a).children("img:first").length?b(a).children("img:first"):b(a);if(o===""&&e.orig)o=e.orig.attr("alt");d=a.nodeName&&/^(?:javascript|#)/i.test(a.href)?e.href||null:e.href||a.href||null;if(e.type){f=e.type;if(!d)d=e.content}else if(e.content)f="html";else if(d)if(d.match(G))f=
"image";else if(d.match(S))f="swf";else if(b(a).hasClass("iframe"))f="iframe";else if(d.match(/#/)){a=d.substr(d.indexOf("#"));f=b(a).length>0?"inline":"ajax"}else f="ajax";else f="inline";e.type=f;e.href=d;e.title=o;if(e.autoDimensions&&e.type!=="iframe"&&e.type!=="swf"){e.width="auto";e.height="auto"}if(e.modal){e.overlayShow=true;e.hideOnOverlayClick=false;e.hideOnContentClick=false;e.enableEscapeButton=false;e.showCloseButton=false}if(b.isFunction(e.onStart))if(e.onStart(q,p,e)===false){h=false;
return}m.css("padding",20+e.padding+e.margin);b(".fancybox-inline-tmp").unbind("fancybox-cancel").bind("fancybox-change",function(){b(this).replaceWith(i.children())});switch(f){case "html":m.html(e.content);F();break;case "inline":b('<div class="fancybox-inline-tmp" />').hide().insertBefore(b(a)).bind("fancybox-cleanup",function(){b(this).replaceWith(i.children())}).bind("fancybox-cancel",function(){b(this).replaceWith(m.children())});b(a).appendTo(m);F();break;case "image":h=false;b.fancybox.showActivity();
s=new Image;s.onerror=function(){P()};s.onload=function(){s.onerror=null;s.onload=null;Z()};s.src=d;break;case "swf":t='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+e.width+'" height="'+e.height+'"><param name="movie" value="'+d+'"></param>';w="";b.each(e.swf,function(r,R){t+='<param name="'+r+'" value="'+R+'"></param>';w+=" "+r+'="'+R+'"'});t+='<embed src="'+d+'" type="application/x-shockwave-flash" width="'+e.width+'" height="'+e.height+'"'+w+"></embed></object>";m.html(t);
F();break;case "ajax":a=d.split("#",2);f=e.ajax.data||{};if(a.length>1){d=a[0];if(typeof f=="string")f+="&selector="+a[1];else f.selector=a[1]}h=false;b.fancybox.showActivity();E=b.ajax(b.extend(e.ajax,{url:d,data:f,error:P,success:function(r){if(E.status==200){m.html(r);F()}}}));break;case "iframe":b('<iframe id="fancybox-frame" name="fancybox-frame'+(new Date).getTime()+'" frameborder="0" hspace="0" scrolling="'+e.scrolling+'" src="'+e.href+'"></iframe>').appendTo(m);N();break}},$=function(){if(u.is(":visible")){b("div",
u).css("top",I*-40+"px");I=(I+1)%12}else clearInterval(H)},aa=function(){if(!b("#fancybox-wrap").length){b("body").append(m=b('<div id="fancybox-tmp"></div>'),u=b('<div id="fancybox-loading"><div></div></div>'),x=b('<div id="fancybox-overlay"></div>'),g=b('<div id="fancybox-wrap"></div>'));if(!b.support.opacity){g.addClass("fancybox-ie");u.addClass("fancybox-ie")}D=b('<div id="fancybox-outer"></div>').append('<div class="fancy-bg" id="fancy-bg-n"></div><div class="fancy-bg" id="fancy-bg-ne"></div><div class="fancy-bg" id="fancy-bg-e"></div><div class="fancy-bg" id="fancy-bg-se"></div><div class="fancy-bg" id="fancy-bg-s"></div><div class="fancy-bg" id="fancy-bg-sw"></div><div class="fancy-bg" id="fancy-bg-w"></div><div class="fancy-bg" id="fancy-bg-nw"></div>').appendTo(g);
D.append(i=b('<div id="fancybox-inner"></div>'),z=b('<a id="fancybox-close"></a>'),A=b('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),B=b('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>'));z.click(b.fancybox.close);u.click(b.fancybox.cancel);A.click(function(a){a.preventDefault();b.fancybox.prev()});B.click(function(a){a.preventDefault();b.fancybox.next()});if(O){x.get(0).style.setExpression("height",
"document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'");u.get(0).style.setExpression("top","(-20 + (document.documentElement.clientHeight ? document.documentElement.clientHeight/2 : document.body.clientHeight/2 ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop )) + 'px'");D.prepend('<iframe id="fancybox-hide-sel-frame" src="javascript:\'\';" scrolling="no" frameborder="0" ></iframe>')}}};
b.fn.fancybox=function(a){b(this).data("fancybox",b.extend({},a,b.metadata?b(this).metadata():{})).unbind("click.fb").bind("click.fb",function(d){d.preventDefault();if(!h){h=true;b(this).blur();q=[];p=0;d=b(this).attr("rel")||"";if(!d||d==""||d==="nofollow")q.push(this);else{q=b("a[rel="+d+"], area[rel="+d+"]");p=q.index(this)}C();return false}});return this};b.fancybox=function(a,d){if(!h){h=true;d=typeof d!=="undefined"?d:{};q=[];p=d.index||0;if(b.isArray(a)){for(var f=0,o=a.length;f<o;f++)if(typeof a[f]==
"object")b(a[f]).data("fancybox",b.extend({},d,a[f]));else a[f]=b({}).data("fancybox",b.extend({content:a[f]},d));q=jQuery.merge(q,a)}else{if(typeof a=="object")b(a).data("fancybox",b.extend({},d,a));else a=b({}).data("fancybox",b.extend({content:a},d));q.push(a)}if(p>q.length||p<0)p=0;C()}};b.fancybox.showActivity=function(){clearInterval(H);u.show();H=setInterval($,66)};b.fancybox.hideActivity=function(){u.hide()};b.fancybox.next=function(){return b.fancybox.pos(n+1)};b.fancybox.prev=function(){return b.fancybox.pos(n-
1)};b.fancybox.pos=function(a){if(!h){a=parseInt(a,10);if(a>-1&&j.length>a){p=a;C()}if(c.cyclic&&j.length>1&&a<0){p=j.length-1;C()}if(c.cyclic&&j.length>1&&a>=j.length){p=0;C()}}};b.fancybox.cancel=function(){if(!h){h=true;b.event.trigger("fancybox-cancel");J();e&&b.isFunction(e.onCancel)&&e.onCancel(q,p,e);h=false}};b.fancybox.close=function(){function a(){x.fadeOut("fast");g.hide();b.event.trigger("fancybox-cleanup");i.empty();b.isFunction(c.onClosed)&&c.onClosed(j,n,c);j=e=[];n=p=0;c=e={};h=false}
if(!(h||g.is(":hidden"))){h=true;if(c&&b.isFunction(c.onCleanup))if(c.onCleanup(j,n,c)===false){h=false;return}J();b(z.add(A).add(B)).hide();b("#fancybox-title").remove();g.add(i).add(x).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");i.css("overflow","hidden");if(c.transitionOut=="elastic"){k=Q();var d=g.position();l={top:d.top,left:d.left,width:g.width(),height:g.height()};if(c.opacity)l.opacity=1;y.prop=1;b(y).animate({prop:0},{duration:c.speedOut,easing:c.easingOut,
step:M,complete:a})}else g.fadeOut(c.transitionOut=="none"?0:c.speedOut,a)}};b.fancybox.resize=function(){var a,d;if(!(h||g.is(":hidden"))){h=true;a=i.wrapInner("<div style='overflow:auto'></div>").children();d=a.height();g.css({height:d+c.padding*2+v});i.css({height:d});a.replaceWith(a.children());b.fancybox.center()}};b.fancybox.center=function(){h=true;var a=K(),d=c.margin,f={};f.top=a[3]+(a[1]-(g.height()-v+40))*0.5;f.left=a[2]+(a[0]-(g.width()+40))*0.5;f.top=Math.max(a[3]+d,f.top);f.left=Math.max(a[2]+
d,f.left);g.css(f);h=false};b.fn.fancybox.defaults={padding:10,margin:20,opacity:false,modal:false,cyclic:false,scrolling:"auto",width:560,height:340,autoScale:true,autoDimensions:true,centerOnScroll:false,ajax:{},swf:{wmode:"transparent"},hideOnOverlayClick:true,hideOnContentClick:false,overlayShow:true,overlayOpacity:0.3,overlayColor:"#666",titleShow:true,titlePosition:"outside",titleFormat:null,transitionIn:"fade",transitionOut:"fade",speedIn:300,speedOut:300,changeSpeed:300,changeFade:"fast",
easingIn:"swing",easingOut:"swing",showCloseButton:true,showNavArrows:true,enableEscapeButton:true,onStart:null,onCancel:null,onComplete:null,onCleanup:null,onClosed:null};b(document).ready(function(){aa()})})(jQuery);

(function($) {

    /*
     * Auto-growing textareas; technique ripped from Facebook
     */
    $.fn.autogrow = function(options) {
        
        this.filter('textarea').each(function() {

            var $this = $(this);

            var $update = function() {
                $this.css({'height': 0});
                $this.css({'height': $this.attr('scrollHeight') + 'px'});
            };

            $this.bind('change keyup keydown', $update);

            $update.apply(this);

        }).css({'overflow':'hidden'});

        return this;
        
    }
    
})(jQuery);

/*
 FCBKcomplete 2.7.6 on select something focus textfield
 FCBKcomplete 2.7.5 changed json returned
 - Jquery version required: 1.2.x, 1.3.x, 1.4.x
 
 Changelog:
 - 2.00	new version of fcbkcomplete
 
 - 2.01 fixed bugs & added features
 		fixed filter bug for preadded items
		focus on the input after selecting tag
		the element removed pressing backspace when the element is selected
		input tag in the control has a border in IE7
		added iterate over each match and apply the plugin separately
		set focus on the input after selecting tag
 
 - 2.02 fixed fist element selected bug
		fixed defaultfilter error bug
 
 - 2.5 	removed selected="selected" attribute due ie bug
		element search algorithm changed
		better performance fix added
		fixed many small bugs
		onselect event added
		onremove event added
 
 - 2.6 	ie6/7 support fix added
		added new public method addItem due request
		added new options "firstselected" that you can set true/false to select first element on dropdown list
		autoexpand input element added
		removeItem bug fixed
		and many more bug fixed
 		fixed public method to use it $("elem").trigger("addItem",[{"title": "test", "value": "test"}]);
		
- 2.7 	jquery 1.4 compability
 		item lock possability added by adding locked class to preadded option <option value="value" class="selected locked">text</option>
 		maximum item that can be added

- 2.7.1 bug fixed
		ajax delay added thanks to http://github.com/dolorian

- 2.7.2 some minor bug fixed
		minified version recompacted due some problems
		
- 2.7.3 event call fixed thanks to William Parry <williamparry!at!gmail.com>

- 2.7.4 standart event change call added on addItem, removeItem
		preSet also check if item have "selected" attribute
		addItem minor fix

 */
/* Coded by: emposha <admin@emposha.com> */
/* Copyright: Emposha.com <http://www.emposha.com/> - Distributed under MIT - Keep this message! */
/*
 * json_             - url to fetch json object
 * cache       		- use cache
 * height           - maximum number of element shown before scroll will apear
 * newel            - show typed text like a element
 * firstselected	- automaticly select first element from dropdown
 * filter_case      - case sensitive filter
 * filter_selected  - filter selected items from list
 * complete_text    - text for complete page
 * maxshownitems	- maximum numbers that will be shown at dropdown list (less better performance)
 * onselect			- fire event on item select
 * onremove			- fire event on item remove
 * maxitimes		- maximum items that can be added
 * delay			- delay between ajax request (bigger delay, lower server time request)
 */
jQuery(function($){
    $.fn.fcbkcomplete = function(opt){
        return this.each(function(){
            function init(){
                createFCBK();
                preSet();
                addInput(0);
            }
            
            function createFCBK(){
                element.hide();
//                element.attr("multiple", "multiple");
/*                if (element.attr("name").indexOf("[]") == -1) {
                    element.attr("name", element.attr("name") + "[]");
                }
*/              
                holder = $(document.createElement("ul"));
                holder.attr("class", "holder");
                element.after(holder);
                
                complete = $(document.createElement("div"));
                complete.addClass("facebook-auto");
                complete.append('<div class="default">' + options.complete_text + "</div>");
                
                if (browser_msie) {
                    complete.append('<iframe class="ie6fix" scrolling="no" frameborder="0"></iframe>');
                    browser_msie_frame = complete.children('.ie6fix');
                }
                
                feed = $(document.createElement("ul"));
                feed.attr("id", elemid + "_feed");
                
                complete.prepend(feed);
                holder.after(complete);
                feed.css("width", complete.width());
            }
            
            function preSet(){
                element.children("option").each(function(i, option){
                    option = $(option);
                    if (option.hasClass("selected") || option.is(':selected')) {
                        addItem(option.text(), option.val(), true, option.hasClass("locked"));
                        option.attr("selected", "selected");
                    }
                    else {
                        option.removeAttr("selected");
                    }
                    
                    cache.push({
                        caption: option.text(),
                        value: option.val()
                    });
                    search_string += "" + (cache.length - 1) + ":" + option.text() + ";";
                });
            }
            
            //public method to add new item
            $(this).bind("addItem", function(event, data){
                addItem(data.title, data.value, 0, 0, 0);
            });

            $(this).bind('initiated_true', function(event){
                initiated = true;
            });

            function addItem(title, value, preadded, locked, focusme){
                if (!maxItems()) {
                    return false;
                }
                var li = document.createElement("li");
                var txt = document.createTextNode(title);
                var aclose = document.createElement("a");
                var liclass = "bit-box" + (locked ? " locked" : "");
                $(li).attr({
                    "class": liclass,
                    "rel": value
                });
                $(li).prepend(txt);
                $(aclose).attr({
                    "class": "closebutton",
                    "href": "#"
                });
                
                li.appendChild(aclose);
                holder.append(li);
                
                $(aclose).click(function(){
                    removeItem($(this).parent("li"));
                    return false;
                });
                
                if (!preadded) {
                    $("#" + elemid + "_annoninput").remove();
                    var _item;
                    addInput(focusme);
                    if (element.children("option[value=" + value + "]").length) {
                        _item = element.children("option[value=" + value + "]");
                        _item.get(0).setAttribute("selected", "selected");
                        if (!_item.hasClass("selected")) {
                            _item.addClass("selected");
                        }
                    }
                    else {
                        var _item = $(document.createElement("option"));
                        _item.attr("value", value).get(0).setAttribute("selected", "selected");
                        _item.attr("value", value).addClass("selected");
                        _item.text(title);
                        try{
                            element.append(_item);
                        } catch(i){}
                        
                    }
                    if (options.onselect.length) {
                        funCall(options.onselect, _item)
                    }
					element.change();

					if( initiated ) {
    					element.parent().find('.maininput').blur();
    					setTimeout(function(){ element.parent().find('.maininput').focus(); }, 100 );
    				}
                }
                holder.children("li.bit-box.deleted").removeClass("deleted");
                feed.hide();
                browser_msie ? browser_msie_frame.hide() : '';
            }
            
            function removeItem(item){
                if (!item.hasClass('locked')) {
                    item.fadeOut("fast");
                    if (options.onremove.length) {
                        var _item = element.children("option[value=" + item.attr("rel") + "]");
                        funCall(options.onremove, _item)
                    }
                    element.children('option[value="' + item.attr("rel") + '"]').removeAttr("selected").removeClass("selected");
                    item.remove();
					element.change();
                    deleting = 0;
                }
            }
            
            function addInput(focusme){
                var li = $(document.createElement("li"));
                var input = $(document.createElement("input"));
                var getBoxTimeout = 0;
				
                li.attr({
                    "class": "bit-input",
                    "id": elemid + "_annoninput"
                });
                input.attr({
                    "type": "text",
                    "class": "maininput",
                    "size": "1"
                });
                holder.append(li.append(input));
                
                input.focus(function(){
                    complete.fadeIn("fast");
                });
                
                input.blur(function(){
                    complete.fadeOut("fast");
                });
                
                holder.click(function(){
                    input.focus();
                    if (feed.length && input.val().length) {
                        feed.show();
                    }
                    else {
                        feed.hide();
                        browser_msie ? browser_msie_frame.hide() : '';
                        complete.children(".default").show();
                    }
                });
                
                input.keypress(function(event){
                    if (event.keyCode == 13 || event.keyCode == 9) {
                        return false;
                    }
                    //auto expand input							
                    input.attr("size", input.val().length + 1);
                });
                
                input.keydown(function(event){
                    //prevent to enter some bad chars when input is empty
                    if (event.keyCode == 191) {
                        event.preventDefault();
                        return false;
                    }
                });
                
                input.keyup(function(event){
                    var etext = xssPrevent(input.val());
                        etext = etext.replace(/\'/g,'');
                    
                    if (event.keyCode == 8 && etext.length == 0) {
                        feed.hide();
                        browser_msie ? browser_msie_frame.hide() : '';
                        if (!holder.children("li.bit-box:last").hasClass('locked')) {
                            if (holder.children("li.bit-box.deleted").length == 0) {
                                holder.children("li.bit-box:last").addClass("deleted");
                                return false;
                            }
                            else {
                                if (deleting) {
                                    return;
                                }
                                deleting = 1;
                                holder.children("li.bit-box.deleted").fadeOut("fast", function(){
                                    removeItem($(this));
                                    return false;
                                });
                            }
                        }
                    }
                    
                    if (event.keyCode != 40 && event.keyCode != 38 && etext.length != 0) {
                        counter = 0;
                        
                        if (options.json_url) {
                            if (options.cache && json_cache) {
                                addMembers(etext);
                                bindEvents();
                            }
                            else {
                                getBoxTimeout++;
                                var getBoxTimeoutValue = getBoxTimeout;   
                                setTimeout (function() {
                                    if (getBoxTimeoutValue != getBoxTimeout) return;
                                    $.getJSON(options.json_url + ( options.json_url.indexOf("?") > -1 ? "&" : "?" ) + "tag=" + etext, null, function (data) {
                                        addMembers(etext, data);
                                        json_cache = true;
                                        bindEvents();
                                    });
                                }, options.delay);                            
							}
                        }
                        else {
                            if( options.json_string ) {
                                addMembers(etext, options.json_string);
                                json_cache = true;
                                bindEvents();
                            } else {
                                addMembers(etext);
                                bindEvents();
                            }
                        }
                        complete.children(".default").hide();
                        feed.show();
                    }
                });
                if (focusme) {
                    setTimeout(function(){
                        input.focus();
                        complete.children(".default").show();
                    }, 1);
                }
            }
            
            function addMembers(etext, data){
                feed.html('');
                
                if (!options.cache && data != null) {
                    cache = new Array();
                    search_string = "";
                }
                
                addTextItem(etext);

                if (data != null && data.length) {
                    $.each(data, function(i, val){
                        cache.push({
                            caption: val,
                            value: val
                        });
                        search_string += "" + (cache.length - 1) + ":" + val + ";";
                    });
                }
                
                var maximum = options.maxshownitems < cache.length ? options.maxshownitems : cache.length;
                var filter = "i";
                if (options.filter_case) {
                    filter = "";
                }
                
                var myregexp, match;
                try {
                    myregexp = eval('/(?:^|;)\\s*(\\d+)\\s*:[^;]*?' + etext + '[^;]*/g' + filter);
                    match = myregexp.exec(search_string);
                } 
                catch (ex) {
                };
                
                var content = '';
                while (match != null && maximum > 0) {
                    var id = match[1];
                    var object = cache[id];
                    if (options.filter_selected && element.children("option[value=" + object.value + "]").hasClass("selected")) {
                        //nothing here...
                    }
                    else {
                        content += '<li rel="' + object.value + '">' + itemIllumination(object.caption, etext) + '</li>';
                        counter++;
                        maximum--;
                    }
                    match = myregexp.exec(search_string);
                }
                feed.append(content);
                
                if (options.firstselected) {
                    focuson = feed.children("li:visible:first");
                    focuson.addClass("auto-focus");
                }
                
                if (counter > options.height) {
                    feed.css({
                        "height": (options.height * 24) + "px",
                        "overflow": "auto"
                    });
                    if (browser_msie) {
                        browser_msie_frame.css({
                            "height": (options.height * 24) + "px",
                            "width": feed.width() + "px"
                        }).show();
                    }
                }
                else {
                    feed.css("height", "auto");
                    if (browser_msie) {
                        browser_msie_frame.css({
                            "height": feed.height() + "px",
                            "width": feed.width() + "px"
                        }).show();
                    }
                }
            }
            
            function itemIllumination(text, etext){
                if (options.filter_case) {
                    try {
                        eval("var text = text.replace(/(.*)(" + etext + ")(.*)/gi,'$1<em>$2</em>$3');");
                    } 
                    catch (ex) {
                    };
                                    }
                else {
                    try {
                        eval("var text = text.replace(/(.*)(" + etext.toLowerCase() + ")(.*)/gi,'$1<em>$2</em>$3');");
                    } 
                    catch (ex) {
                    };
                                    }
                return text;
            }
            
            function bindFeedEvent(){
                feed.children("li").mouseover(function(){
                    feed.children("li").removeClass("auto-focus");
                    $(this).addClass("auto-focus");
                    focuson = $(this);
                });
                
                feed.children("li").mouseout(function(){
                    $(this).removeClass("auto-focus");
                    focuson = null;
                });
            }
            
            function removeFeedEvent(){
                feed.children("li").unbind("mouseover");
                feed.children("li").unbind("mouseout");
                feed.mousemove(function(){
                    bindFeedEvent();
                    feed.unbind("mousemove");
                });
            }
            
            function bindEvents(){
                var maininput = $("#" + elemid + "_annoninput").children(".maininput");
                bindFeedEvent();
                feed.children("li").unbind("mousedown");
                feed.children("li").mousedown(function(){
                    var option = $(this);
                    addItem(option.text(), option.attr("rel"),0,0,1);
                    feed.hide();
                    complete.hide();
                });
                
                maininput.unbind("keydown");
                maininput.keydown(function(event){
                    if (event.keyCode == 191) {
                        event.preventDefault();
                        return false;
                    }
                    
                    if (event.keyCode != 8) {
                        holder.children("li.bit-box.deleted").removeClass("deleted");
                    }
                    
                    if ((event.keyCode == 13 || event.keyCode == 9) && checkFocusOn()) {
                        var option = focuson;
                        addItem(option.text(), option.attr("rel"),0,0,1);
                        complete.hide();
                        event.preventDefault();
                        focuson = null;
                        return false;
                    }
                    
                    if ((event.keyCode == 13 || event.keyCode == 9) && !checkFocusOn()) {
                        if (options.newel) {
                            var value = xssPrevent($(this).val());
                            addItem(value, value,0,0,1);
                            complete.hide();
                            event.preventDefault();
                            focuson = null;
                            return false;
                        }
                        
                        if (options.addontab) {
                          focuson = feed.children("li:visible:first");
                          var option = focuson;
                          addItem(option.text(), option.attr("rel"), 0, 0, 1);
                          complete.hide();
                          event.preventDefault();
                          focuson = null;
                          return false;
                        }      
                    }
                    
                    if (event.keyCode == 40) {
                        removeFeedEvent();
                        if (focuson == null || focuson.length == 0) {
                            focuson = feed.children("li:visible:first");
                            feed.get(0).scrollTop = 0;
                        }
                        else {
                            focuson.removeClass("auto-focus");
                            focuson = focuson.nextAll("li:visible:first");
                            var prev = parseInt(focuson.prevAll("li:visible").length, 10);
                            var next = parseInt(focuson.nextAll("li:visible").length, 10);
                            if ((prev > Math.round(options.height / 2) || next <= Math.round(options.height / 2)) && typeof(focuson.get(0)) != "undefined") {
                                feed.get(0).scrollTop = parseInt(focuson.get(0).scrollHeight, 10) * (prev - Math.round(options.height / 2));
                            }
                        }
                        feed.children("li").removeClass("auto-focus");
                        focuson.addClass("auto-focus");
                    }
                    if (event.keyCode == 38) {
                        removeFeedEvent();
                        if (focuson == null || focuson.length == 0) {
                            focuson = feed.children("li:visible:last");
                            feed.get(0).scrollTop = parseInt(focuson.get(0).scrollHeight, 10) * (parseInt(feed.children("li:visible").length, 10) - Math.round(options.height / 2));
                        }
                        else {
                            focuson.removeClass("auto-focus");
                            focuson = focuson.prevAll("li:visible:first");
                            var prev = parseInt(focuson.prevAll("li:visible").length, 10);
                            var next = parseInt(focuson.nextAll("li:visible").length, 10);
                            if ((next > Math.round(options.height / 2) || prev <= Math.round(options.height / 2)) && typeof(focuson.get(0)) != "undefined") {
                                feed.get(0).scrollTop = parseInt(focuson.get(0).scrollHeight, 10) * (prev - Math.round(options.height / 2));
                            }
                        }
                        feed.children("li").removeClass("auto-focus");
                        focuson.addClass("auto-focus");
                    }
                });
            }
            
            function maxItems(){
                if (options.maxitems != 0) {
                    if (holder.children("li.bit-box").length < options.maxitems) {
                        return true;
                    }
                    else {
                        return false;
                    }
                }
            }
            
            function addTextItem(value){
                if (options.newel && maxItems()) {
                    feed.children("li[fckb=1]").remove();
                    if (value.length == 0) {
                        return;
                    }
                    var li = $(document.createElement("li"));
                    li.attr({
                        "rel": value,
                        "fckb": "1"
                    }).html(value);
                    feed.prepend(li);
                    counter++;
                }
                else {
                    return;
                }
            }
            
            function funCall(func, item){
                var _object = "";
                for (i = 0; i < item.get(0).attributes.length; i++) {
                    if (item.get(0).attributes[i].nodeValue != null) {
                        _object += "\"_" + item.get(0).attributes[i].nodeName + "\": \"" + item.get(0).attributes[i].nodeValue + "\",";
                    }
                }
                _object = "{" + _object + " notinuse: 0}";
                func.call(func, _object);
            }
            
            function checkFocusOn(){
                if (focuson == null) {
                    return false;
                }
                if (focuson.length == 0) {
                    return false;
                }
                return true;
            }
            
            function xssPrevent(string){
                string = string.replace(/[\"\'][\s]*javascript:(.*)[\"\']/g, "\"\"");
                string = string.replace(/script(.*)/g, "");
                string = string.replace(/eval\((.*)\)/g, "");
                string = string.replace('/([\x00-\x08,\x0b-\x0c,\x0e-\x19])/', '');
                return string;
            }
            
            var options = $.extend({
                json_url: null,
                cache: false,
                height: "10",
                newel: false,
                firstselected: false,
                filter_case: false,
                filter_hide: false,
                complete_text: "Start to type...",
                maxshownitems: 30,
                maxitems: 10,
                onselect: "",
                onremove: "",
				delay: 350
            }, opt);
            
            //system variables
            var holder = null;
            var feed = null;
            var complete = null;
            var counter = 0;
            var cache = new Array();
            var json_cache = false;
            var search_string = "";
            var focuson = null;
            var deleting = 0;
            var browser_msie = "\v" == "v";
            var browser_msie_frame;
            var initiated = false;
            
            var element = $(this);
            var elemid = element.attr("id");
            init();
            
            return this;
        });
    };
});

(function($){  
    $.fn.auto_fill = function(options) {

        return this.each(function() {
            obj = $(this);

            obj.bind('focus', function(){
                if( $(this).val() == $(this).attr('alt') ) {
                    $(this).val('');
                }
            });
        
            obj.bind('blur', function(){
                if( $(this).val() == '' ) {
                    $(this).val($(this).attr('alt'));
                }
            });
        });
    };  
})(jQuery);

// v 1.2
(function($){  
    $.fn.lb_feed = function(options) {

        var month = new Array("January","February","March","April","May","June","July","August","September","October","November","December");

        var defaults = {  
            feeds       : [{}],
            auto_refresh: false,
            max_results : 6,
            back_up_max : 6,
            resize      : false,
            truncate    : false,
            interval_ref: false,
            format      : '<div class="activity-item">\
                                <a href="[%url%]" target="_blank" class="img">[%img%]</a>\
                                <div class="text">\
                                    <span class="action"><a href="[%url%]" target="_blank">[%username%]</a>[%action%]</span>\
                                    <div class="activity-text">[%description%]</div>\
                                </div><input type="hidden" class="feed-publish-date" value="[%pubdate%]" />\
                                <div class="clear"></div>\
                            </div>',
            filter      : ['OpenIDEO</a> tweeted: </span>\
                                    <div class="activity-text">@'],
            onComplete : function(){
                obj.closest('.mid').find('.feed-load').delay(1000).fadeOut();
            }
        };
        
        var items   = new Array();

        var feeds   = 0;
        var processed_feeds = 0;
        
        var obj = '';

        options     = $.extend(defaults, options);
        
        function add_to_items(object) {
            items.push(object);
        }
        
        function relative_time(timeString){
                var parsedDate = Date.parse(timeString);
                var delta = (Date.parse(Date()) - parsedDate) / 1000;
                var r = '';
                if (delta < 60) {
                        r = delta + ' seconds ago';
                } else if(delta < 120) {
                        r = 'a minute ago';
                } else if(delta < (45*60)) {
                        r = (parseInt(delta / 60, 10)).toString() + ' minutes ago';
                } else if(delta < (90*60)) {
                        r = 'an hour ago';
                } else if(delta < (24*60*60)) {
                        r = '' + (parseInt(delta / 3600, 10)).toString() + ' hours ago';
                } else if(delta < (48*60*60)) {
                        r = 'a day ago';
                } else {
                        r = (parseInt(delta / 86400, 10)).toString() + ' days ago';
                }
                return r;
        }

        function refresh_time() {
            obj.find('span.time').each(function(){
                $(this).text(relative_time($(this).attr('rel')));
            });
        }

        function feeds_processed(){
            if( feeds == processed_feeds ) return true;
            else return false;
        }

        function return_html() {
            obj.find('>div').each(function(){
                if( !$(this).find('div:not(.clear)').length ) $(this).remove();
            });

            if( feeds == processed_feeds ) {
                var min_date = false;

                if( obj.find('input.feed-publish-date').length ) {
                    min_date = Date.parse(obj.find('input.feed-publish-date').eq(0).val());
                }

                html = '';

                var total_length = items.length < options.max_results ? items.length : options.max_results;

                var newest = -1;
                var order  = new Array();

                for( var j = 0; j < items.length; j++) {
                    newest = j;

                    for( var i = 0; i < items.length; i++) {
                        if( jQuery.inArray(i, order) < 0 ){
                            var date = new Date(items[i].date);
                            var current_newest =  new Date(items[newest].date);

                            if( (date - current_newest) > 0 ) {
                                newest = i;
                            }
                        }
                    }                  

                    if( !min_date || Date.parse(items[newest].date) > min_date ) {
                        order.push(newest);
                    } else if( !min_date ) {
                        alert(items[newest].date + ' :: ' +  min_date)
                    }
                }

                var item_html = '';

                if( order.length < 1 ) {
                    return false;
                }

                for ( var h = 0; (h < order.length && h < defaults.max_results); h++) {
                    
                    item_html = defaults.format.replace('[%title%]', items[order[h]].title);
                    item_html = item_html.replace('[%so_long%]', relative_time(items[order[h]].date));
                    item_html = item_html.replace('[%date%]', items[order[h]].date);
                    var description = link_urls( items[order[h]].description, options.truncate);

                    if( options.truncate )
                        description = link_urls( truncate(items[order[h]].description, options.truncate));

                    if( typeof(items[order[h]].authorlink) != 'undefined' ) {
                        item_html = item_html.replace(/\[\%url\%\]/gi, items[order[h]].authorlink);
                        description = '<a href="' + items[order[h]].link + '" class="internal-link">' + description + '</a>';
                    } else
                        item_html = item_html.replace(/\[\%url\%\]/gi, items[order[h]].link);

                    item_html = item_html.replace('[%description%]', description );

                    item_html = item_html.replace('[%username%]', items[order[h]].username);
                    item_html = item_html.replace('[%pubdate%]', items[order[h]].date);
                    var d = new Date(items[order[h]].date);
                    var dada = month[d.getMonth()] + ' ' + d.getDate() + ', ' + d.getFullYear();

                    item_html = item_html.replace('[%showDate%]', dada);

                    if( items[order[h]].img && items[order[h]].img.indexOf('facebook-logo="true"') > -1 ) {
                        item_html = item_html.replace('[%img%]', items[order[h]].img);
                    } else if( items[order[h]].img ) {
                        item_html = item_html.replace('[%img%]', '<img src="' + items[order[h]].img + '" alt="" />');
                    } else {
                        item_html = item_html.replace('[%img%]', '');
                    }

                    item_html = item_html.replace('[%action%]', items[order[h]].action);
                    
                    if( typeof(items[order[h]].challengeupdate) != 'undefined' && typeof(items[order[h]].challengeurl) != 'undefined' )
                        item_html = item_html.replace('[%challengeupdate%]', '<a href="' + items[order[h]].challengeurl + '" class="upper">' + items[order[h]].challengeupdate) + '</span>';
                    else if( typeof(items[order[h]].challengeupdate) != 'undefined' )
                        item_html = item_html.replace('[%challengeupdate%]', '<span class="upper">' + items[order[h]].challengeupdate) + '</span>';
                    else
                        item_html = item_html.replace('[%challengeupdate%]', '');

                    var filtering = options.filter.length;
                    var insert = true;
                    while( filtering-- ) {
                        if( item_html.indexOf(options.filter[filtering]) > -1 )
                            insert = false;
                            
                        //alert(options.filter[filtering])
                    }

                    if( html.indexOf(item_html) < 0 && insert) // if the item is not already on the feed, add it
                        html += item_html;
                    else
                        defaults.max_results++;
                }                

                if( obj.find('input.feed-publish-date').length && html != '' ) {
                    html = '<div style="display:none">' + html + '<div class="clear"></div><div class="clear"></div></div>' + obj.html();

                    setTimeout(function(){
                                        var total   = obj.find('.feed-publish-date').length;
                                        var to_hide = total - options.max_results;

                                        while ( to_hide--  >= 0 ) {
                                            obj.find('.activity-item').eq(options.max_results+to_hide).addClass('to-hide-away');
                                        }

                                        slideToggle(obj.find('>div:not(:visible)'), 1000);
                                        obj.find('.to-hide-away').wrapAll('<div class="i-will-hide-them-all"></div>');
                                        obj.find('.i-will-hide-them-all').slideUp(800, function(){
                                            $(this).remove();                                            
                                        });
                                        
                                        obj.find('.i-will-hide-them-all').each(function(){
                                            var my_parent = $(this).parent();
                                            var old_height = my_parent.height();
                                            my_parent.css({ height : 'auto' });
                                            var new_par_height = my_parent.outerHeight() - $(this).height();

                                            if( !my_parent.find('div:not(.clear)').length )
                                                new_par_height = 0;

                                            my_parent.css({ height : old_height + 'px', overflow : 'hidden' });
                                            $(this).parent().animate({ height : new_par_height+ 'px' }, 1000);
                                        });
                                        
                                        obj.find('.i-will-hide-them-all').slideUp(1000, function(){
                                            var par = $(this).parent();
                                            $(this).remove();
                                            par.css({ height : 'auto' });
                                        });
                                        /**/
                                        
                                }, 2000);

                } else if( html == '' ) {
//                      obj.closest('.mid').find('.feed-load').fadeIn();
//                    html = '<div class="disappear">There are  no new items to load</div>' + obj.html();
//                    setTimeout(function(){ obj.find('.disappear').fadeOut(function(){ $(this).remove(); }) }, 1000)
                } else {
                    html = '<div style="display : none">' + html + '</div>';

                    setTimeout(function(){
                                        slideToggle(obj.find('>div:not(:visible)'), 2000);
                                }, 1000);
                }

                processed_feeds = 0;
                feeds           = 0;

                if( options.auto_refresh ) {
                    options.auto_refresh = false;
                    obj.auto_refresh();
                }
                
                return html;
            } else {
                return false;
            }
        }
        
        function strip_tags(string) {
            var re= /<\S[^><]*>/g;
            return string.replace(re, "");
        }

        function link_urls(string){
            var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
            return string.replace(exp,'<a href="$1" target="_blank">$1</a>');
        }
        
        function parse_rss($feed) {
            feeds ++;

            $.ajax({
                url     : $feed.url,
                dataType: 'html',
                error   : function(e) {
                    processed_feeds ++;
                    if( feeds_processed() ) { set_new_html(); }
                },
                success : function(d) {

                    if ($.browser.msie && typeof(d) == "string") {
                        var xml = new ActiveXObject("Microsoft.XMLDOM");
                        xml.async = false;
                        xml.loadXML(d);
                        d = xml;
                    }

                    //find each 'item' in the file and parse it
                    $(d).find('item').each(function() {
                        var $new_item = new Object;
                        //name the current found item this for this particular loop run
                        var $item = $(this);
                        
                        try {
                            $item.html($item.html().replace('<!--[CDATA[', '').replace(']]>', '').replace(']]--&gt;', ''));
                        } catch(err){

                        }

                        $new_item.title         = $item.find('title').text();
                        $new_item.link          = $item.find('link').text();

                        if( $new_item.title == '' && $item.find('title_feed').length )
                            $new_item.title         = $item.find('title_feed').text();

                        $new_item.action = $item.find('action').text();
                        
                        if( $feed.url.indexOf('twitter.com') > -1 )
                            $new_item.action = ' tweeted: ';
                        
                        $new_item.action = $new_item.action.replace(' :', ':');

                        if( $new_item.link == '' && $item.find('guid').length )
                            $new_item.link = $item.find('guid').text();

                        $new_item.description   = strip_tags(encode($item.find('description').text()));

                        if( $feed.url.indexOf('twitter.com') < 0 && $feed.url.indexOf('rss.test.xml') < 0 && $item.find('authorLink').length ) {
                            $new_item.authorlink = $item.find('authorLink').text();
                        }

                        if( $item.find('challengeName').length )
                            $new_item.challengeupdate = $item.find('challengeName').text();

                        if( $item.find('challengeURL').length )
                            $new_item.challengeurl = $item.find('challengeURL').text();

                        $new_item.date          = $item.find('pubDate').text();

                        if( isNaN(Date.parse($new_item.date)) ) {   // fix up Safari
                            var date = $new_item.date;
                            date = date.replace(/-/gi, '/').replace('T', ' ');
                            date = date.replace(' ue', 'Tue');
                            
                            if( date.indexOf('+') > -1 ) {
                            var split_date = date.split('+');
                                date = split_date[0] + ' +' + (parseInt(split_date[1]) < 10 ? '0' + parseInt(split_date[1]) : parseInt(split_date[1]) ) + '00';
                            } else if ( date.lastIndexOf('-') > 9 ) {
                            var split_date = new Array();
                                split_date[0] = date.substr(0, date.lastIndexOf('-'));
                                split_date[1] = date.substr((date.lastIndexOf('-')+1), (date.length-1));
                                date = split_date[0] + ' -' + (parseInt(split_date[1]) < 10 ? '0' + parseInt(split_date[1]) : parseInt(split_date[1]) ) + '00';
                            }
                            
                            $new_item.date = date;
                        }

                        if( $(this).find('google\\:image_link').length )
                            $new_item.img = $(this).find('google\\:image_link').text();

                        if( $item.find('author').length )
                            $new_item.username      = $item.find('author').text();
                        
                        if ( $new_item.link.indexOf('twitter.com') > -1 && $new_item.username.indexOf('@') > -1 ) {
                            $new_item.username = $new_item.username.split('@')[0];
                        }

                        add_to_items($new_item);

                    });

                    processed_feeds ++;

                    if( feeds_processed() ) { set_new_html(); }
                }
            })

        }   // end parse rss

        function encode(myString){
        	myString = myString.replace( /\&amp;/g, '&' );
        	myString = myString.replace( /\&lt;/g, '<' );
            myString = myString.replace( /\&gt;/g, '>' );
        	myString = myString.replace( /\&quot;/g, '"' );
        	myString = myString.replace( /\&copy;/g, '©' );
        	myString = myString.replace( /\&reg;/g, '¨' );
        	myString = myString.replace( /\&laquo;/g, 'Ç' );
        	myString = myString.replace( /\&raqou;/g, 'È' );
        	myString = myString.replace( /\&apos;/g, "'" );
        	return myString;
        }

        function parse_json($feed) {
            // json feed

            feeds ++;

            $.ajax(
                {
                    type        : 'get',
                    url         : $feed.url,
                    async       : false,
                    dataType    : 'jsonp',
                    success: function(data, textStatus) {

                        for (var i=0; i < data.length && i < options.max_results; i++) {

                            var $new_item = new Object;

                            item = data[i];

                            $new_item.title         = item.user.screen_name;
                            $new_item.link          = item.link;
                            $new_item.description   = strip_tags(item.text);
                            $new_item.date          = item.created_at;

                            $new_item.img           = item.user.profile_image_url;

                            add_to_items($new_item);
                        }

                        processed_feeds ++;
                        
                        if( feeds_processed() ) { set_new_html(); }

                    }
                    

                }
            );

        }   // end json parse

        function parse($feed) {

            var current = window.location.hostname;

            if( $feed.url.indexOf('http://facebook.com') === 0 || $feed.url.indexOf('http://www.facebook.com') === 0 ) {
                parse_fb_page($feed);
            } else if( typeof($feed.type) != 'undefined' && $feed.type == 'json' ) {
                parse_json($feed);
            } else {
                parse_rss($feed);
            }
        }
        
        function set_new_html() {
            var new_html = return_html();
            
            if( new_html )
                obj.html(new_html);

            refresh_time();
            items = new Array();

            defaults.onComplete();
        }
        
        function truncate(string, length) {
            if (string.length > length) {
                string = string.substring(0, length);
                string = string.replace(/\w+$/, '');
                
                return string + '...';
            } else
                return string;
        }

        return this.each(function() {
            obj = $(this);

            var body = obj.html();
            
            obj.closest('.mid').find('.feed-load').fadeIn();

            jQuery.each( options.feeds, function(count) {
                parse(options.feeds[count]);
            });

            $.fn.refresh_feed = function() {
                obj.closest('.mid').find('.feed-load').fadeIn();
                jQuery.each( options.feeds, function(count) {
                    parse(options.feeds[count]);
                });
            };
            
            $.fn.auto_refresh = function() {
                obj.refresh_feed();
                clearInterval(defaults.interval_ref);
                defaults.interval_ref = setInterval(function(){ obj.refresh_feed(); }, 300000);
            };

            $.fn.stop_refresh = function() {
                clearInterval(defaults.interval_ref);
            };

            $.fn.update_max_options = function(i) {
                options.max_results = i;
            };

        });
    };  
})(jQuery);

function slideToggle(el, speed, bShow){
    var $el = $(el), height = $el.data("originalHeight"), visible = $el.is(":visible");
    if( arguments.length == 2 ) bShow = !visible;

//    if( bShow == visible ) return false;
    
    // get the original height
    if( !height ){
        height = $el.show().height();
        $el.data("originalHeight", height);

        if( !visible ) $el.hide().css({height: 0});
    }
    
    // expand the knowledge (instead of slideDown/Up, use custom animation which applies fix)
    if( bShow ){
        $el.show().animate({height: height}, {duration: speed});
    } else {
        $el.animate({height: 0}, {duration: speed, complete:function (){
                                                                        $el.hide();
                                                                    }
                                });
    }
}

(function($){  
    $.fn.lb_validate = function(options) {

        var defaults = {  
            valid_class     : 'valid',
            error_class     : 'error',
            beforeSubmit    : function(){ }
        };

        options         = $.extend(defaults, options);
        var obj         = '';
        var invalid_form= false;
        var form        = false;

        function validate() {   // validate the form
            form = $(this);
            invalid_form = false;

            // sync up niceditors with their textareas
            if( typeof(nicEditors) != 'undefined' ) {
                for( var i=0; i < nicEditors.editors.length; i++ ) {
                    for( var j=0; j < nicEditors.editors[i].nicInstances.length; j++ ) {
                        nicEditors.editors[i].nicInstances[j].saveContent();
                    }
                }
            }

            form.find('input, textarea, select').each(function(){        // check each field in the form

                if( $(this).hasClass('check-text') ) {              // check text has been inserted
                    if( jQuery.trim($(this).val()) == '' || jQuery.trim($(this).val()) == '<br>' || jQuery.trim($(this).val()) == '<BR>' ) {
                        if( $(this).hasClass('spaceless') ) $(this).closest('.input-container').find('.err-text').text('');
                        if( !invalid_form ) invalid_form = $(this);
                        showErr($(this),'This is a required field');
                    } else {
						if( $(this).hasClass('limit-chars') ) {
							if( ($(this).attr('maxlength') - $(this).val().length) < 0 ) { // too long
								if( !invalid_form ) invalid_form = $(this);
		                        showErr($(this), 'You have inserted too many characters');
							} else {
								hideErr($(this));
							}
						} else {
							hideErr($(this));
						}
                    }
                } else if( $(this).hasClass('check-html') ) {       // check html has been inserted
                    if( jQuery.trim($(this).val()) == '' ) {
                        if( !invalid_form ) invalid_form = $(this);
                        showErr($(this),'This is a required field');
                    } else {
						if( $(this).hasClass('limit-chars') ) {
							if( ($(this).attr('maxlength') - $(this).val().length) < 0 ) { // too long
								if( !invalid_form ) invalid_form = $(this);
		                        showErr($(this), 'You have inserted too many characters');
							} else {
								hideErr($(this));
							}
						} else {
                        	hideErr($(this));
                        }
                    }
                } else if( $(this).hasClass('check-url') ) {
                    var $triggeroo = $(this);

                    var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;

                    if( regexp.test($(this).val()) ) {
                        hideErr($(this));
                    } else {
                    	if( !invalid_form ) invalid_form = $(this);
                    	showErr($triggeroo);
                    }

                } else if( $(this).hasClass('check-not-zero') ) {
                    if( jQuery.trim($(this).val()) == 0 ) {
                        if( !invalid_form ) invalid_form = $(this);
                        showErr($(this));
                    } else {
                        hideErr($(this));
                    }
                } else if( $(this).hasClass('at-least-one-check') ) {
                    if( $('input[name=' + $(this).attr('name') + ']:checked').length < 1 ) {
                        if( !invalid_form ) invalid_form = $(this);
                        showErr($(this));
                    } else {
                        hideErr($(this));
                    }
                } else if( $(this).hasClass('check-date') ) {

                    if( valid_date($(this).val()) ) {
                        if( !invalid_form ) invalid_form = $(this);
                        showErr($(this));
                    } else {
                        hideErr($(this));
                    }
                }
                
                if( $(this).hasClass('date-field') && $(this).attr('name') == 'signup.dob' ) {
                    var $this = $(this);

                    if( jQuery.trim($this.val()) != '' ) {
                    
                        if( !valid_date($this.val()) ) {
                            if( !invalid_form ) invalid_form = $this;
                            showErr($this, 'Please insert a valid date');
                        } else {
                            // check older the 18
                            var date_val    = $this.val().split('/');
                            var dd          = parseInt(date_val[0], 10);
                            var mm          = parseInt(date_val[1], 10);
                            var yyyy        = parseInt(date_val[2]);
    
                            var current_d   = new Date();
                            var cday        = parseInt(current_d.getDate());
                            var cmonth      = parseInt(current_d.getMonth()) + 1;
                            var cyear       = parseInt(current_d.getFullYear());
                            var age         = cyear - yyyy;
    
                            if (
                                !( mm == cmonth && dd <= cday ) &&   // this month and earlier than today or today
                                !( mm < cmonth )                    // before this month
                               ) {
                                age--;
                            }
    
                            if( age < 18 ) {
                                jAlert('You must be 18 years of age or over to enter into this agreement.<br /><br /> Please ask your parent or guardian to register on your behalf.');
                                if( !invalid_form ) invalid_form = $this;
                                showErr($this, 'You must be 18 years of age or over to enter into this agreement.');
                            } else {
                                hideErr($this);
                            }
                        }
                    }
                }

                if( $(this).hasClass('spaceless') ) {
                    $(this).val(jQuery.trim($(this).val()));

                    if( jQuery.trim($(this).val()) == '' || $(this).val().indexOf(' ') > -1 ) {
                    
                        if( jQuery.trim($(this).val()) != '')
                            $(this).closest('.input-container').find('.err-text').text('No spaces allowed');
                        else
                            $(this).closest('.input-container').find('.err-text').text('');

                        if( !invalid_form ) invalid_form = $(this);
                        showErr($(this));
                    }
                }
            });

            if( invalid_form ) {
//                $(document).scrollTop(invalid_form.scrollTop());
//                $('html').animate({scrollTop: parseInt(invalid_form.offset().top) - 30 }, 500,'easeOutBack');
//                $('html').scrollTo( {top: (parseInt(invalid_form.offset().top) - 30) + 'px'}, 800 );
                $.scrollTo( ( parseInt(invalid_form.offset().top) - 30 ), 500, { easing : 'easeOutBack' });
                invalid_form.focus();
                return false;
            } else {
                
                var accept_terms = true;
                
                if( form.find('.terms-label').length && !form.find('.terms-label input').is(':checked') ) {
                    form.find('.terms-label .terms-conditions-link').eq(0).click();
                    return false;
                }

                if(accept_terms) {
                
                    if( form.find('.captcha-container:hidden').length ) {
                        form.find('.captcha-container:hidden').slideDown();
                        return false;
                    }

                    form.find('.terms-label input').attr('checked', true);
                    submittingDisplay();
                    options.beforeSubmit();
    
                    if( $('ul.delete-me input').length ) {
                        var new_name = $('ul.delete-me input').attr('name').replace('_order', '_delete');
                        $('ul.delete-me input').attr({ name : new_name });
                    }
    
                    $('.link-technical input:checked').each(function(){
                         $(this).parent().parent().parent().parent().find('.side-queue').remove();
                    });
    
                    if( $( '#image-uploadQueue .uploadifyQueueItem').length > 0 ) {
                        $( '#' + form.attr('id') + ' #image-upload').uploadifyUpload();
                        return false;
                    } else if( $('.side-queue .uploadifyQueueItem.uploaditem').length > 0) {
                        $('#' + $('.side-queue .uploadifyQueueItem.uploaditem').attr('id')).parent().prev().find('input[type="file"]').uploadifyUpload();
                        return false;
                    } else if( $('#multiple-files-uploadQueue .uploadifyQueueItem').length > 0 ) {
                        $('#multiple-files-upload').uploadifyUpload();
                        return false;
                    }else {
                        if( form.find('#usertags-fill').length ) {
                            var value_tags = '';
                            $('.bit-box').each(function(i){
                                if( $(this).attr('rel') != '' ) {
                                    if ( i > 0 ) value_tags += ',';
                                    value_tags += $(this).attr('rel');
                                }
                            });
    
                            $('#usertags-fill').val(value_tags);
                        }

                        form.find('.to-delte-on-submit').each(function(){
                            jQuery.ajax({
                                url     :   $(this).val() + '/delete.html',
                                async   :   false
                            });
                        });
    
                        form.unbind('submit', validate);
                        setTimeout(function(){ if( form.find('#submitter').length ) form.find('#submitter').click(); else form.submit();}, 1000);
                        return false;
                    }
                }

            }

            
            return false;
        }

        function submittingDisplay() {                              // hide submit buttons and show patience
            if( form.find('.form-buttons .patience-msg').length > 0 && form.find('.form-buttons .patience-msg').css('display') == 'none' )
                form.find('.form-buttons .patience-msg').remove();
            else if ( form.find('.form-buttons .patience-msg').length > 0 && form.find('.form-buttons .patience-msg').css('display') != 'none' )
                return false;

            form.find('.form-buttons .button-container').before('<div class="patience-msg" style="display : none">Please be patient while the form is submitted. Thank you.</div>');
            form.find('.form-buttons .button-container').slideUp();
            form.find('.form-buttons .patience-msg').slideDown();
            return true;
        }

        function showErr (element, message) {    // show error
	    
	    	if( typeof(message) == 'undefined' ){
	    		message = false;
	    	}

            var parent = element.parent();
            if( parent[0].tagName == 'LABEL' ) {
                parent = parent.parent();
            } else if( element.hasClass('at-least-one-check') ) {
				parent = element.closest('.input-container');
	    	}

            parent.removeClass(options.valid_class).addClass(options.error_class);
            if( parent.find('.err-text').text() == '' ) {
                parent.find('.err-text').text('This is a required field');
            }
            
            if( message ){
            	parent.find('.err-text').text(message);
            }
        }

        function hideErr (element) {    // hide error
            var parent = element.parent();
            if( parent[0].tagName == 'LABEL' ) {
                parent = parent.parent();
            } else if( element.hasClass('at-least-one-check') ) {
				parent = element.closest('.input-container');
		    }

            parent.removeClass(options.error_class).addClass(options.valid_class);
        }
        
        function valid_date (date_val) {
            var date   = date_val.split('/');
            var day    = parseInt(date[0], 10);
            var month  = parseInt(date[1], 10);
            var year   = parseInt(date[2]);

            if( !day || ! month || !year ||
                ( day > 30 && ( month == 4 || month == 6 || month == 9 || month == 11 ) ) || // 30 day months
                ( day > 31 ) ||                                                              // no month has more than 31 days
                ( day > 28 && ( month == 2 && year ) ) ||                                    // february
                ( day > 29 && ( month == 2 && !( year%4 ) ) )                                // february 29 days
              ) {
                return false;
            } else {
                return true;
            }
        }


        return this.each(function() {
            form = $(this);
            form.find('.captcha-container').hide();
            form.submit(validate);
        });

    };
})(jQuery);

// jQuery SWFObject v1.1.1 MIT/GPL @jon_neal
// http://jquery.thewikies.com/swfobject
(function(f,h,i){function k(a,c){var b=(a[0]||0)-(c[0]||0);return b>0||!b&&a.length>0&&k(a.slice(1),c.slice(1))}function l(a){if(typeof a!=g)return a;var c=[],b="";for(var d in a){b=typeof a[d]==g?l(a[d]):[d,m?encodeURI(a[d]):a[d]].join("=");c.push(b)}return c.join("&")}function n(a){var c=[];for(var b in a)a[b]&&c.push([b,'="',a[b],'"'].join(""));return c.join(" ")}function o(a){var c=[];for(var b in a)c.push(['<param name="',b,'" value="',l(a[b]),'" />'].join(""));return c.join("")}var g="object",m=true;try{var j=i.description||function(){return(new i("ShockwaveFlash.ShockwaveFlash")).GetVariable("$version")}()}catch(p){j="Unavailable"}var e=j.match(/\d+/g)||[0];f[h]={available:e[0]>0,activeX:i&&!i.name,version:{original:j,array:e,string:e.join("."),major:parseInt(e[0],10)||0,minor:parseInt(e[1],10)||0,release:parseInt(e[2],10)||0},hasVersion:function(a){a=/string|number/.test(typeof a)?a.toString().split("."):/object/.test(typeof a)?[a.major,a.minor]:a||[0,0];return k(e,a)},encodeParams:true,expressInstall:"expressInstall.swf",expressInstallIsActive:false,create:function(a){if(!a.swf||this.expressInstallIsActive||!this.available&&!a.hasVersionFail)return false;if(!this.hasVersion(a.hasVersion||1)){this.expressInstallIsActive=true;if(typeof a.hasVersionFail=="function")if(!a.hasVersionFail.apply(a))return false;a={swf:a.expressInstall||this.expressInstall,height:137,width:214,flashvars:{MMredirectURL:location.href,MMplayerType:this.activeX?"ActiveX":"PlugIn",MMdoctitle:document.title.slice(0,47)+" - Flash Player Installation"}}}attrs={data:a.swf,type:"application/x-shockwave-flash",id:a.id||"flash_"+Math.floor(Math.random()*999999999),width:a.width||320,height:a.height||180,style:a.style||""};m=typeof a.useEncode!=="undefined"?a.useEncode:this.encodeParams;a.movie=a.swf;a.wmode=a.wmode||"opaque";delete a.fallback;delete a.hasVersion;delete a.hasVersionFail;delete a.height;delete a.id;delete a.swf;delete a.useEncode;delete a.width;var c=document.createElement("div");c.innerHTML=["<object ",n(attrs),">",o(a),"</object>"].join("");return c.firstChild}};f.fn[h]=function(a){var c=this.find(g).andSelf().filter(g);/string|object/.test(typeof a)&&this.each(function(){var b=f(this),d;a=typeof a==g?a:{swf:a};a.fallback=this;if(d=f[h].create(a)){b.children().remove();b.html(d)}});typeof a=="function"&&c.each(function(){var b=this;b.jsInteractionTimeoutMs=b.jsInteractionTimeoutMs||0;if(b.jsInteractionTimeoutMs<660)b.clientWidth||b.clientHeight?a.call(b):setTimeout(function(){f(b)[h](a)},b.jsInteractionTimeoutMs+66)});return c}})(jQuery,"flash",navigator.plugins["Shockwave Flash"]||window.ActiveXObject);

/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1
 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2008 George McGinley Smith
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
*/

// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	easeInCubic: function (x, t, b, c, d) {
		return c*(t/=d)*t*t + b;
	},
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	},
	easeInOutCubic: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	},
	easeInQuart: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t + b;
	},
	easeOutQuart: function (x, t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	},
	easeInOutQuart: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
		return -c/2 * ((t-=2)*t*t*t - 2) + b;
	},
	easeInQuint: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t*t + b;
	},
	easeOutQuint: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
	},
	easeInOutQuint: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	},
	easeInSine: function (x, t, b, c, d) {
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
	},
	easeOutSine: function (x, t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	},
	easeInOutSine: function (x, t, b, c, d) {
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	},
	easeInExpo: function (x, t, b, c, d) {
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
	easeInCirc: function (x, t, b, c, d) {
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
	},
	easeOutCirc: function (x, t, b, c, d) {
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
	},
	easeInOutCirc: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
	},
	easeInElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	},
	easeOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	},
	easeInOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
	},
	easeInBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*(t/=d)*t*((s+1)*t - s) + b;
	},
	easeOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	},
	easeInOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158; 
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	},
	easeInBounce: function (x, t, b, c, d) {
		return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
	},
	easeOutBounce: function (x, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	},
	easeInOutBounce: function (x, t, b, c, d) {
		if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
	}
});

/*
 *
 * TERMS OF USE - EASING EQUATIONS
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2001 Robert Penner
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
 */
