
function OnLoad()
{
	var Browser = {
  Version: function() {
    var version = 999;
    if (navigator.appVersion.indexOf("MSIE") != -1)
      version = parseFloat(navigator.appVersion.split("MSIE")[1]);
    return version;
  	}
	}
	
	if(Browser.Version() < 7)
	{
		FixContentDivHeight();
		//FixPNGImage();
	}
}

function FixContentDivHeight()
{
	var elementDiv = document.getElementById("contentContainer");
	if(elementDiv != null)
	{
        if(elementDiv.offsetHeight < 410)
        {
            elementDiv.style.height = '410px';
        }
	}
}

function FixPNGImage()
{
	pngfix=function()
	{
		var els=document.getElementsByTagName('*');
		var ip=/\.png/i;
		var i=els.length;
		
		while(i-- >0)
		{
			var el=els[i];
			var es=el.style;
			
			if(el.src&&el.src.match(ip)	&&!es.filter)
			{
				es.height=el.height;
				es.width=el.width;es.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+el.src+"',sizingMethod='crop')";
				el.src=clear;
			}
			else
			{
				var elb=el.currentStyle.backgroundImage;
				if(elb.match(ip))
				{
					var path=elb.split('"');
					var rep=(el.currentStyle.backgroundRepeat=='no-repeat')?'crop':'scale';
					es.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+path[1]+"',sizingMethod='"+rep+"')";
					es.height=el.clientHeight+'px';
					es.backgroundImage='none';
					var elkids=el.getElementsByTagName('*');
					
					if (elkids)
					{
						var j=elkids.length;
						if(el.currentStyle.position!="absolute")
							es.position='static';
						
						while (j-- >0)
							if(!elkids[j].style.position)
								elkids[j].style.position="relative";
					}
				}
			}
		}
	}
	window.attachEvent('onload',pngfix);
}

var slCtl = null;

         //DO NOT FORGET TO REGISTER THIS FUNCTION WITH THE SILVERIGHT CONTROL
         // <param name="onload" value="pluginLoaded" />
         function pluginLoaded(sender) {

             //IMPORTANT: Make sure this is the same ID as the ID in your <OBJECT tag (<object id="MultiFileUploader" etc)
             slCtl = document.getElementById("MultiFileUploader");


             //Register All Files Finished Uploading event
             slCtl.Content.Files.AllFilesFinished = AllFilesFinished;

             //Register single file finished event
             slCtl.Content.Files.SingleFileUploadFinished = SingleFileFinished;

             //Register Error occurred during uploading event
             slCtl.Content.Files.ErrorOccurred = ShowErrorDiv;

             //Set your custom parameter using javascript
             //This parameter will be available in the webservice and you can use it for your business logic
             //Or use it to identity the upload to a sinle row in your database
             //slCtl.Content.Files.CustomParams = "custom_id=1";
         }


         function ShowNumberOfFilesUploaded() {
             if (slCtl != null) {
                 alert("Total Files Uploaded: " + slCtl.Content.Files.TotalUploadedFiles);
             }
         }

         function ShowTotalNumberOfFilesSelected() {
             if (slCtl != null) {
                 alert("Total Files Selected: " + slCtl.Content.Files.TotalFilesSelected);
             }
         }

         function ShowUploadProgress() {
             if (slCtl != null) {
                 alert("Progress: " + slCtl.Content.Files.Percentage);
             }
         }



         //This function is registred in the pluginLoaded function (slCtl.Content.Files.AllFilesFinished = AllFilesFinished;)
         function AllFilesFinished() {
             document.getElementById('AllFinishedDiv').style.display = 'block';
         }

         //This function is registred in the pluginLoaded function (slCtl.Content.Files.SingleFileUploadFinished = SingleFileFinished;)
         function SingleFileFinished() {
             document.getElementById('SingleFileFinishedDiv').style.display = 'block';
         }

         //This function is registred in the pluginLoaded function (slCtl.Content.Files.ErrorOccurred = ShowErrorDiv;)
         function ShowErrorDiv() {
             document.getElementById('ErrorDiv').style.display = 'block';
         }

         //Actions
         function StartUpload() {
             if (slCtl != null) {
                 slCtl.Content.Control.StartUpload();
             }
         }

         function ClearList() {
             if (slCtl != null) {
                 slCtl.Content.Control.ClearList();
             }
         }

         function SelectFiles() {
             if (slCtl != null) {
                 slCtl.Content.Control.SelectFiles();
             }
         }
        function onSilverlightError(sender, args) {

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

            var errMsg = "Unhandled Error in Silverlight 2 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);
        }

