/*****
Copyright © 2011 UC Regents and ALEKS Corporation
ALEKS® is a registered trademark of ALEKS Corporation.
*****/
var g_UG=[];var g_C2=['gif','jpg','jpeg','png','bmp','pdf','doc','xls','ppt','pps','ps','wps','psp','rtf','txt','xml','zip','docx','pptx','xlsx'];var g_s1="/aleks/gif/mb/ajax-attach.gif";function g_R7(i,S){g_UG[i]=new g_rN(i,S);g_UG[i].init();if(0==1&&S!=null&&S==true){window.onunload=function(u){g_UG[i].clean();};}}function g_ED(H){g_UG[H].show();}function g_rN(v,H){this.g_XO=v;this.g_Rk="attachments_root_"+this.g_XO;this.g_dy="attachments_"+this.g_XO;this.g_6B;this.g_dp=0;this.g_Aq;this.g_Od='/aleks/attach_file';
this.g_oc=H;this.show=function(){di('attachment_switch_'+this.g_XO).style.display='none';di('attachment_panel_'+this.g_XO).style.display='block';};this.clean=function(){g_z6(this.g_XO);};this.init=function(){if(di(this.g_dy).value !=""&&di(this.g_dy).value !="/"){this.g_Aq=0;var s=di(this.g_dy).value.split("/");var S=0;for(S=0;S<s.length;S=S+1){if(s[S]!=""){var o=s[S].split("|");var div=document.createElement('div');div.setAttribute('id','attach_'+this.g_XO+'_'+(this.g_Aq+1));div.className='clearLDiv';
div.innerHTML=g_cO(this.g_XO,{attach_id:o[0]+'|'+o[1],filename:o[3],filesize:o[2]},(this.g_Aq+1),'file');di(this.g_Rk).appendChild(div);this.g_Aq++;}};this.g_dp=1;g_ri(this.g_XO,this.g_Aq+1);this.show();}else{g_z6(this.g_XO);this.g_dp=1;g_ri(this.g_XO,1);}};}function g_ri(P,v){g_UG[P].g_6B=-1;var div=document.createElement('div');var M=[];var k=[];if(g_UG[P].g_Aq<5){var e=document.createElement('div');e.setAttribute('id','attach_form_'+P+'_'+v);div.setAttribute('id','attach_'+P+'_'+v);div.className='clearLDiv';
var o=new g_Vo('myBtnBrowse','',attach_translations['ButtonBrowse']);M.push('<form id="form_attach" name="form_attach" action="'+g_UG[P].g_Od+'" enctype="multipart/form-data" encoding="multipart/form-data" method="POST" onsubmit="return g_2d(\''+P+'\',this,'+v+');" class="form_sm">');k.push("<span class='read_field'>"+attach_translations['AttcheFileCSR2']+"</span>");M.push('<input type="hidden" name="_form_" id="_form_" value="true"/>');M.push('<input type="hidden" name="action" id="action" value="uploadfile"/>');
M.push('<input type="hidden" name="origin" id="origin" value="'+P+'"/>');M.push('<input type="hidden" name="attachField2" id="attachField2" value="/"/>');k.push('<div id="userfile_div" class="userfile_div">');k.push('<input type="file" name="userfile" id="userfile" class="userfile" onchange=\'g_2d("'+P+'",di("form_attach"),'+v+')\' size=33 onmouseover="g_MZ(event)" onmouseout="g_BD(di(\'myBtnBrowse\'))" onmousedown="g_d2(event);" onmousemove="g_MZ(event)" onkeyup="g_6K()"/>');k.push('<div id="fakefile" class="fakefile">');
k.push('<input id="fakeinput"/><div id="btnBrwse" class="btnBrwse">');k.push(o.generateBtn());k.push('</div></div>');k.push('<span id="ajax_loader_ul" class="ajax_loader_ul"></span>');k.push('</div>');k.push("<span>&nbsp;"+attach_translations['AttachCommentUserfile']+"</span>");M.push('</form>');k.push('<div id="test_userfile"></div>');div.innerHTML=k.join("");di(g_UG[P].g_Rk).appendChild(div);e.innerHTML=M.join("");e.style.position='absolute';e.style.display='none';document.body.appendChild(e);}else{
k.push("<strong>"+attach_translations['AttachMax5']+"</strong>");div.setAttribute('id','limit_attach');div.className='clearDiv';div.innerHTML=k.join("");di(g_UG[P].g_Rk).appendChild(div);}if(o){var t=o.getWidth();di('btnBrwse').style.width=t+'px';di('userfile').onmousemove=g_MZ;di('userfile').onmouseover=g_MZ;di('userfile').onmousedown=g_d2;di('userfile').onmouseout=g_zV;di('userfile').onmouseup=g_zV;di('ajax_loader_ul').style.left=parseInt(230+t)+'px';}}function g_6K(){di('fakeinput').value=di('userfile').value;
}function g_MZ(l){var H=di('myBtnBrowse');var pos=g_qm(H);var c=findMousePos(l||window.event);di('myBtnBrowse').innerHTML+='';if(!this.mouseDown){if(c[0]>=pos[0]&&c[0]<=parseInt(pos[0]+H.offsetWidth)){g_UU(H);}else{g_BD(H);this.mouseDown=false;}}else{if(c[0]<pos[0]||c[0]>parseInt(pos[0]+H.offsetWidth)){g_BD(H);this.mouseDown=false;}}}function g_zV(){g_BD(di('myBtnBrowse'));this.mouseDown=false;}function g_d2(t){var k=di('myBtnBrowse');var pos=g_qm(k);var U=findMousePos(t||window.event);if(U[0]>=pos[0]&&U[0]<=parseInt(pos[0]+k.offsetWidth)){
g_hx(k);this.mouseDown=true;}}function g_BF(t,G){di(g_UG[t].g_Rk).removeChild(di('attach_'+t+'_'+G));document.body.removeChild(di('attach_form_'+t+'_'+G));}function g_s7(b,V,o){if(g_UG[b].g_6B==-1){switch(V){case "tooBig":case "forbiddenExt":case "tooMuchFiles":case "totalTooBig":case "error":if(V=="tooBig"){alert(attach_translations['AttcheFileErrorTooBig']);}else if(V=="forbiddenExt"){alert(attach_translations['AttcheFileErrorExt']);}else if(V=="totalTooBig"){alert(attach_translations['AttcheFilesErrorTotalTooBig']);
}else if(V=="tooMuchFiles"){alert(attach_translations['AttcheFilesErrorTooMuch']);}else{alert(attach_translations['AttachError']);}g_BF(b,o);g_ri(b,parseInt(o));break;default:eval(V);g_UG[b].g_Aq++;di(g_UG[b].g_dy).value+=single_attachment.attach_id+"|"+single_attachment.filesize+"|"+single_attachment.filename+"/";di('attach_'+b+'_'+o).innerHTML=g_cO(b,single_attachment,o,'file');document.body.removeChild(di('attach_form_'+b+'_'+o));g_ri(b,parseInt(o)+1);}}else{g_UG[b].g_6B=-1;switch(V){case "tooBig":case "forbiddenExt":case "tooMuchFiles":case "totalTooBig":case "error":break;
default:eval(V);var M=single_attachment.attach_id;var t=g_ZW();var A=t.o;var J="_form_=true&action=del_attach&id="+encodeURIComponent(M);try{A.open('POST',g_UG[b].g_Od,true);}catch(e){alert("Open failed");}try{t.g_pa(J);}catch(e){alert("Send failed");}break;}}}function g_cO(H,v,G,type){var g_Ya=[];g_Ya.push('<span class="attach_name">'+v.filename+"</span><span class='attach_detail'>("+v.filesize+")</span>");g_Ya.push("<span id='remove_"+v.attach_id.replace(/|/,"_")+"' class='attach_remove' onclick='g_LS(\""+H+"\",\""+v.attach_id+"\",\""+type+"\","+G+")'>"+attach_translations['Remove']+"</span>");
return g_Ya.join("");}function g_LS(a,U,type,j){var c=g_ZW();var F=c.o;var A="";var I=function(a){di(g_UG[a].g_Rk).removeChild(di('attach_'+a+'_'+j));g_UG[a].g_Aq--;myAttachsIds=di(g_UG[a].g_dy).value.split("/");for(var B=1;B<myAttachsIds.length;B=B+1){var M=myAttachsIds[B].split("|");if(M[0]+'|'+M[1]==U){myAttachsIds.splice(B,1);}}di(g_UG[a].g_dy).value=myAttachsIds.join("/");if(g_UG[a].g_Aq==4){di(g_UG[a].g_Rk).removeChild(di('limit_attach'));while(di('attach_'+a+'_'+j)){j++;}g_ri(a,j);}};if(confirm(attach_translations['ConfirmRemoveAttach'])){
A="_form_=true&action=del_attach&id="+encodeURIComponent(U);F.onreadystatechange=function(){if(F.readyState==4&&F){if(F.status==200){I(a);}}}}if(A !=''){try{F.open('POST',g_UG[a].g_Od,true);di('remove_'+U.replace(/|/,"_")).innerHTML="<img style='vertical-align:center' src="+g_s1+"/>";di('remove_'+U.replace(/|/,"_")).style.cursor="default";}catch(e){alert("Open failed");}try{c.g_pa(A);}catch(e){alert("Send failed");}}}function g_Zz(form){return true;}function g_2d(b,form,M){di('attachField2').value=di(g_UG[b].g_dy).value;if(di('userfile').value){
di('fakeinput').value=di('userfile').value;var C=di('userfile').value;C=C.split('.');C=C[C.length-1];if(g_un(C.toLowerCase())){di('form_attach').appendChild(di('userfile'));var div=document.createElement('DIV');var o=Math.floor(Math.random()*100000);div.setAttribute('id','div_send_'+o);div.innerHTML='<iframe width=1 height=1 style="width:1px;height:1px;border: red 1px solid;top:-10px;left:-10px;position: absolute;" src="about:blank" id="iframe_send_'+o+'" name="iframe_send_'+o+'" onload="g_zM(\''+b+'\','+M+','+o+')"></iframe>';
document.body.appendChild(div);form.setAttribute('target', "iframe_send_"+o);setTimeout(function(){if(g_Zz(form)){di("ajax_loader_ul").innerHTML="<img style='vertical-align:center;cursor:pointer;' src="+g_s1+" title='"+attach_translations['CancelFileUpload']+"' onclick='g_jf(\""+b+"\","+M+")'/>";form.submit();di('userfile').disabled=true;di('fakeinput').disabled=true;g_ya(di('myBtnBrowse'));}}, 1000);}else{alert(attach_translations['AttcheFileErrorExt']);di('fakeinput').value=di('userfile').value='';
return false;}}return false;}function g_zM(A,m,U){var i=di("iframe_send_"+U);if(i.contentDocument){var g=i.contentDocument;}else if(i.contentWindow){var g=i.contentWindow.document;}else{var g=window.frames[id].document;}if(g.location.href=="about:blank"){return;}if(g.getElementById('answer')){g_s7(A,g.getElementById('answer').getAttribute('content'),m);}else{g_s7(A,'error',m);}}function g_jf(s,O){g_UG[s].g_6B=O;di('userfile').disabled=false;di('userfile').value="";di('ajax_loader_ul').innerHTML='';
}function g_un(K){if(g_IV(K,g_C2)){return true;}else{return false;}}function g_IV(L, s){var w=0;for(w=0;w<s.length;w++){if((s[w]==L)){return true;}}return false;}String.prototype.getFuncBody=function(){var H=this.toString();H=H.replace(/[^{]+{/,"");H=H.substring(0,H.length-1);H=H.replace(/\n/gi,"");return H;};function g_z6(a){if(g_UG[a].g_dp==1){g_UG[a].g_dp=0;if(di(g_UG[a].g_dy).value!="/"){var e=g_ZW();var m=e.o;try{m.open('POST',g_UG[a].g_Od,true);}catch(e){}var K='_form_=true&action=clean_attach&attachField='+encodeURIComponent(di(g_UG[a].g_dy).value);
try{e.g_pa(K);}catch(e){}di(g_UG[a].g_dy).value="/";g_UG[a].g_Aq=0;}}else{di(g_UG[a].g_dy).value="/";g_UG[a].g_Aq=0;}}function g_Vo(G,n,value,title){this.id=G;this.onclick=n;this.value=value;this.title=title||value;this.generateBtn=function(){var g_Ya=[];g_Ya.push('<span id="'+this.id+'" onclick="'+this.onclick+'" title="'+this.title+'" class="button_mc" onmouseover="g_UU(this)" onmouseout="g_BD(this)" onmousedown="g_hx(this)" onmouseup="g_UU(this)" style="-moz-user-select: none;" onselectstart="return false;">');
g_Ya.push('<span class="left_button">');g_Ya.push(this.value);g_Ya.push('</span></span>');return g_Ya.join("");};this.getWidth=function(){var l=g_ym(this.generateBtn());return l[0];};}function g_UU(s){if(s.className !='button_mc_disabled'){s.className='button_mc_hover';}}function g_BD(m){if(m.className !='button_mc_disabled'){m.className='button_mc';}}function g_hx(T){if(T.className !='button_mc_disabled'){T.className='button_mc_down';}}function g_ya(){var v=g_ya.arguments;for(i=0;i<v.length;i++){
btn=v[i];btn.className='button_mc_disabled';if(btn.onclick){btn.onclick=new Function("return false;"+btn.onclick.toString().getFuncBody());}else{btn.onclick=function(){var a;return false;};}}}
