$(function(){	
	$.easy.navigation();
	$.easy.tooltip();
	$.easy.popup();
	$.easy.external();
	$.easy.rotate();
	$.easy.cycle();
	$.easy.forms();
	$.easy.showhide();
	$.easy.jump();
	$.easy.tabs();
	$.easy.accordion();	
});

$(document).ready(function() {
	$("#searchbutton").click(function() {
		$("#frmsearch").submit();
	});
	
	// Get involved hover
	$("#get-involved").hover(function() {
		$("#cat_797562_divs").show();
		$("#cat_797562_divs").css("top", $(this).position().top + 45);
		$("#get-involved").addClass("hovering");
	}, function() {
		$("#cat_797562_divs").hide();
		$("#get-involved").removeClass("hovering");
	});
	$("#cat_797562_divs").hover(function() {
		$("#get-involved").addClass("hovering");
		$("#cat_797562_divs").show();
	}, function() {
		$("#cat_797562_divs").hide();
		$("#get-involved").removeClass("hovering");
	});
	

	// Login hover
	$("#login").hover(function() {
		$("#cat_802378_divs").show();
		$("#cat_802378_divs").css("top", $(this).position().top + 45);
		$("#login").addClass("hovering");
	}, function() {
		$("#cat_802378_divs").hide();
		$("#login").removeClass("hovering");
	});
	$("#cat_802378_divs").hover(function() {
		$("#login").addClass("hovering");
		$("#cat_802378_divs").show();
	}, function() {
		$("#cat_802378_divs").hide();
		$("#login").removeClass("hovering");
	});
	
	preload([
		'/images/get-involved2.png',
		'/images/login2.png',
		'/images/subscribe-hover.png'
	]);
	
	$(".textinput").focus(function() {
		if(this.value == this.defaultValue) {
			this.value = '';
		}
	});
	$(".textinput").blur(function() {
		if(this.value == '') {
			this.value = this.defaultValue;
		}
	});
	$(".ticker1").vTicker();

	$("#coda-slider1").codaSlider({
		dynamicTabs: true,
		dynamicArrows: false,
		autoSlide: true,
		autoSlideInterval: 5000
		});
		
	//Remove all URLs that say hidden
	$('a[href="hidden"]').remove();
	
	data = $("#loginstatus").html();
	//alert(data);
	if(data.indexOf("No one logged in") != -1) {
		$("#loginstatus").remove();
	}
	
});

function preload(arrayOfImages) {
    $(arrayOfImages).each(function(){
		$("<img>").attr({
		  src: this,
		}).appendTo("#preloader").css({ display: "none" });
    });
}

/*
CSS Browser Selector v0.4.0 (Nov 02, 2010)
Rafael Lima (http://rafael.adm.br)
http://rafael.adm.br/css_browser_selector
License: http://creativecommons.org/licenses/by/2.5/
Contributors: http://rafael.adm.br/css_browser_selector#contributors
*/
function css_browser_selector(u){var ua=u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1},g='gecko',w='webkit',s='safari',o='opera',m='mobile',h=document.documentElement,b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3.6')?g+' ff3 ff3_6':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('blackberry')?m+' blackberry':is('android')?m+' android':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?m+' j2me':is('iphone')?m+' iphone':is('ipod')?m+' ipod':is('ipad')?m+' ipad':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win'+(is('windows nt 6.0')?' vista':''):is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);
/* End CSS browser Selector */

// Ticker plugin
/*
* vertical news ticker
* Tadas Juozapaitis ( kasp3rito@gmail.com )
* http://www.jugbit.com/jquery-vticker-vertical-news-ticker/
*/
(function($){
$.fn.vTicker = function(options) {
	var defaults = {
		speed: 700,
		pause: 4000,
		showItems: 3,
		animation: '',
		mousePause: true,
		isPaused: false,
		direction: 'up',
		height: 0
	};

	var options = $.extend(defaults, options);

	moveUp = function(obj2, height, options){
		if(options.isPaused)
			return;
		
		var obj = obj2.children('ul');
		
    	var clone = obj.children('li:first').clone(true);
		
		if(options.height > 0)
		{
			height = obj.children('li:first').height();
		}		
		
    	obj.animate({top: '-=' + height + 'px'}, options.speed, function() {
        	$(this).children('li:first').remove();
        	$(this).css('top', '0px');
        });
		
		if(options.animation == 'fade')
		{
			obj.children('li:first').fadeOut(options.speed);
			if(options.height == 0)
			{
			obj.children('li:eq(' + options.showItems + ')').hide().fadeIn(options.speed).show();
			}
		}

    	clone.appendTo(obj);
	};
	
	moveDown = function(obj2, height, options){
		if(options.isPaused)
			return;
		
		var obj = obj2.children('ul');
		
    	var clone = obj.children('li:last').clone(true);
		
		if(options.height > 0)
		{
			height = obj.children('li:first').height();
		}
		
		obj.css('top', '-' + height + 'px')
			.prepend(clone);
			
    	obj.animate({top: 0}, options.speed, function() {
        	$(this).children('li:last').remove();
        });
		
		if(options.animation == 'fade')
		{
			if(options.height == 0)
			{
				obj.children('li:eq(' + options.showItems + ')').fadeOut(options.speed);
			}
			obj.children('li:first').hide().fadeIn(options.speed).show();
		}
	};
	
	return this.each(function() {
		var obj = $(this);
		var maxHeight = 0;

		obj.css({overflow: 'hidden', position: 'relative'})
			.children('ul').css({position: 'absolute', margin: 0, padding: 0})
			.children('li').css({margin: 0, padding: 0});

		if(options.height == 0)
		{
			obj.children('ul').children('li').each(function(){
				if($(this).height() > maxHeight)
				{
					maxHeight = $(this).height();
				}
			});

			obj.children('ul').children('li').each(function(){
				$(this).height(maxHeight);
			});

			obj.height(maxHeight * options.showItems);
		}
		else
		{
			obj.height(options.height);
		}
		
    	var interval = setInterval(function(){ 
			if(options.direction == 'up')
			{ 
				moveUp(obj, maxHeight, options); 
			}
			else
			{ 
				moveDown(obj, maxHeight, options); 
			} 
		}, options.pause);
		
		if(options.mousePause)
		{
			obj.bind("mouseenter",function(){
				options.isPaused = true;
			}).bind("mouseleave",function(){
				options.isPaused = false;
			});
		}
	});
};
})(jQuery);


