var timer;
var otimer;
var i;
function setBanner(b, l) {
	clearTimeout(timer);	
	if ( $('#banner-photo').attr('src') == ('images/banner/' + b + '.gif')) {
		return true;
	}
	clearTimeout(otimer);
	$('#banner-photo').css('opacity',0.0);
	$('#banner-photo').attr('src', 'images/banner/' + b + '.gif');
	i = 0;
	animateBanner();
	$('#banner-link').attr('href', l);	
}
function animateBanner() {
	if (i < 1) {
		i = i + .1;
		$('#banner-photo').css('opacity',i);
		$('#banner-photo').css('filter','alpha(opacity='+(i*100)+')');
		otimer = setTimeout("animateBanner()",40);
	} else {
		clearTimeout(otimer);
	}
}
function goNext () {
	clearTimeout(timer);
	spinBanner('1');
}
function goPrevious () {
	clearTimeout(timer);
	spinBanner('-1');
}
function spinBanner(d) {
	p = $('#banner-photo').attr('src');
	if (d == '1') {
		switch( p )	{
			case 'images/banner/gs.gif':
				setBanner('ananta_new','../products/ananta/index.html');
				break;
			case 'images/banner/ananta_new.gif':
				setBanner('sportura_new','../products/sportura/index.html');
				break;
			case 'images/banner/sportura_new.gif':
				setBanner('team','../products/premier/index.html');
				break;
			case 'images/banner/team.gif':
				setBanner('premier_new','../products/premier/index.html');
				break;
			case 'images/banner/premier_new.gif':
				setBanner('ladies_coutura','../products/coutura/index.html');
				break;
			case 'images/banner/ladies_coutura.gif':
				setBanner('gs','http://www.grand-seiko.com');
				break;

		}
	} else {
		switch( p )	{
			case 'images/banner/ladies_coutura.gif':
				setBanner('gs','http://www.grand-seiko.com');
				break;
			case 'images/banner/ananta_new.gif':
				setBanner('coutura','../products/coutura/index.html');
				break;
			case 'images/banner/sportura_new.gif':
				setBanner('ananta_new','../products/ananta/index.html');
				break;
			case 'images/banner/team.gif':
				setBanner('sportura_new','../products/ananta/index.html');
				break;
			case 'images/banner/premier_new.gif':
				setBanner('team','../products/sportura/index.html');
				break;
			case 'images/banner/ladies_coutura.gif':
				setBanner('premier_new','../products/premier/index.html');
				break;
			case 'images/banner/gs.gif':
				setBanner('ladies_coutura','../products/coutura/index.html');
				break;
		}
	}
	timer = setTimeout("spinBanner('1')",5000);
}
function startTiming() {
	timer = setTimeout("spinBanner('1')",5000);
}
function showArrows(on) {
	if (on == '1') {
		$('#arrow-next').css('display','block');
		$('#arrow-previous').css('display','block');
	} else {
		$('#arrow-next').css('display','none');
		$('#arrow-previous').css('display','none');
	}
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
$(document).ready(function(){ 
	MM_preloadImages('images/banner/gs.gif','images/banner/coutura.gif','images/banner/ananta_new.gif','images/banner/sportura_new.gif','images/banner/premier_new.gif','images/banner/ladies_coutura.gif', 'images/banner/team.gif');
	startTiming();
}); 

