/*******************************************************************************/
/* Copyright ©2007, Dennis Teunissen - Filmhuis Hoorn: www.filmhuishoorn.nl    */
/* JAVASRIPTFILE FOR THE WEBSITE OF FILMHUIS HOORN                             */
/* SCRIPT: MOVIESLIDER                                                         */
/*******************************************************************************/

// Initialise variable position
position = 0;

// Set the frame width
frWidth  = 600;
	  
// Browsercheck
var IE = document.all?true:false;

// In case user is using Netscape or Mozilla Firefox
if(!IE){
	document.captureEvents(Event.MOUSEMOVE);
	x = frWidth/2 + 200; // to give the slider some motion at initialisation
// In case user is using Internet Explorer
}else{
	x = frWidth/2 + 40; // to give the slider some motion at initialisation
}

// What should this document do on mouseover?
document.onmousemove = getMouseX;


// onmouseout slider will gain back its initial speed and direction
document.onmouseout = mouseOutFunction;
function mouseOutFunction(){
	// In case user is using Netscape or Mozilla Firefox
	if(!IE){
		document.captureEvents(Event.MOUSEMOVE);
		x = frWidth/2 + 200; // to give the slider some motion at initialisation
	// In case user is using Internet Explorer
	}else{
		x = frWidth/2 + 40; // to give the slider some motion at initialisation
	}
}


// Function to get the X-mouseposition...
function getMouseX(e){	
	if(IE){ // ...in case of Internet Explorer
		x = window.event.x;
	}else{  // ...in case of Netscape or Mozilla Firefox
		  x = e.pageX;
	}
	// Just in case of a negative value
	if(x<0){
		x = 0;
	}
}

// Function to be executed on pageload (and to be repeated every millisec)
function loop(){
	if(x<(frWidth/2)){
		motion = ((frWidth/2)-x)/50;		// = motion between 0 and 6
	}else{
		motion = -((x-(frWidth/2))/50);		// = motion between -6 and 0
	}

	motion = motion/3; // slow it down a bit more (otherwise it is too fast)

	moveSlider(-motion);
}

// Function to actually move the slider
function moveSlider(movement){
	position -= movement;
	if(document.getElementById){
		if(!document.getElementById("divA"))
			return;
		wdth = document.getElementById("divA").offsetWidth
		if(position>-wdth){
			document.getElementById('divA').style.left=position
			document.getElementById('divB').style.left=position+wdth				
		}
		if(position>0){		  
			document.getElementById('divA').style.left=position
			document.getElementById('divB').style.left=position-wdth		  
		}
		if(position>wdth){	
			position = 0
			document.getElementById('divA').style.left=position			
			document.getElementById('divB').style.left=position+wdth
		}
		if(position<-wdth){
			position = 0
			document.getElementById('divA').style.left=position
			document.getElementById('divB').style.left=position+wdth
		}
	}else{
		wdth = document.layers["divA"].document.width
		if(position>-wdth){
			document.layers['divA'].left=position
			document.layers['divB'].left=position+wdth
		}else{
			position = 0
			document.layers['divA'].left=position
			document.layers['divB'].left=position+wdth
		}
	}
}

// function which opens the movie.php file in the content frame
function gotoMovie(id){
	top.overall.menu.main.content.location.href = "movie.php?movie="+id;
}