/*  jQupload - jQuery Upload v0.1
 *  jQupload is distributed under the terms of the MIT license
 *  For more information visit http://jqframework.com/jqupload
 *  Copyright (C) 2010  jqframework.com
 * Do not remove this copyright message
 */
jQuery.jQupload={fadeOutTime:3000,callback:{},output:{},init:function(id,obj){if(obj.callback){jQuery.jQupload.callback[id]=obj.callback
}if(obj.output){jQuery.jQupload.output[id]=obj.output
}if(obj.fadeOutTime){jQuery.jQupload.fadeOutTime=obj.fadeOutTime
}},defaultMessage:function(data){alert(data)
},jsonMessage:function(data){eval("data="+data);
jQuery("#"+jQuery.jQupload.output[data.formid.value]).html(data.message).fadeOut(jQuery.jQupload.fadeOutTime)
}};
jQuery.fn.extend({jqupload:function(obj){return this.each(function(){var id=this.id;
if(typeof this.id=="object"){id=jQuery(this).attr("id")
}if(!obj) obj={};jQuery.jQupload.init(id,obj)
})
},jqupload_form:function(){return this.each(function(){var id=this.id;
if(typeof this.id=="object"){id=jQuery(this).attr("id")
}var data=jQuery.extend({},{iframe:id+"_iframe"},data);
jQuery("body").append("<iframe name="+data.iframe+' id="'+data.iframe+'"></iframe>');
jQuery("#"+data.iframe).css({position:"absolute",left:"-1000px",top:"-1000px",width:"0px",height:"0px"});
jQuery(this).attr("target",data.iframe).submit(function(){jQuery("#"+data.iframe).load(function(){var data1=jQuery("#"+data.iframe).contents().find("body").html();
data1='{"formid":{"value":"'+id+'"},'+data1.substr(1);
if(jQuery.jQupload.callback[id]){eval(jQuery.jQupload.callback[id]+"('"+data1+"')")
}else{if(jQuery.jQupload.output[id]){jQuery.jQupload.jsonMessage(data1)
}else{jQuery.jQupload.defaultMessage(data1)
}}jQuery("#"+data.iframe).contents().find("body").html("");
jQuery("#"+data.iframe).unbind("load")
})
});
return true
})
}});
