//*********************************************************
//* Librería para la subida dinámica de archivos vía http *
//*                                                       *
//* Escrito por Israel García							  *
//* Versión: 1.2	Última modificación: 01/Jun/2009	  *
//*														  *
//*********************************************************
//
// Revise el manual para obtener soporte.


//Configurar aquí los parametros básicos
//--------------------------------------
var enable_external="false";
var allow_extensions=".jpg,.jpeg,.gif,.png";
var img_width=600;
var img_height=400;
var img_minsize="false";
var img_allowcut="false";
var thumb_width=200;
var thumb_height=120;
var thumb_minsize="false";
var thumb_allowcut="false";
var uploadfolder="../public/images/";
var thumbfolder="../public/thumbnails/";
var renameto="";
var prefixname="";
var showversion="false";


//No modificar a partir de este punto
//-----------------------------------

(function($) {
$.fn.jqm=function(o){
var p={
overlay: 50,
overlayClass: 'jqmOverlay',
closeClass: 'jqmClose',
trigger: '.jqModal',
ajax: F,
ajaxText: '',
target: F,
modal: F,
toTop: F,
onShow: F,
onHide: F,
onLoad: F
};
return this.each(function(){if(this._jqm)return H[this._jqm].c=$.extend({},H[this._jqm].c,o);s++;this._jqm=s;
H[s]={c:$.extend(p,$.jqm.params,o),a:F,w:$(this).addClass('jqmID'+s),s:s};
if(p.trigger)$(this).jqmAddTrigger(p.trigger);
});};

$.fn.jqmAddClose=function(e){return hs(this,e,'jqmHide');};
$.fn.jqmAddTrigger=function(e){return hs(this,e,'jqmShow');};
$.fn.jqmShow=function(t){return this.each(function(){t=t||window.event;$.jqm.open(this._jqm,t);});};
$.fn.jqmHide=function(t){return this.each(function(){t=t||window.event;$.jqm.close(this._jqm,t)});};

$.jqm = {
hash:{},
open:function(s,t){var h=H[s],c=h.c,cc='.'+c.closeClass,z=(parseInt(h.w.css('z-index'))),z=(z>0)?z:3000,o=$('<div></div>').css({height:'100%',width:'100%',position:'fixed',left:0,top:0,'z-index':z-1,opacity:c.overlay/100});if(h.a)return F;h.t=t;h.a=true;h.w.css('z-index',z);
 if(c.modal) {if(!A[0])L('bind');A.push(s);}
 else if(c.overlay > 0)h.w.jqmAddClose(o);
 else o=F;

 h.o=(o)?o.addClass(c.overlayClass).prependTo('body'):F;
 if(ie6){$('html,body').css({height:'100%',width:'100%'});if(o){o=o.css({position:'absolute'})[0];for(var y in {Top:1,Left:1})o.style.setExpression(y.toLowerCase(),"(_=(document.documentElement.scroll"+y+" || document.body.scroll"+y+"))+'px'");}}

 if(c.ajax) {var r=c.target||h.w,u=c.ajax,r=(typeof r == 'string')?$(r,h.w):$(r),u=(u.substr(0,1) == '@')?$(t).attr(u.substring(1)):u;
  r.html(c.ajaxText).load(u,function(){if(c.onLoad)c.onLoad.call(this,h);if(cc)h.w.jqmAddClose($(cc,h.w));e(h);});}
 else if(cc)h.w.jqmAddClose($(cc,h.w));

 if(c.toTop&&h.o)h.w.before('<span id="jqmP'+h.w[0]._jqm+'"></span>').insertAfter(h.o);	
 (c.onShow)?c.onShow(h):h.w.show();e(h);return F;
},
close:function(s){var h=H[s];if(!h.a)return F;h.a=F;
 if(A[0]){A.pop();if(!A[0])L('unbind');}
 if(h.c.toTop&&h.o)$('#jqmP'+h.w[0]._jqm).after(h.w).remove();
 if(h.c.onHide)h.c.onHide(h);else{h.w.hide();if(h.o)h.o.remove();} return F;
},
params:{}};
var s=0,H=$.jqm.hash,A=[],ie6=$.browser.msie&&($.browser.version == "6.0"),F=false,
i=$('<iframe src="javascript:false;document.write(\'\');" class="jqm"></iframe>').css({opacity:0}),
e=function(h){if(ie6)if(h.o)h.o.html('<p style="width:100%;height:100%"/>').prepend(i);else if(!$('iframe.jqm',h.w)[0])h.w.prepend(i); f(h);},
f=function(h){try{$(':input:visible',h.w)[0].focus();}catch(_){}},
L=function(t){$()[t]("keypress",m)[t]("keydown",m)[t]("mousedown",m);},
m=function(e){var h=H[A[A.length-1]],r=(!$(e.target).parents('.jqmID'+h.s)[0]);if(r)f(h);return !r;},
hs=function(w,t,c){return w.each(function(){var s=this._jqm;$(t).each(function() {
 if(!this[c]){this[c]=[];$(this).click(function(){for(var i in {jqmShow:1,jqmHide:1})for(var s in this[i])if(H[this[i][s]])H[this[i][s]].w[i](this);return F;});}this[c].push(s);});});};
})(jQuery);


//Don't touch this parameters
//----------------------------
var waiting='ver';

var backupimagewidth;
var backupimageheight;

var backupthumbwidth;
var backupthumbheight;

jQuery.extend({
	

    createUploadIframe: function(id, uri)
	{
			//create frame
            var frameId = 'jUploadFrame' + id;
            
            if(window.ActiveXObject) {
                var io = document.createElement('<iframe id="' + frameId + '" name="' + frameId + '" />');
                if(typeof uri== 'boolean'){
                    io.src = 'javascript:false';
                }
                else if(typeof uri== 'string'){
                    io.src = uri;
                }
            }
            else {
                var io = document.createElement('iframe');
                io.id = frameId;
                io.name = frameId;
            }
            io.style.position = 'absolute';
            io.style.top = '-1000px';
            io.style.left = '-1000px';

            document.body.appendChild(io);

            return io			
    },
    createUploadForm: function(id, fileElementId)
	{
		//create form	
		var formId = 'jUploadForm' + id;
		var fileId = 'jUploadFile' + id;
		var form = $('<form  action="" method="POST" name="' + formId + '" id="' + formId + '" enctype="multipart/form-data"></form>');	
		var oldElement = $('#' + fileElementId);
		var newElement = $(oldElement).clone();
		$(oldElement).attr('id', fileId);
		$(oldElement).before(newElement);
		$(oldElement).appendTo(form);
		//set attributes
		$(form).css('position', 'absolute');
		$(form).css('top', '-1200px');
		$(form).css('left', '-1200px');
		$(form).appendTo('body');		
		return form;
    },

    ajaxFileUpload: function(s) {
        // TODO introduce global settings, allowing the client to modify them for all requests, not only timeout		
        s = jQuery.extend({}, jQuery.ajaxSettings, s);
        var id = new Date().getTime()        
		var form = jQuery.createUploadForm(id, s.fileElementId);
		var io = jQuery.createUploadIframe(id, s.secureuri);
		var frameId = 'jUploadFrame' + id;
		var formId = 'jUploadForm' + id;		
        // Watch for a new set of requests
        if ( s.global && ! jQuery.active++ )
		{
			jQuery.event.trigger( "ajaxStart" );
		}            
        var requestDone = false;
        // Create the request object
        var xml = {}   
        if ( s.global )
            jQuery.event.trigger("ajaxSend", [xml, s]);
        // Wait for a response to come back
        var uploadCallback = function(isTimeout)
		{			
			var io = document.getElementById(frameId);
            try 
			{				
				if(io.contentWindow)
				{
					 xml.responseText = io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null;
                	 xml.responseXML = io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:io.contentWindow.document;
					 
				}else if(io.contentDocument)
				{
					 xml.responseText = io.contentDocument.document.body?io.contentDocument.document.body.innerHTML:null;
                	xml.responseXML = io.contentDocument.document.XMLDocument?io.contentDocument.document.XMLDocument:io.contentDocument.document;
				}						
            }catch(e)
			{
				jQuery.handleError(s, xml, null, e);
			}
            if ( xml || isTimeout == "timeout") 
			{				
                requestDone = true;
                var status;
                try {
                    status = isTimeout != "timeout" ? "success" : "error";
                    // Make sure that the request was successful or notmodified
                    if ( status != "error" )
					{
                        // process the data (runs the xml through httpData regardless of callback)
                        var data = jQuery.uploadHttpData( xml, s.dataType );    
                        // If a local callback was specified, fire it and pass it the data
                        if ( s.success )
                            s.success( data, status );
    
                        // Fire the global callback
                        if( s.global )
                            jQuery.event.trigger( "ajaxSuccess", [xml, s] );
                    } else
                        jQuery.handleError(s, xml, status);
                } catch(e) 
				{
                    status = "error";
                    jQuery.handleError(s, xml, status, e);
                }

                // The request was completed
                if( s.global )
                    jQuery.event.trigger( "ajaxComplete", [xml, s] );

                // Handle the global AJAX counter
                if ( s.global && ! --jQuery.active )
                    jQuery.event.trigger( "ajaxStop" );

                // Process result
                if ( s.complete )
                    s.complete(xml, status);

                jQuery(io).unbind()

                setTimeout(function()
									{	try 
										{
											$(io).remove();
											$(form).remove();	
											
										} catch(e) 
										{
											jQuery.handleError(s, xml, null, e);
										}									

									}, 100)

                xml = null

            }
        }
        // Timeout checker
        if ( s.timeout > 0 ) 
		{
            setTimeout(function(){
                // Check to see if the request is still happening
                if( !requestDone ) uploadCallback( "timeout" );
            }, s.timeout);
        }
        try 
		{
           // var io = $('#' + frameId);
			var form = $('#' + formId);
			$(form).attr('action', s.url);
			$(form).attr('method', 'POST');
			$(form).attr('target', frameId);
            if(form.encoding)
			{
                form.encoding = 'multipart/form-data';				
            }
            else
			{				
                form.enctype = 'multipart/form-data';
            }			
            $(form).submit();

        } catch(e) 
		{			
            jQuery.handleError(s, xml, null, e);
        }
        if(window.attachEvent){
            document.getElementById(frameId).attachEvent('onload', uploadCallback);
        }
        else{
            document.getElementById(frameId).addEventListener('load', uploadCallback, false);
        } 		
        return {abort: function () {}};	

    },

    uploadHttpData: function( r, type ) {
        var data = !type;
        data = type == "xml" || data ? r.responseXML : r.responseText;
        // If the type is "script", eval it in global context
        if ( type == "script" )
            jQuery.globalEval( data );
        // Get the JavaScript object, if JSON is used.
        if ( type == "json" )
            eval( "data = " + data );
        // evaluate scripts within html
        if ( type == "html" )
            jQuery("<div>").html(data).evalScripts();
			//alert($('param', data).each(function(){alert($(this).attr('value'));}));
        return data;
    }
})

function inicializar() {
	$('#'+waiting).show();
}

function finalizar() {
	$("#" + waiting)
	$(this).hide()	
}

function ComprobarExtensiones(fieldupload,extensiones)
{
extensiones_permitidas = new Array(".gif", ".jpg", ".jpeg", ".png", ".doc", ".docx", ".pdf", ".zip"); 
if (extensiones!="") {extensiones_permitidas = extensiones.split(","); }

archivo=document.getElementById(fieldupload).value;
extension = (archivo.substring(archivo.lastIndexOf("."))).toLowerCase();
permitida = false; 
for (var i = 0; i < extensiones_permitidas.length; i++) {
 if (extensiones_permitidas[i] == extension) {
 permitida = true;
 break;
 }
} 
return permitida;
}

function urlencode(str) {
str = escape(str);
str = str.replace('+', '%2B');
str = str.replace('%20', '+');
str = str.replace('*', '%2A');
str = str.replace('/', '%2F');
str = str.replace('@', '%40');
return str;
}

function Close(field) {
$('#popup').jqmHide(); 
}

function SetParameters(parameters) {
	matrizparam=parameters.split(";");
	matrizlong=matrizparam.length;
	if (matrizlong>0) {
		for(x=0;x<matrizlong;x++) {
			actualparam=matrizparam[x];
			if (actualparam.length>2) {
				clavevalor=actualparam.split("=");
				clave=clavevalor[0].toLowerCase();
				valor=clavevalor[1].toLowerCase();
				switch(clave) {
					case "enable_external": enable_external=valor; break;
					case "allow_extensions": allow_extensions=valor; break;
					case "img_width": img_width=valor; break;
					case "img_height": img_height=valor; break;
					case "img_minsize": img_minsize=valor; break;
					case "img_allowcut": img_allowcut=valor; break;
					case "thumb_width": thumb_width=valor; break;
					case "thumb_height": thumb_height=valor; break;
					case "thumb_minsize": thumb_minsize=valor; break;
					case "thumb_allowcut": thumb_allowcut=valor; break;
					case "uploadfolder": uploadfolder=valor; break;
					case "thumbfolder": thumbfolder=valor; break;
					case "renameto": renameto=valor; break;
					case "prefixname": prefixname=valor; break;
					case "showversion": showversion=valor; break;
				}
			}
		}
	}
}

function StartUpload(field) {
	url_allow_extensions=document.getElementById('tmp_'+field+'_allow_extensions').value;
	url_img_width=document.getElementById('tmp_'+field+'_img_width').value;
	url_img_height=document.getElementById('tmp_'+field+'_img_height').value;
	url_img_minsize=document.getElementById('tmp_'+field+'_img_minsize').value;
	url_img_allowcut=document.getElementById('tmp_'+field+'_img_allowcut').value;
	url_thumb_width=document.getElementById('tmp_'+field+'_thumb_width').value;
	url_thumb_height=document.getElementById('tmp_'+field+'_thumb_height').value;
	url_thumb_minsize=document.getElementById('tmp_'+field+'_thumb_minsize').value;
	url_thumb_allowcut=document.getElementById('tmp_'+field+'_thumb_allowcut').value;
	url_uploadfolder=document.getElementById('tmp_'+field+'_uploadfolder').value;
	url_thumbfolder=document.getElementById('tmp_'+field+'_thumbfolder').value;
	url_renameto=document.getElementById('tmp_'+field+'_renameto').value;
	url_prefixname=document.getElementById('tmp_'+field+'_prefixname').value;
	if (ComprobarExtensiones(field,url_allow_extensions)) {
		waiting="tmp_"+field + "_loading";
		$("#" + waiting)
		.ajaxStart(inicializar)
		.ajaxComplete(finalizar);
		$.ajaxFileUpload
			(
				{
				url: '../lib/upload/run_upload.php?id=' + field + '&img_width=' + url_img_width + '&img_height=' + url_img_height + '&img_minsize=' + url_img_minsize + '&img_allowcut=' + url_img_allowcut  + '&thumb_width=' + url_thumb_width + '&thumb_height=' + url_thumb_height + '&thumb_minsize=' + url_thumb_minsize + '&thumb_allowcut=' + url_thumb_allowcut + '&uploadfolder=' + url_uploadfolder + '&thumbfolder=' + url_thumbfolder + '&renameto=' + url_renameto + '&prefixname=' + url_prefixname,
				secureuri:false,
				fileElementId:field,
				dataType: 'json',
				success: function (data, status)
					{
						if(typeof(data.error) != 'undefined')
						{
							if(data.error != '')
							{
								alert(data.error);
							}else
							{
								putUpload(field,data.msg);
								document.getElementById(field).value='';
								document.getElementById('tmp_'+field+'_up').value='1';
							}
						}
					},
					error: function (data, status, e)
					{
								document.getElementById(field).value='';
								document.getElementById('tmp_'+field+'_up').value='0';
					}
				}
			)
		}
	else
	{ alert("Extensión no permitida"); }
return false;
}

function ShowState(field) {
	ponerhtml="";
	var archivo = document.getElementById('old_'+field).value;
	if (archivo.length>0) {
		extension = (archivo.substring(archivo.lastIndexOf("."))).toLowerCase();
		es_imagen= false;
		if (extension=='.pdf') { tipo="PDF"; icono="pdf.gif"; } else
		if (extension=='.zip') { tipo="ZIP"; icono="zip.gif"; } else
		if (extension=='.rar') { tipo="RAR"; icono="rar.gif"; } else
		if (extension=='.doc') { tipo="Word"; icono="doc.gif"; } else
		if (extension=='.docx') { tipo="Word"; icono="doc.gif"; } else
		if (extension=='.xls') { tipo="Excel"; icono="xls.gif"; } else
		if (extension=='.xlsx') { tipo="Excel"; icono="xls.gif"; } else
		if (extension=='.ppt') { tipo="Powerpoint"; icono="ppt.gif"; } else
		if (extension=='.jpg') { tipo="JPEG"; icono="jpg.gif"; es_imagen=true; } else
		if (extension=='.jpeg') { tipo="JPEG"; icono="jpg.gif"; es_imagen=true; } else
		if (extension=='.gif') { tipo="GIF"; icono="gif.gif";es_imagen=true; } else
		if (extension=='.png') { tipo="GIF"; icono="gif.gif"; es_imagen=true; } else
		if (extension=='.mp3') { tipo="MP3 Audio"; icono="audio.gif"; } else
		if (extension=='.mp4') { tipo="MP4"; icono="audio.gif"; } else
		if (extension=='.wma') { tipo="WMA"; icono="audio.gif"; } else
		if (extension=='.asx') { tipo="ASX"; icono="wma.gif"; } else
		if (extension=='.ogg') { tipo="Audio"; icono="ogg.gif"; } else
		if (extension=='.wmv') { tipo="Video"; icono="wmv.gif"; } else
		if (extension=='.swf') { tipo="Flash"; icono="swf.gif"; } else
							   { tipo="File"; icono="other.gif"; }
		
		ponerhtml="<img src='../lib/upload/images/icon_" + icono +"' align='absmiddle'>" + archivo+"   ";
		if (es_imagen) {
			//Si es imagen pintamos su miniatura y permitimos su redimensión
			var aleatorio=Math.round(Math.random()*10000000); 
			buffer=new Image();
			buffer.src = document.getElementById('tmp_'+field+'_thumbfolder').value + archivo + "?d=" +aleatorio+ new Date().getTime();
			ponerhtml="<img src='" + buffer.src +"' align='absmiddle'><br />";
			ponerhtml=ponerhtml+"<img src='../lib/upload/images/thumb.png' alt='Generar Miniatura' onclick='CutThumb(" + '"' + field + '"' + ");'>";
		}
		ponerhtml=ponerhtml+"<img src='../lib/upload/images/del.png' alt='Borrar' onclick='ClearUpload(" + '"' + field + '"' +");'>";
	}
	if (document.getElementById('tmp_'+field+'_original').value.length>0) {
		ponerhtml=ponerhtml+"<img src='../lib/upload/images/previous.png' alt='Original' onclick='RestoreUpload(" + '"' + field + '"' +");'>";
	}
	var to=document.getElementById('view_'+field);
	to.innerHTML=ponerhtml;	
}
	
function putUpload(field,archivo) {
	document.getElementById('old_'+field).value=archivo;
	ShowState(field);
}	

function ClearUpload(field) {
	document.getElementById('view_'+ field).innerHTML="";
	document.getElementById('old_'+field).value="";
	document.getElementById('tmp_'+field+'_up').value='0';
	ShowState(field);
}

function RestoreUpload(field) {
	document.getElementById('view_'+field).innerHTML="";
	document.getElementById('old_'+field).value=document.getElementById('tmp_'+field+'_original').value;
	document.getElementById('tmp_'+field+'_up').value='0';
	ShowState(field);
}

function CutThumb(field) {
	url_allow_extensions=document.getElementById('tmp_'+field+'_allow_extensions').value;
	url_img_width=document.getElementById('tmp_'+field+'_img_width').value;
	url_img_height=document.getElementById('tmp_'+field+'_img_height').value;
	url_img_minsize=document.getElementById('tmp_'+field+'_img_minsize').value;
	url_img_allowcut=document.getElementById('tmp_'+field+'_img_allowcut').value;
	url_thumb_width=document.getElementById('tmp_'+field+'_thumb_width').value;
	url_thumb_height=document.getElementById('tmp_'+field+'_thumb_height').value;
	url_thumb_minsize=document.getElementById('tmp_'+field+'_thumb_minsize').value;
	url_thumb_allowcut=document.getElementById('tmp_'+field+'_thumb_allowcut').value;
	url_uploadfolder=document.getElementById('tmp_'+field+'_uploadfolder').value;
	url_thumbfolder=document.getElementById('tmp_'+field+'_thumbfolder').value;
	url_uploadfile=document.getElementById('old_'+field).value;
	
	urlventana='../lib/upload/popup.php?id=' + field + '&img_width=' + url_img_width + '&img_height=' + url_img_height + '&img_minsize=' + url_img_minsize + '&img_allowcut=' + url_img_allowcut  + '&thumb_width=' + url_thumb_width + '&thumb_height=' + url_thumb_height + '&thumb_minsize=' + url_thumb_minsize + '&thumb_allowcut=' + url_thumb_allowcut + '&uploadfolder=' + url_uploadfolder+ '&thumbfolder=' + url_thumbfolder + '&uploadfile=' + url_uploadfile + '&refresh=' + Math.round(Math.random()*10000); 
	$('#popup').jqm({modal:true, ajax: urlventana  });
	$('#popup').jqmShow(); 
}

function Close() {
$('#popup').jqmHide(); 
}

function upload(field,actualvalue,actualparams) {	
	//Iniciamos las variables temporales...
	tmp_enable_external=enable_external;
	tmp_allow_extensions=allow_extensions;
	tmp_img_width=img_width;
	tmp_img_height=img_height;
	tmp_img_minsize=img_minsize;
	tmp_img_allowcut=img_allowcut;
	tmp_thumb_width=thumb_width;
	tmp_thumb_height=thumb_height;
	tmp_thumb_minsize=thumb_minsize;
	tmp_thumb_allowcut=thumb_allowcut;
	tmp_uploadfolder=uploadfolder;
	tmp_thumbfolder=thumbfolder;
	tmp_renameto=renameto;
	tmp_prefixname=prefixname;
	tmp_showversion=showversion;
	//Cargamos los parametros que lleguen desde "actualparams"
	matrizparam=actualparams.split(";");
	matrizlong=matrizparam.length;
	if (matrizlong>-1) {
		for(x=0;x<matrizlong;x++) {
			actualparam=matrizparam[x];
			if (actualparam.length>2) {
				clavevalor=actualparam.split("=");
				clave=clavevalor[0].toLowerCase();
				valor=clavevalor[1].toLowerCase();
				switch(clave) {
					case "enable_external": tmp_enable_external=valor; break;
					case "allow_extensions": tmp_allow_extensions=valor; break;
					case "img_width": tmp_img_width=valor; break;
					case "img_height": tmp_img_height=valor; break;
					case "img_minsize": tmp_img_minsize=valor; break;
					case "img_allowcut": tmp_img_allowcut=valor; break;
					case "thumb_width": tmp_thumb_width=valor; break;
					case "thumb_height": tmp_thumb_height=valor; break;
					case "thumb_minsize": tmp_thumb_minsize=valor; break;
					case "thumb_allowcut": tmp_thumb_allowcut=valor; break;
					case "uploadfolder": tmp_uploadfolder=valor; break;
					case "thumbfolder": tmp_thumbfolder=valor; break;
					case "renameto": tmp_renameto=valor; break;
					case "prefixname": tmp_prefixname=valor; break;
					case "showversion": tmp_showversion=valor; break;
				}
			}
		}
	}
	//Creamos los items del formulario
	document.write('<input name="'+field+'" type="file" id="'+field+'" onChange="return StartUpload('+"'"+field+"'"+ ')" /><br />');
	document.write('<img name="tmp_'+field+'_loading" id="tmp_'+field+'_loading" src="../lib/upload/images/loading.gif" style="display:none;">');
	if (tmp_enable_external=="true") {
		document.write('<input name="old_'+field+'" type="text" id="old_'+field+'" value="'+actualvalue+'" />');
	}
	if (tmp_enable_external!="true") {
		document.write('<input name="old_'+field+'" type="hidden" id="old_'+field+'" value="'+actualvalue+'" />');
	}	
	document.write('<input name="tmp_'+field+'_allow_extensions" id="tmp_'+field+'_allow_extensions" value="'+tmp_allow_extensions+'" type="hidden" />');
	document.write('<input name="tmp_'+field+'_img_width" id="tmp_'+field+'_img_width" value="'+tmp_img_width+'" type="hidden" />');
	document.write('<input name="tmp_'+field+'_img_height" id="tmp_'+field+'_img_height" value="'+tmp_img_height+'" type="hidden" />');
	document.write('<input name="tmp_'+field+'_img_minsize" id="tmp_'+field+'_img_minsize" value="'+tmp_img_minsize+'" type="hidden" />');
	document.write('<input name="tmp_'+field+'_img_allowcut" id="tmp_'+field+'_img_allowcut" value="'+tmp_img_allowcut+'" type="hidden" />');
	document.write('<input name="tmp_'+field+'_thumb_width" id="tmp_'+field+'_thumb_width" value="'+tmp_thumb_width+'" type="hidden" />');
	document.write('<input name="tmp_'+field+'_thumb_height" id="tmp_'+field+'_thumb_height" value="'+tmp_thumb_height+'" type="hidden" />');
	document.write('<input name="tmp_'+field+'_thumb_minsize" id="tmp_'+field+'_thumb_minsize" value="'+tmp_thumb_minsize+'" type="hidden" />');
	document.write('<input name="tmp_'+field+'_thumb_allowcut" id="tmp_'+field+'_thumb_allowcut" value="'+tmp_thumb_allowcut+'" type="hidden" />');	
	document.write('<input name="tmp_'+field+'_uploadfolder" id="tmp_'+field+'_uploadfolder" value="'+tmp_uploadfolder+'" type="hidden" />');
	document.write('<input name="tmp_'+field+'_thumbfolder" id="tmp_'+field+'_thumbfolder" value="'+tmp_thumbfolder+'" type="hidden" />');
	document.write('<input name="tmp_'+field+'_renameto" id="tmp_'+field+'_renameto" value="'+tmp_renameto+'" type="hidden" />');
	document.write('<input name="tmp_'+field+'_prefixname" id="tmp_'+field+'_prefixname" value="'+tmp_prefixname+'" type="hidden" />');
	document.write('<input name="tmp_'+field+'_original" id="tmp_'+field+'_original" value="'+actualvalue+'" type="hidden" />');
	document.write('<input name="tmp_'+field+'_up" id="tmp_'+field+'_up" value="0" type="hidden" />');
	document.write('<br /><span id="view_'+field+'"> </span>');
	ShowState(field);
}



document.write('<link type="text/css" id="estilopopup" rel="stylesheet" media="all" href="../lib/upload/jqModal.css" />');
document.write('<div class="jqmWindow" id="popup"></div>');

