
function createFlashPlayer(DivID, WIDTH, HEIGHT, URL, CONTEXT_PATH) {
	createFlashPlayer(DivID, WIDTH, HEIGHT, URL, CONTEXT_PATH, 'left');
}

function createFlashPlayer(DivID, WIDTH, HEIGHT, URL, FLASH_VARS, ALIGN) {

	var d = document.getElementById(DivID);
	
	var inner 	 = '<object id ="' + DivID + 'flash"';
		inner	+= '    classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
		inner	+= '    codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" ';
		inner	+= '    width="' + WIDTH + '" height="' + HEIGHT + '" align="' + ALIGN + '">';
		inner	+= '  <param name="autoplay" value="false">';
		inner	+= '  <param name="movie" value="' + URL + '" />';
		inner	+= '  <param name="quality" value="high" />';
		inner	+= '  <param name="FlashVars" value="' + FLASH_VARS + '">';
		inner	+= '  <param name="AUTOGOTOURL" value="false">';
		inner	+= '  <embed width="' + WIDTH + '" height="' + HEIGHT + '" ';
		inner	+= '    id ="' + DivID + 'flash"';
		inner	+= '    autoplay="false"';
		inner	+= '    FlashVars="' + FLASH_VARS + '" ';
		inner	+= '    src="' + URL + '" ';
		inner	+= '    quality="high" ';
		inner	+= '    pluginspage="http://www.macromedia.com/go/getflashplayer" ';
		inner	+= '    type="application/x-shockwave-flash">';
		inner	+= '  </embed>';
		inner	+= '</object>';

	d.innerHTML = inner;
}

function onSilverlightError(sender, args) {
    var appSource = "";
    if (sender != null && sender != 0) {
      appSource = sender.getHost().Source;
    }
    
    var errorType = args.ErrorType;
    var iErrorCode = args.ErrorCode;

    if (errorType == "ImageError" || errorType == "MediaError") {
      return;
    }

    var errMsg = "Unhandled Error in Silverlight Application " +  appSource + "\n" ;

    errMsg += "Code: "+ iErrorCode + "    \n";
    errMsg += "Category: " + errorType + "       \n";
    errMsg += "Message: " + args.ErrorMessage + "     \n";

    if (errorType == "ParserError") {
        errMsg += "File: " + args.xamlFile + "     \n";
        errMsg += "Line: " + args.lineNumber + "     \n";
        errMsg += "Position: " + args.charPosition + "     \n";
    }
    else if (errorType == "RuntimeError") {           
        if (args.lineNumber != 0) {
            errMsg += "Line: " + args.lineNumber + "     \n";
            errMsg += "Position: " +  args.charPosition + "     \n";
        }
        errMsg += "MethodName: " + args.methodName + "     \n";
    }

    throw new Error(errMsg);
}
