<!--
// This calls our function ClearInput, and the two variables we
// will need for it to function the original value and the id.
function ClearInput(value, id){ 
	var input = document.getElementById(id); // Gets the input field based on its id.

	if(value == input.value){ // If the default value is equal to the current value.
		input.value = ''; // Empty It.
	}
} 
function ResetInput(value, id){ 
	var input = document.getElementById(id); // Gets the input field based on its id.
	if (input.value== '') {
		input.value = value;
	}
} 

// AJAX function
function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 // Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}


function myFocus(id){
	var focusarea =	document.getElementById(id);
	focusarea.focus();
}

function formHandler ( formid, fieldvalue )
{
	
	if (fieldvalue!='')
	{
		document.getElementById(formid).deleteid.value = fieldvalue;
	}
	
	
	document.getElementById(formid).submit();
} 

function polaroid_focus(polaroid)
{
	polaroid.className = "polaroid_focus clickable";
}

function polaroid_blur(polaroid)
{
	polaroid.className = "polaroid_blur clickable";
}

// CODE FOR THE MAIN MENU

var hideTimerId = -1;

function showSubMenu(id)
{
	/***CODE FOR NEW MENU****/
	//RESET MENU'S

	if (hideTimerId >= 0) {
		clearTimeout (hideTimerId);
	}

	for (var x=1; x <= 7; x++)
	{
		$('SubMenu_'+x).style.display = 'none';
		$('MainMenu_' + x).setStyle({background:'none'});
	}

	//ACTIVATE SELECTED MENU
	$('MainMenu_' + id).setStyle({background:'url(images/menu_bg_stroke_selected.gif) repeat-x'});
	$('SubMenu_' + id).style.display = 'block';
} 



function hideSubMenus() {
	if (hideTimerId >= 0) {
		clearTimeout (hideTimerId);
	}
	hideTimerId = setTimeout("hideSubMenusNow();",400)
}

function hideSubMenusNow()
{
	/***CODE FOR NEW MENU****/
	//RESET MENU'S

	for (var x=1; x <= 7; x++)
	{
		$('SubMenu_'+x).style.display = 'none';
		$('MainMenu_' + x).setStyle({background:'none'});
	}

	for (var x=1; x <= 7; x++)
	{
		$('SubMenu_'+x).style.display = 'none';
		
	}
} 

//FRONTPAGE
page_nr = 0;
timer_id = null;

function tour_page(nr) {
	if (nextPageTimer != null) clearTimeout(nextPageTimer);
	nextPageTimer = setTimeout("nextPage();",7000);
	
	if (nr == page_nr) return;
		
	page_nr = nr;
	
	queue = Effect.Queues.get('tour');
	queue.each(function(effect) { effect.cancel(); });

	//Effect.Queue.each(function(effect) { effect.cancel(); });
	
	xvalue = (nr * -574);
	new Effect.Move('tour_back', { x: xvalue, y: 0, mode: 'absolute', duration: 1, queue: { scope: 'tour' }});//, transition: Effect.Transitions.spring, duration: 2.0
	if (timer_id != null) clearTimeout(timer_id);
	timer_id = setTimeout("showText();",950);
	$('tour_title').hide();
	$('tour_text').hide();
	
	for (i=0;i<3;i++)
	{
		$('tour_btn'+i).removeClassName('tour_btn_select');
	}
	$('tour_btn'+nr).addClassName('tour_btn_select');
	return false;
}

function nextMediaPage(nr) {
	nextvalue = (nr+1)%5;
	setTimeout("nextMediaPage(nextvalue);",4100);
	yvalue = (nr * -120);
	new Effect.Move('media_content', { x: 0, y: yvalue, mode: 'absolute', duration: 1.5, queue: { scope: 'media' }});//, transition: Effect.Transitions.spring, duration: 2.0
}

nextPageTimer = null;

function nextPage() {
	tour_page((page_nr+1)%3);
}

function showText() {
	text_array = new Array(new Array('Ontvang je eigen Fitplan', 'met een trainingsplan op maat, voedingsadvies en inzicht in je voortgang'), new Array('Zie dat het werkt', 'door inzicht in je vorderingen zul je extra gemotiveerd zijn je Fitplan vol te houden'),
		new Array('Iedereen kan fit zijn', 'met kleine aanpassingen aan je levensstijl. VirtuaGym helpt je gratis, doe nu mee!'));
	$('tour_title').innerHTML = text_array[page_nr][0];
	$('tour_text').innerHTML = text_array[page_nr][1];
	new Effect.Appear('tour_title', {duration: 0.25, queue: { scope: 'tour' }});
	new Effect.Appear('tour_text', {duration: 0.25, queue: { scope: 'tour' }});
}

var scores = new Array(75701120,137400,12521,14567 );
var upcview = new Array(42,1,0.25,0.2 );
var upcreal = new Array(172800,311,103,86);
var startd = new Date(2010, 0, 10);
var startdpage = new Date();
var score= new Array(0,0,0,0);

function init_scores() {
	time_def = ((startdpage.getTime() - startd.getTime()) / 86400000);
	for (i=0;i<4;i++)
	{
		score[i] = Math.round(( scores[i] + ( time_def * upcreal[i]) ));
	}
}

init_scores();

function update_scores() {
	var d=new Date();
	var time_def = ((d.getTime() - startdpage.getTime()) / 1000);	//sec
	
	randomnumber=Math.floor(Math.random()*4);
	
	score_temp = Math.round(( score[randomnumber] + ( time_def * upcview[randomnumber]) ));
	
	score_str = score_temp.toString();
	if (score_str.length>3) score_str = score_str.substr(0, score_str.length-3) + '.' + score_str.substr(score_str.length-3,3);
	if (score_str.length>7) score_str = score_str.substr(0, score_str.length-7) + '.' + score_str.substr(score_str.length-7,7);
	$('score_'+randomnumber).innerHTML = score_str;
	setTimeout("update_scores();", Math.round(Math.random() * 300));
}

function keep_scrolling(id, width, startnr, maxnr, duration, time) {
	new Effect.Move(id, { x: (-1*width*startnr), y: 0, mode: 'absolute', duration: duration}); 
	setTimeout("keep_scrolling('"+id+"',"+width+","+((startnr+1)%maxnr)+","+maxnr+","+duration+","+time+");", time);
	return false;
}


// CALL WAKEUP.PHP TO MAKE SURE THE USER DOESN'T GET LOGGED OUT WHILE WEBSITE IS STILL OPEN
function wakeup() {
                new Ajax.Updater('wakeup', 'wakeup.php');
                setTimeout("wakeup();",3300000); // an hour
}



//-->