/*
	@ All scripts
	@ ViTools Project
	@ 2009 - Virtual Developpement
*/

function link_submit(form,vn,val,cs,ci) { vn.value = val; if(form_submit(form,cs,ci)) { form.submit(); } }
function link_submit2(form,cs,ci) { if(form_submit(form,cs,ci)) { form.submit(); } }
function link_submit3(form,vn,val,cs,ci) { vn.value = val; if(form_submit2(form,cs,ci)) { form.submit(); } }
function form_submit(form,cs,ci) { if(cs.value==0) { cs.value=1; ci.value=parseInt(ci.value)+1; return true; } else { return false; } }
function form_submit2(form,cs,ci) { if(cs.value==0) { cs.value=1; ci.value=parseInt(ci.value)+1; } return true; }
function majSpan(span,value) { span.innerHTML = value;  }
function majHidden(hid,value) { hid.value = value;  }
function writeNumber(obj,th,dec) { obj.value = number_format(Math.round(obj.value.replace(/\./g,'').replace(/\,/g,'')),th,dec); }
function number_format(number,thousands_sep,dec_point) { if(number<0) { return 0; } decimals = 0; var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals; var d = dec_point == undefined ? '.' : dec_point; var t = thousands_sep == undefined ? ',' : thousands_sep, s = n < 0 ? '-' : ''; var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + '', j = (j = i.length) > 3 ? j % 3 : 0; return s + (j ? i.substr(0, j) + t : '') + i.substr(j).replace(/(\d{3})(?=\d)/g, '$1' + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : ''); }
function refresh_page() { window.history.go(0); }
function ajax_return(responseText) { ret = responseText.match(/\<\!\-\- \[([^\]]+)\] \-\-\>/); if(ret!=null && ret!='') { responseText = '&nbsp;'; document.location = './'+ret[1]; } return responseText; }
var oxOffset=6,oyOffset=5,oba=false,ow3c=document.getElementById&&!document.all,oie=document.all;if(oie||ow3c)var xBulle;
function ietruebody(){return document.compatMode&&document.compatMode!="BackCompat"?document.documentElement:document.body}
function aBulle(html,css){$('overdiv').innerHTML = html; $('overdiv').className = css; zBulle();if(ow3c||oie){xBulle=$('overdiv');xBulle.style.display="block";oba=true}}
function zBulle(){if((ow3c||oie)&&xBulle){xBulle.style.display="none";oba=false}}
function mbulle(c){var a="px";if(!oba)return; var d=ow3c?c.pageX:event.clientX+ietruebody().scrollLeft,f=ow3c?c.pageY:event.clientY+ietruebody().scrollTop,b=oie&&!window.opera?document.body.clientWidth-20:window.innerWidth-20,e=oie&&!window.opera?document.body.clientHeight-20:window.innerHeight-20,h=oie&&!window.opera?b-window.event.clientX-oxOffset:b-c.clientX-oxOffset,g=oie&&!window.opera?e-window.event.clientY-oyOffset:e-c.clientY-oyOffset,i=oxOffset<0?oxOffset*-1:-1e3; if(xBulle.offsetWidth>b/3)xBulle.style.width=b/3;if(h<xBulle.offsetWidth)xBulle.style.left=d-xBulle.offsetWidth+a;else xBulle.style.left=d<i?"5px":d+oxOffset+a;xBulle.style.top=g<xBulle.offsetHeight?f-xBulle.offsetHeight-oyOffset+a:f+oyOffset+a} document.onmousemove=mbulle;
var Chrono=function(sec,id,format){this.sec=sec;this.obj=document.getElementById(id);this.format=format.split(',');this.Init();};Chrono.prototype={Init:function(){this.Lancer();},Lancer:function(){this.Affiche();if(this.sec>0){this.sec--;var courant=this;setTimeout(function(){courant.Lancer();},1000);}},Affiche:function(){span=this.obj;if(this.sec>0){minu=Math.floor(this.sec/60);sec=this.sec-minu*60;heur=Math.floor(minu/60);minu=minu-heur*60;jour=Math.floor(heur/24);heur=heur-jour*24;chr='';if(jour>0){chr=chr+Chrono.Digit(jour)+this.format[0];}if(heur>0){chr=chr+Chrono.Digit(heur)+this.format[1];}if(minu>0){chr=chr+Chrono.Digit(minu)+this.format[2];}if(sec>0){chr=chr+Chrono.Digit(sec)+this.format[3];}span.innerHTML=chr;}else{span.innerHTML=this.format[4];}}};Chrono.Digit=function(nb){if(nb<=9&&nb>=0){return'0'+nb;}else{return nb;}};
function bbcode(textArea,tag){if(navigator.appName.indexOf('Internet Explorer')!=-1){textArea.selectedText=document.selection.createRange().text;textArea.selectionStart=textArea.value.indexOf(textArea.selectedText);textArea.selectionEnd=textArea.selectionStart+textArea.selectedText.length;if(textArea.selectionStart<0){textArea.selectionStart=0;textArea.selectionEnd=0;}}else{textArea.selectedText=textArea.value.substring(textArea.selectionStart,textArea.selectionEnd);}if(textArea.selectedText!=''){textArea.value=textArea.value.substring(0,textArea.selectionStart)+'['+tag+']'+textArea.selectedText+'[/'+tag+']'+textArea.value.substring(textArea.selectionEnd,textArea.value.length);}else{textArea.value=textArea.value+'['+tag+']'+'[/'+tag+']';}}

/*
	CRIR - Checkbox & Radio Input Replacement
	Author: Chris Erwin (me[at]chriserwin.com)
	www.chriserwin.com/scripts/crir/

	Updated July 27, 2006.
	Jesse Gavin added the AddEvent function to initialize
	the script. He also converted the script to JSON format.
	
	Updated July 30, 2006.
	Added the ability to tab to elements and use the spacebar
	to check the input element. This bit of functionality was
	based on a tip from Adam Burmister.
*/

crir={userAgent:'',isSafari:false,init:function(){this.userAgent=navigator.userAgent.toLowerCase();this.isSafari=((this.userAgent.indexOf('safari')!=-1)&&(this.userAgent.indexOf('mac')!=-1))?true:false;if(!this.isSafari){arrLabels=document.getElementsByTagName('label');searchLabels:for(var i=0;i<arrLabels.length;i++){if(arrLabels[i].getAttributeNode('for')&&arrLabels[i].getAttributeNode('for').value!=''){labelElementFor=arrLabels[i].getAttributeNode('for').value;inputElement=document.getElementById(labelElementFor);}else{continue searchLabels;}inputElementClass=inputElement.className;if(inputElementClass=='crirHiddenJS'){inputElement.className='crirHidden';inputElementType=inputElement.getAttributeNode('type').value;if(inputElementType=="checkbox"){inputElement.onclick=crir.toggleCheckboxLabel;}else{inputElement.onclick=crir.toggleRadioLabel;}if(inputElement.checked){if(inputElementType=='checkbox'){arrLabels[i].className='checkbox_checked';}else{arrLabels[i].className='radio_checked';}}else{if(inputElementType=='checkbox'){arrLabels[i].className='checkbox_unchecked';}else{arrLabels[i].className='radio_unchecked';}}}else if(inputElement.nodeName!='SELECT'&&inputElement.getAttributeNode('type').value=='radio'){arrLabels[i].onclick=crir.toggleRadioLabel;inputElement.onclick=crir.toggleRadioLabel;}}}},findLabel:function(inputElementID){arrLabels=document.getElementsByTagName('label');searchLoop:for(var i=0;i<arrLabels.length;i++){if(arrLabels[i].getAttributeNode('for')&&arrLabels[i].getAttributeNode('for').value==inputElementID){return arrLabels[i];break searchLoop;}}},toggleCheckboxLabel:function(){labelElement=crir.findLabel(this.getAttributeNode('id').value);hiddenElement=document.getElementById(this.getAttributeNode('id').value.replace(/check_/g,''));if(labelElement.className=='checkbox_checked'){hiddenElement.value=0;labelElement.className="checkbox_unchecked";}else{hiddenElement.value=1;labelElement.className="checkbox_checked";}},toggleRadioLabel:function(){clickedLabelElement=crir.findLabel(this.getAttributeNode('id').value);clickedInputElement=this;clickedInputElementName=clickedInputElement.getAttributeNode('name').value;arrInputs=document.getElementsByTagName('input');for(var i=0;i<arrInputs.length;i++){inputElementType=arrInputs[i].getAttributeNode('type').value;if(inputElementType=='radio'){inputElementName=arrInputs[i].getAttributeNode('name').value;inputElementClass=arrInputs[i].className;if(inputElementName==clickedInputElementName&&inputElementClass=='crirHidden'){inputElementID=arrInputs[i].getAttributeNode('id').value;labelElement=crir.findLabel(inputElementID);labelElement.className='radio_unchecked';}}}if(clickedInputElement.className=='crirHidden'){clickedLabelElement.className='radio_checked';}},addEvent:function(element,eventType,doFunction,useCapture){if(element.addEventListener){element.addEventListener(eventType,doFunction,useCapture);return true;}else if(element.attachEvent){var r=element.attachEvent('on'+eventType,doFunction);return r;}else{element['on'+eventType]=doFunction;}}};crir.addEvent(window,'load',crir.init,false);

/*****************************************************************
 *
 * jsProgressBarHandler 0.3.3 - by Bramus! - http://www.bram.us/
 *
 * @see http://www.barenakedapp.com/the-design/displaying-percentages on how to create a progressBar Background Image!
 *
 * Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
 *
 *****************************************************************/

var autoHook=true;var defaultOptions={animate:false,showText:true,width:100,boxImage:'./skins/default/medias/percentImage.png',barImage:'./skins/default/medias/percentImage_back.png',height:6,onTick:function(pbObj){return true;}};if(!JS_BRAMUS){var JS_BRAMUS=new Object();}JS_BRAMUS.jsProgressBar=Class.create();JS_BRAMUS.jsProgressBar.prototype={el:null,id:null,percentage:null,options:null,initialPos:null,initialPerc:null,pxPerPercent:null,backIndex:null,numPreloaded:null,running:null,queue:false,initialize:function(el,percentage,options){this.options=Object.clone(defaultOptions);Object.extend(this.options,options||{});this.el=$(el);this.id=$(el).id;this.percentage=0;this.backIndex=0;this.numPreloaded=0;this.running=false;this.queue=Array();this.imgWidth=this.options.width*2;this.initialPos=this.options.width*(-1);this.pxPerPercent=this.options.width/100;this.initialPerc=percentage;if(this.options.barImage.constructor!=Array){this.options.barImage=Array(this.options.barImage);}this.preloadImages();},preloadImages:function(){for(i=0;i<this.options.barImage.length;i++){var newImage=null;newImage=new Image();newImage.onload=function(){this.numPreloaded++;}.bind(this);newImage.onerror=function(){this.numPreloaded++;}.bind(this);newImage.onabort=function(){this.numPreloaded++;}.bind(this);newImage.src=this.options.barImage[i];if(newImage.complete){this.numPreloaded++;}}if(!Prototype.Browser.IE){this.checkPreloadedImages();}else{this.initVisuals();}},checkPreloadedImages:function(){if(parseInt(this.numPreloaded,10)>=parseInt(this.options.barImage.length,10)){this.initVisuals();}else{if(parseInt(this.numPreloaded,10)<=parseInt(this.options.barImage.length,10)){setTimeout(function(){this.checkPreloadedImages();}.bind(this),100);}}},initVisuals:function(){$(this.el).update('<div style="float:left; width:auto; height:auto; margin:5px 5px 0px 0px; display:inline;"><img id="'+this.id+'_percentImage" src="'+this.options.boxImage+'" alt="0%" style="width: '+this.options.width+'px; height: '+this.options.height+'px; background-position: '+this.initialPos+'px 50%; background-image: url('+this.options.barImage[this.backIndex]+'); padding: 0; margin: 0;" class="percentImage" /></div>'+((this.options.showText==true)?' <div style="float:left; width:30px; height:auto;" id="'+this.id+'_percentText" class="percentText">0%</div>':''));this.setPercentage(this.initialPerc);},setPercentage:function(targetPercentage,clearQueue){if(clearQueue){this.percentage=(this.queue.length!=0)?this.queue[0]:targetPercentage;this.timer=null;this.queue=[];setTimeout(function(){this.setPercentage(targetPercentage);}.bind(this),10);}else{this.queue.push(targetPercentage);if(this.running==false){this.processQueue();}}},processQueue:function(){if(this.queue.length>0){this.running=true;this.processQueueEntry(this.queue[0]);}else{return;}},processQueueEntry:function(targetPercentage){var curPercentage=parseInt(this.percentage,10);if((targetPercentage.toString().substring(0,1)=="+")||(targetPercentage.toString().substring(0,1)=="-")){targetPercentage=curPercentage+parseInt(targetPercentage);}if(targetPercentage<0)targetPercentage=0;if(targetPercentage>100)targetPercentage=100;if(this.options.animate==false){this.options.animate=true;this.queue.splice(0,1);this._setBgPosition(targetPercentage);if(!this.options.onTick(this)){return;}this.running=false;this.processQueue();return;}if(targetPercentage!=curPercentage){if(curPercentage<targetPercentage){newPercentage=curPercentage+1;}else{newPercentage=curPercentage-1;}callTick=true;}else{newPercentage=curPercentage;callTick=false;}this._setBgPosition(newPercentage);if(callTick&&!this.options.onTick(this)){return;}if(curPercentage!=newPercentage){this.timer=setTimeout(function(){this.processQueueEntry(targetPercentage);}.bind(this),10);}else{this.queue.splice(0,1);this.running=false;this.timer=null;this.processQueue();return;}},getPercentage:function(id){return this.percentage;},_setBgPosition:function(percentage){$(this.id+"_percentImage").style.backgroundPosition=(this.initialPos+(percentage*this.pxPerPercent))+"px 50%";var newBackIndex=Math.floor((percentage-1)/(100/this.options.barImage.length));if((newBackIndex!=this.backIndex)&&(this.options.barImage[newBackIndex]!=undefined)){$(this.id+"_percentImage").style.backgroundImage="url("+this.options.barImage[newBackIndex]+")";}this.backIndex=newBackIndex;$(this.id+"_percentImage").alt=percentage+"%";$(this.id+"_percentImage").title=percentage+"%";if(this.options.showText==true){$(this.id+"_percentText").update(""+percentage+"%");}this.percentage=percentage;}};JS_BRAMUS.jsProgressBarHandler=Class.create();JS_BRAMUS.jsProgressBarHandler.prototype={pbArray:new Array(),initialize:function(){$$('span.progressBar').each(function(el){this.pbArray[el.id]=new JS_BRAMUS.jsProgressBar(el,parseInt(el.innerHTML.replace("%","")));}.bind(this));},setPercentage:function(el,percentage,clearQueue){this.pbArray[el].setPercentage(percentage,clearQueue);},getPercentage:function(el){return this.pbArray[el].getPercentage();}};if(autoHook==true){function initProgressBarHandler(){myJsProgressBarHandler=new JS_BRAMUS.jsProgressBarHandler();}document.observe('dom:loaded',initProgressBarHandler,false);}

// Copyright (c) 2006 - 2007 Gabriel Lanzani (http://www.glanzani.com.ar)
// 
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditpuuions:
// 
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// SEE CHANGELOG FOR A COMPLETE CHANGES OVERVIEW
// VERSION 0.3

Autocompleter.SelectBox=Class.create();Autocompleter.SelectBox.prototype=Object.extend(new Autocompleter.Base(),{initialize:function(select,options){ this.element="<input type=\"text\" id=\""+$(select).id+"_combo\"/>";new Insertion.Before(select,this.element);var inputClasses=Element.classNames(select);inputClasses.each(function(inputClass){Element.addClassName($(select).id+"_combo",inputClass);});this.update="<div id=\""+$(select).id+"_options\" class=\"autocomplete\"></div>";new Insertion.Before(select,this.update);this.baseInitialize($(select).id+"_combo",$(select).id+"_options",options);this.select=select;this.selectOptions=[];$(this.element.id).setAttribute('readonly','readonly');this.element.readOnly=true;$($(select).id+"_combo").style.borderColor = this.options.bordercss;if(this.options.debug)alert('input '+this.element.id+' and div '+this.update.id+' created, Autocompleter.Base() initialized');if(!this.options.debug)Element.hide(select);var optionList=$(this.select).getElementsByTagName('option');var nodes=$A(optionList);for(i=0;i<nodes.length;i++){this.selectOptions.push("<li id=\""+nodes[i].value+"\">"+nodes[i].innerHTML+'</li>');if(nodes[i].getAttribute("selected")){this.element.value=nodes[i].innerHTML;}if(this.options.debug)alert('option '+nodes[i].innerHTML+' added to '+this.update.id);}Event.observe(this.element,"click",this.activate.bindAsEventListener(this));if($(select).selectedIndex>=0){this.element.value=$(select).options[$(select).selectedIndex].text;}var self=this;this.options.afterUpdateElement=function(text,li){var optionList=$(select).getElementsByTagName('option');var nodes=$A(optionList);self.element.blur();var opt=nodes.find(function(node){return(node.value==li.id);});$(select).selectedIndex=opt.index;text.value=$(select).options[$(select).selectedIndex].text;if(self.options.redirect)document.location.href=opt.value;if(self.options.autoSubmit!=''){$(self.options.autoSubmit).submit();}if(self.options.autoComplete!=''){$(self.options.autoComplete).value=$(select).options[$(select).selectedIndex].value;}if(self.options.autoLaunch!=''){eval(self.options.autoLaunch)();}}},getUpdatedChoices:function(){this.updateChoices(this.setValues());},setValues:function(){return("<ul>"+this.selectOptions.join('')+"</ul>");},setOptions:function(options){this.options=Object.extend({redirect:false,debug:false,autoSubmit:'',autoComplete:'',autoLaunch:'',bordercss:''},options||{});}})

// marquee js equivalent
var tHeight='22px';var cps=2;var aw,mq;var fsz=parseInt(tHeight)-4;var tWidth='200px';var tSpeed=2;var moStop=true;function startMarquee(){if(document.getElementById){var tick='<div id="rsstick" ';if(moStop)tick+=' onmouseover="cps=0" onmouseout="cps=tSpeed"';tick+='><div id="rssmq"><\/div><\/div>';content=document.getElementById('rssmarquee').innerHTML;document.getElementById('rssmarquee').innerHTML=tick;mq=document.getElementById("rssmq");mq.style.left=(parseInt(tWidth)+10)+"px";mq.innerHTML='<span id="tx">'+content+'<\/span>';aw=document.getElementById("tx").offsetWidth;lefttime=setInterval("scrollMarquee()",50)}}function scrollMarquee(){mq.style.left=(parseInt(mq.style.left)>(-10-aw))?parseInt(mq.style.left)-cps+"px":parseInt(tWidth)+10+"px"}

                  