/*global jQuery */

/**
	REFRESH_APP is the global namespace container
	@namespace
	@requires jQuery.js
*/
var REFRESH_APP = {};

/**
	@class
	@description General page initialization
*/
REFRESH_APP.general = {

	ssl: (("https:" == document.location.protocol) ? true : false),
	protocol: (("https:" == document.location.protocol) ? 'https://' : 'http://'),
	sslDomain: function() {
		if(this.sslDomainCached) return this.sslDomainCached;
  		var re = /^(http\:\/\/[w\.]*refresheverything\.)/g;
		var domain = document.location.protocol + '//' + document.domain;
		this.sslDomainCached = domain.replace(re, "https://secure.refresheverything.");
		return this.sslDomainCached;
	},

	getScript: function(url,callback) {
		var cache = jQuery.ajaxSettings.cache;
		jQuery.ajaxSettings.cache = true;
		if(callback) $.getScript(url,callback);
		else $.getScript(url);
		jQuery.ajaxSettings.cache = cache;
	},

	init: function() {
	
		$('body').addClass('has-js');

		$('a[rel=external]').live('click', function(e) {
			$(this).attr('target','blank');
		});

		REFRESH_APP.globalValidation.init();

		// Initialize pepsiAnimation
		REFRESH_APP.pepsiAnimation.init();
		// Initialize login
		REFRESH_APP.login.init();
		// Initialize lightRegistration
		//REFRESH_APP.lightRegistration.init();
		// Initialize status bar
		REFRESH_APP.statusBar.init();
		// facebook connect - removed facebook support
		// REFRESH_APP.fbConnectLogin.init();
		// pepsi sound
		REFRESH_APP.pepsiSound.init();
		// test if just signed in
		REFRESH_APP.signUpPop.init();

		// Nice to have features that should load last
		$(window).load( function() {
			// Implement rounded corners
			REFRESH_APP.roundedCorners.init();
			// Activate more
			REFRESH_APP.morebox.init();
		});

	}

};

/**
	@class
	@description Google Analytics custom vars
*/
REFRESH_APP.gaCustomVars = {

	/**
		Reset custom variable
	*/
	reset: function() {

		try {
			pageTracker._deleteCustomVar(1);
			pageTracker._deleteCustomVar(2);
			pageTracker._deleteCustomVar(3);
			pageTracker._deleteCustomVar(4);
			pageTracker._deleteCustomVar(5);
		} catch(e) {}

	},

	/**
		Check if first vote and if not logged in as PCNA
	*/
	init: function() {

		var bodyId = $('body').attr('id');

		if (bodyId == 'home') {
			pageTracker._setCustomVar(3, 'page-type', 'homepage', 3);
		} else if (bodyId == 'categories') {
			pageTracker._setCustomVar(3, 'page-type', 'category-page', 3);
			REFRESH_APP.gaCustomVars.checkIdeaCategory();
		} else if (bodyId == 'idea') {
			pageTracker._setCustomVar(3, 'page-type', 'idea-details', 3);
			REFRESH_APP.gaCustomVars.checkPrizeCategory();
			REFRESH_APP.gaCustomVars.checkIdeaCategory('idea');
		} else if (bodyId == 'search-results') {
			pageTracker._setCustomVar(3, 'page-type', 'search-results', 3);
		} else if (bodyId == 'leaderboard') {
			pageTracker._setCustomVar(3, 'page-type', 'leaderboard', 3);
		} else if (bodyId == 'finalists') {
			pageTracker._setCustomVar(3, 'page-type', 'finalists', 3);
		}  else if (bodyId == 'submitIdea') {
			pageTracker._setCustomVar(3, 'page-type', 'submission-idea', 3);
		}  else if (bodyId == 'submitBasics') {
			pageTracker._setCustomVar(3, 'page-type', 'submission-basics', 3);
		}  else if (bodyId == 'projectDetails') {
			pageTracker._setCustomVar(3, 'page-type', 'submission-project details', 3);
		}  else if (bodyId == 'submitPreview') {
			pageTracker._setCustomVar(3, 'page-type', 'submission-preview', 3);
		}  else if (bodyId == 'generic') {
			REFRESH_APP.gaCustomVars.checkGeneric();
		}

	},

	/**
		Generic pages
	*/
	checkGeneric: function() {
		if ( $('body').hasClass('how-it-works') ) {
			pageTracker._setCustomVar(3, 'page-type', 'how-it-works', 3);
		} else if ( $('body').hasClass('official-application-guidelines') ) {
			pageTracker._setCustomVar(3, 'page-type', 'official-application-guidelines', 3);
		} else if ( $('body').hasClass('faq') ) {
			pageTracker._setCustomVar(3, 'page-type', 'faq', 3);
		}
	},

	/**
		Prize category
	*/
	checkPrizeCategory: function() {
		pageTracker._setCustomVar(4, 'idea-prize-category', '$'+$('#monetary-tier').html(), 3);
	},

	/**
		Idea category
	*/
	checkIdeaCategory: function(t) {
		var ideaCategory = (t=='idea') ? $('#idea-header-content .category-name').html() : $('#header-category h2').html();
		pageTracker._setCustomVar(5, 'idea-category', ideaCategory, 3);
	}
};

/**
	@class
	@description Sign up for PCNA on first vote popup
*/
REFRESH_APP.signUpPop = {

	/**
		Check if first vote and if not logged in as PCNA
	*/
	check: function() {

		var isFirstTime =  $.cookie("PEPSI_FIRSTVOTE");
		if(isFirstTime != null) return;

		$.cookie("PEPSI_FIRSTVOTE", 'true', { expires: 365 });

		if($('#profile-pcna').length) return;

		//this.show();

	},

	/**
		Show PCNA login and set id#profile-facebook as active (class is necessary to show login withou FB)
	*/
	yesClick: function(e) {

		e.preventDefault();
		$('#sign-question').remove();
		// removed facebook support $('#profile-facebook').addClass('active');
		REFRESH_APP.login.ajaxInit();

	},

	/**
		Close login popup
	*/
	noClick: function(e) {
		e.preventDefault();
		$.fn.colorbox.close();
	},

	/**
		Initialize yes/no button click
	*/
	init:function() {

		$("#sign-question a.sign-question-yes").live('click', REFRESH_APP.signUpPop.yesClick);
		$("#sign-question a.sign-question-no").live('click', REFRESH_APP.signUpPop.noClick);

	},

	/**
		Show popup
	*/
	show:function() {

		if($('#sign-question').length) return;

		$.fn.colorbox({
			href:'/index/ajaxquestion',
			scrolling:false,
			open:true,
			speed:300
		});

	}

};

/**
	@class
	@description Handle light registration
*/
REFRESH_APP.lightRegistration = {
	/**
		Initializes Registration
	*/
	init: function() {
		$('a[rel=light-registration]').live('click', function(e) {
			e.preventDefault();
/*
			// analytics removed
			//spotlight tracking
			var axel = Math.random() + "";
			var a = axel * 1000000000000000000;
			document.url = location.href;
			var doPing = new Image();
			// the URL below is a spotlight tag for page1
			doPing.src = REFRESH_APP.general.protocol + "fls.doubleclick.net/activityi;src=2155040;type=2010s621;cat=refre561;ord="+ a + "?";
*/
			REFRESH_APP.lightRegistration.ajaxInit();
		});
	},
	numErrors: 0,
	/**
		Set signup pop validation
	*/
	ajaxOnload: function() {
		pageTracker._trackEvent('Account', 'registration lightbox load');
		REFRESH_APP.selectBirthday.init();
		//REFRESH_APP.captcha.init();
		REFRESH_APP.lightRegistration.setValidation();
		var email = $.cookie("PEPSI_LOGINEMAIL");
		if(email != null) $('#light-registration.ajax #register #emailAddress').val(email);
		//$.cookie("PEPSI_LOGINEMAIL", null);
	},
	/**
		Initializes ajax signup
	*/
	ajaxInit: function() {
	
		var href = '/index/light-registration/lightbox/1';
		if(REFRESH_APP.ssl) href = '/index/light-registration-secure/lightbox/1';

		$.fn.colorbox({
			href:href,
			scrolling:false,
			open:true,
			speed:300,
			onComplete: REFRESH_APP.lightRegistration.ajaxOnload
		});
	},
	/**
		Initializes set validation
	*/
	setValidation: function() {
		REFRESH_APP.general.getScript('/js/validation-light-registration.js');
		//$.getScript('/js/validation-light-registration.js');
	}
};

/**
	@class
	@description Handle logging in
*/
REFRESH_APP.login = {

	/**
		Initializes login
	*/
	init: function() {

/*
		// removed facebook support
		$('#RES_ID_fb_login_text').live('click', function(e) {
			//tracking
			pageTracker._trackEvent('Account', 'login step load - facebook');
			$.fn.colorbox.close();
		});
*/

		$('a[rel=login]').live('click', function(e) {
			e.preventDefault();
			//tracking
			pageTracker._trackEvent('Account', 'login step load - lightbox');
			REFRESH_APP.login.ajaxInit();
		});

	},
	numErrors: 0,
	/**
		Set login pop validation
	*/
	ajaxOnload: function() {
		REFRESH_APP.login.setValidation();
		REFRESH_APP.login.togglePassword();
/*
		// removed facebook support
		var loc = location.href;		
		if(loc.indexOf('/myidea') > -1 || $('#profile-facebook.active').length > 0) {
			if($('#profile-facebook.active').length) {
				$('#login.ajax h2').html('Do you have a Pepsi account?');
			}
			$('#profile-facebook').removeClass('active');
			$('#login strong.or').hide();
			$('#login .login-facebook').hide();
		}
		if(typeof FB != 'undefined') FB.XFBML.Host.parseDomElement(document.getElementById('login'));
*/		

	},
	/**
		Initializes ajax login
	*/
	ajaxInit: function(msg) {

		var href = '/index/login/lightbox/1';
		if(REFRESH_APP.ssl) href = '/index/loginsecure/lightbox/1';		
		
		if(msg) href+= '?msg=' + msg;
		
		// init colorbox
		$.fn.colorbox({
			href:href,
			scrolling:false,
			open:true,
			speed:300,
			onComplete: REFRESH_APP.login.ajaxOnload
		});

	},
	/**
		Initializes set validation
	*/
	setValidation: function() {
		REFRESH_APP.general.getScript('/js/validation-login.js');
		//$.getScript('/js/validation-login.js');
	},
	/**
		Initializes password toggling
	*/
	togglePassword: function() {
		$('#user-login input[name=hasPepsiPassword]').click( function() {
			var disabled = ( $(this).val() == 'N' ) ? 'disabled' : '';
			var $pass = $('#user-login #password');
			if (disabled == '') {
				$pass.removeClass('disabled');
			} else {
				$pass.addClass('disabled');
			}
			$pass.attr('disabled', disabled);
		});
	}
};

/**
	@class
	@description Handle promote email
*/
REFRESH_APP.promoteEmail = {
	/**
		Initializes promote email
	*/
	init: function() {
		$('a[rel=promote-email]').live('click', function(e) {
			e.preventDefault();
/*
			// analytics removed
			//spotlight tracking
			var axel = Math.random() + "";
			var a = axel * 1000000000000000000;
			document.url = location.href;
			var doPing = new Image();
			// the URL below is a spotlight tag for page1
			doPing.src = REFRESH_APP.general.protocol + "fls.doubleclick.net/activityi;src=2155040;type=2010s621;cat=refre561;ord="+ a + "?";
*/
			REFRESH_APP.promoteEmail.ajaxInit();
		});
	},
	numErrors: 0,
	/**
		Set signup pop validation
	*/
	ajaxOnload: function() {
		//pageTracker._trackEvent('PromoteEmail', 'registration lightbox load');
		REFRESH_APP.captcha.init();
		REFRESH_APP.promoteEmail.setValidation();
	},
	/**
		Initializes ajax signup
	*/
	ajaxInit: function(url, title) {
		$.fn.colorbox({
			href:'/index/promote-email/idea?url=' + url + '&title=' + title,
			scrolling:false,
			open:true,
			speed:300,
			height:860,
			width:612,
			iframe:true
		});
	},
	/**
		Initializes set validation
	*/
	setValidation: function() {
		REFRESH_APP.general.getScript('/js/validation-promote-email.js');
	}
};

REFRESH_APP.autoSuggest = {

	init: function() {
		REFRESH_APP.general.getScript('/js/library/jquery.autocomplete-min.js',REFRESH_APP.autoSuggest.onLoad)
		//$.getScript('/js/library/jquery.autocomplete-min.js',REFRESH_APP.autoSuggest.onLoad);
		$('#nav-submit').click(function(e) {
			e.preventDefault();
			$('#nav-search').submit();
		});
	},

	onLoad: function() {
		var obj = $('#searchQueryNav');
		if(obj.length > 0) obj.autocomplete( { serviceUrl:('/static/search-results/suggest.php') } );
	}

};

/**
	@class
	@description Handle logging in via Facebook Connect
*/
REFRESH_APP.fbConnectLogin = {
	/**
		Initializes login
	*/
	init: function() {

		$('#facebook-logout').live('click', function(e) {
			e.preventDefault();
			var url = this.href;
			try{
			    FB.Connect.ifUserConnected(function(){
			        FB.Connect.logoutAndRedirect(url);
			    }, url);
			}catch(e){
			    location.href = url;
			}
		});

	},
	onload: function() {

		var href = '/index/facebookconnect';

		$.ajax({
			dataType: 'json',
			type: 'post',
			data: { ok:true },
			url: href,
			success: function(resp){
				if (resp.ok == true) {
					pageTracker._setCustomVar(1, 'account-type', 'facebook-connect', 2);
					pageTracker._trackEvent('Account', 'login', 'facebook');
					location.reload();
				} else {
					REFRESH_APP.login.ajaxInit('A problem was encountered while trying to sign you in. Please try again.');
				}
			},
			error: function() {
				REFRESH_APP.login.ajaxInit('A problem was encountered while trying to sign you in. Please try again.');
			}
		});
	}

};

/**
	@class
	@description Handle the status bar
*/
REFRESH_APP.statusBar = {
	/**
		Initializes datepicker
	*/
	init: function() {

		var loc = location.href;
		if( loc.indexOf('/myidea') > -1 || $('#nav').hasClass('nav-maintenance') ) return;

		var obj = $('#status-bar');
		if(obj.length < 1) return;

		obj.load('/status/index', {}, function() {
			// handle for ie6
			if ( $.browser.msie && $.browser.version == 6 ) {
				REFRESH_APP.statusBar.initIE6();
			}
			
			//check if user is logged in on funded ideas page
			if($("#fundedideas").length != 0 || $("#recent-updates").length != 0 || $("#success-stories").length != 0) {
		    	REFRESH_APP.fundedideas.showCheckbox();	
			}
			
			if($("#idea").length != 0) {
				REFRESH_APP.fundedideaLogin.init();
			}
		});

	},
	/**
		Initializes for IE6
	*/
	initIE6: function() {

		var $bar = $('#status-bar');
		var $window = $(window);
		var $wrapper = $('#status-bar-ie6-wrapper');

		// insert and set
		$bar.addClass('ie6').insertAfter('.extra-tracking:first');
		REFRESH_APP.statusBar.resizeContainer();
		// detect window events
		$window.scroll( function() {
			REFRESH_APP.statusBar.resizeContainer();
		});
		$window.resize( function() {
			$bar.hide();
			clearTimeout(REFRESH_APP.statusBar.timeOut);
			REFRESH_APP.statusBar.timeOut = setTimeout(REFRESH_APP.statusBar.resizeContainer, 300);
		});
	},
	resizeContainer: function() {
		var $bar = $('#status-bar');
		var $window = $(window);
		var newHeight = $window.scrollTop() + $window.height() - $bar.height();
		$bar.css({
			'margin-top' : newHeight+'px'
		}).show();
	},
	updateCounter: function(counter) {
		var counter = counter * -28;
		$("#status-number").animate({ top: counter + 'px' }, 1500 );
	},
	setCounter: function(counter) {
		var counter = counter * -28;
		$("#status-number").css("top", counter + "px");

	}
};


/**
	@class
	@description Sets rounded corners for items classed 'rounded'
*/
REFRESH_APP.roundedCorners = {
	/**
		Initializes rounded corners
	*/
	init: function() {
		if ($.browser.mozilla) {
			$("img.rounded").each( function () {
				var $img = $(this);
				var $wrapper = $('<div class="rounded"></div>');
				$wrapper.width($img.width());
				$wrapper.height($img.height());
				$wrapper.css({
					'background-image' : 'url('+$img.attr('src')+')',
					'float' : $img.css('float'),
					'margin-right' : $img.css('margin-right'),
					'margin-left' : $img.css('margin-left'),
					'margin-bottom' : $img.css('margin-bottom'),
					'margin-top' : $img.css('margin-top')
				});
				$img.replaceWith($wrapper);
			});
		} else {
			REFRESH_APP.general.getScript('/js/library/dd_roundies.min.js',function() {
				DD_roundies.addRule('.rounded', '10px', true);
			});
		}
	}
};

/**
	@class
	@description Pepsi can sound
*/
REFRESH_APP.pepsiSound = {
	/**
		play sound
	*/
	play: function() {
		$('#pepsi-sound').remove();
		var soundDiv = $('<div id="pepsi-sound"><div id="pepsi-sound-flash"></div></div>');
		$('body').append(soundDiv);
		var params = {
			menu: "false",
			allowfullscreen: "true",
			allowscriptaccess: "always",
			wmode: "transparent"
		};
		swfobject.embedSWF('/swf/sound.swf', 'pepsi-sound-flash', 1, 1, '9.0.0', null, null, params);
	},
	/**
		attach sound click event
	*/
	init: function() {

		var playSound =  $.cookie("PEPSI_PLAY_SOUND");
		if(playSound != null) {
			REFRESH_APP.pepsiSound.play();
		}

		$.cookie("PEPSI_PLAY_SOUND", null);

		$('#pepsi-can').live('click',function(e) {
			e.preventDefault();
			REFRESH_APP.pepsiSound.play();
		});
	}
}

/**
	@class
	@description Pepsi animation
*/
REFRESH_APP.pepsiAnimation = {
	/**
		shows pepsi can animation on the footer
	*/
	
	init: function() {	
	
			var swfFooterFile = null;
			
			if($('body').hasClass('french')) {
			    swfFooterFile = '/swf/pepsi_footer_fr.swf';
			} else {
			    swfFooterFile = '/swf/pepsi_footer.swf';		
			}
			
			if($("#pepsi-can-animation").length != 0) {
			var params = {
				menu: "false",
				allowscriptaccess: "always",
				bgcolor: "#00AEDB",
				wmode: "transparent"
			};
			swfobject.embedSWF(swfFooterFile, 'pepsi-can-animation', 442, 129, '9.0.0', null, null, params);
		}
	}
}

/**
	@class
	@description Forces tabbing through
*/
REFRESH_APP.forceTabbing = {
	/**
		Force tabbing through elements
	*/
	init: function() {
		var keyEvent = ($.browser.safari) ? 'keydown' : 'keypress';
		// track focused elements
		var currentFocus = -1;
		$('input:not(:hidden), select, textarea, button').live('focus', function() {
			$('.focus').removeClass('focus');
			$(this).addClass('focus');
		});
		// handle tab event
		$('body').live(keyEvent, function(e) {
			// detect 'tab' pressed
			if (e.keyCode == 9) {
				e.preventDefault();
				REFRESH_APP.forceTabbing.goToNext();
			}
		});
	},
	goToNext: function() {
		$fields = $('input:visible, select:visible, textarea:visible, button:visible');
		if ( $('.focus').length == 0 ) {
			$fields[0].focus();
		} else {
			var i = $fields.index( $('.focus') );
			var next = i+1;
			next = (next >= $fields.length) ? 0 : next;
			$fields[next].focus();
		}
	}
};

/**
	@class
	@description Defines validation handling
*/
REFRESH_APP.globalValidation = {

	loaded: false,

	hideLoading: function(form, validator) {
		$('#form-sending').remove();
	},

	showLoading: function(form) {

		if($('#light-registration #register').length || $('#login #user-login').length || $('#promote-email').length) return;

		var container = $('div.form-buttons');
		var loading = $('<div id="form-sending">'+msg_form_send+'</div>');
		container.prepend(loading);
		var topPx = 0;
		if($('#submitPreview').length > 0) loading.css( { top:'100px' });
		else loading.animate( { top:'0px' }, 400);

	},

	/**
		Initializes app validation
	*/
	init: function() {

		if(this.loaded) return;
		this.loaded = true;

		this.setValidationDefaults();
		this.addCustomValidationMethods();
		this.setTabIndex();
		REFRESH_APP.forceTabbing.init();

	},
	/**
		Set tabindex on form elements
	*/
	setTabIndex: function() {
		var tabindex = 1;
		$('input, select, textarea, button').each(function() {
			if (this.type != 'hidden') {
				var $input = $(this);
				$input.attr('tabindex', tabindex);
				tabindex++;
			}
		});
	},
	/**
		Sets default properties for the validator
	*/
	setValidationDefaults: function(){

		jQuery.validator.setDefaults({

			highlight: function(element, errorClass) {
				var $wrap = $(element).parents('.checkoff');
				if ($wrap.length) {
					$wrap.removeClass('checkoff-success');
					$wrap.addClass('checkoff-error');
				}
			},

			unhighlight: function(element, errorClass) {

				if($('#ideaAdmin').length > 0) {

					$(element).parents('fieldset')
					.find('p.error').not('.binded').addClass('binded')
					.bind('onafterhide', REFRESH_APP.submission.ideaAdmin.checkError)
					.bind('onshow', REFRESH_APP.submission.ideaAdmin.checkError);

				}

				var $wrap = $(element).parents('.checkoff');
				if ($wrap.length) {
					$wrap.removeClass('checkoff-error');
					$wrap.addClass('checkoff-success');
				}
			},

			errorElement: "p",

			errorPlacement: function(error, element) {
				var $g = $(element).parents('.fieldset-group:first');
				if ( $g.length ) {
					error.insertAfter( $g );
				} else {
					error.insertAfter( element );
				}
			}

		});

		$('form').submit( function() {
			if($('#submitIdea').length > 0) {
				var elm = $('input[name=grantCategoryId]:checked');
				if(elm.length > 0) {
					var n = elm.val();
					var category = $('label[for=grantCategoryId-'+n+']').text();
					if(category.length > 0) pageTracker._trackEvent('Idea Submission Process', 'idea submission save', category);
				}
			} else if($('#tracker-idea-category').length > 0) {
				var category = $('#tracker-idea-category').html();
				pageTracker._trackEvent('Idea Submission Process', 'submit idea', category);
			} else if($('#grantCategory').length > 0) {
				var category = $('#grantCategory').val();
				if(category.length > 0) pageTracker._trackEvent('Idea Submission Process', 'idea submission save', category);
			}
			REFRESH_APP.globalValidation.showLoading();
			if(typeof REFRESH_APP.submission !== 'undefined') REFRESH_APP.submission.autoSave.changed = false;
			$('ul.errors, p.error').hide();
		});

		$('.btn-goback').click( function() {
			REFRESH_APP.globalValidation.showLoading();
			if(typeof REFRESH_APP.submission !== 'undefined') REFRESH_APP.submission.autoSave.changed = false;
			$(this).parents('form').unbind('submit');
		});

	},
	/**
		Adds custom validation methods for the validator
	*/
	addCustomValidationMethods: function(){

		// handle the character count
		$('.fieldset-counter textarea').keyup( function() {
			$textarea = $(this);
			var $fieldset = $textarea.parents('fieldset');
			var $wrapper = $textarea.parents('.fieldset-counter');
			var id = $fieldset.attr('id');
			if ($wrapper.find('.secret-style').length == 0) {
				$wrapper.prepend('<div class="secret-style"></div>');
			}
			var $ss = $wrapper.find('.secret-style');
			if ( $textarea.val() != '' ) {
				if($ss.html()==''){
					$ss.html('<style type="text/css">#'+id+' .fieldset-counter p.error {display:none !important; padding:0 !important;}</style>');
				}
			} else {
				$ss.html('');
			}
		});

		// validYearsOld
		jQuery.validator.addMethod('validYearsOld', function(value, element) {
			if(value == 0) return false;
			return true;
        }, error_age);

		// validName
		jQuery.validator.addMethod('validName', function(value, element) {
 			return this.optional(element) || /^[^\s][a-zA-Z]*\s{0,1}[a-zA-Z]+$/.test(value);
        }, error_valid_characters);

		// validZipcode
		jQuery.validator.addMethod('validZipcode', function(value, element) {
 			return this.optional(element) ||  /(^\d{5}$)|(^\d{5}-\d{4}$)/.test(value);
        }, error_valid_postal_code);

		// validYoutubeLink
		jQuery.validator.addMethod('validYoutubeLink', function(value, element) {
// 			return this.optional(element) || /^((http[s]?|ftp):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+[^#?\s]+)(.*)?(#[\w\-]+)?$/.test(value);
			var validResults = ( $('#yt-results').html() !=  REFRESH_APP.submission.findYoutubeVideo.noMatch);
 			return this.optional(element) || ( /^((http):\/\/)?(www.)?(youtube.com\/watch\?v\=){1}(.)+$/.test(value) && validResults );
        }, error_valid_youtube);

		// validGoals
		jQuery.validator.addMethod('validGoals', function(value, element) {
			var $p = $(element).parents('.fieldset-group');
			var $goals = $p.find('.validGoals');
			var html = '';
			$goals.each( function() {
				html = html + $.trim( $(this).val() );
			});
 			return ( html !== '' );
        }, error_valid_goal);

		// validVision
		jQuery.validator.addMethod('validVision', function(value, element) {
			var $p = $(element).parents('.fieldset-group');
			var c = Number( $p.find('.textarea-help .count').text() );
 			return (c>-1 && c!=1000 );
        }, error_valid_plan);

		// validChallenges
		jQuery.validator.addMethod('validChallenges', function(value, element) {
			var $p = $(element).parents('.fieldset-group');
			var $challenges = $p.find('.validChallenges');
			var html = '';
			$challenges.each( function() {
				html = html + $.trim( $(this).val() );
			});
 			return ( html !== '' );
        }, error_valid_challenge);

		// validBudget
		jQuery.validator.addMethod('validBudget', function(value, element) {
			var $p = $(element).parents('.fieldset-group');
			var $wraps = $p.find('.field-wrap');
			var valid = false;
			$wraps.each( function() {
				var cost = $(this).find('input.budgetItemAmount').val();
				var item = $(this).find('input.budgetItemDescription').val();
				if ( cost !== '' && item !== '' ) {
					valid = true;
				}
			});
 			return valid;
        }, error_valid_budget);

		// validBudgetTotal
		jQuery.validator.addMethod('validBudgetTotal', function(value, element) {
			var n = parseFloat( $('#budget-total span').html().toString().replace(/\$|\,| /g,'') );
			var tier = $('#monetaryTier').val().toString().replace(/\$|\,| /g,'');
			if(tier == '') tier = '5000';
			var l = parseFloat( tier );
 			return (n <= l);
        }, error_over_budget);

		// countLimit
		/*
		jQuery.validator.addMethod('countLimit', function(value, element) {
			var $parent = $(element).parents('fieldset');
			var id = $parent.attr('id');
			if ($parent.find('.secret-style').length == 0) {
				$parent.prepend('<div class="secret-style"></div>');
			}
			var $ss = $parent.find('.secret-style');
			if ( value.length>1 ) {
				if($ss.html()==''){
					$ss.html('<style type="text/css">#'+id+' p.error {display:none !important; padding:0 !important;}</style>');
				}
			} else {
				$ss.html('');
			}
        }, "");
        */

		// validStaffing
		jQuery.validator.addMethod('validStaffing', function(value, element) {
			var valid = false;
			if ( $('#staffingTypeId-2:checked').length ) {
				var $p = $(element).parents('.fieldset-group');
				var $wraps = $p.find('.field-wrap');
				$wraps.each( function() {
					var ppl = $(this).find('input.staffingPeople').val();
					var res = $(this).find('input.staffingResponsibility').val();
					if ( ppl !== '' && res !== '' ) {
						valid = true;
					}
				});
			} else {
				valid = true;
			}
 			return valid;
        }, error_valid_staff);

		// validMilestone
		jQuery.validator.addMethod('validMilestone', function(value, element) {
			var $p = $(element).parents('.fieldset-group');
			var $wraps = $p.find('.field-wrap');
			var valid = false;
			$wraps.each( function() {
				var $fields = $(this).find('input.input-text');
				var filled = true;
				$fields.each( function() {
					if ( $(this).val() === '' ) {
						filled = false;
					}
				});
				if (filled) {
					valid = true;
				}
			});
 			return valid;
        }, error_valid_milestone);

	},

	/**
		Builds group string for validator; concatenates indices to string 'x' for 'n' times
	*/
	stringBuilder: function(x, n){
		var s='';
		for (var i=1; i<=n; i++) {
			var z = (i<10) ? '0'+i : i;
			s = s + x+z + ' ';
		}
		return s;
	}

};

/**
	@class
	@description More third parties
*/
REFRESH_APP.morebox = {

	initialized: false,
	active: false,
	$morebox: false,
	timeout: false,
	preventClose: false,

	/**
		Init
	*/
	init: function() {
		this.initLink();
	},

	/**
		Init
	*/
	initLink: function() {
		var $moreLink = $('.more-button');
		$moreLink.click( function(e) {
			e.preventDefault();
		});
		/*$moreLink.mouseover( function(e) {
			e.stopPropagation();

			clearTimeout(REFRESH_APP.morebox.timeout);
			if ( !REFRESH_APP.morebox.initialized ) {
				REFRESH_APP.morebox.initialized = true;
				REFRESH_APP.morebox.initBox($(this));
			} else {
				$('div.' + $(this).attr("id")).addClass("activeMoreBox");
				REFRESH_APP.morebox.$morebox = $('div.' + $(this).attr("id"));
				REFRESH_APP.morebox.$morebox.fadeIn();
			}
		});*/
		$("#more-button-header").mouseover( function(e) {
			e.stopPropagation();

			clearTimeout(REFRESH_APP.morebox.timeout);
			if ( !REFRESH_APP.morebox.initialized ) {
				REFRESH_APP.morebox.initialized = true;
				REFRESH_APP.morebox.initBox($(this));
			} else {
				$('div.' + $(this).attr("id")).addClass("activeMoreBox");
				REFRESH_APP.morebox.$morebox = $('div.' + $(this).attr("id"));
				REFRESH_APP.morebox.$morebox.fadeIn();
			}
		});

		$("#more-button-idea1").mouseover( function(e) {
			e.stopPropagation();

			clearTimeout(REFRESH_APP.morebox.timeout);
			if ( !REFRESH_APP.morebox.initialized ) {
				REFRESH_APP.morebox.initialized = true;
				REFRESH_APP.morebox.initBox($(this));
			} else {
				$('div.' + $(this).attr("id")).addClass("activeMoreBox");
				REFRESH_APP.morebox.$morebox = $('div.' + $(this).attr("id"));
				REFRESH_APP.morebox.$morebox.fadeIn();
			}
		});

		$("#more-button-idea2").mouseover( function(e) {
			e.stopPropagation();

			clearTimeout(REFRESH_APP.morebox.timeout);
			if ( !REFRESH_APP.morebox.initialized ) {
				REFRESH_APP.morebox.initialized = true;
				REFRESH_APP.morebox.initBox($(this));
			} else {
				$('div.' + $(this).attr("id")).addClass("activeMoreBox");
				REFRESH_APP.morebox.$morebox = $('div.' + $(this).attr("id"));
				REFRESH_APP.morebox.$morebox.fadeIn();
			}
		});
	},

	/**
		Init
	*/
	initBox: function(obj) {
		REFRESH_APP.morebox.$morebox = $('div.' + obj.attr("id"));
		REFRESH_APP.morebox.$morebox.fadeIn();
		REFRESH_APP.morebox.$morebox.mouseover( function(e) {
			e.stopPropagation();
			clearTimeout(REFRESH_APP.morebox.timeout);
		});
		REFRESH_APP.morebox.initBody();
	},

	/**
		Init
	*/
	initBody: function() {
		$('body').mouseover( function(e) {
			var id = e.target.id;
			clearTimeout(REFRESH_APP.morebox.timeout);
			REFRESH_APP.morebox.timeout = setTimeout(REFRESH_APP.morebox.close, 200);
		});
	},

	close: function() {
		clearTimeout(REFRESH_APP.morebox.timeout);
		REFRESH_APP.morebox.$morebox.fadeOut();
		$('div.activeMoreBox').each(function() {
			$(this).fadeOut().removeClass("activeMoreBox");
		});
	}

};

/**
	@class
	@description Video loading
*/
REFRESH_APP.loadvideo = {
	/**
		Init
	*/
	init: function(video, id, width, height, flashvars, params, attributes) {

		// home page video

		this.videoContainer = $('#about-player-wrapper');

		$(window).scroll(this.resizeTimeOut);
		$(window).resize(this.resizeTimeOut);

		// how it works video

		$('#refresh-video-wrap').animate( { 'height':'354px' }, "fast", "linear",
			function(){
				swfobject.embedSWF(video, id, width, height, '9.0.0', '/video/expressInstall.swf', flashvars, params, attributes);
				$('#refresh-video-wrap div.flash-disclaimer').removeClass('flash-disclaimer-hidden');
				$('#refresh-video-wrap').css( { 'height':'auto' } );
				$('#flashContent-wrapper').css( { 'height':'354px' } );
			}
		);

	},

	initPosition: null,

	resizeTimeOut: function() {

		var self = REFRESH_APP.loadvideo;
		clearTimeout(self.timeOut);
		self.timeOut = setTimeout( self.resize, 100 );

	},

	resize: function() {

		var self = REFRESH_APP.loadvideo;

		if(self.videoContainer.length > 0) if(self.videoContainer.hasClass('active')) {

			var w = $(window).width();
			var h = $(window).height();
			var t = $(window).scrollTop();
			self.videoContainer.css('zIndex',1000).animate( { width: w, height: h, left:0, top:t }, 'fast' );

		}

	},

	expand: function() {
	
		this.videoContainer.addClass('active');
		this.resize();

		if($.browser.msie) $('#content select').hide();

	},

	collapse: function() {
	
		var position = $('#about-player-placeholder').position();
		this.videoContainer.css('zIndex',99).animate( { width: '200px', height: '113px', left:position.left, top:position.top }, 'fast' , function() {
			$(this).css( { left:'', top:'' } );
		}).removeClass('active');

		if($.browser.msie) $('#content select').show();

	},

	handleEvents: function(e) {

		if( $("#generic").length > 0 ) {

			if(e==="stop") REFRESH_APP.loadvideo.shrinkVideo();
			if(e==="play") REFRESH_APP.loadvideo.growVideo();

		} else {

			if(e==="play") REFRESH_APP.loadvideo.expand();
			if(e==="pause") REFRESH_APP.loadvideo.collapse();
			if(e==="stop") REFRESH_APP.loadvideo.collapse();

		}
	},

	growVideo: function(e) {
		if(e) e.preventDefault();
		$.scrollTo('#refresh-video-wrap', 500);
		$('#flashContent-wrapper').animate( { width:'945px', height:'531px' } , "fast");
	},

	shrinkVideo: function(e) {
		if(e) e.preventDefault();
		$('#flashContent-wrapper').animate( { width:'630px', height:'354px' } , "fast");
	}
};

/**
	@class
	@description Handle birthday selection
*/
REFRESH_APP.selectBirthday = {
	/**
		Init
	*/
	init: function() {
		REFRESH_APP.selectBirthday.updateDays( $('#dobMonth'), $('#dobDay'), $('#dobYear') );
		$('#dobMonth, #dobYear').change( function() {
			REFRESH_APP.selectBirthday.updateDays( $('#dobMonth'), $('#dobDay'), $('#dobYear') );
		});
	},
	/**
		Handle drop downs for birthday
	*/
	updateDays: function( $months, $days, $years ) {
		var daysInMonth = ['', 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
		// handle leap years
		var year = $years.find('option:selected').val();
		daysInMonth[2] = ((year%4==0 && year%100!=0) || (year%400==0)) ? 29 : 28;
		// get month / day values
		var month = $months.find('option:selected').val();
		// build options for month selected
		var options = '';
		if( month == 0 ) {
			options = '<option value="0">- Day -</option>';
		} else {
			var day = $days.find('option:selected').val();
			options = '<option value="0">- Day -</option>';
			for( var z = 1; z <= daysInMonth[month]; z++) {
				options = options + '<option label="'+z+'" value="'+z+'"';
				if (z == day) {
					options = options + ' selected="selected"';
				}
				options = options + '>'+z+'</option>';
			}
		}
		$days.html(options);
	}
};

/**
	@class
	@description Captcha handling
*/
REFRESH_APP.captcha = {
	/**
		Init
	*/
	init: function() {
		$('#captchaText').val('');
		// refresh image
		$('#captcha-refresh').click( function(e) {
			//$link = $(this);
			//$link.addClass('processing');
			e.preventDefault();
			$.ajax({
				type: 'post',
				url: '/myidea/get-captcha',
				dataType: 'json',
				data: { ok:true },
				success: function(resp){
					$('#captcha-image').attr('src', resp.captchaUrl);
					$('input#sessionId').val(resp.sessionId);
					$('input#captchaText').val('');
					//$link.removeClass('processing');
				},
				error: function() {
					//$link.removeClass('processing');
					alert('Sorry, we encountered a problem. Please try again.');
				}
			});
		});
		// refresh audio
		$('#captcha-refresh-audio').click( function(e) {
			//$link = $(this);
			//$link.addClass('processing');
			e.preventDefault();
			$.ajax({
				type: 'post',
				url: '/myidea/get-captcha-audio',
				dataType: 'json',
				data: { ok:true },
				success: function(resp){
					$('#captcha_param_file').attr('value', 'file=' + resp.captchaUrl);
					$('#captchaaudioswfemb').attr('flashvars', 'file=' + resp.captchaUrl);
					$('input#sessionIdAudio').val(resp.sessionId);
					$('input#captchaText').val('');

					var captchaAudioHolderFlashHtml = $("#captchaAudioHolderFlash").html();
					$("#captchaAudioHolderFlash").html('');
					$("#captchaAudioHolderFlash").html(captchaAudioHolderFlashHtml);

					//setTimeout ( '$("#captchaAudioHolder").css("display", "block"); $("#captchaAudioHolder object").css("visibility", "visible");', 200 );
					//$link.removeClass('processing');
				},
				error: function() {
					//$link.removeClass('processing');
					alert(error_try_again);
				}
			});
		});
	}
};


/**
	@class
	@description Toggler
*/
REFRESH_APP.toggler = {
	active: false,
	/**
		Init
	*/
	init: function($button, $content) {
		$button.click( function(e) {
			e.preventDefault();
			if (REFRESH_APP.toggler.active) {
				$content.slideUp();
				REFRESH_APP.toggler.active = false;
			} else {
				$content.slideDown();
				REFRESH_APP.toggler.active = true;
			}
		});
	}
	
};

/**
	@class
	@description Toggler
*/
REFRESH_APP.alertEmail = {
	/**
		Init
	*/
	init: function($button, $content) {
		REFRESH_APP.alertEmail.setValidation();
	},
	/**
		Set validation
	*/
	setValidation: function() {
		$('#alert-signup').validate({
			rules: {
				'alert-email': {
					required: false,
					email: true,
					maxlength:120
				}
			},
			messages: {
				'alert-email': {
					email: "Please enter a valid email address"
				}
			},
			submitHandler: function(form) {
				REFRESH_APP.alertEmail.ajaxSubmit(form);
				//REFRESH_APP.alertEmail.showConfirmation(form);
			}
		});
	},
	/**
		AJAX submission
	*/
	ajaxSubmit: function(form) {
	    if ($('body').hasClass('french')) {
	        $.ajax({
    			type: 'post',
    			url: '/email/save',
    			data: {emailAddress : $(form).find('#emailAddress').val()},
    			success: function(resp){
    				if (resp == 1) {
    					REFRESH_APP.alertEmail.showConfirmation(form);
    				} else if (resp == 'ALREADY_IN_DATABASE') {
    					var msg = 'Oups ! Cette adresse courriel existe déjà. Essaie de nouveau.';
    					REFRESH_APP.alertEmail.showError(form, msg);
    				} else if (resp == 'INVALID_FORMAT') {
    					var msg = 'Désolé il y a un problème avec le format de votre adresse courriel. Veuillez essayer de nouveau.';
    					REFRESH_APP.alertEmail.showError(form, msg);
    				} else if (resp == 'GENERAL_FAILURE') {
    					var msg = 'Nous éprouvons malheureusement des difficultés à soumettre ta demande. Essaie de nouveau, s\'il te plaît.';
    					REFRESH_APP.alertEmail.showError(form, msg);
    				} else {
    					var msg = 'Nous éprouvons malheureusement des difficultés à soumettre ta demande. Essaie de nouveau, s\'il te plaît.';
    					REFRESH_APP.alertEmail.showError(form, msg);
    				}
    			},
    			error: function() {
    				var msg = 'Nous éprouvons malheureusement des difficultés à soumettre ta demande. Essaie de nouveau, s\'il te plaît.';
    				REFRESH_APP.alertEmail.showError(form, msg);
    			}
    		});
	    } else {
	        $.ajax({
    			type: 'post',
    			url: '/email/save',
    			data: {emailAddress : $(form).find('#emailAddress').val()},
    			success: function(resp){
    				if (resp == 1) {
    					REFRESH_APP.alertEmail.showConfirmation(form);
    				} else if (resp == 'ALREADY_IN_DATABASE') {
    					var msg = 'Oops! That email address is already signed up. Please try again.';
    					REFRESH_APP.alertEmail.showError(form, msg);
    				} else if (resp == 'INVALID_FORMAT') {
    					var msg = 'Oops! There was a problem with the format of your email address. Please try again.';
    					REFRESH_APP.alertEmail.showError(form, msg);
    				} else if (resp == 'GENERAL_FAILURE') {
    					var msg = 'Sorry, we had some trouble submitting your request. Please try again.';
    					REFRESH_APP.alertEmail.showError(form, msg);
    				} else {
    					var msg = 'Sorry, we had some trouble submitting your request. Please try again.';
    					REFRESH_APP.alertEmail.showError(form, msg);
    				}
    			},
    			error: function() {
    				var msg = 'Sorry, we had some trouble submitting your request. Please try again.';
    				REFRESH_APP.alertEmail.showError(form, msg);
    			}
    		});
	    }
	    
	},
	/**
		Handle confirmation
	*/
	showConfirmation: function(form) {
	    var $pe = $('<p class="confirm">Done! We\'ll let you know.</p>');
	    var $pf = $('<p class="confirm">C\'est fait ! Nous te tiendrons au courant.</p>');
		
		$(form).fadeOut( 100, function() {
			if ($('body').hasClass('french')) {
    	        $(this).html($pf).fadeIn(100);
    	    } else {
    	        $(this).html($pe).fadeIn(100);
    	    }
		});

	},
	/**
		Handle error
	*/
	showError: function(form, msg) {
		$(form).find('ul.errors').remove();
		var $ul = $('<ul class="errors"><li>'+msg+'</li></ul>');
		$(form).find('fieldset').after($ul);
	}
	
};


/**
	@class
	@description Toggles alert emails
*/
REFRESH_APP.showAlertEmail = {
	/**
		Handle display of alert email
	*/
	init: function() {
		$('#alert-me').live('click', function(e) {
			e.preventDefault();
			$(this).fadeOut( 100, function() {
				$('#alert-signup').fadeIn(100)
			});
		});
	}
};

/**
	@class
	@description Countdown timer
*/

REFRESH_APP.timeCountdown = {
	targetDate: false,
	$counter: false,
	/**
		Init
	*/
	init: function( $c ) {
		var d = new Date( appNextVotingDate );
		d.setSeconds(d.getSeconds() + 1);
		REFRESH_APP.timeCountdown.targetDate = d;
		if ($c.length) {
			this.$counter = $c;
			REFRESH_APP.timeCountdown.setDefaults();
			$('#countdown').countdown({
				until: REFRESH_APP.timeCountdown.targetDate,
				onExpiry: REFRESH_APP.timeCountdown.complete
			});
		}
	},
	/**
		Set countdown defaults
	*/
	setDefaults: function() {
		$.countdown.setDefaults({
			serverSync: REFRESH_APP.timeCountdown.syncServer,
			format: 'DHMS',
			layout:
				'<ul class="clearfix">' +
				'{y<}<li>{yn}</li>{y>}' + 
				'{o<}<li>{on}</li>{o>}' + 
				'{d<}<li class="days">{dnn}</li>{d>}' + 
				'{h<}<li class="hours">:{hnn}</li>{h>}' + 
				'{m<}<li class="minutes">:{mnn}</li>{m>}' + 
				'{s<}<li class="seconds">:{snn}</li>{s>}' + 
				'</ul>'
		});
	},
	/**
		Set countdown defaults
	*/
	syncServer: function() {
	    var time = null; 
	    var randomNumber = Math.floor(Math.random()*100000000);
	    $.ajax({
	    	url: '/utilities/servertime?'+randomNumber, 
			async: false,
			dataType: 'text', 
			success: function(text) { 
				time = new Date(text); 
			}, error: function(http, message, exc) { 
				time = new Date();
			}
	    });
	    return time; 
	},
	/**
		Set countdown timer with deadline and callback
	*/
	setCountdown: function(deadline, callback) {
		var dl = new Date();
		dl.setSeconds(dl.getSeconds() + deadline);
		$('#countdown').countdown('change', {
			until: dl,
			onExpiry: callback
		});
	},
	/**
		Completed countdown
	*/
	complete: function(headlineHTML, actionHTML) {
		var randomNumber = Math.floor( Math.random() * 10000000000 )
		var loc = window.location;
		window.location = loc + '?' + randomNumber;
	}
	
};

/**
	@class
	@description Countdown timer
*/

REFRESH_APP.heightMatch = {
	/**
		Init
	*/
	init: function( $elems ) {

		$(window).load( REFRESH_APP.heightMatch.setHeights( $elems ) );

	},
	/**
		Match the heights
	*/
	setHeights: function( $elems ) {

		var height_tar = 0, height_obj, pad_top, pad_bot, bor_top, bor_bot, offset;
	
		$elems.each(function() {
			height_obj = $(this).outerHeight();
			height_tar = Math.max(height_tar, height_obj);
		});
	
		$elems.each(function() {
		
			pad_top = parseInt($(this).css("padding-top"), 10),
			pad_bot = parseInt($(this).css("padding-bottom"), 10),
			offset  = pad_top + pad_bot;
	
			// fix for ie6
			if ($.browser.msie && $.browser.version == 6) {
				$(this).css("height", (height_tar - offset) + "px");
			} else {
				$(this).css("min-height", (height_tar - offset) + "px");
			}
	
		});

	}
	
};


/**
	@class
	@description Activates input text refill
*/

REFRESH_APP.refillText = {

	initValues : new Array(),

	/**
		Saves initial values into array and activates the watch for a field
	*/
	init: function() {
		var iv = new Array();
		$('input.input-refill').each( function() {
			$i = $(this);
			iv[$i.attr('id')] = $i.val();
			REFRESH_APP.refillText.watchFieldEvent(this);
		});
		this.initValues = iv;
	},
	
	/**
		Handles the focus and blur events for the form field;
		onFocus checks if value matches initial,
		onBlur checks to see if value is empty
	*/
	watchFieldEvent: function(field) {
		var $field = $(field);
		// Handle focus
		$field.focus( function() {
			var v = $field.val();
			var id = $field.attr('id');
			if ( REFRESH_APP.refillText.initValues[id] == v ) {
				$field.val('').addClass('active');
			}
		});
		// Handle blur
		$field.blur( function() {
			if ( $field.val() == '' ) {
				$field.val( REFRESH_APP.refillText.initValues[$field.attr('id')] ).removeClass('active');
			}
		});
	}
	
};


jQuery(function($) {

	REFRESH_APP.general.init();
	//REFRESH_APP.autoSuggest.init();

});

// page Privacy Policy requires both functions:

function openWin(theURL,winName,params){
	window.open(theURL,winName,params + ',menubar=no,resizable=no,toolbar=no,status=no,titlebar=no,location=no');
}
function MM_openBrWindow(theURL,winName,params){
	window.open(theURL,winName,params + ',menubar=no,resizable=no,toolbar=no,status=no,titlebar=no,location=no');
}

/* http://keith-wood.name/countdown.html
   Countdown for jQuery v1.5.5.
   Written by Keith Wood (kbwood{at}iinet.com.au) January 2008.
   Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and 
   MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses. 
   Please attribute the author if you use it. */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(A($){A 1i(){8.1B=[];8.1B[\'\']={1j:[\'2t\',\'2u\',\'2v\',\'2w\',\'2x\',\'2y\',\'2z\'],2A:[\'2B\',\'2C\',\'2D\',\'2E\',\'2F\',\'2G\',\'2H\'],1k:[\'y\',\'m\',\'w\',\'d\'],1C:\':\',1R:1e};8.1f={1S:E,1T:E,1U:E,1V:E,1W:\'2I\',1l:\'\',1X:1e,1D:\'\',1Y:\'\',1Z:\'\',20:1e,21:E,22:E};$.1t(8.1f,8.1B[\'\'])}x w=\'G\';x Y=0;x O=1;x W=2;x D=3;x H=4;x M=5;x S=6;$.1t(1i.23,{1m:\'2J\',2K:2L(A(){$.G.25()},2M),18:[],2N:A(a){8.1E(8.1f,a);1F(8.1f,a||{})},1G:A(a,b,c,e,f,g,h,i){B(1n b==\'2O\'&&b.2P==Q){i=b.1H();h=b.1I();g=b.1J();f=b.1K();e=b.T();c=b.15();b=b.16()}x d=P Q();d.2Q(b);d.26(1);d.2R(c||0);d.26(e||1);d.2S(f||0);d.2T((g||0)-(U.2U(a)<30?a*1g:a));d.2V(h||0);d.2W(i||0);C d},2X:A(a,b){B(!b){C $.G.1f}x c=$.V(a,w);C(b==\'2Y\'?c.X:c.X[b])},27:A(a,b){x c=$(a);B(c.28(8.1m)){C}c.2Z(8.1m);x d={X:$.1t({},b),z:[0,0,0,0,0,0,0]};$.V(a,w,d);8.29(a)},1L:A(a){B(!8.1M(a)){8.18.31(a)}},1M:A(a){C($.33(a,8.18)>-1)},1u:A(b){8.18=$.34(8.18,A(a){C(a==b?E:a)})},25:A(){19(x i=0;i<8.18.1v;i++){8.1o(8.18[i])}},1o:A(a,b){x c=$(a);b=b||$.V(a,w);B(!b){C}c.35(8.2a(b));c[(8.F(b,\'1R\')?\'36\':\'37\')+\'38\'](\'39\');x d=8.F(b,\'22\');B(d){d.1p(a,[b.R!=\'2b\'?b.z:8.1w(b,b.I,P Q())])}x e=b.R!=\'1q\'&&(b.J?b.1a.K()<=b.J.K():b.1a.K()>=b.Z.K());B(e&&!b.1N){b.1N=2c;B(8.1M(a)||8.F(b,\'20\')){8.1u(a);x f=8.F(b,\'21\');B(f){f.1p(a,[])}x g=8.F(b,\'1Z\');B(g){x h=8.F(b,\'1l\');b.X.1l=g;8.1o(a,b);b.X.1l=h}x i=8.F(b,\'1Y\');B(i){3a.3b=i}}b.1N=1e}1r B(b.R==\'1q\'){8.1u(a)}$.V(a,w,b)},29:A(a,b,c){b=b||{};B(1n b==\'1O\'){x d=b;b={};b[d]=c}x e=$.V(a,w);B(e){8.1E(e.X,b);1F(e.X,b);8.2d(a,e);$.V(a,w,e);x f=P Q();B((e.J&&e.J<f)||(e.Z&&e.Z>f)){8.1L(a)}8.1o(a,e)}},1E:A(a,b){x c=1e;19(x n 1P b){B(n.N(/[2e]2f/)){c=2c;17}}B(c){19(x n 1P a){B(n.N(/[2e]2f[0-9]/)){a[n]=E}}}},2d:A(a,b){x c=8.F(b,\'1V\');c=(c?c.1p(a,[]):E);x d=P Q();x e=8.F(b,\'1U\');e=(e==E?-d.3c():e);b.J=8.F(b,\'1T\');B(b.J){b.J=8.1G(e,8.1x(b.J,E));B(b.J&&c){b.J.1y(b.J.1H()+d.K()-c.K())}}b.Z=8.1G(e,8.1x(8.F(b,\'1S\'),d));B(c){b.Z.1y(b.Z.1H()+d.K()-c.K())}b.I=8.2g(b)},3d:A(a){x b=$(a);B(!b.28(8.1m)){C}8.1u(a);b.3e(8.1m).3f();$.3g(a,w)},3h:A(a){8.R(a,\'1q\')},3i:A(a){8.R(a,\'2b\')},3j:A(a){8.R(a,E)},R:A(a,b){x c=$.V(a,w);B(c){B(c.R==\'1q\'&&!b){c.z=c.2h;x d=(c.J?\'-\':\'+\');c[c.J?\'J\':\'Z\']=8.1x(d+c.z[0]+\'y\'+d+c.z[1]+\'o\'+d+c.z[2]+\'w\'+d+c.z[3]+\'d\'+d+c.z[4]+\'h\'+d+c.z[5]+\'m\'+d+c.z[6]+\'s\');8.1L(a)}c.R=b;c.2h=(b==\'1q\'?c.z:E);$.V(a,w,c);8.1o(a,c)}},3k:A(a){x b=$.V(a,w);C(!b?E:(!b.R?b.z:8.1w(b,b.I,P Q())))},F:A(a,b){C(a.X[b]!=E?a.X[b]:$.G.1f[b])},1x:A(k,l){x m=A(a){x b=P Q();b.2i(b.K()+a*11);C b};x n=A(a){a=a.3l();x b=P Q();x c=b.16();x d=b.15();x e=b.T();x f=b.1K();x g=b.1J();x h=b.1I();x i=/([+-]?[0-9]+)\\s*(s|m|h|d|w|o|y)?/g;x j=i.2j(a);3m(j){3n(j[2]||\'s\'){1b\'s\':h+=1c(j[1],10);17;1b\'m\':g+=1c(j[1],10);17;1b\'h\':f+=1c(j[1],10);17;1b\'d\':e+=1c(j[1],10);17;1b\'w\':e+=1c(j[1],10)*7;17;1b\'o\':d+=1c(j[1],10);e=U.1z(e,$.G.1h(c,d));17;1b\'y\':c+=1c(j[1],10);e=U.1z(e,$.G.1h(c,d));17}j=i.2j(a)}C P Q(c,d,e,f,g,h,0)};x o=(k==E?l:(1n k==\'1O\'?n(k):(1n k==\'3o\'?m(k):k)));B(o)o.1y(0);C o},1h:A(a,b){C 32-P Q(a,b,32).T()},2a:A(c){c.z=13=(c.R?c.z:8.1w(c,c.I,P Q()));x d=1e;x e=0;19(x f=0;f<c.I.1v;f++){d|=(c.I[f]==\'?\'&&13[f]>0);c.I[f]=(c.I[f]==\'?\'&&!d?E:c.I[f]);e+=(c.I[f]?1:0)}x g=8.F(c,\'1X\');x h=8.F(c,\'1l\');x i=(g?8.F(c,\'1k\'):8.F(c,\'1j\'));x j=8.F(c,\'1C\');x k=8.F(c,\'1D\')||\'\';x l=A(a){x b=$.G.F(c,\'1k\'+13[a]);C(c.I[a]?13[a]+(b?b[a]:i[a])+\' \':\'\')};x m=A(a){x b=$.G.F(c,\'1j\'+13[a]);C(c.I[a]?\'<14 1s="3p"><14 1s="2k">\'+13[a]+\'</14><3q/>\'+(b?b[a]:i[a])+\'</14>\':\'\')};C(h?8.2l(c,h,g):((g?\'<14 1s="1Q 2k\'+(c.R?\' 2m\':\'\')+\'">\'+l(Y)+l(O)+l(W)+l(D)+(c.I[H]?8.L(13[H],2):\'\')+(c.I[M]?(c.I[H]?j:\'\')+8.L(13[M],2):\'\')+(c.I[S]?(c.I[H]||c.I[M]?j:\'\')+8.L(13[S],2):\'\'):\'<14 1s="1Q 3r\'+e+(c.R?\' 2m\':\'\')+\'">\'+m(Y)+m(O)+m(W)+m(D)+m(H)+m(M)+m(S))+\'</14>\'+(k?\'<14 1s="1Q 3s">\'+k+\'</14>\':\'\')))},2l:A(c,d,e){x f=8.F(c,(e?\'1k\':\'1j\'));x g=A(a){C($.G.F(c,(e?\'1k\':\'1j\')+c.z[a])||f)[a]};x h=A(a,b){C U.1A(a/b)%10};x j={3t:8.F(c,\'1D\'),3u:8.F(c,\'1C\'),3v:g(Y),3w:c.z[Y],3x:8.L(c.z[Y],2),3y:8.L(c.z[Y],3),3z:h(c.z[Y],1),3A:h(c.z[Y],10),3B:h(c.z[Y],1d),3C:h(c.z[Y],11),3D:g(O),3E:c.z[O],3F:8.L(c.z[O],2),3G:8.L(c.z[O],3),3H:h(c.z[O],1),3I:h(c.z[O],10),3J:h(c.z[O],1d),3K:h(c.z[O],11),3L:g(W),3M:c.z[W],3N:8.L(c.z[W],2),3O:8.L(c.z[W],3),3P:h(c.z[W],1),3Q:h(c.z[W],10),3R:h(c.z[W],1d),3S:h(c.z[W],11),3T:g(D),3U:c.z[D],3V:8.L(c.z[D],2),3W:8.L(c.z[D],3),3X:h(c.z[D],1),3Y:h(c.z[D],10),3Z:h(c.z[D],1d),40:h(c.z[D],11),41:g(H),42:c.z[H],43:8.L(c.z[H],2),44:8.L(c.z[H],3),45:h(c.z[H],1),46:h(c.z[H],10),47:h(c.z[H],1d),48:h(c.z[H],11),49:g(M),4a:c.z[M],4b:8.L(c.z[M],2),4c:8.L(c.z[M],3),4d:h(c.z[M],1),4e:h(c.z[M],10),4f:h(c.z[M],1d),4g:h(c.z[M],11),4h:g(S),4i:c.z[S],4j:8.L(c.z[S],2),4k:8.L(c.z[S],3),4l:h(c.z[S],1),4m:h(c.z[S],10),4n:h(c.z[S],1d),4o:h(c.z[S],11)};x k=d;19(x i=0;i<7;i++){x l=\'4p\'.4q(i);x m=P 2n(\'\\\\{\'+l+\'<\\\\}(.*)\\\\{\'+l+\'>\\\\}\',\'g\');k=k.2o(m,(c.I[i]?\'$1\':\'\'))}$.2p(j,A(n,v){x a=P 2n(\'\\\\{\'+n+\'\\\\}\',\'g\');k=k.2o(a,v)});C k},L:A(a,b){a=\'\'+a;B(a.1v>=b){C a}a=\'4r\'+a;C a.4s(a.1v-b)},2g:A(a){x b=8.F(a,\'1W\');x c=[];c[Y]=(b.N(\'y\')?\'?\':(b.N(\'Y\')?\'!\':E));c[O]=(b.N(\'o\')?\'?\':(b.N(\'O\')?\'!\':E));c[W]=(b.N(\'w\')?\'?\':(b.N(\'W\')?\'!\':E));c[D]=(b.N(\'d\')?\'?\':(b.N(\'D\')?\'!\':E));c[H]=(b.N(\'h\')?\'?\':(b.N(\'H\')?\'!\':E));c[M]=(b.N(\'m\')?\'?\':(b.N(\'M\')?\'!\':E));c[S]=(b.N(\'s\')?\'?\':(b.N(\'S\')?\'!\':E));C c},1w:A(f,g,h){f.1a=h;f.1a.1y(0);x i=P Q(f.1a.K());B(f.J){B(h.K()<f.J.K()){f.1a=h=i}1r{h=f.J}}1r{i.2i(f.Z.K());B(h.K()>f.Z.K()){f.1a=h=i}}x j=[0,0,0,0,0,0,0];B(g[Y]||g[O]){x k=$.G.1h(h.16(),h.15());x l=$.G.1h(i.16(),i.15());x m=(i.T()==h.T()||(i.T()>=U.1z(k,l)&&h.T()>=U.1z(k,l)));x n=A(a){C(a.1K()*1g+a.1J())*1g+a.1I()};x o=U.4t(0,(i.16()-h.16())*12+i.15()-h.15()+((i.T()<h.T()&&!m)||(m&&n(i)<n(h))?-1:0));j[Y]=(g[Y]?U.1A(o/12):0);j[O]=(g[O]?o-j[Y]*12:0);x p=A(a,b,c){x d=(a.T()==c);x e=$.G.1h(a.16()+b*j[Y],a.15()+b*j[O]);B(a.T()>e){a.2q(e)}a.4u(a.16()+b*j[Y]);a.4v(a.15()+b*j[O]);B(d){a.2q(e)}C a};B(f.J){i=p(i,-1,l)}1r{h=p(P Q(h.K()),+1,k)}}x q=U.1A((i.K()-h.K())/11);x r=A(a,b){j[a]=(g[a]?U.1A(q/b):0);q-=j[a]*b};r(W,4w);r(D,4x);r(H,4y);r(M,1g);r(S,1);B(q>0&&!f.J){x s=[1,12,4.4z,7,24,1g,1g];x t=S;x u=1;19(x v=S;v>=Y;v--){B(g[v]){B(j[t]>=u){j[t]=0;q=1}B(q>0){j[v]++;q=0;t=v;u=1}}u*=s[v]}}C j}});A 1F(a,b){$.1t(a,b);19(x c 1P b){B(b[c]==E){a[c]=E}}C a}$.4A.G=A(a){x b=4B.23.4C.4D(4E,1);B(a==\'4F\'||a==\'4G\'){C $.G[\'2r\'+a+\'1i\'].1p($.G,[8[0]].2s(b))}C 8.2p(A(){B(1n a==\'1O\'){$.G[\'2r\'+a+\'1i\'].1p($.G,[8].2s(b))}1r{$.G.27(8,a)}})};$.G=P 1i()})(4H);',62,292,'||||||||this|||||||||||||||||||||||||var||_periods|function|if|return||null|_get|countdown||_show|_since|getTime|_minDigits||match||new|Date|_hold||getDate|Math|data||options||_until||1000||periods|span|getMonth|getFullYear|break|_timerTargets|for|_now|case|parseInt|100|false|_defaults|60|_getDaysInMonth|Countdown|labels|compactLabels|layout|markerClassName|typeof|_updateCountdown|apply|pause|else|class|extend|_removeTarget|length|_calculatePeriods|_determineTime|setMilliseconds|min|floor|regional|timeSeparator|description|_resetExtraLabels|extendRemove|UTCDate|getMilliseconds|getSeconds|getMinutes|getHours|_addTarget|_hasTarget|_expiring|string|in|countdown_row|isRTL|until|since|timezone|serverSync|format|compact|expiryUrl|expiryText|alwaysExpire|onExpiry|onTick|prototype||_updateTargets|setUTCDate|_attachCountdown|hasClass|_changeCountdown|_generateHTML|lap|true|_adjustSettings|Ll|abels|_determineShow|_savePeriods|setTime|exec|countdown_amount|_buildLayout|countdown_holding|RegExp|replace|each|setDate|_|concat|Years|Months|Weeks|Days|Hours|Minutes|Seconds|labels1|Year|Month|Week|Day|Hour|Minute|Second|dHMS|hasCountdown|_timer|setInterval|980|setDefaults|object|constructor|setUTCFullYear|setUTCMonth|setUTCHours|setUTCMinutes|abs|setUTCSeconds|setUTCMilliseconds|_settingsCountdown|all|addClass||push||inArray|map|html|add|remove|Class|countdown_rtl|window|location|getTimezoneOffset|_destroyCountdown|removeClass|empty|removeData|_pauseCountdown|_lapCountdown|_resumeCountdown|_getTimesCountdown|toLowerCase|while|switch|number|countdown_section|br|countdown_show|countdown_descr|desc|sep|yl|yn|ynn|ynnn|y1|y10|y100|y1000|ol|on|onn|onnn|o1|o10|o100|o1000|wl|wn|wnn|wnnn|w1|w10|w100|w1000|dl|dn|dnn|dnnn|d1|d10|d100|d1000|hl|hn|hnn|hnnn|h1|h10|h100|h1000|ml|mn|mnn|mnnn|m1|m10|m100|m1000|sl|sn|snn|snnn|s1|s10|s100|s1000|yowdhms|charAt|0000000000|substr|max|setFullYear|setMonth|604800|86400|3600|3482|fn|Array|slice|call|arguments|getTimes|settings|jQuery'.split('|'),0,{}));

//	--------------------------------
//	    jquery.colorbox-min.js
//	--------------------------------
(function(c){function r(b,d){d=d==="x"?m.width():m.height();return typeof b==="string"?Math.round(b.match(/%/)?d/100*parseInt(b,10):parseInt(b,10)):b}function N(b){b=c.isFunction(b)?b.call(i):b;return a.photo||b.match(/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i)}function Y(){for(var b in a)if(c.isFunction(a[b])&&b.substring(0,2)!=="on")a[b]=a[b].call(i)}function Z(b){i=b;a=c(i).data(q);Y();var d=a.rel||i.rel;if(d&&d!=="nofollow"){h=c(".cboxElement").filter(function(){return(c(this).data(q).rel|| this.rel)===d});j=h.index(i);if(j<0){h=h.add(i);j=h.length-1}}else{h=c(i);j=0}if(!C){D=C=n;O=i;O.blur();c().bind("keydown.cbox_close",function(e){if(e.keyCode===27){e.preventDefault();f.close()}}).bind("keydown.cbox_arrows",function(e){if(h.length>1)if(e.keyCode===37){e.preventDefault();E.click()}else if(e.keyCode===39){e.preventDefault();F.click()}});a.overlayClose&&s.css({cursor:"pointer"}).one("click",f.close);c.event.trigger(aa);a.onOpen&&a.onOpen.call(i);s.css({opacity:a.opacity}).show();a.w= r(a.initialWidth,"x");a.h=r(a.initialHeight,"y");f.position(0);P&&m.bind("resize.cboxie6 scroll.cboxie6",function(){s.css({width:m.width(),height:m.height(),top:m.scrollTop(),left:m.scrollLeft()})}).trigger("scroll.cboxie6")}Q.add(E).add(F).add(t).add(H).hide();R.html(a.close).show();f.slideshow();f.load()}var q="colorbox",x="hover",n=true,f,y=!c.support.opacity,P=y&&!window.XMLHttpRequest,aa="cbox_open",I="cbox_load",S="cbox_complete",T="resize.cbox_resize",s,k,u,p,U,V,W,X,h,m,l,J,K,L,H,Q,t,F,E, R,z,A,v,w,i,O,j,a,C,D,$={transition:"elastic",speed:350,width:false,height:false,innerWidth:false,innerHeight:false,initialWidth:"400",initialHeight:"400",maxWidth:false,maxHeight:false,scalePhotos:n,scrolling:n,inline:false,html:false,iframe:false,photo:false,href:false,title:false,rel:false,opacity:0.9,preloading:n,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:false,overlayClose:n,slideshow:false,slideshowAuto:n,slideshowSpeed:2500,slideshowStart:"start slideshow", slideshowStop:"stop slideshow",onOpen:false,onLoad:false,onComplete:false,onCleanup:false,onClosed:false};f=c.fn.colorbox=function(b,d){var e=this;if(!e.length)if(e.selector===""){e=c(e);b.open=n}else return this;e.each(function(){var g=c.extend({},c(this).data(q)?c(this).data(q):$,b);c(this).data(q,g).addClass("cboxElement");if(d)c(this).data(q).onComplete=d});b&&b.open&&Z(e);return this};f.init=function(){function b(d){return c('<div id="cbox'+d+'"/>')}m=c(window);k=c('<div id="colorbox"/>');s= b("Overlay").hide();u=b("Wrapper");p=b("Content").append(l=b("LoadedContent").css({width:0,height:0}),K=b("LoadingOverlay"),L=b("LoadingGraphic"),H=b("Title"),Q=b("Current"),t=b("Slideshow"),F=b("Next"),E=b("Previous"),R=b("Close"));u.append(c("<div/>").append(b("TopLeft"),U=b("TopCenter"),b("TopRight")),c("<div/>").append(V=b("MiddleLeft"),p,W=b("MiddleRight")),c("<div/>").append(b("BottomLeft"),X=b("BottomCenter"),b("BottomRight"))).children().children().css({"float":"left"});J=c("<div style='position:absolute; top:0; left:0; width:9999px; height:0;'/>"); c("body").prepend(s,k.append(u,J));if(y){k.addClass("cboxIE");P&&s.css("position","absolute")}p.children().addClass(x).mouseover(function(){c(this).addClass(x)}).mouseout(function(){c(this).removeClass(x)});z=U.height()+X.height()+p.outerHeight(n)-p.height();A=V.width()+W.width()+p.outerWidth(n)-p.width();v=l.outerHeight(n);w=l.outerWidth(n);k.css({"padding-bottom":z,"padding-right":A}).hide();F.click(f.next);E.click(f.prev);R.click(f.close);p.children().removeClass(x);c(".cboxElement").live("click", function(d){if(d.button!==0&&typeof d.button!=="undefined")return n;else{Z(this);return false}})};f.position=function(b,d){function e(B){U[0].style.width=X[0].style.width=p[0].style.width=B.style.width;L[0].style.height=K[0].style.height=p[0].style.height=V[0].style.height=W[0].style.height=B.style.height}var g=m.height();g=Math.max(g-a.h-v-z,0)/2+m.scrollTop();var o=Math.max(document.documentElement.clientWidth-a.w-w-A,0)/2+m.scrollLeft();b=k.width()===a.w+w&&k.height()===a.h+v?0:b;u[0].style.width= u[0].style.height="9999px";k.dequeue().animate({width:a.w+w,height:a.h+v,top:g,left:o},{duration:b,complete:function(){e(this);D=false;u[0].style.width=a.w+w+A+"px";u[0].style.height=a.h+v+z+"px";d&&d()},step:function(){e(this)}})};f.resize=function(b){function d(){a.w=a.w||l.width();a.w=a.mw&&a.mw<a.w?a.mw:a.w;return a.w}function e(){a.h=a.h||l.height();a.h=a.mh&&a.mh<a.h?a.mh:a.h;return a.h}function g(G){f.position(G,function(){if(C){if(y){B&&l.fadeIn(100);k[0].style.removeAttribute("filter")}if(a.iframe)l.append("<iframe id='cboxIframe'"+ (a.scrolling?" ":"scrolling='no'")+" name='iframe_"+(new Date).getTime()+"' frameborder=0 src='"+(a.href||i.href)+"' "+(y?"allowtransparency='true'":"")+" />");l.show();H.html(a.title||i.title);H.show();if(h.length>1){Q.html(a.current.replace(/\{current\}/,j+1).replace(/\{total\}/,h.length)).show();F.html(a.next).show();E.html(a.previous).show();a.slideshow&&t.show()}K.hide();L.hide();c.event.trigger(S);a.onComplete&&a.onComplete.call(i);a.transition==="fade"&&k.fadeTo(M,1,function(){y&&k[0].style.removeAttribute("filter")}); m.bind(T,function(){f.position(0)})}})}if(C){var o,B,M=a.transition==="none"?0:a.speed;m.unbind(T);if(b){l.remove();l=c('<div id="cboxLoadedContent"/>').html(b);l.hide().appendTo(J).css({width:d(),overflow:a.scrolling?"auto":"hidden"}).css({height:e()}).prependTo(p);c("#cboxPhoto").css({cssFloat:"none"});P&&c("select:not(#colorbox select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one("cbox_cleanup",function(){this.style.visibility="inherit"});a.transition=== "fade"&&k.fadeTo(M,0,function(){g(0)})||g(M);if(a.preloading&&h.length>1){b=j>0?h[j-1]:h[h.length-1];o=j<h.length-1?h[j+1]:h[0];o=c(o).data(q).href||o.href;b=c(b).data(q).href||b.href;N(o)&&c("<img />").attr("src",o);N(b)&&c("<img />").attr("src",b)}}else setTimeout(function(){var G=l.wrapInner("<div style='overflow:auto'></div>").children();a.h=G.height();l.css({height:a.h});G.replaceWith(G.children());f.position(M)},1)}};f.load=function(){var b,d,e,g=f.resize;D=n;i=h[j];a=c(i).data(q);Y();c.event.trigger(I); a.onLoad&&a.onLoad.call(i);a.h=a.height?r(a.height,"y")-v-z:a.innerHeight?r(a.innerHeight,"y"):false;a.w=a.width?r(a.width,"x")-w-A:a.innerWidth?r(a.innerWidth,"x"):false;a.mw=a.w;a.mh=a.h;if(a.maxWidth){a.mw=r(a.maxWidth,"x")-w-A;a.mw=a.w&&a.w<a.mw?a.w:a.mw}if(a.maxHeight){a.mh=r(a.maxHeight,"y")-v-z;a.mh=a.h&&a.h<a.mh?a.h:a.mh}b=a.href||c(i).attr("href");K.show();L.show();if(a.inline){c('<div id="cboxInlineTemp" />').hide().insertBefore(c(b)[0]).bind(I+" cbox_cleanup",function(){c(this).replaceWith(l.children())}); g(c(b))}else if(a.iframe)g(" ");else if(a.html)g(a.html);else if(N(b)){d=new Image;d.onload=function(){var o;d.onload=null;d.id="cboxPhoto";c(d).css({margin:"auto",border:"none",display:"block",cssFloat:"left"});if(a.scalePhotos){e=function(){d.height-=d.height*o;d.width-=d.width*o};if(a.mw&&d.width>a.mw){o=(d.width-a.mw)/d.width;e()}if(a.mh&&d.height>a.mh){o=(d.height-a.mh)/d.height;e()}}if(a.h)d.style.marginTop=Math.max(a.h-d.height,0)/2+"px";g(d);h.length>1&&c(d).css({cursor:"pointer"}).click(f.next); if(y)d.style.msInterpolationMode="bicubic"};d.src=b}else c("<div />").appendTo(J).load(b,function(o,B){B==="success"?g(this):g(c("<p>Request unsuccessful.</p>"))})};f.next=function(){if(!D){j=j<h.length-1?j+1:0;f.load()}};f.prev=function(){if(!D){j=j>0?j-1:h.length-1;f.load()}};f.slideshow=function(){function b(){t.text(a.slideshowStop).bind(S,function(){e=setTimeout(f.next,a.slideshowSpeed)}).bind(I,function(){clearTimeout(e)}).one("click",function(){d();c(this).removeClass(x)});k.removeClass(g+ "off").addClass(g+"on")}var d,e,g="cboxSlideshow_";t.bind("cbox_closed",function(){t.unbind();clearTimeout(e);k.removeClass(g+"off "+g+"on")});d=function(){clearTimeout(e);t.text(a.slideshowStart).unbind(S+" "+I).one("click",function(){b();e=setTimeout(f.next,a.slideshowSpeed);c(this).removeClass(x)});k.removeClass(g+"on").addClass(g+"off")};if(a.slideshow&&h.length>1)a.slideshowAuto?b():d()};f.close=function(){c.event.trigger("cbox_cleanup");a.onCleanup&&a.onCleanup.call(i);C=false;c().unbind("keydown.cbox_close keydown.cbox_arrows"); m.unbind(T+" resize.cboxie6 scroll.cboxie6");s.css({cursor:"auto"}).fadeOut("fast");k.stop(n,false).fadeOut("fast",function(){l.remove();k.css({opacity:1});try{O.focus()}catch(b){}c.event.trigger("cbox_closed");a.onClosed&&a.onClosed.call(i)})};f.element=function(){return c(i)};f.settings=$;c(f.init)})(jQuery);

//	--------------------------------
//	    jquery.validate.pack.js
//	--------------------------------


/*
 * jQuery validation plug-in 1.6
 *
 * http://bassistance.de/jquery-plugins/jquery-plugin-validation/
 * http://docs.jquery.com/Plugins/Validation
 *
 * Copyright (c) 2006 - 2008 Jrn Zaefferer
 *
 * $Id: jquery.validate.js 6403 2009-06-17 14:27:16Z joern.zaefferer $
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */

(function($){$.extend($.fn,{validate:function(options){if(!this.length){options&&options.debug&&window.console&&console.warn("nothing selected, can't validate, returning nothing");return;}
var validator=$.data(this[0],'validator');if(validator){return validator;}
validator=new $.validator(options,this[0]);$.data(this[0],'validator',validator);if(validator.settings.onsubmit){this.find("input, button").filter(".cancel").click(function(){validator.cancelSubmit=true;});if(validator.settings.submitHandler){this.find("input, button").filter(":submit").click(function(){validator.submitButton=this;});}
this.submit(function(event){if(validator.settings.debug)
event.preventDefault();function handle(){if(validator.settings.submitHandler){if(validator.submitButton){var hidden=$("<input type='hidden'/>").attr("name",validator.submitButton.name).val(validator.submitButton.value).appendTo(validator.currentForm);}
validator.settings.submitHandler.call(validator,validator.currentForm);if(validator.submitButton){hidden.remove();}
return false;}
return true;}
if(validator.cancelSubmit){validator.cancelSubmit=false;return handle();}
if(validator.form()){if(validator.pendingRequest){validator.formSubmitted=true;return false;}
return handle();}else{validator.focusInvalid();return false;}});}
return validator;},valid:function(){if($(this[0]).is('form')){return this.validate().form();}else{var valid=true;var validator=$(this[0].form).validate();this.each(function(){valid&=validator.element(this);});return valid;}},removeAttrs:function(attributes){var result={},$element=this;$.each(attributes.split(/\s/),function(index,value){result[value]=$element.attr(value);$element.removeAttr(value);});return result;},rules:function(command,argument){var element=this[0];if(command){var settings=$.data(element.form,'validator').settings;var staticRules=settings.rules;var existingRules=$.validator.staticRules(element);switch(command){case"add":$.extend(existingRules,$.validator.normalizeRule(argument));staticRules[element.name]=existingRules;if(argument.messages)
settings.messages[element.name]=$.extend(settings.messages[element.name],argument.messages);break;case"remove":if(!argument){delete staticRules[element.name];return existingRules;}
var filtered={};$.each(argument.split(/\s/),function(index,method){filtered[method]=existingRules[method];delete existingRules[method];});return filtered;}}
var data=$.validator.normalizeRules($.extend({},$.validator.metadataRules(element),$.validator.classRules(element),$.validator.attributeRules(element),$.validator.staticRules(element)),element);if(data.required){var param=data.required;delete data.required;data=$.extend({required:param},data);}
return data;}});$.extend($.expr[":"],{blank:function(a){return!$.trim(""+a.value);},filled:function(a){return!!$.trim(""+a.value);},unchecked:function(a){return!a.checked;}});$.validator=function(options,form){this.settings=$.extend({},$.validator.defaults,options);this.currentForm=form;this.init();};$.validator.format=function(source,params){if(arguments.length==1)
return function(){var args=$.makeArray(arguments);args.unshift(source);return $.validator.format.apply(this,args);};if(arguments.length>2&&params.constructor!=Array){params=$.makeArray(arguments).slice(1);}
if(params.constructor!=Array){params=[params];}
$.each(params,function(i,n){source=source.replace(new RegExp("\\{"+i+"\\}","g"),n);});return source;};$.extend($.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",validClass:"valid",errorElement:"label",focusInvalid:true,errorContainer:$([]),errorLabelContainer:$([]),onsubmit:true,ignore:[],ignoreTitle:false,onfocusin:function(element){this.lastActive=element;if(this.settings.focusCleanup&&!this.blockFocusCleanup){this.settings.unhighlight&&this.settings.unhighlight.call(this,element,this.settings.errorClass,this.settings.validClass);this.errorsFor(element).hide();}},onfocusout:function(element){if(!this.checkable(element)&&(element.name in this.submitted||!this.optional(element))){this.element(element);}},onkeyup:function(element){if(element.name in this.submitted||element==this.lastElement){this.element(element);}},onclick:function(element){if(element.name in this.submitted)
this.element(element);else if(element.parentNode.name in this.submitted)
this.element(element.parentNode)},highlight:function(element,errorClass,validClass){$(element).addClass(errorClass).removeClass(validClass);},unhighlight:function(element,errorClass,validClass){$(element).removeClass(errorClass).addClass(validClass);}},setDefaults:function(settings){$.extend($.validator.defaults,settings);},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",number:"Please enter a valid number.",digits:"Please enter only digits.",creditcard:"Please enter a valid credit card number.",equalTo:"Please enter the same value again.",accept:"Please enter a value with a valid extension.",maxlength:$.validator.format("Please enter no more than {0} characters."),minlength:$.validator.format("Please enter at least {0} characters."),rangelength:$.validator.format("Please enter a value between {0} and {1} characters long."),range:$.validator.format("Please enter a value between {0} and {1}."),max:$.validator.format("Please enter a value less than or equal to {0}."),min:$.validator.format("Please enter a value greater than or equal to {0}.")},autoCreateRanges:false,prototype:{init:function(){this.labelContainer=$(this.settings.errorLabelContainer);this.errorContext=this.labelContainer.length&&this.labelContainer||$(this.currentForm);this.containers=$(this.settings.errorContainer).add(this.settings.errorLabelContainer);this.submitted={};this.valueCache={};this.pendingRequest=0;this.pending={};this.invalid={};this.reset();var groups=(this.groups={});$.each(this.settings.groups,function(key,value){$.each(value.split(/\s/),function(index,name){groups[name]=key;});});var rules=this.settings.rules;$.each(rules,function(key,value){rules[key]=$.validator.normalizeRule(value);});function delegate(event){var validator=$.data(this[0].form,"validator");validator.settings["on"+event.type]&&validator.settings["on"+event.type].call(validator,this[0]);}
$(this.currentForm).delegate("focusin focusout keyup",":text, :password, :file, select, textarea",delegate).delegate("click",":radio, :checkbox, select, option",delegate);if(this.settings.invalidHandler)
$(this.currentForm).bind("invalid-form.validate",this.settings.invalidHandler);},form:function(){this.checkForm();$.extend(this.submitted,this.errorMap);this.invalid=$.extend({},this.errorMap);if(!this.valid())
$(this.currentForm).triggerHandler("invalid-form",[this]);this.showErrors();return this.valid();},checkForm:function(){this.prepareForm();for(var i=0,elements=(this.currentElements=this.elements());elements[i];i++){this.check(elements[i]);}
return this.valid();},element:function(element){element=this.clean(element);this.lastElement=element;this.prepareElement(element);this.currentElements=$(element);var result=this.check(element);if(result){delete this.invalid[element.name];}else{this.invalid[element.name]=true;}
if(!this.numberOfInvalids()){this.toHide=this.toHide.add(this.containers);}
this.showErrors();return result;},showErrors:function(errors){if(errors){$.extend(this.errorMap,errors);this.errorList=[];for(var name in errors){this.errorList.push({message:errors[name],element:this.findByName(name)[0]});}
this.successList=$.grep(this.successList,function(element){return!(element.name in errors);});}
this.settings.showErrors?this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors();},resetForm:function(){if($.fn.resetForm)
$(this.currentForm).resetForm();this.submitted={};this.prepareForm();this.hideErrors();this.elements().removeClass(this.settings.errorClass);},numberOfInvalids:function(){return this.objectLength(this.invalid);},objectLength:function(obj){var count=0;for(var i in obj)
count++;return count;},hideErrors:function(){this.addWrapper(this.toHide).hide();},valid:function(){return this.size()==0;},size:function(){return this.errorList.length;},focusInvalid:function(){if(this.settings.focusInvalid){try{var obj=$(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible");if(obj.length>0)obj.focus();else{$.scrollTo($('p.error').filter(':visible').parent());}}catch(e){}}},findLastActive:function(){var lastActive=this.lastActive;return lastActive&&$.grep(this.errorList,function(n){return n.element.name==lastActive.name;}).length==1&&lastActive;},elements:function(){var validator=this,rulesCache={};return $([]).add(this.currentForm.elements).filter(":input").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function(){!this.name&&validator.settings.debug&&window.console&&console.error("%o has no name assigned",this);if(this.name in rulesCache||!validator.objectLength($(this).rules()))
return false;rulesCache[this.name]=true;return true;});},clean:function(selector){return $(selector)[0];},errors:function(){return $(this.settings.errorElement+"."+this.settings.errorClass,this.errorContext);},reset:function(){this.successList=[];this.errorList=[];this.errorMap={};this.toShow=$([]);this.toHide=$([]);this.currentElements=$([]);},prepareForm:function(){this.reset();this.toHide=this.errors().add(this.containers);},prepareElement:function(element){this.reset();this.toHide=this.errorsFor(element);},check:function(element){element=this.clean(element);if(this.checkable(element)){element=this.findByName(element.name)[0];}
var rules=$(element).rules();var dependencyMismatch=false;for(method in rules){var rule={method:method,parameters:rules[method]};try{var result=$.validator.methods[method].call(this,element.value.replace(/\r/g,""),element,rule.parameters);if(result=="dependency-mismatch"){dependencyMismatch=true;continue;}
dependencyMismatch=false;if(result=="pending"){this.toHide=this.toHide.not(this.errorsFor(element));return;}
if(!result){this.formatAndAdd(element,rule);return false;}}catch(e){this.settings.debug&&window.console&&console.log("exception occured when checking element "+element.id
+", check the '"+rule.method+"' method",e);throw e;}}
if(dependencyMismatch)
return;if(this.objectLength(rules))
this.successList.push(element);return true;},customMetaMessage:function(element,method){if(!$.metadata)
return;var meta=this.settings.meta?$(element).metadata()[this.settings.meta]:$(element).metadata();return meta&&meta.messages&&meta.messages[method];},customMessage:function(name,method){var m=this.settings.messages[name];return m&&(m.constructor==String?m:m[method]);},findDefined:function(){for(var i=0;i<arguments.length;i++){if(arguments[i]!==undefined)
return arguments[i];}
return undefined;},defaultMessage:function(element,method){return this.findDefined(this.customMessage(element.name,method),this.customMetaMessage(element,method),!this.settings.ignoreTitle&&element.title||undefined,$.validator.messages[method],"<strong>Warning: No message defined for "+element.name+"</strong>");},formatAndAdd:function(element,rule){var message=this.defaultMessage(element,rule.method),theregex=/\$?\{(\d+)\}/g;if(typeof message=="function"){message=message.call(this,rule.parameters,element);}else if(theregex.test(message)){message=jQuery.format(message.replace(theregex,'{$1}'),rule.parameters);}
this.errorList.push({message:message,element:element});this.errorMap[element.name]=message;this.submitted[element.name]=message;},addWrapper:function(toToggle){if(this.settings.wrapper)
toToggle=toToggle.add(toToggle.parent(this.settings.wrapper));return toToggle;},defaultShowErrors:function(){for(var i=0;this.errorList[i];i++){var error=this.errorList[i];this.settings.highlight&&this.settings.highlight.call(this,error.element,this.settings.errorClass,this.settings.validClass);this.showLabel(error.element,error.message);}
if(this.errorList.length){this.toShow=this.toShow.add(this.containers);}
if(this.settings.success){for(var i=0;this.successList[i];i++){this.showLabel(this.successList[i]);}}
if(this.settings.unhighlight){for(var i=0,elements=this.validElements();elements[i];i++){this.settings.unhighlight.call(this,elements[i],this.settings.errorClass,this.settings.validClass);}}
this.toHide=this.toHide.not(this.toShow);this.hideErrors();this.addWrapper(this.toShow).show();},validElements:function(){return this.currentElements.not(this.invalidElements());},invalidElements:function(){return $(this.errorList).map(function(){return this.element;});},showLabel:function(element,message){var label=this.errorsFor(element);if(label.length){label.removeClass().addClass(this.settings.errorClass);label.attr("generated")&&label.html(message);}else{label=$("<"+this.settings.errorElement+"/>").attr({"for":this.idOrName(element),generated:true}).addClass(this.settings.errorClass).html(message||"");if(this.settings.wrapper){label=label.hide().show().wrap("<"+this.settings.wrapper+"/>").parent();}
if(!this.labelContainer.append(label).length)
this.settings.errorPlacement?this.settings.errorPlacement(label,$(element)):label.insertAfter(element);}
if(!message&&this.settings.success){label.text("");typeof this.settings.success=="string"?label.addClass(this.settings.success):this.settings.success(label);}
this.toShow=this.toShow.add(label);},errorsFor:function(element){var name=this.idOrName(element);return this.errors().filter(function(){return $(this).attr('for')==name});},idOrName:function(element){return this.groups[element.name]||(this.checkable(element)?element.name:element.id||element.name);},checkable:function(element){return/radio|checkbox/i.test(element.type);},findByName:function(name){var form=this.currentForm;return $(document.getElementsByName(name)).map(function(index,element){return element.form==form&&element.name==name&&element||null;});},getLength:function(value,element){switch(element.nodeName.toLowerCase()){case'select':return $("option:selected",element).length;case'input':if(this.checkable(element))
return this.findByName(element.name).filter(':checked').length;}
return value.length;},depend:function(param,element){return this.dependTypes[typeof param]?this.dependTypes[typeof param](param,element):true;},dependTypes:{"boolean":function(param,element){return param;},"string":function(param,element){return!!$(param,element.form).length;},"function":function(param,element){return param(element);}},optional:function(element){return!$.validator.methods.required.call(this,$.trim(element.value),element)&&"dependency-mismatch";},startRequest:function(element){if(!this.pending[element.name]){this.pendingRequest++;this.pending[element.name]=true;}},stopRequest:function(element,valid){this.pendingRequest--;if(this.pendingRequest<0)
this.pendingRequest=0;delete this.pending[element.name];if(valid&&this.pendingRequest==0&&this.formSubmitted&&this.form()){$(this.currentForm).submit();this.formSubmitted=false;}else if(!valid&&this.pendingRequest==0&&this.formSubmitted){$(this.currentForm).triggerHandler("invalid-form",[this]);this.formSubmitted=false;}},previousValue:function(element){return $.data(element,"previousValue")||$.data(element,"previousValue",{old:null,valid:true,message:this.defaultMessage(element,"remote")});}},classRuleSettings:{required:{required:true},email:{email:true},url:{url:true},date:{date:true},dateISO:{dateISO:true},dateDE:{dateDE:true},number:{number:true},numberDE:{numberDE:true},digits:{digits:true},creditcard:{creditcard:true}},addClassRules:function(className,rules){className.constructor==String?this.classRuleSettings[className]=rules:$.extend(this.classRuleSettings,className);},classRules:function(element){var rules={};var classes=$(element).attr('class');classes&&$.each(classes.split(' '),function(){if(this in $.validator.classRuleSettings){$.extend(rules,$.validator.classRuleSettings[this]);}});return rules;},attributeRules:function(element){var rules={};var $element=$(element);for(method in $.validator.methods){var value=$element.attr(method);if(value){rules[method]=value;}}
if(rules.maxlength&&/-1|2147483647|524288/.test(rules.maxlength)){delete rules.maxlength;}
return rules;},metadataRules:function(element){if(!$.metadata)return{};var meta=$.data(element.form,'validator').settings.meta;return meta?$(element).metadata()[meta]:$(element).metadata();},staticRules:function(element){var rules={};var validator=$.data(element.form,'validator');if(validator.settings.rules){rules=$.validator.normalizeRule(validator.settings.rules[element.name])||{};}
return rules;},normalizeRules:function(rules,element){$.each(rules,function(prop,val){if(val===false){delete rules[prop];return;}
if(val.param||val.depends){var keepRule=true;switch(typeof val.depends){case"string":keepRule=!!$(val.depends,element.form).length;break;case"function":keepRule=val.depends.call(element,element);break;}
if(keepRule){rules[prop]=val.param!==undefined?val.param:true;}else{delete rules[prop];}}});$.each(rules,function(rule,parameter){rules[rule]=$.isFunction(parameter)?parameter(element):parameter;});$.each(['minlength','maxlength','min','max'],function(){if(rules[this]){rules[this]=Number(rules[this]);}});$.each(['rangelength','range'],function(){if(rules[this]){rules[this]=[Number(rules[this][0]),Number(rules[this][1])];}});if($.validator.autoCreateRanges){if(rules.min&&rules.max){rules.range=[rules.min,rules.max];delete rules.min;delete rules.max;}
if(rules.minlength&&rules.maxlength){rules.rangelength=[rules.minlength,rules.maxlength];delete rules.minlength;delete rules.maxlength;}}
if(rules.messages){delete rules.messages}
return rules;},normalizeRule:function(data){if(typeof data=="string"){var transformed={};$.each(data.split(/\s/),function(){transformed[this]=true;});data=transformed;}
return data;},addMethod:function(name,method,message){$.validator.methods[name]=method;$.validator.messages[name]=message!=undefined?message:$.validator.messages[name];if(method.length<3){$.validator.addClassRules(name,$.validator.normalizeRule(name));}},methods:{required:function(value,element,param){if(!this.depend(param,element))
return"dependency-mismatch";switch(element.nodeName.toLowerCase()){case'select':var val=$(element).val();return val&&val.length>0;case'input':if(this.checkable(element))
return this.getLength(value,element)>0;default:return $.trim(value).length>0;}},remote:function(value,element,param){if(this.optional(element))
return"dependency-mismatch";var previous=this.previousValue(element);if(!this.settings.messages[element.name])
this.settings.messages[element.name]={};previous.originalMessage=this.settings.messages[element.name].remote;this.settings.messages[element.name].remote=previous.message;param=typeof param=="string"&&{url:param}||param;if(previous.old!==value){previous.old=value;var validator=this;this.startRequest(element);var data={};data[element.name]=value;$.ajax($.extend(true,{url:param,mode:"abort",port:"validate"+element.name,dataType:"json",data:data,success:function(response){validator.settings.messages[element.name].remote=previous.originalMessage;var valid=response===true;if(valid){var submitted=validator.formSubmitted;validator.prepareElement(element);validator.formSubmitted=submitted;validator.successList.push(element);validator.showErrors();}else{var errors={};var message=(previous.message=response||validator.defaultMessage(element,"remote"));errors[element.name]=$.isFunction(message)?message(value):message;validator.showErrors(errors);}
previous.valid=valid;validator.stopRequest(element,valid);}},param));return"pending";}else if(this.pending[element.name]){return"pending";}
return previous.valid;},minlength:function(value,element,param){return this.optional(element)||this.getLength($.trim(value),element)>=param;},maxlength:function(value,element,param){return this.optional(element)||this.getLength($.trim(value),element)<=param;},rangelength:function(value,element,param){var length=this.getLength($.trim(value),element);return this.optional(element)||(length>=param[0]&&length<=param[1]);},min:function(value,element,param){return this.optional(element)||value>=param;},max:function(value,element,param){return this.optional(element)||value<=param;},range:function(value,element,param){return this.optional(element)||(value>=param[0]&&value<=param[1]);},email:function(value,element){return this.optional(element)||/^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/.test(value);},url:function(value,element){return this.optional(element)||/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value);},date:function(value,element){return this.optional(element)||!/Invalid|NaN/.test(new Date(value));},dateISO:function(value,element){return this.optional(element)||/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(value);},number:function(value,element){return this.optional(element)||/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(value);},digits:function(value,element){return this.optional(element)||/^\d+$/.test(value);},creditcard:function(value,element){if(this.optional(element))
return"dependency-mismatch";if(/[^0-9-]+/.test(value))
return false;var nCheck=0,nDigit=0,bEven=false;value=value.replace(/\D/g,"");for(var n=value.length-1;n>=0;n--){var cDigit=value.charAt(n);var nDigit=parseInt(cDigit,10);if(bEven){if((nDigit*=2)>9)
nDigit-=9;}
nCheck+=nDigit;bEven=!bEven;}
return(nCheck%10)==0;},accept:function(value,element,param){param=typeof param=="string"?param.replace(/,/g,'|'):"png|jpe?g|gif";return this.optional(element)||value.match(new RegExp(".("+param+")$","i"));},equalTo:function(value,element,param){var target=$(param).unbind(".validate-equalTo").bind("blur.validate-equalTo",function(){$(element).valid();});return value==target.val();}}});$.format=$.validator.format;})(jQuery);;(function($){var ajax=$.ajax;var pendingRequests={};$.ajax=function(settings){settings=$.extend(settings,$.extend({},$.ajaxSettings,settings));var port=settings.port;if(settings.mode=="abort"){if(pendingRequests[port]){pendingRequests[port].abort();}
return(pendingRequests[port]=ajax.apply(this,arguments));}
return ajax.apply(this,arguments);};})(jQuery);;(function($){$.each({focus:'focusin',blur:'focusout'},function(original,fix){$.event.special[fix]={setup:function(){if($.browser.msie)return false;this.addEventListener(original,$.event.special[fix].handler,true);},teardown:function(){if($.browser.msie)return false;this.removeEventListener(original,$.event.special[fix].handler,true);},handler:function(e){arguments[0]=$.event.fix(e);arguments[0].type=fix;return $.event.handle.apply(this,arguments);}};});$.extend($.fn,{delegate:function(type,delegate,handler){return this.bind(type,function(event){var target=$(event.target);if(target.is(delegate)){return handler.apply(target,arguments);}});},triggerEvent:function(type,target){return this.triggerHandler(type,[$.event.fix({type:type,target:target})]);}})})(jQuery);

//	--------------------------------
//	    swfobjectswfobject.js
//	--------------------------------
var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();

/**
 * 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);


/*!
* jQuery.hook v1.0
*
* Copyright (c) 2009 Aaron Heckmann
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/

;(function($){$.hook=function(fns){fns=typeof fns==='string'?fns.split(' '):$.makeArray(fns);jQuery.each(fns,function(i,method){var old=$.fn[method];if(old&&!old.__hookold){$.fn[method]=function(){this.triggerHandler('onbefore'+method);this.triggerHandler('on'+method);var ret=old.apply(this,arguments);this.triggerHandler('onafter'+method);return ret};$.fn[method].__hookold=old}})};$.unhook=function(fns){fns=typeof fns==='string'?fns.split(' '):$.makeArray(fns);jQuery.each($.makeArray(fns),function(i,method){var cur=$.fn[method];if(cur&&cur.__hookold){$.fn[method]=cur.__hookold}})}})(jQuery);$.hook('show hide');

/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;}
var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}
expires='; expires='+date.toUTCString();}
var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}
return cookieValue;}};
