function examineForm(formName, fieldName){
  var form = document.forms[formName];
  if (form.elements[fieldName].value.length > 0){
    form.submit();
  }
}
function dsp_photo(url, w, h){
  var winphoto=window.open(url, 'photo', 'width='+w+',height='+h+',status=yes,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes,screenX=0,screenY=0');
  winphoto.focus();
}
function open_live(game_number, micrositescope){
  var winlive=window.open('http://live.fibaeurope.com/netcasting/default.asp?game_number=' + game_number + '&microsite_scope=' + micrositescope, 'live', 'width=720,height=525,status=no,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes,screenX=0,screenY=0');
  winlive.focus();
}

// Front page functions
function fpSwitchLeft(id, animate)
{
	$(".fpl_tab_enabled").hide();
	$(".fpl_tab_disabled").show();
	$("#tab_" + id + "_disabled").hide();
	$("#tab_" + id + "_enabled").show();
	
	$(".fpArt").hide();
	$("#fpArt_" + id).show();
	
	var artID = $("#fpArt_" + id).find("td.fpArticleTab:eq(0)").attr("id").substr(13);
	fpSwitchArticle(artID, animate);
}

function fpSwitchRight(id)
{
	$(".fpr_tab_enabled").hide();
	$(".fpr_tab_disabled").show();
	$("#tab_" + id + "_disabled").hide();
	$("#tab_" + id + "_enabled").show();

	$(".fpOther").hide();
	$("#fpOther_" + id).fadeIn();
}

var cancelAnimation = false;

function fpSwitchArticle(id, animate)
{
	$(".fpArticleTabA").removeClass("fpArticleTabA").addClass("fpArticleTab");
	$("#fpArticleTab_" + id).removeClass("fpArticleTab").addClass("fpArticleTabA");
	$(".fpVideoWrapper").hide();
	$(".fpArtBig").hide();
	$("#fpArtBig_"+id).fadeIn();
	
	if (animate){
		var nextTabID = $("#fpArticleTab_" + id).next("td").next("td").attr("id");
		if (!nextTabID){
			nextTabID = $("#fpArticleTab_" + id).siblings(":eq(0)").attr("id");
		}
		setTimeout(function(){ if (!cancelAnimation) fpSwitchArticle(nextTabID.substr(13), true) }, 5000);
	}
	else {
		cancelAnimation = true;
	}
}

function fpAddVideo(id, clip_id)
{
	if (swfobject.hasFlashPlayerVersion("10")) {
		var params = { 
			wmode:"transparent", 
			allowScriptAccess:"always", 
			bgcolor: "#ffffff", 
			allowFullScreen:"true"
		};
		var flashVars = {
			configXML: "http://www.fibatv.com/ptvFlash/unifiedplayer/fibavod/data/xml/config/unified_config-vod.xml", 
			resourceLocalePath:"http://www.fibatv.com/ptvFlash/unifiedplayer/aljazeera/assets/resources/", 
			setPlayerType:"vod", 
			locale:"en_GB",
			disableControls:"false", 
			siteId:"12805",
			useInitialSplashScreen:"false",
			useMetaSizing:"true",
			autoPlay:"false",
			clipId: clip_id
		};
		swfobject.embedSWF("http://www.fibatv.com/ptvFlash/unifiedplayer/fibavod/UnifiedPlayer.swf", "fpVideo_"+id, "656", "369", "10", false, flashVars, params, {})
	}
	$("fpVideo_"+id).show();
	swfobject.registerObject("fpVideo_"+id, "10.0.0", "/ptvFlash/SWFObject/SWFObject2_2/expressInstall.swf");
}

function fpShowVideo(id)
{
	$("#fpArtBig_"+id).hide();
	$("#fpVideoWrapper_"+id).show();
}

function scroll(id, direction)
{
	var scrollTo = $("#fpOtherInner_" + id).scrollTop() + 250 * direction;
	var scrollHeight = $("#fpOtherInner_" + id)[0].scrollHeight;
	var height = $("#fpOtherInner_" + id).height();
	if (scrollTo < 0) scrollTo = 0;
	if (scrollTo > scrollHeight - height) scrollTo = scrollHeight - height;
	$("#fpOtherInner_" + id).animate({scrollTop: scrollTo}, 300);
}
