//function add_to_textfield addts to the hidden text field the values of layed tunes
function add_to_textfield(value) {
	//alert(value);
	if(value=='')
		return;
	tune = document.getElementById('tune1');
	if(tune.value=='')
	{
		tune.value=value;
	}
	else
	{
		tune.value+="|"+value;
	}
}
//function clear_textfield is to reset the textfiled hidden
function clear_textfield(id) {
	document.getElementById(id).value='';
}
//function listen is to split the values inside  the array  and give each value to the sound manager.loop into the array to play all its elements
function listen(){
	//alert("eeeeeee!");
	var myString=document.getElementById('tune1').value;
	var myArray = myString.split('|');
	for(var i=0;i<myArray.length;i++)
	{
		soundManager.play(myArray[i]);
		sleep_fewsecs(0.02);
	}
	return;
}
function listen_2(t){
	//alert(t);
	var myString=t;
	var myArray = myString.split('|');
	for(var i=0;i<myArray.length;i++)
	{
		soundManager.play(myArray[i]);
		//sleep_fewsecs(0.7);
	}
	return;
}
function sleep_fewsecs(naptime){
     naptime = naptime * 1000;
     var sleeping = true;
     var now = new Date();
     var alarm;
     var startingMSeconds = now.getTime();
     //alert("starting nap at timestamp: " + startingMSeconds + "\nWill sleep for: " + naptime + " ms");
     while(sleeping){
        alarm = new Date();
        alarmMSeconds = alarm.getTime();
        if(alarmMSeconds - startingMSeconds > naptime){ sleeping = false; }
     }      
     //alert("Wakeup!");
}
function callPlayer(id){
	if (id == '1'){
		var s1 = new SWFObject('../back2school0910/swf/videocontroller.swf','player','250','202','9');
			s1.addParam('allowfullscreen','false');
			s1.addParam('autostart','true');
			s1.addParam('allowscriptaccess','always');
			s1.addParam('flashvars','file=../videos/Odyssee.flv');
			s1.write('mov');
	}	
	else if (id == '2'){
		var s1 = new SWFObject('../back2school0910/swf/videocontroller.swf','player','250','202','9');
			s1.addParam('allowfullscreen','false');
			s1.addParam('allowscriptaccess','always');
			s1.addParam('flashvars','file=../videos/Earth2.flv');
			s1.write('mov');
	}
	else if (id == '3'){
		var s1 = new SWFObject('../back2school0910/swf/videocontroller.swf','player','250','202','9');
			s1.addParam('allowfullscreen','false');
			s1.addParam('allowscriptaccess','always');
			s1.addParam('flashvars','file=../videos/Earth.flv');
			s1.write('mov');
	}
	else if (id == '4'){
		var s1 = new SWFObject('../back2school0910/swf/videocontroller.swf','player','250','202','9');
			s1.addParam('allowfullscreen','false');
			s1.addParam('allowscriptaccess','always');
			s1.addParam('flashvars','file=../videos/Mushrooms.flv');
			s1.write('mov');
	}
	else if (id == '5'){
		var s1 = new SWFObject('../back2school0910/swf/videocontroller.swf','player','250','202','9');
			s1.addParam('allowfullscreen','false');
			s1.addParam('allowscriptaccess','always');
			s1.addParam('flashvars','file=../videos/Rain.flv');
			s1.write('mov');
	}
}
function displayhideOne(a){
 var target = document.getElementById(a);
 if(target.style.display==''){
  target.style.display = 'none';
 }else{
  target.style.display = '';
 }
}
function displayhide(id1, id2, id3, id4, id5){
	document.getElementById(id1).style.display='';
	document.getElementById(id2).style.display='none';
	document.getElementById(id3).style.display='none';
	document.getElementById(id4).style.display='none';
	document.getElementById(id5).style.display='none';
}