function writeFlashCode(movieName,movieWidth,movieHeight,transToggle) {

	document.write('	<object type="application/x-shockwave-flash" quality="best" data="'+movieName+'.swf" width="'+movieWidth+'" height="'+movieHeight+'">');
	document.write('		<param name="movie" value="'+movieName+'.swf">');
	document.write('		<param name="quality" value="best">');

	if(transToggle=="transparent" || transToggle==true) { document.write('		<param name="wmode" value="transparent">'); }

	document.write ('	</object>');

}

function showElement(elementID) {

	document.getElementById(elementID).style.display="block";

}

function hideElement(elementID) {

	document.getElementById(elementID).style.display="none";

}

function toggleElement(elementID) {

	if(document.getElementById(elementID).style.display=="none" | document.getElementById(elementID).style.display=="") { document.getElementById(elementID).style.display="block"; } else { document.getElementById(elementID).style.display="none"; }

}

function URLEncode(stringToEncode)
{
	s = new String(stringToEncode);
	s.replace("&","%26");

	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = stringToEncode;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	return encoded;
}

var xmlhttp;

function ajaxContent(url,elementID)
{

theElementID=elementID;

// code for Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest()
  xmlhttp.onreadystatechange=state_Change
  xmlhttp.open("GET",url,true)
  xmlhttp.send(null)
  }
// code for IE
else if (window.ActiveXObject)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
    if (xmlhttp)
    {
    xmlhttp.onreadystatechange=state_Change;
    xmlhttp.open("GET",url,true)
    xmlhttp.send()
    }
  }
}

function state_Change()
{
// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
  {
  // if "OK"
  if (xmlhttp.status==200)
  {
	 document.getElementById(theElementID).innerHTML=xmlhttp.responseText;
	 theElementID="";
  }
  }
}

function ajaxRunScript(url,takeThisAction,bonusInfo)
{

	actionToTake=takeThisAction;
	extraInformation=bonusInfo;

// code for Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest()
  xmlhttp.onreadystatechange=state_Change2
  xmlhttp.open("GET",url,true)
  xmlhttp.send(null)
  }
// code for IE
else if (window.ActiveXObject)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
    if (xmlhttp)
    {
    xmlhttp.onreadystatechange=state_Change2;
    xmlhttp.open("GET",url,true)
    xmlhttp.send()
    }
  }
}

function state_Change2()
{
// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
  {
  // if "OK"
  if (xmlhttp.status==200)
  {
	 if(actionToTake=="refresh") { window.location.reload(); }
	 if(actionToTake=="reveal") { showElement(extraInformation); }
	 if(actionToTake=="print") { return xmlhttp.responseText; }
  }
  }
}


function replaceContent(contentCode,elementID) {

	document.getElementById(elementID).innerHTML = contentCode;

}

function debugCode(codeToDebug) {

	openedWindow = window.open("","popup","width=780,height=500,toolbars=no,status=no,scrolling=yes");
	openedWindow.document.write(codeToDebug);

}

function popUp(popUpPage,popUpWidth,popUpHeight,scrollBars) {

	if(scrollBars==true) { scrollBars="auto"; }

	window.open(popUpPage,'popup','width='+popUpWidth+',height='+popUpHeight+',scrollbars='+scrollBars+',title=no,status=no');

}

function waitAndRedirect(url,timeWait) {

	setTimeout("redirect('"+url+"');",(timeWait*1000));

}

function redirect(url) {

	document.location.href=url;

}

function el(elementID) {

	return document.getElementById(elementID);

}

function es(elementID) {

	return document.getElementById(elementID).style;

}
