if (Drupal.jsEnabled) {
	$(document).ready(function () {

    var movieObj = thisMovie("GenEsisClient");

		$("#FlashLogIn").click(function(){
			sendFlashLogIn();
		});

		$("#FlashLogOut").click(function(){
			sendFlashLogOut();
		});


		function thisMovie(movieObj) {
			// This function returns the appropriate syntax depending on the browser.
			if (navigator.appName.indexOf ("Microsoft") !=-1) {
				return window[movieObj]
			} else {
				return document[movieObj]
			};

		};

		function movieIsLoaded (theMovie) {
			// Checks if movie is completely loaded. First make sure the movie's defined.
			if (typeof(theMovie) != "undefined") {
				return theMovie.PercentLoaded() == 100;
			} else {
				return false;
			}
		};

		function sendFlashLogIn() {
			if (movieIsLoaded(movieObj)) {
				movieObj.logIn();
			}
		};

		function sendFlashLogOut() {
			if (movieIsLoaded(movieObj)) {
				movieObj.logOut();
			}
		};

		$("#gamesPageTabs").show();

		$("#mySkip").click(function(){
			$("#win_draw_draw").attr("checked","checked");
			$("#score_a").text("0");
			$("#score_b").text("0");
			tb_remove();
		});

		$("#sg_edit-submit").click(function(){
			$("#sg_edit-submit").hide();
			$("#loadingAnimation").show();
		});

		$("#gamesPageTabs").tabs({
			fxSlide: false,
			fxFade: true,
			fxSpeed: 'normal',
			disabled: [0],
			fxAutoHeight: false,
			remote: true,
			bookmarkable: false
		});


	});
};


//*** DoFSCommand Script ***
function launcher(url){
AC_FL_RunContent(
		'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,28,0',
		'width','730',
		'height','420',
		'id','GenEsisClient',
		'name','GenEsisClient',
		'src','/genesis/client?'+url,
    'base','/genesis',
		'quality','high',
		'pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash',
		'movie','/genesis/client?'+url
	);
};

function GenEsisClient_DoFSCommand(command, args) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	var GenEsisClientObj = isIE ? document.all.GenEsisClient : document.GenEsisClient;
	//
	// Place your FSCommand code here.
	//
	if (command == "alert") {
		alert(args);
	};
};

// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub GenEsisClient_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call GenEsisClient_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
};

function mypop(gid,teamA,teamB,teamAid,teamBid,scoreA,scoreB){
  //alert(" gid:"+gid+"\n teamA:"+teamA+"\n teamB:"+teamB+"\n teamAid:"+teamAid+"\n teamBid:"+teamBid+"\n scoreA:"+scoreA+"\n scoreB:"+scoreB);
  $("#game_id").val(gid);
  $("#teamA").text(teamA);
  $("#teamB").text(teamB);
  $("#score_a").val(scoreA);
  $("#score_b").val(scoreB);
  $("#win_draw_a").val(teamAid);
  $("#win_draw_b").val(teamBid);
  if (scoreA>scoreB){
    $("#win_draw_a").attr("checked","checked");
  }
  if (scoreA<scoreB){
      $("#win_draw_b").attr("checked","checked");
  }
  tb_show(null, "#TB_inline?height=305&width=310&modal=true&inlineId=myOnPageContent", false);
  return false;
};
