

	var exts = "jpg|jpeg|gif";//|png|bmp|mp3|mpg|mpeg|avi|rar|zip|7z|gz|txt";
	//var exts = ".*"; //Use this to accept all Extensions

	//- Fix for Netscape 6/Mozilla ------------
/*	if(typeof HTMLElement!="undefined" && !HTMLElement.prototype.insertAdjacentElement)
	{
		HTMLElement.prototype.insertAdjacentElement = function (where,parsedNode)
		{
			switch (where)
			{
				case 'beforeBegin':
					this.parentNode.insertBefore(parsedNode,this)
				break;

				case 'afterBegin':
					this.insertBefore(parsedNode,this.firstChild);
				break;

				case 'beforeEnd':
					this.appendChild(parsedNode);
				break;

				case 'afterEnd':
					if (this.nextSibling)
						this.parentNode.insertBefore(parsedNode,this.nextSibling);
					else this.parentNode.appendChild(parsedNode);
				break;
			}
		}

		HTMLElement.prototype.insertAdjacentHTML = function (where,htmlStr)
		{
			var r = this.ownerDocument.createRange();
			r.setStartBefore(this);
			var parsedHTML = r.createContextualFragment(htmlStr);
			this.insertAdjacentElement(where,parsedHTML)
		}
	}
*/
	//---------------------

	var GLOBALlastFile = "";
	var UID,NF=0,cx=0;
	function openStatusWindow()
	{
		file_name 		= document.getElementById('file1x').value;

		file_name 		= file_name.replace(/\\/g,'/').replace( /.*\//, '' );

		GLOBALlastFile	= file_name;
		document.getElementById("uploadIframe").src = '/cgi-bin/xupload/upload_status.cgi?upload_id='+UID+'&num_files='+NF+'&css_name=&tmpl_name=&file_name='+file_name;
		document.getElementById('F1').submit();
	}

	function generateSID()
	{
		UID = Math.round(10000*Math.random())+'0'+Math.round(10000*Math.random());
		var f1=document.F1;
		f1.action = f1.action.split('?')[0]+'?upload_id='+UID;
	}

	function StartUpload()
	{
	    NF=0;
	    for (var i=0;i<document.F1.length;i++)
	    {
			current = document.F1.elements[i];
			if(current.type=='file' && current.value!='')
			{
				if(!checkFileExt(current.value)) return false;
				NF++;
			}
	    }

	    generateSID();
	    openStatusWindow();
	}

	function checkFileExt(value)
	{
	    if(value=="")return true;
	    var re = new RegExp("^.+\.("+exts+")$","i");
	    if(!re.test(value))
	    {
	        alert("This extension is not allowed for file: \"" + value + "\"\nOnly the following extensions are allowed for upload: "+exts.replace(/\|/g,',')+" \n\n");
	        return false;
	    }
	    return true;
	}
