jQuery.log=function(A){console.log(A)};jQuery.mousePos=function(A){this.x=0;this.y=0;if(!A){var A=window.event}if(A.pageX||A.pageY){this.x=A.pageX;this.y=A.pageY}else{if(A.clientX||A.clientY){this.x=A.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;this.y=A.clientY+document.body.scrollTop+document.documentElement.scrollTop}}};jQuery.wHigh=function(){var A=0;if(typeof (window.innerHeight)=="number"){A=window.innerHeight}else{if(document.documentElement&&document.documentElement.clientHeight){A=document.documentElement.clientHeight}else{if(document.body&&document.body.clientHeight){A=document.body.clientHeight}}}return A};jQuery.wWide=function(){return window.innerWidth?window.innerWidth:document.body.offsetWidth};jQuery.scrollbarWidth=function(){var C=$('<div style="width:50px;height:50px;overflow:hidden;position:absolute;top:-200px;left:-200px;"><div style="height:100px;"></div>');$("body").append(C);var B=$("div",C).innerWidth();C.css("overflow-y","scroll");var A=$("div",C).innerWidth();$(C).remove();return(B-A)};jQuery.getSizeValue=function(B){var A=B.replace(" ","");A=A.replace("px","");A=A.replace("em","");return A};jQuery.sleep=function(B){var A=new Date().getTime();while(new Date().getTime()<A+B){}};jQuery.showErrorData=function(B,A){dialog.setDialog({Type:"error",Buttons:"ok",Text:B,Title:A});dialog.showDialog()};jQuery.showSuccess=function(B,A){dialog.setDialog({Type:"ok",Buttons:"ok",Text:A,Title:B});dialog.showDialog()};jQuery.showError=function(B,A,C){dialog.setDialog({Type:"error",Buttons:"ok",Text:A,Title:B,BackCallback:C});dialog.showDialog()};jQuery.showPrompt=function(C,B,A){dialog.setDialog({Type:"prompt",Buttons:"ok",Text:B,Title:C,YesCallback:A});dialog.showDialog()};function Dialog(){this.dialog=$("#dialog");this.op={};this.op.Type=null;this.op.Buttons=null;this.op.Title=null;this.op.Text=null;this.op.YesJS=null;this.op.NoJS=null;this.op.callback_preload=null;this.StatusOn=false}Dialog.prototype.init=function(B){this.op=jQuery.extend(this.op,B);$("#dialog_button_ok").click(function(){dialog.clickedButton("ok")});$("#dialog_button_yes").click(function(){dialog.clickedButton("ok")});$("#dialog_button_no").click(function(){dialog.clickedButton("cancel")});$("#dialog_button_close").click(function(){dialog.clickedButton("cancel")});$("#dialog_button_back").click(function(){dialog.clickedButton("back")});$(window).resize(function(){dialog.place()})};Dialog.prototype.setDialog=function(C){var D={Type:"error",Buttons:"ok",Text:"Text",Title:"Title",YesCallback:null,NoCallback:null,BackCallback:null};this.op=jQuery.extend(D,C)};Dialog.prototype.place=function(){var L=$(window).height();var I=$(window).width();var J=$.getSizeValue(this.dialog.css("height"));this.dialog.height(J);var G=$.getSizeValue(this.dialog.css("width"));this.dialog.width(G);var K=Math.floor((I-G)/2);var H=Math.floor((L-J)/2)};Dialog.prototype.showDialog=function(){document.body.onkeydown=function A(B){keyCode=(window.event)?window.event.keyCode:B.keyCode;if(keyCode==13){dialog.clickedButton("ok");}if(keyCode==27){dialog.hideDialog();}return(keyCode==9)?false:true};if("Title"==this.op.Title&&"Text"==this.op.Text){return }this.buildDialog();dimmer.show();if(dialog.op.callback_preload){dialog.op.callback_preload({"target":"dialog"})}this.place();this.dialog.show();if("ok"==this.op.Buttons){$("#dialog_button_ok").focus()}else{if("sure"==this.op.Buttons){$("#dialog_button_yes").focus()}}this.StatusOn=true};Dialog.prototype.hideDialog=function(){document.body.onkeydown=function A(B){keyCode=(window.event)?window.event.keyCode:B.keyCode;return(keyCode==9)?true:true};this.dialog.hide();dimmer.hide(2000);this.StatusOn=false};Dialog.prototype.buildDialog=function(){if(this.dialog){$("#dialog_title").html(this.op.Title);$("#dialog_text").html(this.op.Text);var B="";$("#dialog_question").css("visibility","hidden");switch(this.op.Type){case"error":break;case"ok":break;case"help":break;case"howto":break;case"processing":break;case"log":break;case"warning":case"prompt":break;if("sure"==this.op.Buttons){$("#dialog_question").css("visibility","visible")}break}$("#dialog_header").attr("class","box2Header "+B);$("#dialog_button_ok, #dialog_button_yes, #dialog_button_no, #dialog_button_close, #dialog_button_back").hide();switch(this.op.Buttons){case"ok":if(this.op.Type=="prompt"){$("#dialog_button_ok").show()}$("#dialog_button_close").show();break;case"sure":$("#dialog_button_yes").show();$("#dialog_button_no").show();break}if(this.op.BackCallback){$("#dialog_button_ok, #dialog_button_yes, #dialog_button_no, #dialog_button_close, #dialog_button_back").hide();$("#dialog_button_back, #dialog_button_close").show();}}};Dialog.prototype.clickedButton=function(B){switch(B){case"ok":if(this.op.YesCallback){if(this.op.YesCallback()){this.hideDialog();}};break;case"cancel":window.globRemoteUrlFile="";this.hideDialog();if(this.op.NoCallback){this.op.NoCallback()}break;case"back":if(this.op.BackCallback){this.hideDialog();this.op.BackCallback();}break;default:this.hideDialog();break}};function Dimmer(){this.StatusOn=false;if($.browser.msie&&parseInt($.browser.version)==6&&typeof window["XMLHttpRequest"]!="object"){this.IE6=true}else{this.IE6=false}this.dimmer=$("#darkMaskDialog");if(this.IE6){this.dimmershadow=$("#darkMaskDialog")}this.DimmerTrack={"1000":false,"2000":false}}Dimmer.prototype.place=function(){return ;if(this.StatusOn){var A=$(window).height()+$(document).scrollTop();var B=$(window).width()+$(document).scrollLeft();this.dimmer.height(A);this.dimmer.width(B);if(this.IE6){this.dimmershadow.height(A);this.dimmershadow.width(B)}}};Dimmer.prototype.show=function(B){this.setTrack(B,true);var A=this.getZIndex();this.dimmer.css({"zIndex":A-1});this.StatusOn=true;this.dimmer.show();if(this.IE6){this.dimmershadow.show()}this.place()};Dimmer.prototype.hide=function(B){this.setTrack(B,false);var A=this.getZIndex();if(0!=A){this.dimmer.css({"zIndex":A-1})}else{this.StatusOn=false;this.dimmer.hide();if(this.IE6){this.dimmershadow.hide()}}};Dimmer.prototype.getZIndex=function(){var A=0;if(this.DimmerTrack["1000"]){A=1000}if(this.DimmerTrack["2000"]){A=2000}return A};Dimmer.prototype.setTrack=function(A,B){this.DimmerTrack[A]=B};jQuery.isDomain=function(B){if(!B||(256<B.length)){return false}var A=new RegExp("^[a-z0-9]{1,1}([\\-\\.]?[a-z0-9])*\\.[a-z]{2,4}$");return(A.test(B))};jQuery.isURL=function(C){var B=/^(http|https|ftp)\:\/\//;if(!B.test(C)){return false}if(C.indexOf(" ")!=-1){return false}else{if(C=="http://"||C=="https://"||C=="ftp://"){return false}else{if(C.indexOf("http://")>0){return false}}}C=C.substring(7,C.length);if(C.indexOf(".")==-1){return false}else{if(C.indexOf(".")==0){return false}else{if(C.charAt(C.length-1)=="."){return false}}}if(C.indexOf("/")!=-1){C=C.substring(0,C.indexOf("/"));if(C.charAt(C.length-1)=="."){return false}}if(C.indexOf(":")!=-1){if(C.indexOf(":")==(C.length-1)){return false}else{if(C.charAt(C.indexOf(":")+1)=="."){return false}}C=C.substring(0,C.indexOf(":"));if(C.charAt(C.length-1)=="."){return false}}return true}


if(jQuery){(function(C){var B="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var D=C.uTF8Encode=function(F){F=F.replace(/\x0d\x0a/g,"\x0a");var E="";for(var H=0;H<F.length;H++){var G=F.charCodeAt(H);if(G<128){E+=String.fromCharCode(G)}else{if((G>127)&&(G<2048)){E+=String.fromCharCode((G>>6)|192);E+=String.fromCharCode((G&63)|128)}else{E+=String.fromCharCode((G>>12)|224);E+=String.fromCharCode(((G>>6)&63)|128);E+=String.fromCharCode((G&63)|128)}}}return E};var A=C.uTF8Decode=function(E){var F="";var G=0;var H=c1=c2=0;while(G<E.length){H=E.charCodeAt(G);if(H<128){F+=String.fromCharCode(H);G++}else{if((H>191)&&(H<224)){c2=E.charCodeAt(G+1);F+=String.fromCharCode(((H&31)<<6)|(c2&63));G+=2}else{c2=E.charCodeAt(G+1);c3=E.charCodeAt(G+2);F+=String.fromCharCode(((H&15)<<12)|((c2&63)<<6)|(c3&63));G+=3}}}return F};C.extend({base64Encode:function(G){var E="";var N,L,J,M,K,I,H;var F=0;G=D(G);while(F<G.length){N=G.charCodeAt(F++);L=G.charCodeAt(F++);J=G.charCodeAt(F++);M=N>>2;K=((N&3)<<4)|(L>>4);I=((L&15)<<2)|(J>>6);H=J&63;if(isNaN(L)){I=H=64}else{if(isNaN(J)){H=64}}E=E+B.charAt(M)+B.charAt(K)+B.charAt(I)+B.charAt(H)}return E},base64Decode:function(G){if(!G){return G}var E="";var N,L,J;var M,K,I,H;var F=0;G=G.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(F<G.length){M=B.indexOf(G.charAt(F++));K=B.indexOf(G.charAt(F++));I=B.indexOf(G.charAt(F++));H=B.indexOf(G.charAt(F++));N=(M<<2)|(K>>4);L=((K&15)<<4)|(I>>2);J=((I&3)<<6)|H;E=E+String.fromCharCode(N);if(I!=64){E=E+String.fromCharCode(L)}if(H!=64){E=E+String.fromCharCode(J)}}E=A(E);return E}})})(jQuery)};


if(jQuery){(function(a){a.extend(a.fn,{uploadify:function(b){a(this).each(function(){settings=a.extend({id:a(this).attr("id"),uploader:"uploadify.swf",script:"uploadify.php",expressInstall:null,folder:"",height:30,width:110,cancelImg:"cancel.png",wmode:"opaque",scriptAccess:"sameDomain",fileDataName:"Filedata",method:"POST",queueSizeLimit:999,simUploadLimit:1,queueID:false,displayData:"percentage",onInit:function(){},onSelect:function(){},onQueueFull:function(){},onCheck:function(){},onCancel:function(){},onError:function(){},onProgress:function(){},onComplete:function(){},onAllComplete:function(){}},b);var e=location.pathname;e=e.split("/");e.pop();e=e.join("/")+"/";var f={};f.uploadifyID=settings.id;f.pagepath=e;if(settings.buttonImg){f.buttonImg=escape(settings.buttonImg)}if(settings.buttonText){f.buttonText=escape(settings.buttonText)}if(settings.rollover){f.rollover=true}f.script=settings.script;f.folder=escape(settings.folder);if(settings.scriptData){var g="";for(var d in settings.scriptData){g+="&"+d+"="+settings.scriptData[d]}f.scriptData=escape(g.substr(1))}f.width=settings.width;f.height=settings.height;f.wmode=settings.wmode;f.method=settings.method;f.queueSizeLimit=settings.queueSizeLimit;f.simUploadLimit=settings.simUploadLimit;if(settings.hideButton){f.hideButton=true}if(settings.fileDesc){f.fileDesc=settings.fileDesc}if(settings.fileExt){f.fileExt=settings.fileExt}if(settings.multi){f.multi=true}if(settings.auto){f.auto=true}if(settings.sizeLimit){f.sizeLimit=settings.sizeLimit}if(settings.checkScript){f.checkScript=settings.checkScript}if(settings.fileDataName){f.fileDataName=settings.fileDataName}if(settings.queueID){f.queueID=settings.queueID}if(settings.onInit()!==false){a(this).css("display","none");a(this).after('<div id="'+a(this).attr("id")+'Uploader"></div>');swfobject.embedSWF(settings.uploader,settings.id+"Uploader",settings.width,settings.height,"9.0.24",settings.expressInstall,f,{quality:"high",wmode:settings.wmode,allowScriptAccess:settings.scriptAccess});if(settings.queueID==false){a("#"+a(this).attr("id")+"Uploader").after('<div id="'+a(this).attr("id")+'Queue" class="uploadifyQueue"></div>')}}if(typeof(settings.onOpen)=="function"){a(this).bind("uploadifyOpen",settings.onOpen)}a(this).bind("uploadifySelect",{action:settings.onSelect,queueID:settings.queueID},function(j,h,i){if(j.data.action(j,h,i)!==false){var k=Math.round(i.size/1024*100)*0.01;var l="KB";if(k>1000){k=Math.round(k*0.001*100)*0.01;l="MB"}var m=k.toString().split(".");if(m.length>1){k=m[0]+"."+m[1].substr(0,2)}else{k=m[0]}if(i.name.length>20){fileName=i.name.substr(0,20)+"..."}else{fileName=i.name}queue="#"+a(this).attr("id")+"Queue";if(j.data.queueID){queue="#"+j.data.queueID}globSelf._addHistoryFileName(fileName,"FLASH_"+a(this).attr("id")+h,(parseInt(k*1024*1024)));a(queue).append('<div id="'+a(this).attr("id")+h+'" class="uploadifyQueueItem"><div class="cancel"><a href="javascript:jQuery(\'#'+a(this).attr("id")+"').uploadifyCancel('"+h+'\')"><img src="'+settings.cancelImg+'" border="0" /></a></div><span class="fileName">'+fileName+" ("+k+l+')</span><span class="percentage"></span><div class="uploadifyProgress"><div id="'+a(this).attr("id")+h+'ProgressBar" class="uploadifyProgressBar"><!--Progress Bar--></div></div></div>')}});if(typeof(settings.onSelectOnce)=="function"){a(this).bind("uploadifySelectOnce",settings.onSelectOnce)}a(this).bind("uploadifyQueueFull",{action:settings.onQueueFull},function(h,i){if(h.data.action(h,i)!==false){globSelf._error('queueFullError', i, 'Warning')}});a(this).bind("uploadifyCheckExist",{action:settings.onCheck},function(m,l,k,j,o){var i=new Object();i=k;i.folder=e+j;if(o){for(var h in k){var n=h}}a.post(l,i,function(r){for(var p in r){if(m.data.action(m,l,k,j,o)!==false){var q=confirm("Do you want to replace the file "+r[p]+"?");if(!q){document.getElementById(a(m.target).attr("id")+"Uploader").cancelFileUpload(p,true,true)}}}if(o){document.getElementById(a(m.target).attr("id")+"Uploader").startFileUpload(n,true)}else{document.getElementById(a(m.target).attr("id")+"Uploader").startFileUpload(null,true)}},"json")});a(this).bind("uploadifyCancel",{action:settings.onCancel},function(l,h,k,m,j){if(l.data.action(l,h,k,m,j)!==false){var i=(j==true)?0:250;a("#"+a(this).attr("id")+h).fadeOut(i,function(){a(this).remove()})}});if(typeof(settings.onClearQueue)=="function"){a(this).bind("uploadifyClearQueue",settings.onClearQueue)}var c=[];a(this).bind("uploadifyError",{action:settings.onError},function(l,h,k,j){if(l.data.action(l,h,k,j)!==false){var i=new Array(h,k,j);c.push(i);a("#"+a(this).attr("id")+h+" .percentage").text(" - "+j.type+" Error");a("#"+a(this).attr("id")+h).addClass("uploadifyError")}});a(this).bind("uploadifyProgress",{action:settings.onProgress,toDisplay:settings.displayData},function(j,h,i,k){if(j.data.action(j,h,i,k)!==false){a("#"+a(this).attr("id")+h+"ProgressBar").css("width",k.percentage+"%");if(j.data.toDisplay=="percentage"){displayData=" - "+k.percentage+"%"}if(j.data.toDisplay=="speed"){displayData=" - "+k.speed+"KB/s"}if(j.data.toDisplay==null){displayData=" "}a("#"+a(this).attr("id")+h+" .percentage").text(displayData)}});a(this).bind("uploadifyComplete",{action:settings.onComplete},function(k,h,j,i,l){if(k.data.action(k,h,j,unescape(i),l)!==false){a("#"+a(this).attr("id")+h+" .percentage").text(" - Completed");a("#"+a(this).attr("id")+h).fadeOut(250,function(){a(this).remove()})}});if(typeof(settings.onAllComplete)=="function"){a(this).bind("uploadifyAllComplete",{action:settings.onAllComplete},function(h,i){if(h.data.action(h,i)!==false){c=[]}})}})},uploadifySettings:function(f,j,c){var g=false;a(this).each(function(){if(f=="scriptData"&&j!=null){if(c){var i=j}else{var i=a.extend(settings.scriptData,j)}var l="";for(var k in i){l+="&"+k+"="+escape(i[k])}j=l.substr(1)}g=document.getElementById(a(this).attr("id")+"Uploader").updateSettings(f,j)});if(j==null){if(f=="scriptData"){var b=unescape(g).split("&");var e=new Object();for(var d=0;d<b.length;d++){var h=b[d].split("=");e[h[0]]=h[1]}g=e}return g}},uploadifyUpload:function(b){a(this).each(function(){if(qq._flashUploaderQueue(''))document.getElementById(a(this).attr("id")+"Uploader").startFileUpload(b,false)})},uploadifyCancel:function(b){a(this).each(function(){document.getElementById(a(this).attr("id")+"Uploader").cancelFileUpload(b,true,false)})},uploadifyClearQueue:function(){qq._flashRemoveFromQueue('', true);a(this).each(function(){document.getElementById(a(this).attr("id")+"Uploader").clearFileUploadQueue(false)})}})})(jQuery)};


var qq = qq || {};
qq.FileUploader = function(o){
globSelf = this;
this._options = {
onlyInitCore: false,
element: null,
action: '/server/upload',
params: {},
frmAction: 'upload.php',
rmPreviosInput: true,
allowedExtensions: [], // ex. ['jpg', 'jpeg', 'png', 'gif'] or []
ExtDescriptions: '',
sizeLimit: 0,
limitFiles: 10,
onSubmit: function(id, fileName){},
onComplete: function(id, fileName, responseJSON){},
template:        '<div class="qq-uploader">' +
'<input type="hidden" value="1" id="nextId" />' +
'<input type="hidden" value="URL_J6CDFF13Q5" id="nextUrlId" />' +
'<div class="qq-upload-button"><img class="out-btn btn-browse-file" src="/images/pixel.gif" /></div>' +
'<img class="qq-browse-url-btn out-btn" src="/images/pixel.gif" />' +
'<span class="ring-file-props-container"></span>' +
'<div class="qq-upload-list" id="fileQueue"></div>' +
'<div id="uploadactions" style="display:none;">' +
'<a class="qq-upload-btn" href="javascript:void(0)">Upload Files</a> | '+
'<a class="qq-clear-queue-btn" href="javascript:void(0)">Cancel All Uploads</a>' +
'</div>' +
'<div class="qq-upload-drop-area" style="display: none;"><span>Drop files here to upload</span></div>' +
'</div>',
tplTitleUpload: '<div class="qq-upload-title">'+getLangString("msg_uploading_file")+'</div>',
fileTemplate:
'<div class="uploadifyQueueItem">' +
'<div class="qq-upload-title">'+getLangString("msg_uploading_file")+'</div>' +
'<div class="cancel qq-upload-cancel"><a href="javascript:void(0);">' +
'<img border="0" src="/images/upl/cancel2.png"/></a></div>' +
'<span class="qq-upload-file fileName"></span>&nbsp;<span class="qq-upload-size"></span>' +
'<span class="qq-upload-hints" style="display:none;"> - '+getLangString("msg_uploading_more_info")+'</span>' +
'<span class="percentage"/><div class="uploadifyProgress">' +
'<div class="uploadifyProgressBar"></div>' +
'</div></div>',
classes: {
button: 'qq-upload-button',
buttonUrl: 'qq-browse-url-btn',
buttonUpload: 'qq-upload-btn',
buttonClear: 'qq-clear-queue-btn',
fieldFile: 'qq-upload-field',
progress: 'uploadifyProgressBar',
drop: 'qq-upload-drop-area',
dropActive: 'qq-upload-drop-area-active',
list: 'qq-upload-list',
file: 'qq-upload-file',
spinner: 'qq-upload-spinner',
size: 'qq-upload-size',
cancel: 'qq-upload-cancel',
errhint: 'qq-upload-hints',
success: 'qq-upload-success',
fail: 'qq-upload-fail'
},
messages: getLangString("msg_uploading_texts"),
showMessage: function(message, title, back){
if ( !title ) title = getLangString("msg_uploading_error");
if ( !title ) title = "Upload Error"; 
dialog2.showBackWin(title, message, back);
},
isAttachedEventsBtns: false,
nextId: 0
};
qq._isCanUploadList = false;
qq._fileBuff = {};
qq.extend(this._options, o);
this._element = this._options.element;
if (this._element.nodeType != 1){
throw new Error('element param of FileUploader should be dom node');
}
if (!this._options.onlyInitCore) this._element.innerHTML = this._options.template;
this._filesInProgress = 0;
this._classes = this._options.classes;
if (!this._options.onlyInitCore) this._handler = this._createUploadHandler();
if (!this._options.onlyInitCore) this._bindCancelEvent();
var self = this;
if (!this._options.onlyInitCore) {
this._button = new qq.UploadButton({
element: this._getElement('button'),
frmAction: this._options.frmAction,
rmPreviosInput: this._options.rmPreviosInput,
onChange: function(input){
self._onInputChange(input);
}
});
}
var uploadUrl = this._getElement('buttonUrl');
qq.attach(uploadUrl, 'click', function(e) {
qq.showPromptURL(e);
});
if (!this._options.onlyInitCore) this._setupDragDrop();
};
qq.FileUploader.prototype = {
setParams: function(params){
this._options.params = params;
},
isUploading: function(){
return !!this._filesInProgress;
},
_getElement: function(parent, type){
if (typeof parent == 'string'){
type = parent;
parent = this._element;
}
var element = qq.getByClass(parent, this._options.classes[type])[0];
if (!element){
throw new Error('element not found ' + type);
}
return element;
},
_error: function(code, fileName, title, back, maxlfn){
var message = this._options.messages[code];
message = message.replace('{file}', this._formatFileName(fileName, maxlfn));
message = message.replace('{extensions}', this._options.ExtDescriptions);
message = message.replace('{limitFiles}', this._options.limitFiles);
message = message.replace('{sizeLimit}', this._formatSize(this._options.sizeLimit));
this._options.showMessage(message, title, back);
},
_formatFileName: function(name, maxlength){
name = $.uTF8Decode(name);
var max, dim;
if ( !maxlength ) {
max = 15;
dim = 7;
} else {
max = maxlength;
dim = parseInt(Math.round(max / 2));
}
if ( dim > 30 ) dim = 30;
if (name.length > maxlength){
name = name.slice(0, dim) + '...' + name.slice('-'+dim);
}
return name;
},
_isAllowedExtension: function(fileName){
var ext = (-1 !== fileName.indexOf('.')) ? fileName.replace(/.*[.]/, '').toLowerCase() : '';
var allowed = this._options.allowedExtensions;
if (!allowed.length){return true;}
for (var i=0; i<allowed.length; i++){
if (allowed[i].toLowerCase() == ext){
return true;
}
}
return false;
},
_addHistoryFileName: function(fileName, id, size, ifUrl){
var self = this;
qq.addHistoryFileName(self, fileName, id, size, ifUrl);
},
_removeFromHistory: function(id, fromHistory){
qq.removeFromHistory(id, fromHistory);
},
_setupDragDrop: function(){
function isValidDrag(e){
var dt = e.dataTransfer,
isWebkit = navigator.userAgent.indexOf("AppleWebKit") > -1;
return dt && dt.effectAllowed != 'none' &&
(dt.files || (!isWebkit && dt.types.contains && dt.types.contains('Files')));
}
var self = this, dropArea = this._getElement('drop');
dropArea.style.display = 'none';
var hideTimeout;
qq.attach($("div.upContainer").get(0), 'dragenter', function(e){
e.preventDefault();
});
qq.attach($("div.upContainer").get(0), 'dragout', function(e){dropArea.style.display = 'none';});
qq.attach($("div.upContainer").get(0), 'mouseout', function(e){dropArea.style.display = 'none';});
qq.attach(document, 'mouseup', function(e){setTimeout(function(){dropArea.style.display = 'none';}, 300);});
qq.attach($("div.upContainer").get(0), 'dragover', function(e){
if (isValidDrag(e)){
var highDrop = $(".qq-uploader").height();
$(dropArea).height(highDrop);
dropArea.style.display = 'block';
if (hideTimeout){
clearTimeout(hideTimeout);
}
if (dropArea == e.target || qq.contains(dropArea,e.target)){
var effect = e.dataTransfer.effectAllowed;
if (effect == 'move' || effect == 'linkMove'){
e.dataTransfer.dropEffect = 'move'; // for FF (only move allowed)
} else {
e.dataTransfer.dropEffect = 'copy'; // for Chrome
}
qq.addClass(dropArea, self._classes.dropActive);
e.stopPropagation();
} else {
dropArea.style.display = 'block';
e.dataTransfer.dropEffect = 'none';
}
e.preventDefault();
}
});
qq.attach($("div.upContainer").get(0), 'dragleave', function(e){
if (isValidDrag(e)){
if (dropArea == e.target || qq.contains(dropArea,e.target)){
qq.removeClass(dropArea, self._classes.dropActive);
e.stopPropagation();
} else {
if (hideTimeout){
clearTimeout(hideTimeout);
}
hideTimeout = setTimeout(function(){
dropArea.style.display = 'none';
}, 77);
}
}
});
qq.attach(dropArea, 'drop', function(e){
dropArea.style.display = 'none';
self._uploadFileList(e.dataTransfer.files);
e.preventDefault();
});
},
_createUploadHandler: function(){
var self = this,
handlerClass;
if ( qq.UploadHandlerXhr.isSupported() ) {
handlerClass = 'UploadHandlerXhr';
globSelf.handlerClass = 'UploadHandlerXhr';
} else {
handlerClass = 'UploadHandlerForm';
globSelf.handlerClass = 'UploadHandlerForm';
}
var handler = new qq[handlerClass]({
action: this._options.action,
onProgress: function(id, fileName, loaded, total, SaveXhr, anime){
self._updateProgress(id, loaded, total, SaveXhr, anime);
},
onComplete: function(id, fileName, result, SaveXhr){
self._filesInProgress--;
if ( SaveXhr )
{
qq.onCompleteServe('{"success":true,"id":"'+(id + 1)+'"}');
}
}
});
return handler;
},
_onInputChange: function(input){
var preRes = true;
if (this._handler instanceof qq.UploadHandlerXhr){
preRes = this._uploadFileList(input.files, input);
if ( $.browser.chrome || $.browser.safari || ( $.browser.chrome && $.browser.safari ) ) {
return;
}
} else {
if (this._validateFile(input)){
this._uploadFile(input);
}
}
var cVer = $.browser.codeversion.replace(/\./g, '');
cVer = cVer.substr(0, 2);
if ( preRes && cVer < 36 ) this._button.reset();
},
_uploadFileList: function(files, input){
var valid = true;
var i = files.length;
while (i--){
if (!this._validateFile(files[i])){
valid = false;
//break;
}
else
{
this._uploadFile(files[i]);
}
}
var cVer = $.browser.codeversion.replace(/\./g, '');
cVer = cVer.substr(0, 2);
if ( ( $.browser.firefox && cVer >= 36 ) || $.browser.chrome || $.browser.safari || ( $.browser.chrome && $.browser.safari ) ) {
setTimeout(function(){$(input).val("");}, 100);
}
return true;
},
_uploadFile: function(fileContainer){
var id = this._handler.add(fileContainer);
var name = this._handler.getName(id);
this._addToList(id, name);
this._handler.upload(id, this._options.params);
},
_validateFile: function(file){
var name,size;
if ( typeof(filesNum) != "undefined" ) {
if ( filesNum > 0 ){
//backToUpload();
}
}
if (file.value){
name = file.value.replace(/.*(\/|\\)/, "");
} else {
name = file.fileName != null ? file.fileName : file.name;
size = file.fileSize != null ? file.fileSize : file.size;
}
if ( qq._count(qq._fileBuff) >= this._options.limitFiles ){
this._error('filelimitError', name);
return false;
} else if (! this._isAllowedExtension(name)){
this._error('typeError',name);
return false;
} else if (size === 0){
this._error('emptyError',name);
return false;
} else if (size && this._options.sizeLimit && size > this._options.sizeLimit){
this._error('sizeError',name);
return false;
} else if (this._isPresentInList(name)){
this._error('samefileError',name);
return false;
}
var ext = (-1 !== name.indexOf('.')) ? name.replace(/.*[.]/, '').toLowerCase() : '';
setFileProps({name: name, size: size, type: ext});
var idx = qq._getNextFileId();
this._addHistoryFileName(name, idx, size);
if (!this._options.isAttachedEventsBtns) this._attachBtnsEvents();
return true;
},
_attachBtnsEvents: function(){
var self = this;
var uploadBtn = this._getElement('buttonUpload');
var clearBtn = this._getElement('buttonClear');
qq.attach(uploadBtn, 'click', function(e) {
if ( globSelf.dirIsSet == '1' ) {
self._startUploadByQueue(e);
} else {
globSelf.dirIsSet = 1;
folder = randomString();
$("#folder").val(folder);
setTimeout(function(){self._startUploadByQueue(e);}, 80);
}
});
qq.attach(clearBtn, 'click', function(e) {
globSelf.dirIsSet = '';
self._clearQueueUpload(e);
});
this._options.isAttachedEventsBtns = true;
},
_startUploadByQueue: function(e){
var self = this;
if ( typeof $("#fileQueue div.uploadifyQueueItem[_x_inprocess='yes']").attr("id") != "undefined" ) {
setTimeout(function(){globSelf._startUploadByQueue();}, 400);
return;
}
if ( !globSelf._isCanUploadList ) return;
if ( 0 == qq._count(qq._fileBuff) || "0" == qq._count(qq._fileBuff) || !qq._count(qq._fileBuff) ) {
globSelf.submitQueue = false;
globSelf._isCanUploadList = true;
return;
}
if ( !globSelf.submitQueue || typeof(globSelf.submitQueue) == 'undefined' )
{
$("#fileQueue div.uploadifyQueueItem").each(
function(num, elm){
if ( $(this).attr("_x_inprocess") == "yes" ) return;
var itemID = $(this).attr("id");
var idx = parseInt(itemID) ? itemID : itemID;
var data = qq._fileBuff[itemID];
if ( typeof data == 'undefined' ) return;

if ( data.submit ) return;
if ( globSelf.submitQueue ) return;
if ( idx == globSelf.submitedID ) return;
if ( data.name )
{
$(this).attr("_x_inprocess", "yes");
if ( !data.remotefile || data.remotefile == 'false' )
{
var cVer = $.browser.codeversion.replace(/\./g, '');
cVer = cVer.substr(0, 2);
if ( ( $.browser.firefox && cVer >= 36 ) || $.browser.chrome || $.browser.safari || ( $.browser.chrome && $.browser.safari ) )
{
self._handler.upload(idx - 1, self._options.params, true);
}
else
{
if ( !qq.UploadHandlerXhr.isSupported() )
{
var fID  = '<input type="hidden" name="elemID" value="'+idx+'" />';
fID += '<input type="hidden" name="UPLOAD_IDENTIFIER" value="'+qq.getRand()+'"/>"';
fID = $(fID);
$("form[name='qqform_frame_"+idx+"']")
.append(fID)
.submit();
}
else
{
if ( $.browser.msie || $.browser.opera || ( $.browser.firefox && cVer < 36 ) )
{
$("form[name='form_frame_"+idx+"']").submit();
}
}
qq.startCheckProgress(idx);
}
}
else
{
if ( data.remotefile )
{
qq.startUploadURLFile(idx);
}
}
if ( typeof data != 'undefined' )
{
data.submit = 1;
data.submited = 0;
}
globSelf.submitedID = idx;
globSelf.submitQueue = true;
}
}
);
}
},
_removeFileFromQueue: function(elem, idx, hist){
qq.removeFileFromQueue(elem, idx, hist);
},
_clearQueueUpload: function(e){
var self = this;
$(".qq-upload-button form[name*='form_frame_']").each(
function(idx, elm) {
if ( qq._count(qq._fileBuff) || qq._count(qq._fileBuff) != "0" ) { 
var fileName = $.trim($("input[name='file']", this).val());
if ( "" != fileName )
{
var cntForms = eval(($(".qq-upload-button").get(0).getElementsByTagName('form')).length);
if ( cntForms > 1 && !$.browser.msie && !$.browser.opera && !$.browser.chrome && !$.browser.safari )
{
var frameName = $(this).attr('target');
$(this).remove();
$("iframe[name='"+frameName+"']").remove();
}
}
}
}
);
for ( key in qq._fileBuff )
{
self._handler.cancel(key, "qq.removeFromHistory");
if ( globSelf.handlerClass == 'UploadHandlerXhr' ) {
self._handler.cancel(key, "qq.removeFromHistory");
} else {
self._handler.cancel(key);
self._removeFromHistory(key);
}
delete qq._fileBuff[key];
}
if ( !qq._count(qq._fileBuff) && uploadType == 'FAKE' ) {
self._button._createInput();
qq._fileBuff = {};
}
globSelf.submitQueue = false;
globSelf._isCanUploadList = true;
},
_isPresentInList: function(fileName){
for ( key in qq._fileBuff ){
if ( qq._fileBuff[key].name == fileName ) return true;
}
return false;
},
_addToList: function(id, fileName){
var self = this;
var item = qq.toElement(this._options.fileTemplate);
item.qqFileId = id;
var prevID = 0;
if ( id >= 0 || parseInt(id) ) prevID = id + 1;
else prevID = parseInt(id.replace("qq-upload-handler-iframe", "")) + 1;
item.id = prevID;
var fileElement = this._getElement(item, 'file');
qq.setText(fileElement, this._formatFileName(fileName));
this._getElement(item, 'size').innerHTML = '<img class="loading" src="/images/upl/loading.gif" />';
qq.attach(this._getElement(item, 'cancel'), 'click', function(e){
e = e || window.event;
var target = e.target || e.srcElement;
if ( $(target).parent().parent().hasClass(self._classes.cancel) )
{
qq.preventDefault(e);
var idx = $(target).parent().parent().parent().attr("id");
self._handler.cancel(idx);
$(item).fadeOut(200);
self._removeFileFromQueue(target, idx, true);
$("#blockingButtonsShape").hide();
}
});
this._getElement('list').appendChild(item);
this._filesInProgress++;
},
_updateProgress: function(id, loaded, total, SaveXhr, anime){
if ( loaded >= total )
{
var item = this._getItemByFileId(id);
var size = this._getElement(item, 'size');
var text = this._formatSize(total);
if ( !SaveXhr ) qq.setText(size, '('+text+')');
}
if ( SaveXhr ) qq.setProgressBar(id + 1, loaded, total, '', anime);
},
_formatSize: function(bytes){
var i = -1;
do {
bytes = bytes / 1024;
i++;
} while (bytes > 1024);
return Math.max(bytes, 0.1).toFixed(2) + ['kB', 'MB', 'GB', 'TB', 'PB', 'EB'][i];
},
_getItemByFileId: function(id){
var item = this._getElement('list').firstChild;
while (item){
if (item.qqFileId == id){
return item;
}
item = item.nextSibling;
}
},
_bindCancelEvent: function(){
var self = this,
list = this._getElement('list');
qq.attach(list, 'click', function(e){
e = e || window.event;
var target = e.target || e.srcElement;
if (qq.hasClass(target, self._classes.cancel)){
qq.preventDefault(e);
var item = target.parentNode;
self._handler.cancel(item.qqFileId);
qq.remove(item);
$("#blockingButtonsShape").hide();
}
});
},
_getIframeContentJSON: function(iframe){
var doc = iframe.contentDocument ? iframe.contentDocument: iframe.contentWindow.document,
response;
try{
response = eval("(" + doc.body.innerHTML + ")");
} catch(err){
response = {};
}
return response;
}
};
qq.UploadButton = function(o){
this._options = {
element: null,
multiple: false,
name: 'file',
frmName: 'uForm',
frmAction: 'upload.php',
rmPreviosInput: true,
onChange: function(input){},
hoverClass: 'qq-upload-button-hover',
focusClass: 'qq-upload-button-focus'
};
qq.extend(this._options, o);
this._element = this._options.element;
qq.css(this._element, {
position: 'relative',
overflow: 'hidden',
direction: 'ltr'
});
this._input = this._createInput();
};
qq.UploadButton.prototype = {
getInput: function(){
return this._input;
},
reset: function(){
qq.removeClass(this._element, this._options.focusClass);
this._input = this._createInput();
},
_createInput: function(){
var self = this;
var ID = qq._getNextFileId(true);
var input = document.createElement("input");
var uplIdent = document.createElement("input");
var params = "";
if ( !$.browser.msie && !$.browser.opera )
{
var fID = document.createElement("input");
var iframe = this._createIframe(ID);
var form = this._createForm(iframe, params);
}
qq.addClass(input, 'qq-upload-field');
input.setAttribute("type", "file");
input.setAttribute("name", this._options.name);
qq.css(input, {
position: 'absolute',
right: 0,
top: 0,
zIndex: 1,
fontSize: '4em',
margin: 0,
padding: 0,
cursor: 'pointer',
opacity: 0
});
if ( !$.browser.msie && !$.browser.opera )
{
form.appendChild(input);
fID.setAttribute("type", "hidden");
fID.setAttribute("name", "elemID");
fID.value = ID;
form.appendChild(fID);
uplIdent.setAttribute("type", "hidden");
uplIdent.setAttribute("name", "UPLOAD_IDENTIFIER");
uplIdent.value = qq.getRand();
form.appendChild(uplIdent);
this._element.appendChild(form);
this._element.appendChild(iframe);
}
else
{
this._element.appendChild(input);
}
qq.attach(input, 'change', function(){
self._options.onChange(input);
if ( !$.browser.msie && !$.browser.opera && !$.browser.firefox ) {
self.reset();
}
});
return input;
},
_createIframe: function(id){
var iframe = qq.toElement('<iframe src="javascript:\'\';" name="frame_' + id + '"> </iframe>');
iframe.setAttribute('id', 'frame_'+id);
iframe.style.display = 'none';
document.body.appendChild(iframe);
return iframe;
},
_createForm: function(iframe, params){
if ( isMob == 'true' ) {
$("img.buttons_110").remove();
var form = qq.toElement('<form method="post" enctype="multipart/form-data" style="display:none;visibility:hidden;"> </form>');
} else {
var form = qq.toElement('<form method="post" enctype="multipart/form-data"> </form>');
}
var queryString = '?';
for (var key in params){
queryString += '&' + key + '=' + encodeURIComponent(params[key]);
}
queryString += '&x='+qq.getRand();
form.setAttribute('action', this._options.frmAction + queryString);
form.setAttribute('target', iframe.name);
form.setAttribute('name', 'form_'+iframe.id );
return form;
}
};
qq.UploadHandlerForm = function(o){
this._options = {
action: '/upload',
onComplete: function(id, fileName, response){}
};
qq.extend(this._options, o);
this._inputs = {};
};
qq.UploadHandlerForm.prototype = {
add: function(fileInput){
fileInput.setAttribute('name', 'qqfile');
var id = 'qq-upload-handler-iframe' + qq.getUniqueId();
this._inputs[id] = fileInput;
if (fileInput.parentNode){
//qq.remove(fileInput);
}
return id;
},
upload: function(id, params){
var input = this._inputs[id];
var fID = parseInt(id.replace("qq-upload-handler-iframe", "")) + 1;
if (!input){
throw new Error('file with passed id was not added, or already uploaded or cancelled');
}
var fileName = this.getName(id);
var iframe = this._createIframe(id);
var form = this._createForm(iframe, params);
form.appendChild(input);
var self = this;
this._attachLoadEvent(iframe, function(){
var res = self._getIframeContentJSON(iframe);
if ( !res ) qq.onCompleteServe('{"id":"'+$(iframe).attr('id')+'"}');
if ( res.id )
{
var size = qq._fileBuff[res.id]['size'];
$("div#"+res.id+" span.qq-upload-size").text("("+qq.formatSize(size)+")");
qq.onCompleteServe(res);
}
else
{
$("div#"+fID+" span.qq-upload-size").text("("+qq.formatSize(res.size)+")");
qq._fileBuff[fID]['size'] = res.size;
qq._unlockQueue();
}
});
if ( !qq._fileBuff[fID]['submited'] )
{
qq._lockQueue();
form.submit();
qq._fileBuff[fID]['submited'] = 1;
}
return id;
},
cancel: function(id){
var iframe = document.getElementById("qq-upload-handler-iframe"+(id - 1));
if (iframe)
{
iframe.setAttribute('src', "javascript:'';");
$("#qq-upload-handler-iframe"+(id - 1)).remove();
$("form[name='qqform_frame_"+id+"']").remove();
}
},
getName: function(id){
return this._inputs[id].value.replace(/.*(\/|\\)/, "");
},
getSize: function(id){
var file = this._inputs[id];
return file.fileSize != null ? file.fileSize : file.size;
},
_attachLoadEvent: function(iframe, callback){
qq.attach(iframe, 'load', function(){
if (!iframe.parentNode){
return;
}
if (iframe.contentDocument &&
iframe.contentDocument.body &&
iframe.contentDocument.body.innerHTML == "false"){
return;
}
callback();
});
},
_getIframeContentJSON: function(iframe){
var doc = iframe.contentDocument ? iframe.contentDocument: iframe.contentWindow.document,
response;
try{
response = eval("(" + doc.body.innerHTML + ")");
} catch(err){
response = {};
}
return response;
},
_createIframe: function(id){
var sID = qq._getNextFileId(true) - 1;
var iframe = qq.toElement('<iframe src="javascript:\'\';" id="'+sID+'" name="'+id+'" />');
iframe.setAttribute('id', id);
iframe.style.display = 'none';
document.body.appendChild(iframe);
return iframe;
},
_createForm: function(iframe, params){
var sID = qq._getNextFileId(true) -1;
var form = qq.toElement('<form method="post" enctype="multipart/form-data"></form>');
var queryString = '?';
for (var key in params){
queryString += '&' + key + '=' + encodeURIComponent(params[key]);
}
queryString += '&x='+qq.getRand();
form.setAttribute('name', 'qqform_frame_'+sID);
form.setAttribute('action', this._options.action + queryString);
form.setAttribute('target', iframe.name);
form.style.display = 'none';
document.body.appendChild(form);
return form;
}
};
qq.UploadHandlerXhr = function(o){
this._options = {
action: '/upload',
onProgress: function(id, fileName, loaded, total, SaveXhr){},
onComplete: function(id, fileName, response, forseSave){}
};
qq.extend(this._options, o);
this._files = [];
this._xhrs = [];
};
qq.UploadHandlerXhr.isSupported = function(){
return typeof File != "undefined" &&
typeof (new XMLHttpRequest()).upload != "undefined";
};
qq.UploadHandlerXhr.prototype = {
add: function(file){
var ID = this._files.push(file);
return ID - 1;
},
upload: function(id, params, forseSave){
var file = this._files[id],
name = this.getName(id),
size = this.getSize(id);
if ( typeof file.name == 'undefined' ) file.name = name;
if ( typeof file.size == 'undefined' ) file.size = size;
if ( typeof file.mozFullPath == 'undefined' ) file.mozFullPath = "";
if (!file){
throw new Error('file with passed id was not added, or already uploaded or cancelled');
}
var xhr = this._xhrs[id] = new XMLHttpRequest();
var self = this;
xhr.upload.addEventListener('progress', function(event) {
if (event.lengthComputable) {
var SaveXhr = false;
if ( forseSave ) SaveXhr = true;
var loaded = event.loaded;
var total = event.total;
if ( loaded >= total ) {if(!$.browser.chrome){qq.showProcessingWindow();return;}}
var globLoaded = 0;
if ( typeof(qq._fileBuff[(id + 1)]) != 'undefined' && typeof(qq._fileBuff[(id + 1)]['loaded']) == 'undefined' ) {
qq._fileBuff[(id + 1)]['loaded'] = loaded;
if ( loaded > parseInt(total / 2) ) {
globSelf.isSOKS = true;
self._options.onProgress(id, name, loaded, total, SaveXhr, true);
} else {
self._options.onProgress(id, name, loaded, total, SaveXhr);
}	
} else {
if ( typeof(qq._fileBuff[(id + 1)]) != 'undefined' && typeof(qq._fileBuff[(id + 1)]['loaded']) != 'undefined' ) {
globLoaded = qq._fileBuff[(id + 1)]['loaded'];
if ( globSelf.isSOKS || globLoaded > parseInt(total / 2) ) {
globSelf.isSOKS = true;
self._options.onProgress(id, name, loaded, total, SaveXhr, true);
} else {
self._options.onProgress(id, name, loaded, total, SaveXhr);
}
}
}
}
}, false);
xhr.onreadystatechange = function(){
if (!self._files[id]){
return;
}
if (xhr.readyState == 4){
var response = {};
self._options.onProgress(id, name, size, size);
if (forseSave && (!xhr.status || xhr.status == '0' || !$.trim(xhr.responseText)) ) {
response = '{"id":'+(id + 1)+', "error":"'+globSelf._options.messages.serverError2+'"}';
qq.onCompleteServe(response);
self._files[id] = null;
self._xhrs[id] = null;
qq._unlockQueue();
return;
}
if (xhr.status != 200){
try{
var errCode = parseInt(xhr.status);
if ( typeof globSelf._options.messages['serverError'+errCode] != "undefined" ) {
response = '{"id":'+(id + 1)+', "error":"'+globSelf._options.messages['serverError'+errCode]+'"}';
} else {
response = '{"id":'+(id + 1)+', "error":"'+globSelf._options.messages.serverError+'"}';
}
qq.onCompleteServe(response);
self._files[id] = null;
self._xhrs[id] = null;
qq._unlockQueue();
} catch(e) {}
return;
}
if (xhr.status == 200){
try {
response = eval("(" + xhr.responseText + ")");
} catch(err){
}
if ( forseSave ) self._options.onComplete(id, name, response, forseSave);
setTimeout(function(){globSelf._startUploadByQueue();}, 800);
} else {
if ( forseSave ) self._options.onComplete(id, name, response, forseSave);
}
if ( forseSave )
{
self._files[id] = null;
self._xhrs[id] = null;
}
qq._unlockQueue();
}
};
var queryString  = '&fileID='+(id + 1);
queryString += '&qqfile='+encodeURIComponent(name);
queryString += '&summ='+qq._fileBuff[(id + 1)].summ;
queryString += '&size='+size;
if ( forseSave ) queryString += '&save=SaveXhr';
for (var key in params){
queryString += '&' + key + '=' + encodeURIComponent(params[key]);
}
queryString += '&x='+qq.getRand();
xhr.open("POST", this._options.action + queryString, true);
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xhr.setRequestHeader("X-File-Name", file.name);
if ( forseSave ) xhr.setRequestHeader("Content-Type", "text/plain");
if ( forseSave ) xhr.send(file);
else xhr.send(null);
},
cancel: function(id, func){
var preID = id;
id = id - 1;
this._files[id] = null;
if (this._xhrs[id]){
this._xhrs[id].abort();
this._xhrs[id] = null;
}
if ( func ) {
eval ( func+"("+preID+", true);" );
}
},
getName: function(id){
var file = this._files[id];
if (typeof(file)=="undefined" || file == null) return;
return (file.fileName) ? file.fileName : file.name;
},
getSize: function(id){
var file = this._files[id];
if (typeof(file)=="undefined" || file == null) return;
return file.fileSize != null ? file.fileSize : file.size;
}
};
qq.extend = function(obj1, obj2){
for (var prop in obj2){
obj1[prop] = obj2[prop];
}
};
qq.getUniqueId = (function(){
var id = 0;
return function(){
return id++;
};
})();
qq.attach = function(element, type, fn){
if (element.addEventListener){
element.addEventListener(type, fn, false);
} else if (element.attachEvent){
element.attachEvent('on' + type, fn);
}
};
qq.detach = function(element, type, fn){
if (element.removeEventListener){
element.removeEventListener(type, fn, false);
} else if (element.attachEvent){
element.detachEvent('on' + type, fn);
}
};
qq.preventDefault = function(e){
if (e.preventDefault){
e.preventDefault();
} else{
e.returnValue = false;
}
};
qq.insertBefore = function(a, b){
b.parentNode.insertBefore(a, b);
};
qq.remove = function(element){
element.parentNode.removeChild(element);
};
qq.contains = function(parent, descendant){
if (parent.contains){
return parent.contains(descendant);
} else {
return !!(descendant.compareDocumentPosition(parent) & 8);
}
};
qq.toElement = (function(){
var div = document.createElement('div');
return function(html){
div.innerHTML = html;
var element = div.firstChild;
div.removeChild(element);
return element;
};
})();
qq.css = function(element, styles){
if (styles.opacity != null){
if (typeof element.style.opacity != 'string' && typeof(element.filters) != 'undefined'){
styles.filter = 'alpha(opacity=' + Math.round(100 * styles.opacity) + ')';
}
}
qq.extend(element.style, styles);
};
qq.hasClass = function(element, name){
var re = new RegExp('(^| )' + name + '( |$)');
return re.test(element.className);
};
qq.addClass = function(element, name){
if (!qq.hasClass(element, name)){
element.className += ' ' + name;
}
};
qq.removeClass = function(element, name){
var re = new RegExp('(^| )' + name + '( |$)');
element.className = element.className.replace(re, ' ').replace(/^\s+|\s+$/g, "");
};
qq.setText = function(element, text){
element.innerText = text;
element.textContent = text;
};
qq.children = function(element){
var children = [],
child = element.firstChild;
while (child){
if (child.nodeType == 1){
children.push(child);
}
child = child.nextSibling;
}
return children;
};
qq.getByClass = function(element, className){
if (typeof element == 'undefined') return []
if (element.querySelectorAll){
return element.querySelectorAll('.' + className);
}
var result = [];
var candidates = element.getElementsByTagName("*");
var len = candidates.length;
for (var i = 0; i < len; i++){
if (qq.hasClass(candidates[i], className)){
result.push(candidates[i]);
}
}
return result;
};
qq.formatSize = function(bytes, ed, space){
var i = -1;
do {
bytes = bytes / 1024;
i++;
} while (bytes > 1024);
if ( !ed ) {
	if ( !space )
		return Math.max(bytes, 0.1).toFixed(2) + ['kB', 'MB', 'GB', 'TB', 'PB', 'EB'][i];
	else 
		return Math.max(bytes, 0.1).toFixed(2) + ' ' + ['kB', 'MB', 'GB', 'TB', 'PB', 'EB'][i];
}
else return Math.max(bytes, 0.1);
};
qq.getRand = function(){
var rand = Math.random().toString();
return rand.substring(2);
};
qq._getNextFileId = function(notIncrease){
var preValue = document.getElementById("nextId").value;
if ( !notIncrease ) document.getElementById("nextId").value++;
return preValue;
};
qq._getNextURLId = function(notIncrease){
var hash = 'URL_';
var preValue = document.getElementById("nextUrlId").value;
if ( !notIncrease )
{
for (var c=0;c<10;c++)
{
var numm = (Math.random() * (c+1) ).toString();
var base64 = jQuery.base64Encode(numm);
hash += base64.substring(c+3, c+4);
}
document.getElementById("nextUrlId").value = hash.toUpperCase();
}
return preValue;
};
qq._count = function(obj){
var len = 0;
for (var k in obj) len++;
return len;
};
qq._lockQueue = function(){
var self = globSelf;
self._isCanUploadList = false;
};
qq._unlockQueue = function(){
var self = globSelf;
self._isCanUploadList = true;
};
qq.getFileName = function(file){
return $(file).val();
};
qq.removeFileFromQueue = function(elem, idx, fromHistory){
idx = idx ? idx : $(elem).parent().parent().parent().attr("id");
if ( idx )
{
if ( typeof qq._fileBuff[idx] == 'undefined' ) return;
setTimeout('$("div#'+idx+'").remove();', 2000);
var cVer = $.browser.codeversion.replace(/\./g, '');
cVer = cVer.substr(0, 2);
if ( !qq._fileBuff[idx]['remotefile'] && $.browser.firefox && cVer < 36 ) //!$.browser.msie && !$.browser.opera && !$.browser.chrome && !$.browser.safari )
{
var frm = $(".qq-upload-button form[name='form_frame_"+idx+"']");
$(frm).attr("method", "GET").remove();
$("#frame_"+idx).attr("name", "NONE").remove();
}
if ( qq._fileBuff[idx]['submit'] )
{
try{
globSelf._handler.cancel(idx - 1);
} catch(e) {}
globSelf.submitQueue = false;
globSelf._startUploadByQueue();
}
qq.removeFromHistory(idx, fromHistory);
globSelf.submitQueue = false;
globSelf._isCanUploadList = true;
}
if ( qq._count(qq._fileBuff) <= 0 ) {
globSelf.dirIsSet = '';
globSelf._clearQueueUpload();
}
};
qq.addHistoryFileName = function(obj, fileName, id, size, ifUrl){
obj._options.nextId++;
var fileNumm = parseInt(obj._options.nextId);
qq._fileBuff[id] = { //fileNumm] = {
"name": fileName,
"size": size,
"submit" : '',
"submited" : '',
"remotefile" : ( ifUrl ) ? ifUrl : false,
"summ" : randomString(10)
};
$("form[name='form_frame_"+id+"'] input[name='UPLOAD_IDENTIFIER']").val(qq._fileBuff[id].summ);	
var newAct = $("form[name='form_frame_"+id+"']").attr("action");
$("form[name='form_frame_"+id+"']").attr("action", newAct+"&UPLOAD_IDENTIFIER="+qq._fileBuff[id].summ);
$("#blockingButtonsShape").show();
};
qq.removeFromHistory = function(id, fromServerHistory){
if ( typeof(qq._fileBuff[id]) == 'undefined' ) return false;
try
{
if ( fromServerHistory ) {
var params = '?req=delete&fileID='+id;
if ( qq._fileBuff[id]['submit'] == '1' ) {
params += '&blockit=1';
}
if ( qq._fileBuff[id]['remotefile'] )
params = '?remotefile=true&req=delete&fileID='+id;
$.ajax({
url: globSelf._options.action + params,
type: 'GET'
});
}
if ( typeof qq._fileBuff[id] != 'undefined' ) {
qq._fileBuff[id] = "";
delete qq._fileBuff[id];
}
if ( typeof window.sizeBKP != 'undefined' )
if ( typeof window.sizeBKP[id] != 'undefined' )
window.sizeBKP[id] = 0;
} catch(e) {}
};
qq.startCheckProgress = function(id, force, loaded, cntHits){
if ( typeof qq._fileBuff[id] == 'undefined' ) return;
var size = qq._fileBuff[id]['size'];
if ( qq._fileBuff[id]['remotefile'] )
{
if ( size > loaded )
{
qq.setProgressBar(id, loaded, size);
}
else
{
qq.setProgressBar(id, 100, 100, '', '', true);
}
return;
}
var now = 0; // = loaded ? loaded : Math.round(size / decim);
var fileSumm = qq._fileBuff[id]['summ'];
$.ajax({
url: ENV.uploaderScript+'?action=uploadfakeservices_'+$.sessid+'&remotefile=false&fileID='+id+'&req=check',
type: 'POST',
data: 'summ='+fileSumm+'&UPLOAD_IDENTIFIER='+qq._fileBuff[id].summ,
success: function(data) {
var res = eval('('+data+')');
now = res.sizenow;
if ( typeof qq._fileBuff[id]['loaded'] != 'undefined' ) {
if ( now == 0 || !now ) {
if ( cntHits >= 5 ) {
try{clearTimeout(window.delay);}catch(e){}
qq.setProgressBar(id, 100, 100, '', '', true);
qq.onCompleteServe('{"success":true,"id":"'+id+'"}');
return;
}
cntHits++;
window.delay = setTimeout(function(){qq.startCheckProgress(id, true, now, cntHits);}, 500);
return;
}
}
if ( isNaN(parseInt(now)) ) {		
if ( now != 0 ) qq._fileBuff[id]['loaded'] = now;
}
if ( now == loaded ) {
if ( cntHits >= 5 ) {
try{clearTimeout(window.delay);}catch(e){}
qq.setProgressBar(id, 100, 100, '', '', true);
qq.onCompleteServe('{"success":true,"id":"'+id+'"}');
return;
}
cntHits++;
window.delay = setTimeout(function(){qq.startCheckProgress(id, true, now, cntHits);}, 500);
return;
}
if ( size > now )
{
if ( now > size ) now = size;
qq.setProgressBar(id, now, size);
window.delay = setTimeout(function(){qq.startCheckProgress(id, true, now);}, 1000);
}
else
{
try{clearTimeout(window.delay);}catch(e){}
qq.setProgressBar(id, 100, 100, '', '', true);
qq.onCompleteServe('{"success":true,"id":"'+id+'"}');
}
}
});
};
qq.getDecim = function(bytes){
var i = -1;
do {
bytes = bytes / 1024 / 5;
i++;
} while (bytes > 100);
return Math.max(bytes, 0.1).toFixed(2);
};
qq.getStampStr = function(){
var dd = new Date();
var ms = dd.getHours()+':'+dd.getMinutes()+':'+dd.getSeconds()+':'+dd.getMilliseconds();
return ms.replace(/:/g, "");
};
qq.speedTest = function(){
var stmp = qq.getStampStr();
var point1 = 0;
var rr = new XMLHttpRequest();
rr.open("POST", '/upload/server/', true);
rr.send(null);
};
qq.setProgressBar = function(id, loaded, total, fatal, anime, hard){
	var percents = 100;
	var txtSize = qq.formatSize(total);
	if ( qq.formatSize(total, true) <= 0.1 ) {
		txtSize = qq.formatSize($.globLoadSize);
	} else {
		$.globLoadSize = total;
	}
	txtSize = '('+ txtSize +') -';
	var text = "";try{clearInterval($.animateDelay);delete $.animateDelay;} catch(e) {}
	if ( anime ) {
		if ( loaded == total && !fatal && !$.browser.chrome ) {
			try{clearInterval($.animateDelay);delete $.animateDelay;} catch(e) {}
			text = txtSize+' 100%';
			$("div#"+id+" div.uploadifyProgressBar").attr("style", "");
			$("div#"+id+" span.qq-upload-size").text(text);
			return;
		}
		else {
			//$("div#"+id+" div.uploadifyProgressBar").attr("style", "width: 100%; background-color: rgb(255, 255, 255); background-image: url(/images/progress-bar.gif);");
			//text = txtSize+' Uploading';
			//$("div#"+id+" span.qq-upload-size").text(text);
			$.animatePerc = 1;
			$.percAnime = parseInt(total / 1024 / 2) - 200;
			if ( $.percAnime < 100 ) $.percAnime = 100;
			if ( typeof $.animateDelay == "undefined" )
			$.animateDelay = setInterval(function(){
				var prePerc = $.animatePerc;
 				if ( prePerc > 100 ) prePerc = 100;
				$("div#"+id+" div.uploadifyProgressBar").width(prePerc+'%');
				$("div#"+id+" span.qq-upload-size").text(txtSize+' '+prePerc+'%');
				var incRand = parseInt((Math.random() * (5 - 1) + 1).toString()[0]);
				$.animatePerc+=incRand;
                if ( $.animatePerc >= 100 ) {
                    try{clearInterval($.animateDelay);delete $.animateDelay;} catch(e) {}
					$("div#"+id+" span.qq-upload-size").text(txtSize+' 100%');
                    $("div#"+id+" div.uploadifyProgressBar").attr("style", "width: 100%; background-color: rgb(255, 255, 255); background-image: url(/images/progress-bar.gif);");
                    return;
                }
			}, $.percAnime);
		}
		return;
	}

	if ( total > loaded )
	{
		percents = Math.round(loaded / total * 100);
		if ( percents <= 1 ) percents = 1;
		if ( percents >= 100 && !fatal ) text = txtSize+' 100%';
		else text = txtSize+' '+Math.round(loaded / total * 100)+'%';
	}
	if ( percents >= 100 && !fatal ) text = txtSize+' 100%';
	else if ( fatal ) text = txtSize+' 0% ';
	if ( percents == 0 ) percents = 100;
	$("div#"+id+" span.qq-upload-size").text(text);
	$("div#"+id+" div.uploadifyProgressBar").width(percents+'%');
};
qq.showProcessingWindow = function(){
$.isSlowlyUpProc = true;
setTimeout(function(){$("div.uploadifyQueueItem").fadeOut(100);}, 800);
};
qq.onCompleteServe = function(params){
try{clearTimeout(window.delay)}catch(e){}
if ( typeof params != 'object' )
var res = eval('('+params+')');
else
var res = params;
var ID = res.id;
var message = 'Undefined server error!<br>Please try again.';
if ( res.error ) message = res.error;
else if ( res.problem ) message = res.problem;
globSelf.submitQueue = false;
if ( res.success )
{
qq.setProgressBar(ID, 100, 100, '', '', true);
qq.removeFileFromQueue('', ID, false);
globSelf._options.onAllComplete(ID);
}
else
{
if ( ID )
{
$("div#"+ID).removeClass("qq-upload-success").addClass("uploadifyError");
$("div#"+ID+" span.qq-upload-hints")
.attr("hint", message)
.show();
qq.setHintsForElement($("div#"+ID+" span.qq-upload-hints"));
$("div#"+ID+" div.uploadifyProgressBar").css("background", "red");
qq.setProgressBar(ID, 100, 100, true, '', true);
}
globSelf._options.onAllComplete();
}
};
qq.showPromptURL = function(event, type) {
var self = globSelf;
this.winTitle  = getLangString("msg_uploading_upl_file_remote_title");
this.winTitle += '<img style="display:none;float:right;margin: 40px 8px 0px -30px;position:relative;" id="LoadingURLFileICO" src="/images/ajax-loader.gif" />';
this.defUrl = (typeof window.globRemoteUrlFile != "undefined")?decodeURIComponent(window.globRemoteUrlFile):"";
window.globRemoteUrlFile = "";
this.sHtml  = 'URL:&nbsp; &nbsp;<input type="text" id="rfFileURL" class="filedText" value="'+this.defUrl+'" /><br>';
this.sHtml += '<i>'+getLangString("msg_uploading_example_title")+': http://www.domain.com/sound.mp3</i>';
this.request = null;
var FileUrl;
dialog2.showPrompt(
this.winTitle, this.sHtml,
function(){
try{
$.loadRemoteUrlRequest.abort();
$.loadRemoteUrlRequest = null;
window.console.clear();
} catch(e) {}
},
function(){
$("img#LoadingURLFileICO").show();
FileUrl = $.trim($("#rfFileURL").val());
if ( typeof(filesNum) != "undefined" ) {
if ( filesNum > 0 ){
//backToUpload();
}
}
window.globRemoteUrlFile = escape(FileUrl);
if ( !FileUrl ){
self._error('emptyUrlError', FileUrl, this.winTitle, qq.showPromptURL, 70);
return false;
}
if ( FileUrl.toLowerCase().indexOf('http://') == -1 )
FileUrl = 'http://'+FileUrl;
if ( FileUrl.toLowerCase().indexOf('https://') != -1 )
FileUrl = 'http://'+FileUrl;
var shortUrl = $.uTF8Decode(FileUrl);
if ( shortUrl.length > 70 ) {
shortUrl = shortUrl.substring(0, 30)+'...'+shortUrl.substring(FileUrl.length-30);
}
if ( qq._count(qq._fileBuff) >= self._options.limitFiles ){
self._error('filelimitError', shortUrl, this.winTitle, qq.showPromptURL, 70);
return false;
}
if ( !$.isURL(FileUrl.toLowerCase()) )
{
self._error('UrlError', FileUrl, this.winTitle, qq.showPromptURL, 70);
return false;
}
FileUrl = escape(FileUrl);
_getRemoteFileData(FileUrl, function(RMFD){
FileUrl = unescape(FileUrl);
var self = globSelf;
if ( !RMFD ){
self._error('serverError2', FileUrl, winTitle, qq.showPromptURL, 70);
return false;
}
if ( typeof RMFD != 'object' ) RMFD = eval('('+RMFD+')');
if ( typeof RMFD.status == 'undefined' && RMFD.error == "Incorrect URL" ) {
self._error('UrlError', FileUrl, this.winTitle, qq.showPromptURL, 70);
return false;
}
if ( RMFD.error && typeof RMFD.status != 'undefined' && RMFD.status == "504 Gateway Timeout" ) {
self._error('notUrlError', FileUrl, this.winTitle, qq.showPromptURL, 70);
return false;
}
if ( RMFD && RMFD.success )
{
FileUrl = RMFD.realurl;
FileUrl = unescape(FileUrl);
var fileName = FileUrl.replace(/.*(\/|\\)/, "");
var shortUrl = $.uTF8Decode(FileUrl);
if ( shortUrl.length > 70 ) {
shortUrl = shortUrl.substring(0, 30)+'...'+shortUrl.substring(FileUrl.length-30);
}
if ( !self._isAllowedExtension(FileUrl) ) {
self._error('typeError', shortUrl, this.winTitle, qq.showPromptURL, 70);
return false;
}
else if (self._isPresentInList(fileName)) {
self._error('samefileError', shortUrl, this.winTitle, qq.showPromptURL, 70);
return false;
}
else
{
if ( RMFD.status == '200' ) {
qq.addURLFileToList(this.winTitle, FileUrl, shortUrl, RMFD);
window.globRemoteUrlFile = "";
dialog2.hideDialog();
return true;
} else {
self._error('notUrlError', FileUrl, this.winTitle, qq.showPromptURL, 70);
return false;
}
}
}
else if ( ! self._isAllowedExtension(FileUrl) )
{
self._error('typeError', shortUrl, this.winTitle, qq.showPromptURL, 70);
return false;
}
else
{
self._error('UrlError', FileUrl, this.winTitle, qq.showPromptURL);
return false;
}
});
}
);
setTimeout(function(){$("#rfFileURL").focus();}, 100);
function _getRemoteFileData(filePath, cbkFunc, cntHits)
{
var urlMeta = ((type == 2) ? "youtube" : "remote");
var idx = $("#nextUrlId").val();
$.loadRemoteUrlRequest = $.ajax({
url: ENV.remoteFSize+'?GetRemoteFileData=true',
type: 'POST',
data: "GetRemoteFileData=true&remotefile="+filePath+"&fileID="+idx+"&urlmeta="+urlMeta,
dataType: 'json',
success: function(data) {
var res = eval ( data );
if ( res.error ) {
if ( res.status == "504 Gateway Timeout" ) {
if ( cntHits >= 5 ) {
cbkFunc(data);
return;
}
if ( !cntHits || typeof cntHits == 'undefined' ) {
cntHits = 1;
} else {
cntHits += 1;
}
_getRemoteFileData(filePath, cbkFunc, cntHits);
return;
}
} else {
cbkFunc(data);			
}
}
});
};
};
qq.addURLFileToList = function(winTitle, fullUrl, shortUrl, respInfo){
var self = globSelf;
qq._lockQueue();
var fileName = fullUrl.replace(/.*(\/|\\)/, "");
var size = respInfo.size;
if ( qq._count(qq._fileBuff) >= self._options.limitFiles ){
self._error('filelimitError', shortUrl, winTitle, qq.showPromptURL, 70);
return false;
} else if ( ! self._isAllowedExtension(fileName)){
self._error('typeError', shortUrl, winTitle, qq.showPromptURL, 70);
return false;
} else if (size === 0){
self._error('emptyError', shortUrl, winTitle, qq.showPromptURL, 70);
return false;
} else if (size && self._options.sizeLimit && size > self._options.sizeLimit){
self._error('sizeError', shortUrl, winTitle, qq.showPromptURL, 70);
return false;
} else if (self._isPresentInList(fileName)){
self._error('samefileError', shortUrl, winTitle, qq.showPromptURL, 70);
return false;
}
var ext = (-1 !== fileName.indexOf('.')) ? fileName.replace(/.*[.]/, '').toLowerCase() : '';
setFileProps({name: fileName, size: size, type: ext});
var _fName = $.base64Encode(fileName);
var _oldID = $("#fileQueue div.uploadifyQueueItem[filename='"+_fName+"']").attr("id");
if ( _oldID ) {
$("#"+_oldID).fadeOut(300);			
setTimeout(function(){$("#"+_oldID).remove();}, 200);	
}
var idx = qq._getNextURLId();
if ( respInfo.realurl ) fullUrl = respInfo.realurl;
self._addHistoryFileName(fileName, idx, size, fullUrl);
var item = qq.toElement(self._options.fileTemplate);
item.id = idx;
$(item).attr("filename", $.base64Encode(fileName));
self._getElement(item, 'size').innerHTML = '<img class="loading" src="/images/upl/loading.gif" />';
var fileElement = self._getElement(item, 'file');
var sizeElement = self._getElement(item, 'size');
qq.setText(fileElement, self._formatFileName(fileName));
qq.setText(sizeElement, ' ('+self._formatSize(size)+')');
qq.attach(self._getElement(item, 'cancel'), 'click', function(e){
e = e || window.event;
var target = e.target || e.srcElement;
if ( $(target).parent().parent().hasClass(self._classes.cancel) )
{
qq.preventDefault(e);
var itemIco = target.parentNode;
$(item).fadeOut(200);
var idx = $(target).parent().parent().parent().attr("id");
self._removeFileFromQueue(target, idx, true);
$("#blockingButtonsShape").hide();
}
});
if ( !self._options.onlyInitCore )
self._getElement('list').appendChild(item);
else
$("#fileQueue").get(0).appendChild(item);
self._filesInProgress++;
qq._unlockQueue();
setTimeout(function(){self._startUploadByQueue();}, 300);
if ( !self._options.onlyInitCore && !self._options.isAttachedEventsBtns) self._attachBtnsEvents();
};
qq.startUploadURLFile = function(id){
if ( typeof qq._fileBuff[id] == 'undefined' ) return;
var size = qq._fileBuff[id]['size'];
var name = qq._fileBuff[id]['name'];
var url = qq._fileBuff[id]['remotefile'];
var req = $.ajax({
url: ENV.uploaderScript+'?remotefile=true&req=start&fileID='+id,
type: 'POST',
dataType: 'json',
async: false
});
var res = req.responseText;
qq.checkUploadedURLSize(id);
};
qq.checkUploadedURLSize = function(id, cntHits){
if ( !cntHits ) cntHits = 0;
if ( typeof qq._fileBuff[id] == 'undefined' ) return;
var size = parseInt(qq._fileBuff[id]['size']);
var name = qq._fileBuff[id]['name'];
var url = qq._fileBuff[id]['remotefile'];
var req = $.ajax({
url: ENV.uploaderScript+'?remotefile=true&fileID='+id+'&req=check',
type: 'POST',
async: false
});
var res = new Object();
if (req.statusText != "OK") res['error'] = "true";
if ( !req.responseText ) res['error'] = "true";
else res = eval('('+req.responseText+')');
if ( res['error'] )
{
if ( cntHits >= 5 )
{
qq.onCompleteServe(res);
setTimeout(function(){qq.removeFromHistory(res.id, true);}, 200);	
return;
}
cntHits++;
setTimeout(function(){qq.checkUploadedURLSize(id, cntHits);}, 1000);
return;
}
var loaded = parseInt(res.sizenow);
if ( typeof window.sizeBKP == 'undefined' ) window.sizeBKP = {};
if ( window.sizeBKP[id] == loaded ) {
window.sizeBKP[id] = loaded;
if ( cntHits >= 10 )
{
qq.onCompleteServe('{"error":"Sorry. Can\'t load file from remote server.","id":"'+res.id+'"}');
setTimeout(function(){qq.removeFromHistory(res.id, true);}, 200);
window.sizeBKP[id] = 0;
return;
}
cntHits++;
setTimeout(function(){qq.checkUploadedURLSize(id, cntHits);}, 1000);
return;
}
window.sizeBKP[id] = loaded;
if ( size > loaded )
{
loaded = loaded - 100;
qq.setProgressBar(id, loaded, size);
setTimeout(function(){qq.checkUploadedURLSize(id);}, 500);
}
else
{
if ( qq.preCompletteProccess(id) ) {
qq.setProgressBar(id, 100, 100, '', '', true);
qq.onCompleteServe('{"success":true,"id":"'+res.id+'"}');
}
}
};
qq.preCompletteProccess = function(id){
var fName = qq._fileBuff[id]['name'];
var req = $.ajax({
url: ENV.uploaderScript+'?action=uploadprocess_'+$.sessid,
type: 'POST',
data: 'filename='+fName,
async: false
});	
if ( req.status == '200' ) {
return true;
}
};
qq._flashUploaderError = function(l,h,k,j){
var ID = "FLASH_uploadify"+h;
var info = l.type;
var code = j.info;
var type = j.type;
var message = code+" "+type+" Error";
if ( !message ) message = 'Undefined server error!<br>Please try again.';
$("div#uploadify"+h)
.removeClass("qq-upload-success")
.addClass("uploadifyError");
$("div#uploadify"+h+" span.percentage").html("").append('<span class="qq-upload-hints" style="display:none;"> - '+getLangString("msg_uploading_more_info")+'</span>');
$("div#uploadify"+h+" span.qq-upload-hints")
.attr("hint", message)
.show();
qq.setHintsForElement($("div#uploadify"+h+" span.qq-upload-hints"));
$("#uploadify"+h+"ProgressBar").css("background", "red");
qq.removeFromHistory(ID);
$("#blockingButtonsShape").hide();
return false;
};
qq._flashUploaderQueue = function(ID){
if ( !ID ){
for ( key in qq._fileBuff ){
if ( "FLASH_uploadify" == key.substring(0, 15) ) return true;
break;
}
}
var flashID = "FLASH_uploadify"+ID;
if ( typeof qq._fileBuff[flashID] != 'undefined' )
qq.removeFromHistory(flashID);
if ( globSelf.submitQueue ) globSelf.submitQueue = false;
globSelf._startUploadByQueue();
return true;	
};
qq._flashRemoveFromQueue = function(idx, bulk){
$("#blockingButtonsShape").hide();
if ( idx )
{
idx = "FLASH_uploadify"+idx;
if ( typeof qq._fileBuff[idx] == 'undefined' ) return true;
qq._fileBuff[idx] = "";
delete qq._fileBuff[idx];
}
if ( bulk )
{
$("#fileQueue div[id*='URL_']").each(
function(numm, elem) {
var idx = $(this).attr('id');
$(this).fadeOut(200);
qq.removeFileFromQueue('', idx, true);
}
);
}
return true;
};
qq._flashValidateFile = function(j,h,file){
var self = globSelf;
var name = file.name;
var size = file.size;
var mime = file.type;
var winTitle = getLangString("msg_uploading_error");
if ( !winTitle ) winTitle = 'Upload Error';
setTimeout(function(){$("div.uploadifyQueueItem div.cancel").before(globSelf._options.tplTitleUpload);}, 100);
if ( typeof(filesNum) != "undefined" ) {
if ( filesNum > 0 ){
//backToUpload();
}
}
if ( qq._count(qq._fileBuff) >= self._options.limitFiles ){
self._error('filelimitError', name, winTitle);
return false;
} else if ( ! self._isAllowedExtension(name)){
self._error('typeError', name, winTitle);
return false;
} else if (size === 0){
self._error('emptyError', name, winTitle);
return false;
} else if (size && self._options.sizeLimit && size > self._options.sizeLimit){
self._error('sizeError', name, winTitle);
return false;
} else if (self._isPresentInList(name)){
self._error('samefileError', name, winTitle);
return false;
}
$("#uploadifyUploader").blur();
$("#fileQueue").focus();
setFileProps(file);
return true;
};
qq.setHintsForElement = function(elm) {
$(elm).attr("title", "Error: "+$(elm).attr("hint"));
};

// Contents uploader/starter.js
var C=navigator.userAgent.toLowerCase();jQuery.browser={version:(C.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[0,"0"])[1],appVersion:navigator.appVersion,codeversion:(C.match(/.+(?:firefox)[\/: ]([\d.]+)/)||[0,"0"])[1],safari:/webkit/.test(C),opera:/opera/.test(C),chrome:/chrome/.test(navigator.userAgent.toLowerCase()),firefox:/firefox/.test(C),msie:/msie/.test(C)&&!/opera/.test(C),mozilla:/mozilla/.test(C)&&!/(compatible|webkit)/.test(C)};var dialog;var dimmer;var uploadType;function initUploaders(){dimmer=new Dimmer();dialog=new Dialog();dialog.init();var UseFlash=0;var UserDisableFlash=0;if(navigator.mimeTypes&&navigator.mimeTypes["application/x-shockwave-flash"]){var plugin=navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;if(plugin&&parseInt(plugin.description.substring(plugin.description.indexOf(".")-2))>=3){UseFlash=1}else{UserDisableFlash=1}}else{if(navigator.appName&&navigator.appName.indexOf("Microsoft")!=-1&&navigator.userAgent.indexOf("Windows")!=-1&&navigator.userAgent.indexOf("Windows 3.1")==-1){UseFlash=2}}var type=ENV.SwitchToType;switch(type){default:case"AUTO":var nVer=$.browser.version.substring(0,5).replace(/\./g,"");var cVer=$.browser.codeversion.substring(0,5).replace(/\./g,"");if(UseFlash&&!UserDisableFlash){if(($.browser.firefox&&$.browser.mozilla&&cVer<=36)||($.browser.msie&&nVer<=90)||($.browser.opera&&nVer>=90)){switchUploaders("flash");try{setTimeout(function(){if($.browser.msie){var oType=$("#uploadifyUploader").attr("classid")}else{var oType=$("#uploadifyUploader").attr("type")}if(typeof oType=="undefined"||oType==""){var paramName=$($("#uploadifyUploader param").get(1)).attr("name");if(typeof paramName=="undefined"||paramName==""){switchUploaders("fake",true);return }switchUploaders("fake",true);return }},1000)}catch(e){}}else{switchUploaders("fake")}}else{if(!(navigator.appName&&navigator.appName.indexOf("Netscape")>=0&&navigator.appVersion.indexOf("2.")>=0)){switchUploaders("fake")}}break;case"FLASH":if(!UseFlash){return }switchUploaders("flash");break;case"FAKE":switchUploaders("fake");break}}function switchUploaders(to,removeAlien){if(isMob=="true"){to="fake"}if("flash"==to){$("#side2").hide();$("#side1").show();createUploadify()}if("fake"==to){$("#side1").hide();$("#side2").show();createUploader();if(removeAlien){$("#side1").remove()}fakedMouseEvents(to)}uploadType=to}function fakedMouseEvents(type){if("flash"==type){setTimeout(function(){$("object#uploadifyUploader").mouseover(function(){$(this).removeClass("out-btn").addClass("over-btn")}).mouseout(function(){$(this).removeClass("over-btn").addClass("out-btn")});$("img.qq-browse-url-btn").parent().mouseover(function(){$("img",this).removeClass("out-btn").addClass("over-btn")}).mouseout(function(){$("img",this).removeClass("over-btn").addClass("out-btn")})},2000)}if("fake"==type){setTimeout(function(){$("div.qq-upload-button").mouseover(function(){$("img",this).removeClass("out-btn").addClass("over-btn")}).mouseout(function(){$("img",this).removeClass("over-btn").addClass("out-btn")});$("img.qq-browse-url-btn").mouseover(function(){$(this).removeClass("out-btn").addClass("over-btn")}).mouseout(function(){$(this).removeClass("over-btn").addClass("out-btn")})},1000)}}function createUploader(onlyInitCore){setAdvancedEvents("FAKE");var uploader=new qq.FileUploader({onlyInitCore:onlyInitCore,element:(!onlyInitCore)?$("#file-uploader").get(0):$("#file-uploader-flash").get(0),action:ENV.uploaderScript+"?"+getUploadParams(),frmAction:ENV.uploaderScript+"?"+getUploadParams(),multiple:ENV.isMultiple,limitFiles:ENV.limitFiles,limit:ENV.limitFiles,allowedExtensions:ENV.Extensions,ExtDescriptions:ENV.ExtDescriptions,sizeLimit:ENV.SizeLimit,rmPreviosInput:false,debug:true,onAllComplete:function(fid){if(qq._count(qq._fileBuff)>0){return }if(!isAllComplete(fid)){return }}});if(isMob=="true"){setTimeout(function(){$("form[name=form_frame_1], img.buttons_110").remove()},800)}}function createUploadify(){setAdvancedEvents("FLASH");$("#uploadify").uploadify({uploader:ENV.swfScript,script:ENV.uploaderScript+"?"+getUploadParams(),cancelImg:ENV.pathToImages+"/upl/cancel2.png",folder:folder,buttonImg:"/images/ring-sprite-btns-tabs-"+getCookieLang()+".jpg",wmode:"transparent",width:208,height:27,queueID:"fileQueue",multi:false,auto:true,sizeLimit:ENV.SizeLimit,scriptAccess:"always",queueSizeLimit:ENV.limitFiles,fileDataName:"Filedata",fileDesc:"Audio Files "+ENV.ExtDescriptions,fileExt:converterFileExt,onInit:function(){fakedMouseEvents("flash")},onSelect:function(j,h,i){return qq._flashValidateFile(j,h,i)},onComplete:function(k,h,j,i,l){return qq._flashUploaderQueue(h)},onError:function(l,h,k,j){return qq._flashUploaderError(l,h,k,j)},onCancel:function(l,h,k,m,j){return qq._flashRemoveFromQueue(h)},onAllComplete:function(fid){if(qq._count(qq._fileBuff)>0){return }if(!isAllComplete(fid)){return }},onOpen:function(event,queueID,fileObj){},onSelectOnce:function(event,data){$("#uploadify").uploadifySettings("folder",folder)}});setTimeout(function(){createUploader(true)},800)}function isAllComplete(fid){$.isFileUploaded=true;if(fid){setTimeout(function(){$("div#"+fid).fadeOut(10)},800)}}function getFolder(){return((folder)?folder:$("#folder").val())}function setAdvancedEvents(upType){if(!$.browser.msie){folder=$("#folder").val()}}function converterReady(){}function isEmail(email){var r1=new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");var r2=new RegExp("^[a-zA-Z0-9\\-\\.\\_]+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,4})(\\]?)$");return(!r1.test(email)&&r2.test(email))}function randomString(){var chars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";var string_length=16;var randomstring="";for(var i=0;i<string_length;i++){var rnum=Math.floor(Math.random()*chars.length);randomstring+=chars.substring(rnum,rnum+1)}return randomstring}

