

jQuery(document).ready(function($){
	
	$('#content').hide();
	$('h3').nextAll('p').hide();
	$('h3').wrapInner("<span class='over'></span>")
	var ie6 = false;
	var mytimer = {};
	
	if (jQuery.browser.msie) {
			if(parseInt(jQuery.browser.version) == 6) {
					ie6 = true;
				}

		}
	
	
	if($(window).width() >= 1121 && ie6 === false){
		 
		$('#header').css("position","fixed")
		$('.submenu').css("position","fixed")
		
	}
	
	$(window).bind('resize', function(){
		if($(window).width()<1121 && ie6 === false){
			
			$('#header').css("position","absolute")
			$('.submenu').css("position","absolute")
		}else{
			$('#header').css("position","fixed")
			$('.submenu').css("position","fixed")
		}
	})
	
	
	$(".submenu2 li:first").addClass('selected');
	

	$('#content').slideDown(400, function(){
			$('#content').removeAttr('style')
			});
	
	
	
	
	
	//setting up the front page news slider
	$('#postsinner').css("width","10000px")
	$('#posts').css('overflow','hidden');
	$('.newsitem').css('width','445px');
	
	var numposts = $('.newsitem')
	var maxm = numposts.length*445
	maxm -= maxm*2
	
	
	var marginL = 0;
	
	var t
	var intv=setInterval(shiftnews,5000);
	
	
	
	function newstimer(){
		t=setTimeout
	};
	
	function shiftnews(){
		marginL -= 465;
		if(marginL <= maxm ){marginL = 0};
		$('#postsinner').stop().animate({marginLeft:(marginL)+"px"}, 1000);
	};
	
	function reversenews(){
		marginL += 465;
		if(marginL >= 0 ){marginL = 0};
		$('#postsinner').stop().animate({marginLeft:(marginL)+"px"}, 1000);
	}
	
	
	
	
	
	$('#newsnext').click(function(){
		intc=clearInterval(intv)
		//alert('test');
		shiftnews();
		intv=setInterval(shiftnews,5000);
		return false;
	});
	
	$('#newsprev').click(function(){
		intc=clearInterval(intv)
		//alert('test');
		reversenews();
		intv=setInterval(shiftnews,5000);
		return false;
	});
	
	$('#newspause').click(function(){
		if($(this).hasClass("playing")){
			intc=clearInterval(intv)
			$(this).text(" > ")
			$(this).removeClass("playing")
			$(this).addClass("paused")
			
		}
		
		else{
			intv=setInterval(shiftnews,5000);
			$(this).text(" O ")
			$(this).removeClass("paused")
			$(this).addClass("playing")
		}
		
		
		
		//alert('test');
		//reversenews();
		//intv=setInterval(shiftnews,5000);
		return false;
	});

 
	
	
	
	$(".menu li").click(function(){
		//if (event.button != 0) {
		// wasn't the left button - ignore
			//return true;
		//}
		var ur = $("a",this).attr('href') + " #main > *";
		
		$('#main').fadeOut(200);
		
		$('.menu .current_page_item').removeClass('current_page_item');
		
		$('.menu .current_page_ancestor').removeClass('current_page_ancestor');
		$(this).addClass('current_page_item');
		var uu = $(this).children('a').eq('0').attr('href')
		window.location = uu;
		
		
		
		
		
		
		
		
		
		
	})
	
	$(".submenu li a").click(function(event){
		if (event.button != 0) {
		// wasn't the left button - ignore
			return true;
		}else{
		
			$('#content').fadeOut(200);
			$('.submenu .current_page_item').removeClass('current_page_item');
			$(this).parent().addClass('current_page_item');
		}
		//return false;
	})
	
	$('h3').click(function(){
		
		if($(this).hasClass('.curh')){
			$('.curh').removeClass('curh')
			$('.current_faq').slideUp(200);
			$('p .current_faq').removeClass('current_faq');
			return false;
		}else{
		
			$('.curh').removeClass('curh')
			$('.current_faq').slideUp(200);
			$('p .current_faq').removeClass('current_faq');
					
					
				
			
			$(this).addClass('curh');
			var next = $(this).next();
			while (next.length != 0 && next[0].nodeName != 'H3')
				{
					next.addClass('current_faq')
					next.addClass('indent')
					next.slideDown(200)
					next = next.next();
				}
	
			//$(this).next('p').addClass('current_faq')
			//$(this).next('p').slideDown(200)
			
			return false;
		}
	})


 
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
});