function social_mark(url,title){window.open('http://www.addthis.com/bookmark.php?v=10&pub=redorff&url='+encodeURIComponent(url)+'&title='+encodeURIComponent(title)+'&logo='+encodeURIComponent('http://www.artquid.com/img/logo_artquid.png'),'addthis','scrollbars=yes,menubar=no,width=600,height=500,resizable=yes,toolbar=no,location=no,status=no,screenX=200,screenY=100,left=200,top=100');_gaq.push(['_trackEvent','social','bookmark']);return false;}
function social_rss(url,title){window.open('http://www.addthis.com/feed.php?pub=redorff&h1='+encodeURIComponent(url)+'&t1='+encodeURIComponent(title),'addthis','scrollbars=yes,menubar=no,width=600,height=500,resizable=yes,toolbar=no,location=no,status=no,screenX=200,screenY=100,left=200,top=100');_gaq.push(['_trackEvent','social','rss']);return false;}
function printit(i){_gaq.push(['_trackEvent',i,'print']);window.print();return false;}
function trim(s){return s.replace(/^\s+/g,'').replace(/\s+$/g,'');}
function login_submit(defaut,email_err,pwd_err){document.fl['login[email]'].value=trim(document.fl['login[email]'].value);document.fl['login[passwd]'].value=trim(document.fl['login[passwd]'].value);if(document.fl['login[email]'].value==''||document.fl['login[email]'].value==defaut){alert(email_err);document.fl['login[email]'].focus();}
else if(document.fl['login[passwd]'].value==''){alert(pwd_err);document.fl['login[passwd]'].focus();}
else return true;return false;}
var c=0;var d=new Date();var t=d.getTime();function fave(i,o){var e;document.getElementById('fave'+(i^1)+'_'+o).style.display='none';document.getElementById('fave'+i+'_'+o).style.display='';e=new Image();e.src='/select/'+o+'/'+i+'?'+t+(++c);}
function fav(i,o){var e,v;document.getElementById('fave'+(i^1)+'_'+o).style.display='none';document.getElementById('fave'+i+'_'+o).style.display='';v=document.forms['nbff']['nbfc'];if(i==1)v.value++;else if(v.value>0)v.value--;document.getElementById('nbfd').style.display=(v.value>0?'':'none');e=new Image();e.src='/select/'+o+'/'+i+'?'+t+(++c);_gaq.push(['_trackEvent',o>0?'artwork':'post',i?'fave':'unfave']);}
function invoice(i,o){document.getElementById('invoice'+(i^1)+'_'+o).style.display='none';document.getElementById('invoice'+i+'_'+o).style.display='';}
function checkAll(fld,st){for(i=0;i<fld.length;i++)
fld[i].checked=st;return true;}
var onglet=-1;function ongletClic(i){var j;if(onglet>-1){if(onglet==i)return true;j=document.getElementById('onglet'+onglet).className='onglet_off';j=document.getElementById('ongletpage'+onglet).style.display='none';}
onglet=i;j=document.getElementById('onglet'+onglet).className='onglet_on';j=document.getElementById('ongletpage'+onglet).style.display='';_gaq.push(['_trackEvent','onglet','clic']);}
var sd=-1;function showDiv(i){if(sd>-1){if(sd==i)return true;document.getElementById('sd'+sd).style.display='none';}
sd=i;if(sd>-1)
document.getElementById('sd'+sd).style.display='';}
function showDivHide(i){document.getElementById('moreBtn'+i).style.display='none';document.getElementById('moreDiv'+i).style.display='';}
function del_submit(id,lab,lg_id){document.fd.id.value=id;if(lg_id)document.fd.lg_id.value=lg_id;if(lab)document.fd.lab.value=lab;document.fd.submit();}
function my_confirm(msg,id,val){if(confirm(msg)){document.getElementById(id).value=val;return true;}
return false;}
function popup(u){var pop=window.open(u,'pop','height=500,width=720,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,directories=no,status=no');pop.focus();return true;}
function search_submit(frm,defaut,errmsg){frm.q.value=trim(frm.q.value);if(frm.q.value==defaut||frm.q.value==''){alert(errmsg);return false;}else{_gaq.push(['_trackEvent','search','field']);frm.submit();return true;}}
function prevNext(url,off,stp,cnt,prev,next){if(off>cnt)
off=cnt;off=off-off%stp;if(cnt<=stp)
return true;s=new String(url);url=url+(-1<s.indexOf('?')?'&amp;':'?');if(off>0)
document.writeln('<a href="'+url+'o='+(off-stp)+'" class="prevNext">'+prev+'</a>');for(i=off-5*stp,j=off+5*stp;i<cnt&&i<=j;i+=stp)
if(i>=0)
if(i==off)
document.writeln('<b class="prevNext">'+(off/stp+1)+'</b>');else document.writeln('<a href="'+url+'o='+i+'" class="prevNext">'+(i/stp+1)+'</a>');if(off+stp<cnt)
document.writeln('<a href="'+url+'o='+(off+stp)+'" class="prevNext">'+next+'</a>');}
var x=0,y=0,vx=1,vy=1,p=0,pi=1;function bnc(){if(0===(++pi)%400){document.getElementById('bncnt1'+p).style.display='none';document.getElementById('bncnt2'+p).style.display='none';p=(p+1)%4;document.getElementById('bncnt1'+p).style.display='block';document.getElementById('bncnt2'+p).style.display='block';}
x+=vx*Math.cos(x/120*Math.PI);y+=vy*Math.cos(y/110*Math.PI);if(x>49)vx=-1;if(x<-49)vx=1;if(y>49)vy=-1;if(y<-49)vy=1;document.getElementById('bnc1'+p).style.backgroundPosition=Math.round(x+50)+'% '+Math.round(y+50)+'%';document.getElementById('bnc2'+p).style.backgroundPosition=Math.round(y+50)+'% '+Math.round(x+50)+'%';setTimeout('bnc()',40);return true;}
function bnc1(){if(0===(++pi)%400){document.getElementById('bncnt1'+p).style.display='none';p=(p+1)%4;document.getElementById('bncnt1'+p).style.display='block';}
x+=vx*Math.cos(x/120*Math.PI);y+=vy*Math.cos(y/110*Math.PI);if(x>49)vx=-1;if(x<-49)vx=1;if(y>49)vy=-1;if(y<-49)vy=1;document.getElementById('bnc1'+p).style.backgroundPosition=Math.round(x+50)+'% '+Math.round(y+50)+'%';setTimeout('bnc1()',40);return true;}
function bnc3(){x+=vx*Math.cos(x/120*Math.PI);y+=vy*Math.cos(y/110*Math.PI);if(x>49)vx=-1;if(x<-49)vx=1;if(y>49)vy=-1;if(y<-49)vy=1;document.getElementById('bnc1').style.backgroundPosition=Math.round(x+50)+'% '+Math.round(y+50)+'%';document.getElementById('bnc2').style.backgroundPosition=Math.round(50-y)+'% '+Math.round(x+50)+'%';document.getElementById('bnc3').style.backgroundPosition=Math.round(y+50)+'% '+Math.round(50-x)+'%';setTimeout('bnc3()',40);return true;}
function caseLower(f,mode){var txt=new String(f.value);txt=txt.toLowerCase();if(mode=='word'){txt=txt.replace(/\n/g,". [-<br>-] ");var wordSplit=' ';}else{txt=txt.replace(/\.\n/g,".[-<br>-]. ");txt=txt.replace(/\.\s\n/g,". [-<br>-]. ");var wordSplit='. ';}
var wordArray=txt.split(wordSplit);var numWords=wordArray.length;for(x=0;x<numWords;x++){wordArray[x]=wordArray[x].replace(wordArray[x].charAt(0),wordArray[x].charAt(0).toUpperCase());if(mode=='word'){if(x==0){txt=wordArray[x]+" ";}else if(x!=numWords-1){txt=txt+wordArray[x]+" ";}else if(x==numWords-1){txt=txt+wordArray[x];}}else{if(x==0){txt=wordArray[x]+". ";}else if(x!=numWords-1){txt=txt+wordArray[x]+". ";}else if(x==numWords-1){txt=txt+wordArray[x];}}}
if(mode='word'){txt=txt.replace(/\.\s\[-<br>-\]\s/g,"\n");txt=txt.replace(/\.\s\[-<br>-\]/g,"\n");}else{txt=txt.replace(/\[-<br>-\]\.\s/g,"\n");}
txt=txt.replace(/\si\s/g," I ");f.value=txt;return true;}
function clk(url,uid){try{if(document.images){var a=encodeURIComponent||escape;(new Image).src="/trk?uid="+a(uid)+("&url="+a(url.replace(/#.*/,"")).replace(/\+/g,"%2B"));}
_gaq.push(['_trackPageview','/out/'+url.substring(7)]);}catch(err){}
return true;}
function clkmat(url,i){try{if(document.images){var a=encodeURIComponent||escape;(new Image).src="/trk?matid="+a(i)+("&url="+a(url.replace(/#.*/,"")).replace(/\+/g,"%2B"));}
_gaq.push(['_trackPageview','/out/materiel'+a(i)]);}catch(err){}
return true;}
function enableText(field,sta){field.disabled=sta?false:true;field.className=sta?'mod_ko':'mod_ok';}
function txtCounter(field,cnt,maxc){if(field.value.length>maxc)
field.value=field.value.substring(0,maxc);else cnt.value=maxc-field.value.length;}
function txtCtl(field,lim1,lim2,k){var i,j;if(field.value.length<lim1)
i=0;else if(field.value.length<lim2)
i=1;else i=2;j=field.sta;if(j!=i){if(j!=undefined)document.getElementById(k+j).style.display='none';document.getElementById(k+i).style.display='';field.sta=i;}}
function selOpt(s,o){for(var i=s.length-1;i>=0;i--)
if(s.options[i].selected=(s.options[i].value==o))
s.selectedIndex=i;}
function selFil(s,k,v){for(var i=s.length-1;i>0;i--)
s.options[i]=null;var j=1;for(var i in v)
if(k[i])
s.options[j++]=new Option(v[i],i);}
function divDisp(n,i){document.getElementById(n).style.display=i;return true;}
function refillBay(key,bay_lid){var out="";var bay_lid=document.forms["fp"][key+"[bay_lid]"].value;var lab;var siz;var i;var isM;if(1>bay_lid||!props[bay_lid])
divDisp(key+"bs","none");else{for(lab in labs)
if(props[bay_lid][lab]){out+='<label for="'+key+'_'+lab+'_lid"><b>'+labs[lab]+'</b></label> : <select name="'+key+'['+lab+'_lid]" size="1" id="'+key+'_'+lab+'_lid"><option value="0">------</option>';for(i in prps[lab])
if(props[bay_lid][lab][i])
out+='<option value="'+i+'">'+prps[lab][i]+'</option>';out+='</select><br />';}
divDisp(key+"bs","");}
document.getElementById(key+"bs").innerHTML=out;}
function refillBak(key,bay_lid){divDisp(key+"bt1","none");divDisp(key+"bs","none");document.getElementById(key+"bs").innerHTML="";if(1>bay_lid||props[bay_lid]&&props[bay_lid][0]){divDisp(key+"bak","none");selOpt(document.forms["fp"][key+"[bak_lid]"],0);if(!bay_lid);else if(props[bay_lid]&&props[bay_lid][0])
refillBt1(key,0);}else{divDisp(key+"bak","");selFil(document.forms["fp"][key+"[bak_lid]"],props[bay_lid],baks);}}
function refillBt1(key,bak_lid){var bay_lid=document.forms["fp"][key+"[bay_lid]"].value;divDisp(key+"bs","none");document.getElementById(key+"bs").innerHTML="";if(1>bay_lid||1>bak_lid&&!props[bay_lid][bak_lid]){divDisp(key+"bt1","none");selOpt(document.forms["fp"][key+"[bt1_lid]"],0);}else{divDisp(key+"bt1","");selFil(document.forms["fp"][key+"[bt1_lid]"],props[bay_lid][bak_lid],bt1s);}}
function isMono(t){var c=0;var v=0;for(var i in t){v=t[i];if(++c>1)
return false;}
return c>1?false:v;}
function refillBs(key,bt1_lid){var out="";var bay_lid=document.forms["fp"][key+"[bay_lid]"].value;var bak_lid=document.forms["fp"][key+"[bak_lid]"].value;var lab;var siz;var i;var isM;if(1>bay_lid||1>bt1_lid||!props[bay_lid][bak_lid]||!props[bay_lid][bak_lid][bt1_lid])
divDisp(key+"bs","none");else{for(lab in labs)
if(props[bay_lid][bak_lid][bt1_lid][lab])
if(i=isMono(props[bay_lid][bak_lid][bt1_lid][lab]))
out+='<input type="hidden" name="'+key+'['+lab+'_lid]" value="'+i+'" />';else{if(lab!='bth'){out+='<label for="'+key+'_'+lab+'_lid"><b>'+labs[lab]+'</b></label> : <select name="'+key+'['+lab+'_lid]" size="1" id="'+key+'_'+lab+'_lid"><option value="0">------</option>';for(i in prps[lab])
if(props[bay_lid][bak_lid][bt1_lid][lab][i])
out+='<option value="'+i+'">'+prps[lab][i]+'</option>';out+='</select><br />';}
else{out+='<div style="float:left;padding-top:10px;">';out+='<label for="'+key+'_'+lab+'_lid"><b>'+labs[lab]+'</b></label> : <select onchange="checkTheme(this)" name="'+key+'['+lab+'_lid]" size="1" id="'+key+'_'+lab+'_lid"><option value="0">------</option>';for(i in prps[lab])
if(props[bay_lid][bak_lid][bt1_lid][lab][i])
out+='<option value="'+i+'">'+prps[lab][i]+'</option>';out+='</select></div>';if(typeof(theme_errmsg)!="undefined"){out+='<div class="dbul dbul1" style="float:left;" id="objet_bth_lid_msg"><img class="bul1" alt="" src="/img/z.gif">'+theme_errmsg+'</div><div style="clear:both;"></div>';}}}
divDisp(key+"bs","");}
document.getElementById(key+"bs").innerHTML=out;}
function initObj(key,obj){if(0<obj.bay_lid){selOpt(document.forms["fp"][key+"[bay_lid]"],obj.bay_lid);refillBak(key,obj.bay_lid);if(props[obj.bay_lid][obj.bak_lid]){selOpt(document.forms["fp"][key+"[bak_lid]"],obj.bak_lid);refillBt1(key,obj.bak_lid);if(obj.bt1_lid&&props[obj.bay_lid][obj.bak_lid][obj.bt1_lid]){selOpt(document.forms["fp"][key+"[bt1_lid]"],obj.bt1_lid);refillBs(key,obj.bt1_lid);for(var lab in props[obj.bay_lid][obj.bak_lid][obj.bt1_lid]){if(0<obj[lab+'_lid'])
selOpt(document.forms["fp"][key+"["+lab+"_lid]"],obj[lab+"_lid"]);}}}}}
function initBayObj(key,obj){if(0<obj.bay_lid){selOpt(document.forms["fp"][key+"[bay_lid]"],obj.bay_lid);refillBay(key,obj.bay_lid);if(props[obj.bay_lid]){for(var lab in props[obj.bay_lid]){if(0<obj[lab+'_lid'])
selOpt(document.forms["fp"][key+"["+lab+"_lid]"],obj[lab+"_lid"]);}}}}
function apiTrad(key,dst,hid){var xmlHttpReq=false;var self=this;if(window.XMLHttpRequest)
self.xmlHttpReq=new XMLHttpRequest();else if(window.ActiveXObject)
self.xmlHttpReq=new ActiveXObject('Microsoft.XMLHTTP');document.getElementById(hid).style.display='none';self.xmlHttpReq.open('POST','/api/trad/'+key,true);self.xmlHttpReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');self.xmlHttpReq.onreadystatechange=function(){if(self.xmlHttpReq.readyState==4){if(trim(self.xmlHttpReq.responseText).length>1){_gaq.push(['_trackEvent','translate','ok']);document.getElementById(dst).innerHTML=self.xmlHttpReq.responseText;}else _gaq.push(['_trackEvent','translate','failed']);document.getElementById(dst).style.display='block';}}
self.xmlHttpReq.send('');return false;}
function apiTpl(key,dst){var xmlHttpReq=false;var self=this;if(window.XMLHttpRequest)
self.xmlHttpReq=new XMLHttpRequest();else if(window.ActiveXObject)
self.xmlHttpReq=new ActiveXObject('Microsoft.XMLHTTP');self.xmlHttpReq.open('POST','/api/tpl/'+key,true);self.xmlHttpReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');self.xmlHttpReq.onreadystatechange=function(){if(self.xmlHttpReq.readyState==4){dst.value+=self.xmlHttpReq.responseText;}}
self.xmlHttpReq.send('');return false;}
function ds_getleft(el){var tmp=el.offsetLeft;el=el.offsetParent
while(el){tmp+=el.offsetLeft;el=el.offsetParent;}
return tmp;}
function ds_gettop(el){var tmp=el.offsetTop;el=el.offsetParent
while(el){tmp+=el.offsetTop;el=el.offsetParent;}
return tmp;}
function ds_ob_clean(){ds_ob='';}
function ds_ob_flush(){ds_oe.innerHTML=ds_ob;ds_ob_clean();}
function ds_echo(t){ds_ob+=t;}
function ds_template_main_above(ty,tm){return'<table cellpadding="3" cellspacing="1" class="ds_tbl"><tr><td colspan="7" class="ds_head" style="cursor:pointer" onclick="ds_hi();">'+ds_close+'</td></tr><tr><td class="ds_head" style="cursor:pointer" onclick="ds_py();">&lt;&lt;</td><td class="ds_head" colspan="5">'+ty+'</td><td class="ds_head" style="cursor:pointer" onclick="ds_ny();">&gt;&gt;</td></tr><tr><td class="ds_head" style="cursor:pointer" onclick="ds_pm();">&lt;</td><td class="ds_head" colspan="5">'+tm+'</td><td class="ds_head" style="cursor:pointer" onclick="ds_nm();">&gt;</td></tr><tr>';}
function ds_template_day_row(t){return'<td class="ds_subhead">'+t+'</td>';}
function ds_template_new_week(){return'</tr><tr>';}
function ds_template_blank_cell(colspan){return'<td colspan="'+colspan+'"></td>';}
function ds_template_day(d,m,y){return'<td class="ds_cell" onclick="ds_onclick('+d+','+m+','+y+')">'+d+'</td>';}
function ds_template_main_below(){return'</tr></table>';}
function ds_draw_calendar(m,y){ds_ob_clean();ds_echo(ds_template_main_above(y,ds_monthnames[m]));for(i=0;i<7;i++){ds_echo(ds_template_day_row(ds_daynames[i]));}
var ds_dc_date=new Date();ds_dc_date.setMonth(m-1);ds_dc_date.setFullYear(y);ds_dc_date.setDate(1);if(m==1||m==3||m==5||m==7||m==8||m==10||m==12){days=31;}else if(m==4||m==6||m==9||m==11){days=30;}else{days=((y%4==0)&&(y%100!=0)||(y%400==0))?29:28;}
var first_day=ds_dc_date.getDay();var first_loop=1;ds_echo(ds_template_new_week());if(first_day!=0){ds_echo(ds_template_blank_cell(first_day));}
var j=first_day;for(i=0;i<days;i++){if(j==0&&!first_loop){ds_echo(ds_template_new_week());}
ds_echo(ds_template_day(i+1,m,y));first_loop=0;j++;j%=7;}
ds_echo(ds_template_main_below());ds_ob_flush();}
function ds_sh(t){ds_element=t;if(ds_element.value){a=ds_str2date(ds_element.value);ds_c_month=a[1];ds_c_year=a[0];}else{var ds_sh_date=new Date();ds_c_month=ds_sh_date.getMonth()+1;ds_c_year=ds_sh_date.getFullYear();}
ds_draw_calendar(ds_c_month,ds_c_year);ds_ce.style.display='';the_left=ds_getleft(t);the_top=ds_gettop(t)+t.offsetHeight;ds_ce.style.left=the_left+'px';ds_ce.style.top=the_top+'px';}
function ds_hi(){return ds_ce.style.display='none';}
function ds_nm(){ds_c_month++;if(ds_c_month>12){ds_c_month=1;ds_c_year++;}
ds_draw_calendar(ds_c_month,ds_c_year);}
function ds_pm(){ds_c_month=ds_c_month-1;if(ds_c_month<1){ds_c_month=12;ds_c_year=ds_c_year-1;}
ds_draw_calendar(ds_c_month,ds_c_year);}
function ds_ny(){ds_c_year++;ds_draw_calendar(ds_c_month,ds_c_year);}
function ds_py(){ds_c_year=ds_c_year-1;ds_draw_calendar(ds_c_month,ds_c_year);}
function ds_format_date(d,m,y){m2='00'+m;m2=m2.substr(m2.length-2);d2='00'+d;d2=d2.substr(d2.length-2);return y+'-'+m2+'-'+d2;}
function ds_str2date(s){return t=s.split(/\-0?/g);}
function ds_onclick(d,m,y){ds_hi();if(typeof(ds_element.value)!='undefined'){ds_element.value=ds_format_date(d,m,y);ds_element.onchange();}else if(typeof(ds_element.innerHTML)!='undefined'){ds_element.innerHTML=ds_format_date(d,m,y);}else{alert(ds_format_date(d,m,y));}}
function hidSub(){document.getElementById('diForm').style.display='none';document.getElementById('diSub').style.display='block';document.getElementById('diSub').focus();return true;}
function submit_post(btn,tle){if(!document.forms.fp['post[exp_lid]'].selectedIndex){alert(exp_errmsg);return false;}
if(trim(tle)){if('none'==document.getElementById('support').style.display)
document.forms.fp['post[begin_at]'].value=document.forms.fp['post[end_at]'].value='0000-00-00';else if('0000-00-00'==document.forms.fp['post[begin_at]']||''==document.forms.fp['post[begin_at]']){alert(date_errmsg);return false;}
return hidSub();}else{alert(title_errmsg);return false;}}
function changeInvoiceHighlight(elem){elem.parentNode.parentNode.bgColor=elem.parentNode.parentNode.bgColor=='#eeeeee'?'#ffffff':'#eeeeee';}
function clearCheckBoxes(){var chk=document.forms[1].elements["paymentids[]"];for(i=0;i<chk.length;i++){if(chk[i].parentNode.parentNode.bgColor=="#eeeeee")
chk[i].checked=false;}
return true;}
