switchCounter=0;
continueRotate="true";
globalStoryCount=0;

function startRotate(){
	Timer();
}
function Timer(){
	if(continueRotate=="true"){
		mainSwitch(switchCounter,'false');
		switchCounter++;
		window.setTimeout("Timer()",5000);
	}
}

Rollimage = new Array()

Rollimage[0]= new Image(9,9)
Rollimage[0].src = "images/slide_bullet_1.png"
Rollimage[1] = new Image(9,9)
Rollimage[1].src = "images/slide_bullet_2.png"

Rollimage[2]= new Image(9,9)
Rollimage[2].src = "images/slide_bullet_1.png"
Rollimage[3] = new Image(9,9)
Rollimage[3].src = "images/slide_bullet_2.png"

Rollimage[4]= new Image(9,9)
Rollimage[4].src = "images/slide_bullet_1.png"
Rollimage[5] = new Image(9,9)
Rollimage[5].src = "images/slide_bullet_2.png"

Rollimage[6]= new Image(9,9)
Rollimage[6].src = "images/slide_bullet_1.png"
Rollimage[7] = new Image(9,9)
Rollimage[7].src = "images/slide_bullet_2.png"
	
Rollimage[8]= new Image(9,9)
Rollimage[8].src = "images/slide_bullet_1.png"
Rollimage[9] = new Image(9,9)
Rollimage[9].src = "images/slide_bullet_2.png"



function SwapOut(imageName){
	var changeImageName=imageName;
	
    if(imageName=="bt1"){
    	document.bt1.src = Rollimage[1].src;
    }
    else if(imageName=="bt2"){
    	document.bt2.src = Rollimage[3].src;
    }
    else if(imageName=="bt3"){
    	document.bt3.src = Rollimage[5].src;
    }
    else if(imageName=="bt4"){
    	document.bt4.src = Rollimage[7].src;
    }
    else if(imageName=="bt5"){
    	document.bt5.src = Rollimage[9].src;
    }
   
    return true;
}

function SwapBack(imageName){
	try{
		if(imageName=="bt1"){
	    	document.bt1.src = Rollimage[0].src;
	    }
	    else if(imageName=="bt2"){
	    	document.bt2.src = Rollimage[2].src;
	    }
	    else if(imageName=="bt3"){
	    	document.bt3.src = Rollimage[4].src;
	    }
	    else if(imageName=="bt4"){
	    	document.bt4.src = Rollimage[6].src;
	    }
	    else if(imageName=="bt5"){
	    	document.bt5.src = Rollimage[8].src;
	    }
	}
	catch(err){
	  
	}
    return true;
}


function clearAllNumbers(clicked_yn) {
	SwapBack("bt1");
	SwapBack("bt2");
	SwapBack("bt3");
	SwapBack("bt4");
	SwapBack("bt5");
	
}

function mainSwitch(show_story_value, pauseTimer) {
	if(pauseTimer=="true"){
		continueRotate="false";
	}
	
	var storyCount=1;
	
	var v_img1 = $('story_image1');
	var v_teaser1 = $('story_teaser1');
	var v_explore1 = $('explore1');
	var v_img2 = $('story_image2');
	var v_teaser2 = $('story_teaser2');
	var v_explore2 = $('explore2');
	if(v_img2!=null){
		storyCount++;
	}
	var v_img3 = $('story_image3');
	var v_teaser3 = $('story_teaser3');
	var v_explore3 = $('explore3');
	if(v_img3!=null){
		storyCount++;
	}
	var v_img4 = $('story_image4');
	var v_teaser4 = $('story_teaser4');
	var v_explore4 = $('explore4');
	if(v_img4!=null){
		storyCount++;
	}
	var v_img5 = $('story_image5');
	var v_teaser5 = $('story_teaser5');
	var v_explore5 = $('explore5');
	if(v_img5!=null){
		storyCount++;
	}
	
	globalStoryCount=storyCount;
	
	var selected_story=document.getElementById('story_number').value;
	new_story=1;
	
	if(show_story_value=="-1"){
		new_story=parseInt(selected_story)-1;
		if(new_story=="0"){
			/*go to last story*/
			show_story_value=storyCount;
		}
		else{
			/*go to story number*/
			show_story_value=new_story;
		}
	}
	else if(show_story_value=="+1"){
		new_story=parseInt(selected_story)+1;
		if(new_story==storyCount+1){
			/*go to first story*/
			show_story_value=1;
		}
		else{
			/*go to story number*/
			show_story_value=new_story;
		}
	}
	
	if(show_story_value=="1"){
			if(v_img2!=null){
				v_img2.style.display = 'none';
				v_teaser2.style.display = 'none';
				v_explore2.style.display='none';
			}
			if(v_img3!=null){
				v_img3.style.display = 'none';
				v_teaser3.style.display = 'none';
				v_explore3.style.display='none';
			}
			if(v_img4!=null){
				v_img4.style.display = 'none';
				v_teaser4.style.display = 'none';
				v_explore4.style.display='none';
			}
			if(v_img5!=null){
				v_img5.style.display = 'none';
				v_teaser5.style.display = 'none';
				v_explore5.style.display='none';
			}
			
			v_img1.style.display = '';
			v_teaser1.style.display = '';
			v_explore1.style.display = '';
			
			document.getElementById('story_number').value="1";
			/*swap image to red one*/
			clearAllNumbers(pauseTimer);
			SwapOut("bt1");
			
	}
	else if(show_story_value=="2"){
		if(globalStoryCount<2){
			
		}
		else{		
			v_img1.style.display = 'none';
			v_teaser1.style.display = 'none';
			v_explore1.style.display = 'none';
			if(v_img3!=null){
				v_img3.style.display = 'none';
				v_teaser3.style.display = 'none';
				v_explore3.style.display = 'none';
			}
			if(v_img4!=null){
				v_img4.style.display = 'none';
				v_teaser4.style.display = 'none';
				v_explore4.style.display = 'none';
			}
			if(v_img5!=null){
				v_img5.style.display = 'none';
				v_teaser5.style.display = 'none';
				v_explore5.style.display = 'none';
			}
			
			v_img2.style.display = '';
			v_teaser2.style.display = '';
			v_explore2.style.display = '';
			
			document.getElementById('story_number').value="2";
			/*swap image to red one and rest moustover calls*/
			clearAllNumbers(pauseTimer);
			SwapOut("bt2");
		}
			
	}
	else if(show_story_value=="3"){
		if(globalStoryCount<3){
			
		}
		else{	
			v_img1.style.display = 'none';
			v_teaser1.style.display = 'none';
			v_explore1.style.display = 'none';
			v_img2.style.display = 'none';
			v_teaser2.style.display = 'none';
			v_explore2.style.display = 'none';
			if(v_img4!=null){
				v_img4.style.display = 'none';
				v_teaser4.style.display = 'none';
				v_explore4.style.display = 'none';
			}
			if(v_img5!=null){
				v_img5.style.display = 'none';
				v_teaser5.style.display = 'none';
				v_explore5.style.display = 'none';
			}
			
			v_img3.style.display = '';
			v_teaser3.style.display = '';
			v_explore3.style.display = '';
			
			document.getElementById('story_number').value="3";
			/*swap image to red one*/
			clearAllNumbers(pauseTimer);
			SwapOut("bt3");
		}
	}
	else if(show_story_value=="4"){
		if(globalStoryCount<4){
		}
		else{	
			v_img1.style.display = 'none';
			v_teaser1.style.display = 'none';
			v_explore1.style.display = 'none';
			v_img2.style.display = 'none';
			v_teaser2.style.display = 'none';
			v_explore2.style.display = 'none';
			v_img3.style.display = 'none';
			v_teaser3.style.display = 'none';
			v_explore3.style.display = 'none';
			
			if(v_img5!=null){
				v_img5.style.display = 'none';
				v_teaser5.style.display = 'none';
				v_explore5.style.display = 'none';
			}
			
			v_img4.style.display = '';
			v_teaser4.style.display = '';
			v_explore4.style.display = '';
			
			document.getElementById('story_number').value="4";
			/*swap image to red one*/
			clearAllNumbers(pauseTimer);
			SwapOut("bt4");
		}
	}
	else if(show_story_value=="5"){
		if(globalStoryCount<5){
		}
		else{	
			v_img1.style.display = 'none';
			v_teaser1.style.display = 'none';
			v_explore1.style.display = 'none';
			v_img2.style.display = 'none';
			v_teaser2.style.display = 'none';
			v_explore2.style.display = 'none';
			v_img3.style.display = 'none';
			v_teaser3.style.display = 'none';
			v_explore3.style.display = 'none';
			
			v_img4.style.display = 'none';
			v_teaser4.style.display = 'none';
			v_explore4.style.display = 'none';
			
			v_img5.style.display = '';
			v_teaser5.style.display = '';
			v_explore5.style.display = '';
			
			document.getElementById('story_number').value="5";
			/*swap image to red one*/
			clearAllNumbers(pauseTimer);
			SwapOut("bt5");
		}
	}
	
	else{
		if(v_img2!=null){
			v_img2.style.display = 'none';
			v_teaser2.style.display = 'none';
			v_explore2.style.display = 'none';
		}
		if(v_img3!=null){
			v_img3.style.display = 'none';
			v_teaser3.style.display = 'none';
			v_explore3.style.display = 'none';
		}
		if(v_img4!=null){
			v_img4.style.display = 'none';
			v_teaser4.style.display = 'none';
			v_explore4.style.display = 'none';
		}
		if(v_img5!=null){
			v_img5.style.display = 'none';
			v_teaser5.style.display = 'none';
			v_explore5.style.display = 'none';
		}
		v_img1.style.display = '';
		v_teaser1.style.display = '';
		v_explore1.style.display = '';
			
		document.getElementById('story_number').value="1";
		switchCounter=1;
		clearAllNumbers(pauseTimer);
		SwapOut("bt1");
	}
}
/*
function contentSwitch(show_content_value) {
	var v_content1 = $('content1');
	var v_td_content1=$('td_content1');
	
	var v_content2 = $('content2');
	var v_td_content2=$('td_content2');
	
	var v_content3 = $('content3');
	var v_td_content3=$('td_content3');
	
	if(show_content_value=="1"){
		v_content2.style.display = 'none';
		v_content3.style.display = 'none';
		v_content1.style.display = '';
		
		v_td_content2.className='tabnav';
		v_td_content3.className='tabnav';
		v_td_content1.className='tabnavselected';
	}
	else if(show_content_value=="2"){
		v_content3.style.display = 'none';
		v_content1.style.display = 'none';
		v_content2.style.display = '';
		
		v_td_content1.className='tabnav';
		v_td_content3.className='tabnav';
		v_td_content2.className='tabnavselected';
	}
	else if(show_content_value=="3"){
		v_content2.style.display = 'none';
		v_content1.style.display = 'none';
		v_content3.style.display = '';
		
		v_td_content1.className='tabnav';
		v_td_content2.className='tabnav';
		v_td_content3.className='tabnavselected';
	}
}
*/
