﻿// JScript File
function ShowNetImaging(imageToLoad, fileName) {
    /*document.write('<applet id="aplImageEditor" width="100%" height="100%" codebase="./applet/" archive="imaging.jar" code="Main.class">');
    document.write('<param name="load" value=' + imageToLoad + '>');
    document.write('<param name="filename" value=' + fileName + '>');
    document.write('<param name="save" value="save.aspx">');
    document.write('<param name="jpeg_quality" value="90">');
    
    document.write('<param name="bgcolor" value="#CCCCCC">');
    
    document.write('<param name="outline" value="false">');
    
    document.write('<param name="visible_buttons" value="crop,resize,cclockw,clockw,fliph,flipv, ,sepia,redeye,vars, ,undo,redo,zoom">');
    
    document.write('</applet>');*/
    
    document.write('<applet id="aplImageEditor" width="100%" height="100%" codebase="./applet/" archive="imaging.jar" code="Main.class">' +
    
    '<param name="load" value="' + imageToLoad + '">' +
    '<param name="filename" value="' + fileName + '">' +
    '<param name="save" value="save.aspx">' +
    '<param name="jpeg_quality" value="80">' +
     
    '<param name="bgcolor" value="#CCCCCC">' +
    
    '<param name="outline" value="false">' +
    
    '<param name="visible_buttons" value="crop,resize,cclockw,clockw,fliph,flipv, ,sepia,redeye,vars, , ,undo,redo, , ,zoomwin,zoom100">' +   
    '<div style="padding-left: 20px;"><b>You need to have Java installed in order to edit images. To install Java go to <a href="http://www.java.com" target="_blank">www.java.com</a>.</b></div>' +
    '</applet>');
}

function IsChanged()
{    
    var fChanged = false;
    try
    {
        var aplImageEditor = document.getElementById('aplImageEditor');             
        if(aplImageEditor != null)
        {
            fChanged = aplImageEditor.isChanged();
            if(fChanged && aplImageEditor.isSavedAfterRequest())            
            {
                fChanged  = false;
            }
        }
    }
    catch(ex)
    {
        // Don't do anything
        //alert(ex);
    }
    return fChanged;
}

function SaveNetImaging(quality)
{   
    var fSaving = false;
    try
    {    
        var aplImageEditor = document.getElementById('aplImageEditor');                
        
        if(aplImageEditor != null && aplImageEditor.isChanged())
        {
            aplImageEditor.setMessage("Saving the image...");
            aplImageEditor.upload("save.aspx", quality);  
            fSaving = true;
        }               
    }
    catch(ex)
    {
        // Don't do anything
        //alert(ex);
    }
    
    return fSaving;
}

function ShowPainter(fileName)
{
    document.write('<applet width="800" height="600" codebase="./painter/" code="DrawCanvas.class" archive="painter.jar" name="canvas" align="baseline" >');    
    document.write('<param name="load" value="' + fileName + '">');
    document.write('<param name="bgload" value="' + fileName + '">');
    document.write('</applet>'); 
}

function ShowFileUpload(uploadUrl, redirectUrl)
{
    var params = "backgroundColor=#c8c8c8&maxFileCount=100&maxFileSize=10485760&maxFileSizeTotal=10485760";

    document.write('<OBJECT id="FlashFilesUpload" codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"'); 
	document.write('	width="580" height="350" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" VIEWASTEXT>'); 
	document.write('<PARAM NAME="FlashVars" VALUE="uploadUrl=' + uploadUrl + '&redirectUploadUrl=' + redirectUrl + '&' + params + '">'); 
	document.write('<PARAM NAME="BGColor" VALUE="#F8F6E6">'); 			
	document.write('<PARAM NAME="Movie" VALUE="ElementITMultiPowUpload1.7.swf">'); 
	document.write('<PARAM NAME="Src" VALUE="ElementITMultiPowUpload1.7.swf">'); 
	document.write('<PARAM NAME="WMode" VALUE="Window">'); 
	document.write('<PARAM NAME="Play" VALUE="-1">'); 
	document.write('<PARAM NAME="Loop" VALUE="-1">'); 
	document.write('<PARAM NAME="Quality" VALUE="High">'); 
	document.write('<PARAM NAME="SAlign" VALUE="">'); 
	document.write('<PARAM NAME="Menu" VALUE="-1">'); 
	document.write('<PARAM NAME="Base" VALUE="">'); 
	document.write('<PARAM NAME="AllowScriptAccess" VALUE="always">'); 
	document.write('<PARAM NAME="Scale" VALUE="ShowAll">'); 
	document.write('<PARAM NAME="DeviceFont" VALUE="0">'); 
	document.write('<PARAM NAME="EmbedMovie" VALUE="0">'); 	    
	document.write('<PARAM NAME="SWRemote" VALUE="">'); 	
	document.write('<PARAM NAME="MovieData" VALUE="">'); 
	document.write('<PARAM NAME="SeamlessTabbing" VALUE="1">'); 
	document.write('<PARAM NAME="Profile" VALUE="0">'); 
	document.write('<PARAM NAME="ProfileAddress" VALUE="">'); 
	document.write('<PARAM NAME="ProfilePort" VALUE="0">'); 
	//document.write('<param name="wmode" value="transparent">'); 
	
	
	document.write('<PARAM NAME="FileTypes" VALUE="Images|*.jpg\;*.jpeg\;*.gif\;*.png\;*.bmp">'); 		
	
	document.write('<embed bgcolor="#F8F6E6" id="EmbedFlashFilesUpload" src="ElementITMultiPowUpload1.7.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"	type="application/x-shockwave-flash" width="580" height="350" flashvars="uploadUrl=' + uploadUrl + '&redirectUploadUrl=' + redirectUrl + '&' + params + '">'); 
	document.write('</embed>'); 
    document.write('</OBJECT>'); 
}



function GiveDec(Hex)
{
   if(Hex == "A")
      Value = 10;
   else
   if(Hex == "B")
      Value = 11;
   else
   if(Hex == "C")
      Value = 12;
   else
   if(Hex == "D")
      Value = 13;
   else
   if(Hex == "E")
      Value = 14;
   else
   if(Hex == "F")
      Value = 15;
   else
      Value = eval(Hex);

   return Value;
}

function HexToDec(hex)
{
   Input = hex.replace("#", "");

   Input = Input.toUpperCase();

   a = GiveDec(Input.substring(0, 1));
   b = GiveDec(Input.substring(1, 2));
   c = GiveDec(Input.substring(2, 3));
   d = GiveDec(Input.substring(3, 4));
   e = GiveDec(Input.substring(4, 5));
   f = GiveDec(Input.substring(5, 6));

   x = (a * 16) + b;
   y = (c * 16) + d;
   z = (e * 16) + f;

    var result = "rgb(" + x + ", " + y + ", " + x + ")";
    return result;    
}

function IsIE()
{
    var fResult = false;
    if (navigator.userAgent.indexOf("MSIE")!=-1)
    {
        fResult = true;
    }
    
    return fResult;
}

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();