var ns = (navigator.appName.indexOf('Netscape')>-1);
var ie = (navigator.appName.indexOf('Microsoft Internet Explorer')>-1);

function redirect(page)
{
    window.location.href = page
}

function open_window(page,params)
{
    window.open(page,"popup",params)
}

function pop_game(width,height,gameID)
{
	if  (window.screen)
	{
		var w = screen.availWidth;
		var h = screen.availHeight;
	}
	
	var w_win, h_win
	
	if( width > 0 || height > 0 )
	{
		w_win = (w- + width)/2;
		h_win = (h- + height)/2;
		
		width = width + 20; 
		height = height + 150; //add space for logo and game tips
		
	}
	else
	{
		width = 500;
		height = 500;
	
		w_win = 0;
		h_win = 0;
	}
	
	winSets = 'width=' + width + ',height=' + height + ',top=' + h_win + ',left=' + w_win + ',scrollbars=1';

	open_window("popup_play_game.aspx?game=" + gameID, winSets);
}

function load_game(game, w, h, hosted, game_directory)
{
	var game_file = document.getElementById(game).value;
	var games_directory = document.getElementById(game_directory).value;
	var height = document.getElementById(h).value;
	var width = document.getElementById(w).value;
	var isHosted = document.getElementById(hosted).value;

	if( isHosted == 'True' )
	{
		game_file = games_directory + game_file
	}
	
	document.writeln('<OBJECT id=""flash_game"" codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0 height=' + height + ' width=' + width + ' classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 VIEWASTEXT>')
	document.writeln('<PARAM NAME="Movie" VALUE="' + game_file + '">')
	document.writeln('<PARAM NAME="Quality" VALUE="High">')
	document.writeln('<PARAM NAME="Menu" VALUE="false">')
	document.writeln('<embed src="' + game_file + '" menu="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '">')
	document.writeln('</embed>')
	document.writeln('</OBJECT>')
}

function detect_flash_redirect(redirect_page)
{
	if( !document.flashDetected ) 
	{
		redirect(redirect_page)
	}
}

/*
	Source: http://lussumo.com/
*/
function copy(textbox) {

  var inElement = document.getElementById(textbox);

  if (inElement.createTextRange) {
    var range = inElement.createTextRange();
    if (range)
     range.execCommand('Copy');
  } else {

    var flashcopier = 'flashcopier';
    if(!document.getElementById(flashcopier)) {
      var divholder = document.createElement('div');
      divholder.id = flashcopier;
      document.body.appendChild(divholder);
    }
    document.getElementById(flashcopier).innerHTML = '';
    var divinfo = '<embed src="js/_clipboard.swf" FlashVars="clipboard='+escape(inElement.value)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
    document.getElementById(flashcopier).innerHTML = divinfo;
  }
  
  alert("HTML Code Copied To Clipboard.")
  
}
