function resizeOnLoad(){
	screenWidth = $(window).width();
	screenHeight = $(window).height();
	$('.mainSiteContainer').css({width: $(window).width()+'px', height: $(window).height()+'px'})
	$('.scrollerContainer').css({width: screenWidth});
	$('.scrollerArea').css({width: screenWidth-130});
	
	//Entries
	$('.entryContainer').css('height', screenHeight);
	$('.modelsContainer').css('height', screenHeight);
	$('.contentPage .contentContainer').css('height', screenHeight-150);
}
$(document).ready(function(){
	screenWidth = $(window).width();
	screenHeight = $(window).height();
	var startScrollup;
	var startScrollDown;
	var startScrollupVideo;
	var startScrollDownVideo;
	
	//Cufon
	Cufon.replace('.menuContainer a, .countries a, .letterContainer, .mFont, .socialTitle, h2, .subMenuContainer a, .selectCountry a');
	
	resizeOnLoad();
	var sArt =0;
	$('.scrollerArea').slider({
		min: 0,
		max: 150,
		step: 10,
		animate: false,
		slide: function(event, ui){
			sArt = ui.value;
			$('.layoutContainer').css({left: '-'+((ui.value*4))+'px'});
			$('.entry-1').css({left: '-'+(ui.value*7)+'px'});
			$('.entry-1 .entry').css({left: (510-(ui.value))+'px'});
			
			$('.entry-2').css({left: (1210-(ui.value*9))+'px'});
			$('.entry-2 .entry').css({left: -((ui.value*3)-100)+'px'});
			
			$('.entry-3').css({left: (1450-(ui.value*7)+450)+'px'});
			$('.entry-3 .entry').css({left: -((ui.value+150))+'px'});
			
			$('.avatarsContainer').css({'margin-left': '-'+(ui.value+200)+'px'});
		}
	});
	
	$('.btnLightbox').lightBox();
	
	//Text Scroller:
	$('.btnArrowDown').mouseenter(function(){
		startScrollUp = setInterval(scrollUp, 100);
	}).mouseleave(function(){
		clearInterval(startScrollUp);
	});
	
	$('.btnArrowUp').mouseenter(function(){
		startScrollDown = setInterval(scrollDown, 100);
	}).mouseleave(function(){
		clearInterval(startScrollDown);
	});
	
	//Text scroller with mouse scroll.
	$('.contentText').bind('mousewheel', function(event, d){
		if(d < 0){
			scrollUp();
		}else{
			scrollDown();
		}
	});
	
	//Video Scroller:
	$('.btnVideoArrowDown').live('mousedown',function(){
		startScrollUpVideo = setInterval(scrollUpVideo, 100);
	});
	
	$('.btnVideoArrowDown').live('mouseup',function(){
		clearInterval(startScrollUpVideo);
	});
	
	$('.btnVideoArrowUp').live('mousedown',function(){
		startScrollDownVideo = setInterval(scrollDownVideo, 100);
	});
	
	$('.btnVideoArrowUp').live('mouseup',function(){
		clearInterval(startScrollDownVideo);
	});

	//Multimedia Video Next
	videoItem = 0;
	$('.btnNextVideo').live('click', function(){
		if(videoItem < $('.videos li').length-1){
			elem = $('.selectedVideo');
			nextElem = elem.parent().next('li');
			
			$('.selectedVideo').removeClass('selectedVideo');
			selectElem = nextElem.find('a');
			selectElem.addClass('selectedVideo');
			
			replaceVideo(selectElem);
			videoItem++;
		}
	});
	
	$('.btnPreviousVideo').live('click', function(){
		if(videoItem > 0){
			elem = $('.selectedVideo');
			nextElem = elem.parent().prev('li');
			
			$('.selectedVideo').removeClass('selectedVideo');
			selectElem = nextElem.find('a');
			selectElem.addClass('selectedVideo');
			
			replaceVideo(selectElem);
			videoItem--;			
		}
	});
	
	$('.videos li a').live('click', function(){
		$('.selectedVideo').removeClass('selectedVideo');
		$(this).addClass('selectedVideo');
		replaceVideo($('.selectedVideo'));
		videoItem = $('.videos li a').index($(this));
		
		return false;
	});
	
	$('.btnCloseLightBox').live('click', function(){
		$('.overlay, .lightBox').slideUp("fast", function(){
			$('.overlay, .lightBox').remove();
		});
	});
	
	//Contact Page
	$('.selectCountry a').live('click', function(){
		$('.btnSelectedCountry').removeClass('btnSelectedCountry');
		$('.selectedAddress').removeClass('selectedAddress').slideUp();
		$('p.'+$(this).attr('rel')).slideDown().addClass('selectedAddress');
		$(this).addClass('btnSelectedCountry');
		
		Cufon.replace('.selectCountry a');
		Cufon.now();
	});
	
	$('.cityHolder').live('click', function(){
		$(this).next('div').slideToggle();
	});
});

function replaceVideo(elem){
	$('.videoTitleContainer h2').fadeOut('fast', function(){
		$(this).text(elem.text()).fadeIn('fast');
		
		$('.playerContainer iframe').fadeOut('fast', function(){
			$('.playerContainer iframe').remove();
			$('.playerContainer').append('<iframe src="'+elem.attr('href')+'" width="641" height="391" frameborder="0"></iframe>');

			$('.socialSharingContainer').load('multimedia/share/'+elem.attr('rel'));
		});
		
		Cufon.replace('.videoTitleContainer h2');
		Cufon.now();
	});
}

var scrolledAmount = 20;
function scrollUp(){
	if($('.contentText').height() > scrolledAmount+240){
		$('.contentText').animate({
			top: '-='+20+'px'
		},30, 'linear');
		scrolledAmount = scrolledAmount+20;
	}
}

function scrollDown(){
	if(scrolledAmount > 20){
		$('.contentText').animate({
			top: '+='+20+'px'
		},30,'linear');
		scrolledAmount = scrolledAmount-20;
	}
}

var scrolledAmountVideo = 10;
function scrollUpVideo(){
	if($('.videos').height() > scrolledAmountVideo+80){
		$('.videos').animate({
			top: '-='+10+'px'
		},20, 'linear');
		scrolledAmountVideo = scrolledAmountVideo+10;
	}
}

function scrollDownVideo(){
	if(scrolledAmountVideo > 10){
		$('.videos').animate({
			top: '+='+10+'px'
		},30,'linear');
		scrolledAmountVideo = scrolledAmountVideo-10;
	}
}

function closeColinsLook(){
	$('.overlay, .lookContainer').slideUp();
}

$(window).resize(function(){
	resizeOnLoad();
});
