function ShowSection(el) {
var bShow = el.className == "sign plus";
el.className = bShow ? "sign minus" : "sign plus";
var tr = jsUtils.FindParentObject(el,"tr");
var id = tr.id;
if ((tr = jsUtils.FindNextSibling(tr, "tr"))) {
if (tr.className && tr.className == "empty") {
//break;
}
if (bShow) {
try {
tr.style.display = "table-row";
} catch (e) {
tr.style.display = "block";
}
} else {
tr.style.display = "none";
}
}
}

//PShowWaitMessage("photo_note", true);
var temp = [];
var bShowApplet = false, bInitApplet = false;
var strCookie = "";//PhotoUtils.GetCookies('UploadShowMode');
if (typeof oText != "object")
	var oText = {};
	
function __Browser(){
	var a=navigator.userAgent.toLowerCase();
	this.isOpera=(a.indexOf("opera")!=-1);
	this.isKonq=(a.indexOf('konqueror')!=-1);
	this.isSafari=(a.indexOf('safari')!=-1)&&(a.indexOf('mac')!=-1);
	this.isKhtml=this.isSafari||this.isKonq;
	this.isIE=(a.indexOf("msie")!=-1)&&!this.isOpera;
	this.isWinIE=this.isIE&&(a.indexOf("win")!=-1);
	this.isCSS1Compat=(!this.isIE)||(document.compatMode&&document.compatMode=="CSS1Compat");
}
var __browser=new __Browser();

bShowApplet = (strCookie == "form" ? false : true);

if (__browser.isOpera)
{
	bShowApplet = false;
}


//Create set/get expando methods for ActiveX
function _createExpandoMethods(id){
	var o=document.getElementById(id);
	var props=new Array();
	var hasPaneItemApiElements=false;
	for (propName in o){
		var c=propName.charAt(0);
		if (c==c.toUpperCase()){
			props.push(propName);
			if (propName=="PaneItemDesign"){
				hasPaneItemApiElements=true;
			}
		}
	}
	for (i=0;i<props.length;i++){
		//Check whether property is indexed
		if (typeof(o[props[i]])=="unknown"){
			eval("o.set"+props[i]+"=function(i,v){this."+props[i]+"(i)=v;};");
			eval("o.get"+props[i]+"=function(i){return this."+props[i]+"(i);};");
		}
		else{
			eval("o.set"+props[i]+"=function(v){this."+props[i]+"=v};");
			eval("o.get"+props[i]+"=function(){return this."+props[i]+"};");
		}
	}
	if (hasPaneItemApiElements){
		eval("o.setPaneItemDesign = function(Pane, Index, Value){this.PaneItemDesign(Pane, Index) = Value;};");
		eval("o.getPaneItemDesign = function(Pane, Index){return this.PaneItemDesign(Pane, Index);};");		
		//eval("o.getPaneItemCount = function(Pane){return this.PaneItemCount(Pane);};");
		//eval("o.getPaneItemChecked = function(Index){return this.PaneItemChecked(Index);};");
		//eval("o.getPaneItemCanBeUploaded = function(Index){return this.PaneItemCanBeUploaded(Index);};");
		eval("o.getPaneItemSelected = function(Pane, Index){return this.PaneItemSelected(Pane, Index);};");
		eval("o.setPaneItemEnabled = function(Pane, Index, Value){this.PaneItemEnabled(Pane, Index) = Value;};");
		eval("o.getPaneItemEnabled = function(Pane, Index){return this.PaneItemEnabled(Pane, Index);};");
	}
}

//Installation instructions
function _addInstructions(obj){
	obj.instructionsEnabled=true;
	if (obj.controlClass != "FileDownloader")
	{
		obj.instructionsCommon=oText["instructionsCommon1"];
		obj.instructionsNotWinXPSP2=oText["instructionsNotWinXPSP21"];
		obj.instructionsWinXPSP2=oText["instructionsWinXPSP21"];
	}
}

function ControlWriter(id,width,height){
	//Private
	this._params=new Array();
	this._events=new Array();
	
	_addInstructions(this);

	this._getObjectParamHtml=function(name,value){
		return "<param name=\""+name+"\" value=\""+value+"\" />";
	}

	this._getObjectParamsHtml=function(){
		var r="";
		var p=this._params;
		var i;
		for (i=0;i<p.length;i++){
			r+=this._getObjectParamHtml(p[i].name,p[i].value);
		}
		return r;
	}

	this._getObjectEventsHtml=function(){
		var r="";
		var e=this._events;
		for (i=0;i<e.length;i++){
			r+=this._getObjectParamHtml(e[i].name+"Listener",e[i].listener);
		}
		return r;
	}

	this._getEmbedParamHtml=function(name,value){
		return " "+name+"=\""+value+"\"";	
	}

	this._getEmbedParamsHtml=function(){
		var r="";
		var p=this._params;
		var i;
		for (i=0;i<p.length;i++){
			r+=this._getEmbedParamHtml(p[i].name,p[i].value);
		}
		return r;
	}

	this._getEmbedEventsHtml=function(){
		var r="";
		var e=this._events;
		for (i=0;i<e.length;i++){
			r+=this._getEmbedParamHtml(e[i].name+"Listener",e[i].listener);
		}
		return r;
	}

	//Public

	//Properties
	this.id=id;
	this.width=width;
	this.height=height;

	this.activeXControlEnabled=true;
	this.activeXControlVersion="";

	this.javaAppletEnabled=true;
	this.javaAppletCodeBase="./";
	this.javaAppletCached=true;
	this.javaAppletVersion="";

	this.fullPageLoadListenerName=null;

	//Methods
	this.addParam=function(paramName,paramValue){
		var p=new Object();
		p.name=paramName;
		p.value=paramValue;
		this._params.push(p);
	}

	this.addEventListener=function(eventName,eventListener){
		var p=new Object();
		p.name=eventName;
		p.listener=eventListener;
		this._events.push(p);
	}

	this.getActiveXInstalled=function(){
		if (this.activeXProgId){
			try{
				var a=new ActiveXObject(this.activeXProgId);
				return true;
			}
			catch(e){
				return false;
			}
		}
		return false;
	}

	this.getHtml=function(){
		var r="";
		if (this.fullPageLoadListenerName){
			r+="<" + "script type=\"text/javascript\">";
			r+="var __"+this.id+"_pageLoaded=false;";
			r+="var __"+this.id+"_controlLoaded=false;";
			r+="function __fire_"+this.id+"_fullPageLoad(){";
			r+="if (__"+this.id+"_pageLoaded&&__"+this.id+"_controlLoaded){";
			r+=this.fullPageLoadListenerName + "();";
			r+="}";
			r+="}";
			var pageLoadCode="new Function(\"__"+this.id+"_pageLoaded=true;__fire_"+this.id+"_fullPageLoad();\")";
			if (__browser.isWinIE){
				r+="window.attachEvent(\"onload\","+pageLoadCode+");";
			}
			else{
				r+="var r=window.addEventListener?window:document.addEventListener?document:null;";
				r+="if (r){r.addEventListener(\"load\","+pageLoadCode+",false);}";
			}
			r+="<"+"/script>";
		}
		
		//ActiveX control
		if(__browser.isWinIE&&this.activeXControlEnabled&&bShowApplet)
		{
			var v=this.activeXControlVersion.replace(/\./g,",")
			var cb=this.activeXControlCodeBase+(v==""?"":"#version="+v);

			r+="<" + "script for=\""+this.id+"\" event=\"InitComplete()\">";
			r+="_createExpandoMethods(\""+this.id+"\");";
			if (this.fullPageLoadListenerName){
				r+="__"+this.id+"_controlLoaded=true;";
				r+="__fire_"+this.id+"_fullPageLoad();";
			}
			r+="<"+"/script>";

			r+="<object id=\""+this.id+"\" name=\""+this.id+"\" classid=\"clsid:"+this.activeXClassId+"\" codebase=\""+cb+"\" width=\""+this.width+"\" height=\""+this.height+"\">";
			if (this.instructionsEnabled){
				r+=this.instructionsCommon;
				var isXPSP2 = (window.navigator.userAgent.indexOf("SV1") != -1) || (window.navigator.userAgent.indexOf("MSIE 7.0") != -1);
				if (isXPSP2){
					r+=this.instructionsWinXPSP2;
				}
				else{
					r+=this.instructionsNotWinXPSP2;
				}
			}
			r+=this._getObjectParamsHtml();
			r+="</object>";
			//Event handlers
			var e=this._events;
			var eventParams;
			for (i=0;i<e.length;i++){
				if (this.controlClass=="FileDownloader"){
					switch (e[i].name){
						case "DownloadComplete":
							eventParams="Value";
							break;
						case "DownloadItemComplete":
							eventParams="Result, ErrorPage, Url, FileName, ContentType, FileSize";
							break;
						case "DownloadStep":
							eventParams="Step";
							break;
						case "Progress":
							eventParams="PercentTotal, PercentCurrent, Index";
							break;
						case "Error":
							eventParams="ErrorCode, HttpErrorCode, ErrorPage, Url, Index";
							break;
						default:
							eventParams="";
					}
					r+="<script for=\""+this.id+"\" event=\""+e[i].name+"("+eventParams+")\">";
					r+=e[i].listener+"("+eventParams+");";
					r+="<"+"/script>";
				}
				else {
					switch (e[i].name){
						case "Progress":
							eventParams="Status, Progress, ValueMax, Value, StatusText";
							break;
						case "InnerComplete":
							eventParams="Status, StatusText";
							break;
						case "AfterUpload":
							eventParams="htmlPage";
							break;
						case "ViewChange":
						case "SortModeChange":
							eventParams="Pane";
							break;
						case "Error":
							eventParams="ErrorCode, HttpResponseCode, ErrorPage, AdditionalInfo";
							break;
						default:
							eventParams="";
					}
				}
				r+="<" + "script for=\""+this.id+"\" event=\""+e[i].name+"("+eventParams+")\">";
				if (e[i].name=="BeforeUpload"){
					r+="return ";
				}
				r+=e[i].listener+"("+eventParams+");";
				r+="<"+"/script>";
			}
			bInitApplet = true;
		}
		else if(this.javaAppletEnabled&&bShowApplet) //Java appplet
		{
			if (this.fullPageLoadListenerName){
				r+="<" + "script type=\"text/javascript\">";
				r+="function __"+this.id+"_InitComplete(){";
				r+="__"+this.id+"_controlLoaded=true;";
				r+="__fire_"+this.id+"_fullPageLoad();";
				r+="}";
				r+="<"+"/script>";
			}

			//<object> for IE and <applet> for Safari
			if (__browser.isWinIE||__browser.isKhtml){
				if (__browser.isWinIE){
					r+="<object id=\""+this.id+"\" classid=\"clsid:8AD9C840-044E-11D1-B3E9-00805F499D93\" codebase=\""+window.location.protocol+"//java.sun.com/update/1.4.2/jinstall-1_4-windows-i586.cab#Version=1,4,0,0\" width=\""+this.width+"\" height=\""+this.height+"\">";
				}
				else{
					r+="<applet id=\""+this.id+"\" code=\""+this.javaAppletClassName+"\" java_codebase=\"../\" align=\"baseline\" archive=\""+this.javaAppletJarFileName+"\" mayscript=\"true\" scriptable=\"true\" width=\""+this.width+"\" height=\""+this.height+"\">";
				}

				if (this.javaAppletCached&&this.javaAppletVersion!=""){
					r+=this._getObjectParamHtml("cache_archive",this.javaAppletJarFileName);
					var v=this.javaAppletVersion.replace(/\,/g,".");
					//r+=this._getObjectParamHtml("cache_version",v+","+v);
					r+=this._getObjectParamHtml("cache_version",v);
				}

				r+=this._getObjectParamHtml("type","application/x-java-applet;version=1.4");
				r+=this._getObjectParamHtml("codebase",this.javaAppletCodeBase);
				r+=this._getObjectParamHtml("archive",this.javaAppletJarFileName);
				r+=this._getObjectParamHtml("code",this.javaAppletClassName);
				r+=this._getObjectParamHtml("scriptable","true");
				r+=this._getObjectParamHtml("mayscript","true");

				r+=this._getObjectParamsHtml();

				r+=this._getObjectEventsHtml();

				if (this.fullPageLoadListenerName){
					r+=this._getObjectParamHtml("InitCompleteListener","__"+this.id+"_InitComplete");
				}
				if (__browser.isWinIE){
					r+="</object>";
				}
				else{
					r+="</applet>";
				}
			}
			//<embed> for all other browsers
			else{
				r+="<embed id=\""+this.id+"\" type=\"application/x-java-applet;version=1.4\" codebase=\""+this.javaAppletCodeBase+"\" code=\""+this.javaAppletClassName+"\" archive=\""+this.javaAppletJarFileName+"\" width=\""+this.width+"\" height=\""+this.height+"\" scriptable=\"true\" mayscript=\"true\" pluginspage=\""+window.location.protocol+"//java.sun.com/products/plugin/index.html#download\"";

				if (this.javaAppletCached&&this.javaAppletVersion!=""){
					r+=this._getEmbedParamHtml("cache_archive",this.javaAppletJarFileName);
					var v=this.javaAppletVersion.replace(/\,/g,".");
					//r+=this._getEmbedParamHtml("cache_version",v+","+v);
					r+=this._getEmbedParamHtml("cache_version",v);
				}

				r+=this._getEmbedParamsHtml();

				r+=this._getEmbedEventsHtml();

				if (this.fullPageLoadListenerName){
					r+=this._getEmbedParamHtml("InitCompleteListener","__"+this.id+"_InitComplete");
				}
				r+=">";
				r+="</embed>";
			}
			bInitApplet =  true;
		}
		
		PhotoClass.ShowForm(bInitApplet);
		
		//For backward compatibility
		this.controlType=this.getControlType();
			
		return r;
	}

	this.getControlType=function(){
		return (__browser.isWinIE&&this.activeXControlEnabled)?"ActiveX":(this.javaAppletEnabled?"Java":"None");
	}
	
	this.writeHtml=function(){
		document.write(this.getHtml());
	}
}

function ImageUploaderWriter(id,width,height){
	this._base=ControlWriter;
	this._base(id,width,height);
	//These properties should be modified for private-label versions only
	this.activeXControlCodeBase="ImageUploader.cab";
	this.activeXClassId="6E5E167B-1566-4316-B27F-0DDAB3484CF7";
	this.activeXProgId="Aurigma.ImageUploader.5";
	this.javaAppletJarFileName="ImageUploader.jar";
	this.javaAppletClassName="com.aurigma.imageuploader.ImageUploader.class";

	//Extend
	this.showNonemptyResponse="off";
	this._getHtml=this.getHtml;
	this.getHtml=function(){
		var r="";
		if (this.showNonemptyResponse!="off"){
			r+="<" + "script type=\"text/javascript\">";
			r+="function __"+this.id+"_InnerComplete(Status,StatusText){";
			r+="if (new String(Status)==\"COMPLETE\" && new String(StatusText).replace(/\\s*/g,\"\")!=\"\"){";
			if (this.showNonemptyResponse=="dump"){
				r+="var f=document.createElement(\"fieldset\");";
				r+="var l=f.appendChild(document.createElement(\"legend\"));";
				r+="l.appendChild(document.createTextNode(\"Server Response\"));";
				r+="var d=f.appendChild(document.createElement(\"div\"));";
				r+="d.innerHTML=StatusText;";
				r+="var b=f.appendChild(document.createElement(\"button\"));";
				r+="b.appendChild(document.createTextNode(\"Clear Server Response\"));";
				r+="b.onclick=function(){var f=this.parentNode;f.parentNode.removeChild(f)};";
				r+="document.body.appendChild(f);";
			}
			else{
				var s="";
				for (var i=0;i<80;i++){s+="-";}
				r+="alert(\""+s+"\\r\\nServer Response\\r\\n"+s+"\\r\\n\"+StatusText);";
			}
			r+="}";
			r+="}";
			r+="<"+"/script>";
			this.addEventListener("InnerComplete","__"+this.id+"_InnerComplete");
		}
		return r+this._getHtml();
	}
}

function ThumbnailWriter(id,width,height){
	this._base=ControlWriter;
	this._base(id,width,height);
	//These properties should be modified for private label versions only
	this.activeXControlCodeBase="ImageUploader.cab";
	this.activeXClassId="27BE1679-6AEE-4CE0-9748-7773EA94C3AF";
	this.activeXProgId="Aurigma.Thumbnail.5";
	this.javaAppletJarFileName="ImageUploader.jar";
	this.javaAppletClassName="com.aurigma.imageuploader.Thumbnail.class";
}

function ShellComboBoxWriter(id,width,height){
	this._base=ControlWriter;
	this._base(id,width,height);
	//These properties should be modified for private label versions only
	this.activeXControlCodeBase="ImageUploader.cab";
	this.activeXClassId="8B1A14AF-E603-4356-B687-1F7D46522DD3";
	this.activeXProgId="Aurigma.ShellCombo.5";
	this.javaAppletJarFileName="ImageUploader.jar";
	this.javaAppletClassName="com.aurigma.imageuploader.ShellComboBox.class";
}

function UploadPaneWriter(id,width,height){
	this._base=ControlWriter;
	this._base(id,width,height);
	//These properties should be modified for private label versions only
	this.activeXControlCodeBase="ImageUploader.cab";
	this.activeXClassId="6D9D27EE-675E-4BDE-84B1-1C9A94F98555";
	this.activeXProgId="Aurigma.UploadPane.5";
	this.javaAppletJarFileName="ImageUploader.jar";
	this.javaAppletClassName="com.aurigma.imageuploader.UploadPane.class";
}

function FileDownloaderWriter(id,width,height){
	this._base=ControlWriter;
	this._base(id,width,height);
	//These properties should be modified for private label versions only
	this.activeXControlCodeBase="FileDownloader.cab";
	this.activeXClassId="E1A26BBF-26C0-401D-B82B-5C4CC67457E0";
	this.activeXProgId="Aurigma.FileDownloader.1";
	this.javaAppletEnabled=false;
	this.controlClass="FileDownloader";
}

function getControlObject(id){
	if (__browser.isSafari){
		return document[id];
	}
	else{
		return document.getElementById(id);
	}
}

function getImageUploader(id){
	return getControlObject(id);
}

function getFileDownloader(id){
	return getControlObject(id);
}

// User functions
var PhotoClass = 
{
	Uploader: null,
	FileCount: 0,
	Flags: {},
	oFile: {},
	_this: this,
	active: {"number":null, "guid":null},
	photo_album_id : 0,
	Init: function()
	{
		this.Uploader = getImageUploader("ImageUploader1");
		//PCloseWaitMessage("photo_note", true);
		//console.log(">PhotoClass is initialized...");
	},
	
	ChangeFileCount: function()
	{
		if (this.Uploader)
		{
			var guid = 0;
			this.FileCount = this.Uploader.getUploadFileCount();
			
			for (var i = 1; i <= this.FileCount; i++)
			{
				guid = this.Uploader.getUploadFileGuid(i);
				if (typeof(this.oFile[guid]) != "object" || (!this.oFile[guid]) || (this.oFile[guid] == null))
				{
					var sFileName = this.Uploader.getUploadFileName(i);
					sFileName = sFileName.replace('\\', '/');
					var aFileName = sFileName.split('/');
					if (aFileName.length > 0);
						sFileName = aFileName[aFileName.length-1];
					this.oFile[guid] = {"Title":sFileName, "Tag":"", "Description":""};
				}
			}
			
			if (this.FileCount <= 0)
			{
				document.getElementById("photo_count_to_upload").innerHTML = oText["NoPhoto"];
				if (document.getElementById("Send"))
				{
					document.getElementById("Send").onclick = function(){return false;};
					document.getElementById("SendColor").style.color = "gray";
				}
				this.Flags["SetButtonFunction"] = "N";
			}
			else
			{
				if (this.Flags["SetButtonFunction"] != "Y")
				{
					if (document.getElementById("Send"))
					{
						document.getElementById("Send").onclick = function()
						{
							if (getImageUploader("ImageUploader1"))
								getImageUploader("ImageUploader1").Send();
							return;
						}
						document.getElementById("SendColor").style.color = "#4E4EA5";
					}
					this.Flags["SetButtonFunction"] = "Y";
				}
				document.getElementById("photo_count_to_upload").innerHTML = this.FileCount;
			}
		}
	},
	
	ChangeSelection: function()
	{
		var thumbnail1 = getImageUploader("Thumbnail1");
		if (this.Uploader && thumbnail1) 
		{
			this.HideDescription();
			for (var i = 1; i <= this.Uploader.getUploadFileCount(); i++)
			{
				try
				{
					if (this.Uploader.getUploadFileSelected(i))
					{
						this.active = {
							"number" : i,
							"guid" : this.Uploader.getUploadFileGuid(i)
						};
						break;
					}
				}
				catch(e)
				{
					alert('From ChangeSelection i=' + i + '\n\n' + e);
				}
			}
			
			if ((this.active["number"] != null) && (typeof(this.active["number"]) == "number"))
				this.ShowDescription();
		}
	},
	
	ShowDescription: function()
	{
		var thumbnail1 = getImageUploader("Thumbnail1");
		if (this.Uploader && thumbnail1 && (typeof(this.active["number"]) == "number"))
		{
			document.getElementById("PhotoTitle").disabled = false;
			document.getElementById("PhotoTitle").value = this.oFile[this.active["guid"]]["Title"];
			if (document.getElementById("PhotoTag"))
			{
				document.getElementById("PhotoTag").disabled = false;
				document.getElementById("PhotoTag").value = this.oFile[this.active["guid"]]["Tag"];
			}
			document.getElementById("PhotoDescription").disabled = false;
			document.getElementById("PhotoDescription").value = this.oFile[this.active["guid"]]["Description"];
			
			thumbnail1.setGuid(this.active["guid"]);
		}
	},
	
	HideDescription: function()
	{
		var thumbnail1 = getImageUploader("Thumbnail1");
		if (this.Uploader && thumbnail1)
		{
			if (typeof(this.active["number"]) == "number")
			{
				this.oFile[this.active["guid"]]["Title"] = document.getElementById("PhotoTitle").value;
				if (document.getElementById("PhotoTag"))
					this.oFile[this.active["guid"]]["Tag"] = document.getElementById("PhotoTag").value;
				this.oFile[this.active["guid"]]["Description"] = document.getElementById("PhotoDescription").value;
			}
			this.active = {"number":null, "guid":null};
			document.getElementById("PhotoTitle").disabled = true;
			document.getElementById("PhotoTitle").value = "";
			if (document.getElementById("PhotoTag"))
			{
				document.getElementById("PhotoTag").disabled = true;
				document.getElementById("PhotoTag").value = "";
			}
			document.getElementById("PhotoDescription").disabled = true;
			document.getElementById("PhotoDescription").value = "";
			thumbnail1.setGuid("");
		}
	},
	
	BeforeUpload: function()
	{
		if (this.Uploader)
		{
			this.HideDescription();
			try
			{			
				var guid = 0;
				this.FileCount = this.Uploader.getUploadFileCount();
				
				for (var i = 1; i <= this.FileCount; i++)
				{
					guid = this.Uploader.getUploadFileGuid(i);
					this.Uploader.setUploadFileDescription(i, this.oFile[guid]["Description"]);
					this.Uploader.AddField('Title_'+i, this.oFile[guid]["Title"]);
					if (this.oFile[guid]["Tag"])
						this.Uploader.AddField('Tags_'+i, this.oFile[guid]["Tag"]);
				}
				// watermark
				font_color = "000000";
				if (document.getElementById("watermark_color"))
					font_color = document.getElementById("watermark_color").value;
				font_color = "#" + font_color;
				font_size = "15";
				if (document.getElementById("watermark_fonts"))
					font_size = document.getElementById("watermark_fonts").value;
				
				this.Uploader.setUploadThumbnail3Watermark("opacity=100;size=" + font_size + ";FillColor=" + font_color + ";text='" + 
						document.getElementById("watermark").value.split("'").join("''") + "'");
						
				this.Uploader.setUploadThumbnail2Watermark("opacity=100;size=" + font_size + ";FillColor=" + font_color + ";text='" + 
						document.getElementById("watermark").value.split("'").join("''") + "'");
				
				if (document.getElementById("photo_resize_size") && document.getElementById("photo_resize_size").value > 0)
				{
					this.Uploader.setUploadThumbnail3FitMode("Fit");
					if (document.getElementById("photo_resize_size").value == 1)
					{
						this.Uploader.setUploadThumbnail3Width(1024);
						this.Uploader.setUploadThumbnail3Height(1024);
					}
					else if (document.getElementById("photo_resize_size").value == 2)
					{
						this.Uploader.setUploadThumbnail3Width(800);
						this.Uploader.setUploadThumbnail3Height(800);
					}
					else if (document.getElementById("photo_resize_size").value == 3)
					{
						this.Uploader.setUploadThumbnail3Width(640);
						this.Uploader.setUploadThumbnail3Height(640);
					}
				}
				else
				{
					this.Uploader.setUploadThumbnail3FitMode("ActualSize");
				}

				if (document.getElementById("sessid"))
					this.Uploader.AddField("sessid", document.getElementById("sessid").value);
				if (document.getElementById("photo_album_id"))
				{
					this.Uploader.AddField("photo_album_id", document.getElementById("photo_album_id").value);
					this.photo_album_id = document.getElementById("photo_album_id").value;
				}
				this.Uploader.AddField("save_upload", "Y");
				this.Uploader.AddField("AJAX_CALL", "Y");
				this.Uploader.AddField("CACHE_RESULT", "Y");
				this.Uploader.AddField("AlbumId",AlbumSelector.value);
				
				AddCookies();
			}
			catch(e){}
		}
	},
	
	AfterUpload: function(htmlPage)
	{
		var result = {};
		var error = false;
		if (!document.getElementById("photo_error"))
			return;
		document.getElementById("photo_error").innerHTML = "";
		try
		{
			eval("result="+htmlPage);
		}
		catch(e)
		{}
		
		if (typeof result != "object")
			result = {};

		if (result["status"] == "success")
		{
			for (var key in result["files"])
			{
				if (result["files"][key] && result["files"][key]["status"] != "success")
				{
					if (result["files"][key]["error"])
					{
						document.getElementById("photo_error").innerHTML += result["files"][key]["error"] + " (" + key +  ")<br />";
						error = true;
					}
						
				}
			}
		}
		else
		{
			if (result["error"])
			{
				document.getElementById("photo_error").innerHTML = result["error"];
				error = true;
			}
		}
		
		if (!error)
		{
			if (this.photo_album_id > 0)
				jsUtils.Redirect([], window.urlRedirect.replace('#SECTION_ID#', this.photo_album_id));
			else
				jsUtils.Redirect([], window.urlRedirectThis);
		}
	},
	
	SendTags: function(oObj)
	{
		try
		{
			if (TcLoadTI)
			{
				if (typeof window.oObject[oObj.id] != 'object')
					window.oObject[oObj.id] = new JsTc(oObj);
				return;
			}
			setTimeout(PhotoClass.SendTags(oObj), 10);
		}
		catch(e)
		{
			setTimeout(PhotoClass.SendTags(oObj), 10);
		}
	},
	
	ShowForm: function()
	{
		if (document.getElementById('table_photo_object') && document.getElementById('photo_form_table'))
		{
			if (bInitApplet)
			{
				document.getElementById('table_photo_object').style.display = '';
				document.getElementById('photo_form_table').style.display = 'none';
			}
			else
			{
				PCloseWaitMessage("photo_note", true);
				document.getElementById('table_photo_object').style.display = 'none';
				document.getElementById('photo_form_table').style.display = 'block';
			}
		}
		else
		{
			setTimeout(PhotoClass.ShowForm, 100);
		}
	},
	
	ChangeMode: function()
	{
		if (strCookie != "form")
			PhotoUtils.SetCookies('UploadShowMode', 'form');
		else
			PhotoUtils.DelCookies('UploadShowMode');
		return true;
	}
}

function BeforeUploadLink()
{
	PhotoClass.BeforeUpload();
}
function AfterUploadLink(htmlPage)
{
	PhotoClass.AfterUpload(htmlPage);
}
function ChangeSelectionLink()
{
	PhotoClass.ChangeSelection();
}
function ChangeFileCountLink()
{
	PhotoClass.ChangeFileCount();
}
function InitLink()
{
	PhotoClass.Init();
}
PUtilsIsLoaded = true;