﻿var _ulGoldSponsors, _GoldSponsorsMaxScrollLeft, _GoldSponsorScrollDir, _GoldSponsorScrollTimer;
var _ulPlatSponsors, _PlatSponsorsMaxScrollLeft, _PlatSponsorScrollDir, _PlatSponsorScrollTimer;
function InitializeHomeGoldPageScroll() {

	_ulGoldSponsors = document.getElementById('ulGoldSponsor');
	if(_ulGoldSponsors) {
		var liGallery = _ulGoldSponsors.getElementsByTagName('li');
		var galleryScrollWidth = 121 * liGallery.length * 2;
		
		_ulGoldSponsors.innerHTML += _ulGoldSponsors.innerHTML;
		
		_ulGoldSponsors.style.width = galleryScrollWidth + 'px';
		
		_GoldSponsorsMaxScrollLeft = 0 - (galleryScrollWidth / 2) + 1;
		
		_GoldSponsorScrollDir = 'left';
		_ulGoldSponsors.style.left = '0px';
		
		liGallery = _ulGoldSponsors.getElementsByTagName('li');
		for(var i=0;i < liGallery.length; i++) {
			liGallery[i].onmouseover = StopGoldPartnerScroll;
			liGallery[i].onmouseout = StartGoldPartnerScroll;
		}
		
		StartGoldPartnerScroll();
	}
	
}

function InitializeHomePlatPageScroll() {
	
	_ulPlatSponsors = document.getElementById('PlatSponsors');
	if(_ulPlatSponsors) {
		var liGallery2 = _ulPlatSponsors.getElementsByTagName('li');
		var galleryScrollWidth = 121 * liGallery2.length * 2;
		
		_ulPlatSponsors.innerHTML += _ulPlatSponsors.innerHTML;
		
		_ulPlatSponsors.style.width = galleryScrollWidth + 'px';
		
		_PlatSponsorsMaxScrollLeft = 0 - (galleryScrollWidth / 2) + 1;
		
		_PlatSponsorScrollDir = 'left';
		_ulPlatSponsors.style.left = '0px';
		
		liGallery2 = _ulPlatSponsors.getElementsByTagName('li');
		for(var i=0;i < liGallery2.length; i++) {
			liGallery2[i].onmouseover = StopPlatPartnerScroll;
			liGallery2[i].onmouseout = StartPlatPartnerScroll;
		}
		
		StartPlatPartnerScroll();
	}
}

function StartGoldPartnerScroll() {
	if(_GoldSponsorScrollDir != 'right') {
		_ulGoldSponsors.style.left = ((parseInt(_ulGoldSponsors.style.left) <= _GoldSponsorsMaxScrollLeft) ? '0' : (parseInt(_ulGoldSponsors.style.left) - 1)) + 'px';
	}
	else {
		_ulGoldSponsors.style.left = ((parseInt(_ulGoldSponsors.style.left) >= 0) ? _GoldSponsorsMaxScrollLeft : (parseInt(_ulGoldSponsors.style.left) + 1)) + 'px';
	}
	
	if(!_GoldSponsorScrollTimer)
		_GoldSponsorScrollTimer = setInterval(function() { StartGoldPartnerScroll(); }, 40);
}
function StopGoldPartnerScroll(){
  clearInterval(_GoldSponsorScrollTimer);
  _GoldSponsorScrollTimer = null;
}
function ChangeGoldPartnerDirection(dir) {
	if(dir.toLowerCase() == 'left') {
		_GoldSponsorScrollDir = 'left';
	}
	else {
		_GoldSponsorScrollDir = 'right';
	}

	StopGoldPartnerScroll();
	StartGoldPartnerScroll();
}

//Platinum sponsors
function StartPlatPartnerScroll() {
	if(_PlatSponsorScrollDir != 'right') {
		_ulPlatSponsors.style.left = ((parseInt(_ulPlatSponsors.style.left) <= _PlatSponsorsMaxScrollLeft) ? '0' : (parseInt(_ulPlatSponsors.style.left) - 1)) + 'px';
	}
	else {
		_ulPlatSponsors.style.left = ((parseInt(_ulPlatSponsors.style.left) >= 0) ? _PlatSponsorsMaxScrollLeft : (parseInt(_ulPlatSponsors.style.left) + 1)) + 'px';
	}
	
	if(!_PlatSponsorScrollTimer)
		_PlatSponsorScrollTimer = setInterval(function() { StartPlatPartnerScroll(); }, 40);
}
function StopPlatPartnerScroll(){
  clearInterval(_PlatSponsorScrollTimer);
  _PlatSponsorScrollTimer = null;
}
function ChangePlatPartnerDirection(dir) {
	if(dir.toLowerCase() == 'left') {
		_PlatSponsorScrollDir = 'left';
	}
	else {
		_PlatSponsorScrollDir = 'right';
	}

	StopPlatPartnerScroll();
	StartPlatPartnerScroll();
}
