WM = {
	mHover:"",
	//news scroll
	xPos:0,
	step:670,
	videoStep:127,
	photoStep:127,
	numNews:0,
	numVideo:0,
	numPhoto:0,
	speed:400,

	// NEWS
	newsLeft: function(){
		if(this.xPos<=0) return;
		$(".scroll-container").animate({
			marginLeft: '+='+this.step
		}, this.speed);
		this.xPos--;
		$("#arrow-right").show();
		if(this.xPos<=0) {
			$("#arrow-left").hide('slow');
		}
	},
	newsRight: function(){
		if(this.xPos >= this.numNews-2) return;
		$(".scroll-container").animate({
			marginLeft: '-='+this.step
		}, this.speed);
		this.xPos++;
		$("#arrow-left").show();
		if(this.xPos >= this.numNews-2) {
			$("#arrow-right").hide('slow');
		}
	},

	// VIDEO
	videoLeft: function() {
		if(this.xPos<=0) return;
		$(".v-scroll-container").animate({
			marginLeft: '+='+this.videoStep
		}, this.speed);
		this.xPos--;
		$(".v-arrow-right").show();
		if(this.xPos<=0) {
			$(".v-arrow-left").hide('slow');
		}
	},
	videoRight: function(){
		if(this.xPos >= this.numVideo-5) return;
		$(".v-scroll-container").animate({
			marginLeft: '-='+this.videoStep
		}, this.speed);
		this.xPos++;
		$(".v-arrow-left").show();
		if(this.xPos >= this.numVideo-5) {
			$(".v-arrow-right").hide('slow');
		}
	},

	// GALLERY
	photoLeft: function() {
		if(this.xPos<=0) return;
		$(".g-scroll-container").animate({
			marginLeft: '+='+this.photoStep
		}, this.speed);
		this.xPos--;
		$(".g-arrow-right").show();
		if(this.xPos<=0) {
			$(".g-arrow-left").hide('slow');
		}
	},
	photoRight: function(){
		if(this.xPos >= this.numPhoto-5) return;
		$(".g-scroll-container").animate({
			marginLeft: '-='+this.photoStep
		}, this.speed);
		this.xPos++;
		$(".g-arrow-left").show();
		if(this.xPos >= this.numPhoto-5) {
			$(".g-arrow-right").hide('slow');
		}
	}
}

$(function(){

	// main menu hover
	$('.mm-item img').hover(function(){
		WM.mHover = $(this).attr('src');
		$(this).attr('src',$(this).attr('hover'));
		$('.whitmarsh-popup').hide();
		$('.newsmenu-popup').hide();
	},function(){
		$(this).attr('src',WM.mHover);
	})

	// whitmarsh popup
	$('.wm-popup').hover(function(){
		$('.newsmenu-popup').hide();
		$('.whitmarsh-popup').show();
	},function(){
		//$('.whitmarsh-popup').hide();
	});

	// whitmarsh popup
	$('.news-popup').hover(function(){
		$('.whitmarsh-popup').hide();
		$('.newsmenu-popup').show();
	},function(){
		//$('.whitmarsh-popup').hide();
	});

	// scroll events/news/press
	if($(".scrollarrows").length){
		$("#arrow-left").hide();
		if( WM.numNews<=2 ) $("#arrow-right").hide();
		$("#arrow-left").bind("click",function(){
			WM.newsLeft();
		})
		$("#arrow-right").bind("click",function(){
			WM.newsRight();
		})
	}

	// video scroll
	if($('.video-wrap').length){
		$(".v-arrow-left").hide();
		if( WM.numVideo<=5 ) $(".v-arrow-right").hide();
		$(".v-arrow-left").bind("click",function(){
			WM.videoLeft();
		})
		$(".v-arrow-right").bind("click",function(){
			WM.videoRight();
		})
	}

	// photo scroll
	if($('.gallery-wrap').length){
		$(".g-arrow-left").hide();
		if( WM.numPhoto<=5 ) $(".g-arrow-right").hide();
		$(".g-arrow-left").bind("click",function(){
			WM.photoLeft();
		})
		$(".g-arrow-right").bind("click",function(){
			WM.photoRight();
		})
	}
	
	if($('#feedback').length){
		$("a[id='feedback']").colorbox({innerWidth:600,innerHeight:400});
	}
	/*
	if($('.mm-item').length){
		$('.mm-item:first').css('paddingLeft','0px');
		$('.mm-item:last').css('paddingRight','0px');
	}*/
})

