	
	
	//__________________________________________________________________________________________________________________________________________________________________
	// VIDEO PAGE CODE	
	//__________________________________________________________________________________________________________________________________________________________________	
	sting_vid=new Object();
	sting_vid.width=490
	sting_vid.height=367
	sting_vid.stream_url="sting_vid.flv"
	//if (debug) {sting_vid.stream_url="test.swf"}
	
	var player;
	function playerReady(obj) {
		/*
		player = document.getElementById("video_player");
		var config=player.getConfig()
		var str=""
		for(var i in config){
			str+=i+"="+config[i]+"\n"
		}
		*/
		//alert(str)
	};
	
	/**
	* Return the key of the vid in an the vids array using the given vid id
	* @param vid_id The id of the vid in the vids array
	*/
	function getVidKeyById(vid_id){
		for(var i=0;i<vids.length;i++){
			if(vids[i].id==vid_id){
				return i
			}
		}
	}
	
	/**
	* Load in vid
	* @param vids The vids array
	* @param vid_id The id of the vid in the vids array (not the key)
	*/
	loadVid=function(vids, vid_id){
		
		var vid_key=getVidKeyById(vid_id)
		
		if(vid_id==-1){
			var stream_url=sting_vid.stream_url
			var width=sting_vid.width
			var height=sting_vid.height
			var title=""
			var description=""
			var author=""
		}else{
			
			var stream_url=vids[vid_key].stream_url
			var width=parseInt(vids[vid_key].width)
			var height=parseInt(vids[vid_key].height)
			var title=vids[vid_key].title
			var description=vids[vid_key].description
			var author="-- uploaded by <b>"+vids[vid_key].author+"</b>"
		}
		
		/*
		* Load in the flash player
		*/
		// Remove the previous video
		/*
		var container=document.getElementById("video_player_container")
		removeChildNodes(container)
		var new_div = document.createElement("div");
		new_div.id="video_player";
		container.appendChild(new_div);
		*/
		var controlpanelHeight=32;
		var url=media_server+event_dir+video_dir+"/"+stream_url
		var player_url=server+"/includes/live/flash/media_player/player.swf"
		var skin_url=server+"/includes/live/flash/media_player/stylish.swf"
		var express_install_url=server+"/includes/live/flash/expressInstall.swf"
		var flash_version="9.0.28"

		var player_id="video_player";
		var flashvars = {
			file:url,
			autostart:true,
			skin:skin_url
		}
		var params = {
			allowfullscreen:true,
			allowscriptaccess:"always",
			wmode:"transparent"
		}
		var attributes = {
			id:player_id,
			name:player_id
		}
		var attributes = {}
		swfobject.embedSWF(player_url, player_id, width,height+controlpanelHeight,flash_version, express_install_url, flashvars, params, attributes)
		
		
		/*
		* Set the text for the current video
		*/
		var player_text=document.getElementById('video_player_text')
		var str="";
		str+="<p class='title_text_large' style='clear:both'>"+title+"</p>"
		str+="<p class='body_text'>"+description+"</p>"
		str+="<p class='body_text'>"+author+"</p>"
		player_text.innerHTML=str
		
		// Fix recent IE bug to do with plugins that forces the user to click the plugin object to activate it
		objects = document.getElementsByTagName("OBJECT");
		for (var i = 0; i < objects.length; i++)
		{
		    objects[i].outerHTML = objects[i].outerHTML;
		}
	
	
	}
	
	
	
	
	//____________________________________________________________________________________________________________________________________
	// MINOR FUNCTIONS
	function plusUnescape(str) { 
	// the unescape function won't convert plus signs to spaces; like you see in search strings
		str = '' + str; 
		while (true) {
			var j = str.indexOf('+');
			if (j == -1) break;
			str = str.substring(0,j) + ' ' + str.substring(j+1,str.length);
		}
		return unescape(str);
	}
	function addslashes(str) {
		str=str.replace(/\'/g,'\\\'');
		str=str.replace(/\"/g,'\\"');
		str=str.replace(/\\/g,'\\\\');
		str=str.replace(/\0/g,'\\0');
		return str;
	}
	function stripslashes(str) {
		str=str.replace(/\\'/g,'\'');
		str=str.replace(/\\"/g,'"');
		str=str.replace(/\\\\/g,'\\');
		str=str.replace(/\\0/g,'\0');
		return str;
	}
	
	
	// Load in the images which have a thumbnail once everything else has been loaded
	function preloadImages(){
		if(photo_q!=undefined){
			if(photo_q.length>0){
				for(var i=0;i<photo_q.length;i++){
					photo_q[i].image= new Image(10,10); 
					photo_q[i].image.src=photo_q[i].url;
					
				}
			}
		}

			
	}

		
		
	
	

	//__________________________________________________________________________________________________________________________________________________________________
	// GENERIC CODE
	//__________________________________________________________________________________________________________________________________________________________________
	function select_text(input_id){
	
		// Only select the text if it hasn't been clicked before
		if(!input_id.clickedBefore||input_id.clickedBefore==''){
			
			input_id.default_value=input_id.value;
			input_id.select();
			input_id.clickedBefore=true;
			
		}
	
	}
	
	function revert_text(input_id){
		
		// Only select the text if it hasn't been clicked before
		if(input_id.value==''){
			input_id.value=input_id.default_value;
		}
		
	}
	
	function validateForm(form_name){
		var f=document.getElementById(form_name)
		switch (form_name){
			case "intro_form":
			
				var data={"action":"tell_a_friend", "friend":f.friend.value, "sender":f.sender.value};
				var json_string = JSON.stringify(data);
				$.post('ajax.php', { json_string: json_string}, intro_formCallback, "text");
	
				/*
				var data_string="action=tell_a_friend&friend="+f.friend.value+"&sender="+f.sender.value
				var ajax = new GLM.AJAX();
				ajax.callPage("ajax.php?"+data_string, intro_formCallback);
				*/
				break
				
			case "upload_form" :
				
				// Blank filename
				if(!f['file1'].value){
					alert('Please give us a filename');				
				}
				
				else{
				
					// Clear wrong description
					if(f.description.value=="Description"){
						f.description.value="";
					}
					
					// SUBMIT FORM
					f.submit();
				}

				break
			case "music_tell_a_friend_form" :
			
				var friend=document.getElementById('friend').value
				var sender=document.getElementById('sender').value
				
				var data={"action":"tell_a_friend", "friend":friend, "sender":sender};
				var json_string = JSON.stringify(data);
				$.post('ajax.php', { json_string: json_string}, music_tell_a_friend_formCallback, "text");
	
				/*
				var data_string="action=tell_a_friend&friend="+friend+"&sender="+sender
				var ajax = new GLM.AJAX();
				ajax.callPage("ajax.php?"+data_string, music_tell_a_friend_formCallback);
				*/
				break
		}
	}
	
	function preloadMenuImages(){
		
		var dir="../../../images/live/"
		
		pic0= new Image(100,25); 
		pic0.src=dir+"menu0_down.gif";
		pic1= new Image(100,25); 
		pic1.src=dir+"menu1_down.gif";
		pic2= new Image(100,25); 
		pic2.src=dir+"menu2_down.gif";
		pic3= new Image(100,25); 
		pic3.src=dir+"menu3_down.gif";
		
	}

	//__________________________________________________________________________________________________________________________________________________________________
	// INTRO PAGE CODE
	//__________________________________________________________________________________________________________________________________________________________________	
	function intro_formCallback(json_string){
		if(json_string!=""){
			
			var response=JSON.parse(json_string);
			
			
			// Get the vars from the incoming response
			//var phpSerializer = new PHP_Serializer(); 
			//response=(phpSerializer.unserialize(serialized_response));
			
			
			
			// Clear the form if successful
			if(response.message_sent){
				document.getElementById('friend').value=intro_form_friend_default
				// Show the response message
				document.getElementById('intro_form_response').innerHTML="<span class='intro_form_response_good'>"+response.message+"</span>"
			}
			else{
				document.getElementById('friend').select();
				// Show the response message
				document.getElementById('intro_form_response').innerHTML="<span class='intro_form_response_bad'>"+response.message+"</span>"
			}
		}
	}
	

	
	//__________________________________________________________________________________________________________________________________________________________________
	// MUSIC PAGE CODE	
	//__________________________________________________________________________________________________________________________________________________________________	
	
	function music_tell_a_friend_formCallback(json_string){
		//alert("hallo"+json_string)
		if(json_string!=""){
			
			
			// Get the vars from the incoming response
			var response=JSON.parse(json_string);
			//var phpSerializer = new PHP_Serializer(); 
			//response=(phpSerializer.unserialize(serialized_response));

			// Clear the form if successful
			if(response.message_sent){
				document.getElementById('friend').value=intro_form_friend_default
				// Show the response message
				document.getElementById('music_tell_a_friend_form_response').innerHTML="<span class='intro_form_response_good'>"+response.message+"</span>"
			}
			else{
				document.getElementById('friend').select();
				// Show the response message
				document.getElementById('music_tell_a_friend_form_response').innerHTML="<span class='intro_form_response_bad'>"+response.message+"</span>"
			}
		}
	}
	
	
	