function createSmallThumbnail( source ){
    createThumbnail( source, 150, 150 );
}

function createThumbnail( source, height, width ){
    html = "";
    html += "<table width=\"" + width + "\" height=\"" + height + "\" border=\"1\" bodercolor=\"#cccccc\" borderstyle=\"solid\">";
    html += "<tr>";
    html += "<td align=\"center\" valign=\"middle\">";
    html += "<img src=\"" + source + "\" alt=\"" + source + "\" onload=\"javascript:resizeImage( this, " + height + ", " + width + " );\" />";
    html += "</td>";
    html += "</tr>";
    html += "</table>";
    document.write( html );
}

function resizeImage( image, height, width ){
    if( image.width > image.height ){
        var ratio = image.height / image.width;
        image.width = width;
        image.height = ratio * height;
    }
    else{
        var ratio = image.width / image.height;
        image.height = height;
        image.height = ratio;
    }
}

var requiredMajorVersion = 9;
var requiredMinorVersion = 0;
var requiredRevision = 28;

var flashVars = window.location.search + "";
flashVars = flashVars.substr( 1, flashVars.length );
if( flashVars.length > 0 ){
    flashVars += "&";
}

function addFlashContent( swf, width, height, vars ){
    // Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
    var hasProductInstall = DetectFlashVer(6, 0, 65);

    // Version check based upon the values defined in globals
    var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

    // Check to see if a player with Flash Product Install is available and the version does not meet the requirements for playback
    if ( hasProductInstall && !hasRequestedVersion ) {
        // MMdoctitle is the stored document.title value used by the installation process to close the window that started the process
        // This is necessary in order to close browser windows that are still utilizing the older version of the player after installation has completed
        // DO NOT MODIFY THE FOLLOWING FOUR LINES
        // Location visited after installation is complete if installation is required
        var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
        var MMredirectURL = window.location;
        document.title = document.title.slice(0, 47) + " - Flash Player Installation";
        var MMdoctitle = document.title;

        return AC_FL_RunContent(
	        "src", "swf/playerProductInstall",
	        "FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
		    "width", width,
		    "height", height,
	        "align", "top",
	        "salign", "t",
	        "id", "ProductInstall",
	        "quality", "high",
	        "bgcolor", "#ffffff",
	        "name", "ProductInstall",
	        "allowScriptAccess","always",
	        "type", "application/x-shockwave-flash",
	        "pluginspage", "http://www.adobe.com/go/getflashplayer"
        );
    } else if (hasRequestedVersion) {
        // if we've detected an acceptable version
        // embed the Flash Content SWF when all tests are passed
        var swfURL = swf;
        if(swfURL.indexOf("?") > -1)
        {
        	swfURL += "&appbuild=2009-09-22";
        }
        else
        {
        	swfURL += "?appbuild=2009-09-22";
        }
        return AC_FL_RunContent(
		        "src", swfURL,
	        	"width", width,
		        "height", height,
		        "align", "top",
		        "salign", "t",
		        "id", swf,
		        "quality", "high",
		        "bgcolor", "#ffffff",
		        "name", swf,
		        "flashvars",flashVars + "appbuild=2009-09-22&" + vars,
		        "allowScriptAccess", "always",
		        "allowFullScreen", "true",
		        "type", "application/x-shockwave-flash",
		        "pluginspage", "http://www.adobe.com/go/getflashplayer"
        );
      } else {  // flash is too old or we can't detect the plugin
        var alternateContent = 'This content requires the Adobe Flash Player. '
        + '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>';
        return alternateContent;
      }
}

function writeStringTo ( str, object ) {
    object.write(str);
}

function resizeSWF( name, height ){
	var doc = document.getElementById( name );
	if( doc ){		
		doc.setAttribute('height', height);
		
		// This fixes a Safari bug (the image would not
	    // resize until you moused over any part of the web page)
	    doc.blur();
	    doc.focus();
	}
}

function centerImageTo(image, height, width)
{
    top = (height/2)-(image.height);
    left = (width/2)-(image.width);
    image.style.position = "absolute";
    image.style.top = top + "px";
    image.style.left = left + "px";
}

function openWindow(url, name, width, height, full, scrollbars, returnStatus)
{
    var options = "toolbar=0,location=0,status=0,directories=0,menubar=0,resizable=1,";    
    
    full = full == "true" || full == true ? true : false; // Default false
    scrollbars = scrollbars == "true" || scrollbars == true ? true : false; // Default false    
    returnStatus = returnStatus == "false" || returnStatus == false ? false : true; // Default true
    
    if (full == true)
    {
        options += "scrollbars=auto,";
        options += "width=" + screen.availWidth + ",";
        options += "innerWidth=" + screen.availWidth + ",";
        options += "height=" + screen.availHeight + ",";
        options += "innerHeight=" + screen.availHeight + ",";
        options += "left=0,top=0";
    }
    else
    {
        if (scrollbars == true)
            options += "scrollbars=yes,";
            
        options += "width=" + width + ",height=" + height;
    }
    
    result = internalOpenWindow(url, name, options);
    
    if (returnStatus == true)
    {
        return result;
    }
}

function openSimpleWindow(url, width, height)
{
    return internalOpenWindow(url, "window", "toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" + width + ",height=" + height + ",TOP=10,LEFT=10");
}

// Used for checking if window actually opened.
// If the window did not open, is means the browser is blocking pop-ups
function internalOpenWindow(url, name, options)
{
    try
	{	    
		var popup = window.open(url, name, options);
		
		if (popup == null)
			return false;

        if ( window.opera )
            if (!popup.opera)
                return false;
    }
    catch(err)
    {
        return false;
    }
    
    return true;
}
