$(function(){
	$("a.nogo").attr("href", "javascript:void(0);");
	$("div#navPubM a.nogo").click(function(){
		$("div#navPubM a.nogo").removeClass("on");
		$(this).addClass("on");
		var myid = this.id;
		$("div#navPubM div.copy div:visible").hide("fast", function(){
			$("div#navPubM div.copy div#M"+myid).fadeIn();
		});
	});
	
	$("div#navAdvM a.nogo").click(function(){
		$("div#navAdvM a.nogo").removeClass("on");
		$(this).addClass("on");
		var myid = this.id;
		$("div#navAdvM div.copy div:visible").hide("fast", function(){
			$("div#navAdvM div.copy div#M"+myid).fadeIn();
		});
	});
	
	$("a.mainnogo").attr("href", "javascript:void(0);");
	$("a.mainnogo").click(function(){
		if($(this).hasClass("on"))return;
		$("a.mainnogo").removeClass("on");
		$(this).addClass("on");
		var myid = this.id.replace(/F-/, "");
		var scroller = $("div#content div#content-hider");
		
		switch(myid){
			case "navHome":
					$(scroller).animate({scrollLeft: 0});
				break;
			
			case "navPub":
					$(scroller).animate({scrollLeft: 900});
				break;
				
			case "navAdv":
					$(scroller).animate({scrollLeft: 1800});
				break;
			
			case "navAbout":
					$(scroller).animate({scrollLeft: 2700});
				break;
				
			case "navPress":
					$(scroller).animate({scrollLeft: 3600});
				break;
				
			case "navContact":
					$(scroller).animate({scrollLeft: 4500});
				break;
		}
	});
	
	function loadCSS(){
		$("#backload").attr("href", "css/backload.css");		
	}
	
	function scrollticker(){
        $('div#ticker-container marquee').marquee('pointer').mouseover(function () {
            $(this).trigger('stop');
        }).mouseout(function () {
            $(this).trigger('start');
        }).mousemove(function (event) {
            if ($(this).data('drag') == true) {
                this.scrollLeft = $(this).data('scrollX') + ($(this).data('x') - event.clientX);
            }
        }).mousedown(function (event) {
            $(this).data('drag', true).data('x', event.clientX).data('scrollX', this.scrollLeft);
        }).mouseup(function () {
            $(this).data('drag', false);
        });
	}
	
	function loadTicker(){
		$.ajax({
			type: "GET",
			url: "ticker.xml",
			success: function(xml){
				$("headline", xml).each(function(i)
					{
						var mysource = $(this).attr("source");
						$("div#ticker div#ticker-container marquee").append("<span class='tickeritem'>&bull; "+$(this).text()+"<span class='source'>"+mysource+"</span></span>");
					});
				scrollticker()
			}
		});
	}
	
	loadCSS();
	loadTicker();
	
});
