

function displayVideo(sFileName, stillimage){

	stillimage = stillimage || "";
	
	if(sQuality == 'high'){
		sWidth = '640';
		sHeight = '480';
		$('#media_content').css({'margin-top': 0});
	} else {
		sWidth = '320'
		sHeight = '240';
		$('#media_content').css({'margin-top': 110});
	}
	if(sFileName.indexOf('.flv') > 0){

		var v = new SWFObject(site_url+'flash/player.swf','vid',sWidth,sHeight,'8');
		v.addParam('allowscriptaccess','always');
		v.addVariable('width',sWidth);
		v.addVariable('height',sHeight);
		v.addParam('bgcolor','#ffffff');
		v.addVariable('file',sFileName);
		
		if(stillimage == ""){
			v.addVariable('autostart','true');
		}
		
		if(stillimage != ""){
			v.addVariable('image', stillimage);
		}
		v.addVariable('controlbar','over');
		v.addVariable('screencolor','#ffffff');
		v.addVariable('javascriptid','vid');
		v.addVariable('enablejs','true');
		//v.addVariable('repeat', 'always');
		v.write('media_content');
		
		
		
	} else {
		$('#media_content').flash({
		    src: sFileName,
		    width: 640,
		    height: 480
		},
			{ version: '10.0.0' }
			);
		
	
	}
	
}

var player;
function playerReady(obj) {
	player = document.getElementById(obj['id']);
};


function playVideo(){
	player.sendEvent("PLAY","true");	
}

function resetMedia(){
	$('#media_content').css({'margin-top': 0});
}

function changeQuality(sQuality){
	
	// Get the current URL
	sURLFull = window.location.href.split("?");
	
	// Grab the script path.
	sURL = sURLFull[0]+'?quality='+sQuality;
	
	// If there was a query string attached to the current page load...
	if(sURLFull.length > 1 && sURLFull[1].length>0){
		// ... replace any language setting and add it to the new URL.
		sURL += "&" + sURLFull[1].replace('quality','old');
	}
	
	// Reload the window with the new language.
	window.location.href = sURL;
}

function changeLanguage(newLanguage){
	
	if(uses_seo_links == true){
		sURL = window.location.href.replace(sLanguage,newLanguage);
	} else {
		// Get the current URL
		sURLFull = window.location.href.split("?");
	
		// Grab the script path.
		sURL = sURLFull[0]+'?language='+newLanguage;
	
		// If there was a query string attached to the current page load...
		if(sURLFull.length > 1 && sURLFull[1].length>0){
			// ... replace any language setting and add it to the new URL.
			sURL += "&" + sURLFull[1].replace('language','old');
		}
	}
	
	// Reload the window with the new language.
	window.location.href = sURL;
}

function flash_url(filename){
	return site_url+'flash/'+filename;
}
function image_url(filename){
	return site_url+'images/'+filename;
}

$(document).ready(function() {
	
	// For the retarded browser...
	if ($.browser.msie && parseInt($.browser.version)< 8) {

		$(".tabs li.haschildren").each(function(tab){
			$(this).mouseover(function(tab){
				$("#"+this.id+" .children").css({visibility: 'visible'});
			});
			$(this).mouseout(function(tab){
				$("#"+this.id+" .children").css({visibility: 'hidden'});
			});
		});
		

		
	} else {
		$('#video_bandwidth').selectbox();
		$('#language').selectbox()
		
	};
	
	$(".header_form_controls").show();
	$("#video_bandwidth").change(function(){
		changeQuality(this.value);
	});

	$("#language").change(function(){
		changeLanguage(this.value);
	});
	


	

	
});
