

/*
 * jQuery 1.2.6 - New Wave Javascript
 *
 * Copyright (c) 2008 John Resig (jquery.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * $Date: 2008-05-24 14:22:17 -0400 (Sat, 24 May 2008) $
 * $Rev: 5685 $
 */
(function(){var _jQuery=window.jQuery,_$=window.$;var jQuery=window.jQuery=window.$=function(selector,context){return new jQuery.fn.init(selector,context);};var quickExpr=/^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/,isSimple=/^.[^:#\[\.]*$/,undefined;jQuery.fn=jQuery.prototype={init:function(selector,context){selector=selector||document;if(selector.nodeType){this[0]=selector;this.length=1;return this;}if(typeof selector=="string"){var match=quickExpr.exec(selector);if(match&&(match[1]||!context)){if(match[1])selector=jQuery.clean([match[1]],context);else{var elem=document.getElementById(match[3]);if(elem){if(elem.id!=match[3])return jQuery().find(selector);return jQuery(elem);}selector=[];}}else
return jQuery(context).find(selector);}else if(jQuery.isFunction(selector))return jQuery(document)[jQuery.fn.ready?"ready":"load"](selector);return this.setArray(jQuery.makeArray(selector));},jquery:"1.2.6",size:function(){return this.length;},length:0,get:function(num){return num==undefined?jQuery.makeArray(this):this[num];},pushStack:function(elems){var ret=jQuery(elems);ret.prevObject=this;return ret;},setArray:function(elems){this.length=0;Array.prototype.push.apply(this,elems);return this;},each:function(callback,args){return jQuery.each(this,callback,args);},index:function(elem){var ret=-1;return jQuery.inArray(elem&&elem.jquery?elem[0]:elem,this);},attr:function(name,value,type){var options=name;if(name.constructor==String)if(value===undefined)return this[0]&&jQuery[type||"attr"](this[0],name);else{options={};options[name]=value;}return this.each(function(i){for(name in options)jQuery.attr(type?this.style:this,name,jQuery.prop(this,options[name],type,i,name));});},css:function(key,value){if((key=='width'||key=='height')&&parseFloat(value)<0)value=undefined;return this.attr(key,value,"curCSS");},text:function(text){if(typeof text!="object"&&text!=null)return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(text));var ret="";jQuery.each(text||this,function(){jQuery.each(this.childNodes,function(){if(this.nodeType!=8)ret+=this.nodeType!=1?this.nodeValue:jQuery.fn.text([this]);});});return ret;},wrapAll:function(html){if(this[0])jQuery(html,this[0].ownerDocument).clone().insertBefore(this[0]).map(function(){var elem=this;while(elem.firstChild)elem=elem.firstChild;return elem;}).append(this);return this;},wrapInner:function(html){return this.each(function(){jQuery(this).contents().wrapAll(html);});},wrap:function(html){return this.each(function(){jQuery(this).wrapAll(html);});},append:function(){return this.domManip(arguments,true,false,function(elem){if(this.nodeType==1)this.appendChild(elem);});},prepend:function(){return this.domManip(arguments,true,true,function(elem){if(this.nodeType==1)this.insertBefore(elem,this.firstChild);});},before:function(){return this.domManip(arguments,false,false,function(elem){this.parentNode.insertBefore(elem,this);});},after:function(){return this.domManip(arguments,false,true,function(elem){this.parentNode.insertBefore(elem,this.nextSibling);});},end:function(){return this.prevObject||jQuery([]);},find:function(selector){var elems=jQuery.map(this,function(elem){return jQuery.find(selector,elem);});return this.pushStack(/[^+>] [^+>]/.test(selector)||selector.indexOf("..")>-1?jQuery.unique(elems):elems);},clone:function(events){var ret=this.map(function(){if(jQuery.browser.msie&&!jQuery.isXMLDoc(this)){var clone=this.cloneNode(true),container=document.createElement("div");container.appendChild(clone);return jQuery.clean([container.innerHTML])[0];}else
return this.cloneNode(true);});var clone=ret.find("*").andSelf().each(function(){if(this[expando]!=undefined)this[expando]=null;});if(events===true)this.find("*").andSelf().each(function(i){if(this.nodeType==3)return;var events=jQuery.data(this,"events");for(var type in events)for(var handler in events[type])jQuery.event.add(clone[i],type,events[type][handler],events[type][handler].data);});return ret;},filter:function(selector){return this.pushStack(jQuery.isFunction(selector)&&jQuery.grep(this,function(elem,i){return selector.call(elem,i);})||jQuery.multiFilter(selector,this));},not:function(selector){if(selector.constructor==String)if(isSimple.test(selector))return this.pushStack(jQuery.multiFilter(selector,this,true));else
selector=jQuery.multiFilter(selector,this);var isArrayLike=selector.length&&selector[selector.length-1]!==undefined&&!selector.nodeType;return this.filter(function(){return isArrayLike?jQuery.inArray(this,selector)<0:this!=selector;});},add:function(selector){return this.pushStack(jQuery.unique(jQuery.merge(this.get(),typeof selector=='string'?jQuery(selector):jQuery.makeArray(selector))));},is:function(selector){return!!selector&&jQuery.multiFilter(selector,this).length>0;},hasClass:function(selector){return this.is("."+selector);},val:function(value){if(value==undefined){if(this.length){var elem=this[0];if(jQuery.nodeName(elem,"select")){var index=elem.selectedIndex,values=[],options=elem.options,one=elem.type=="select-one";if(index<0)return null;for(var i=one?index:0,max=one?index+1:options.length;i<max;i++){var option=options[i];if(option.selected){value=jQuery.browser.msie&&!option.attributes.value.specified?option.text:option.value;if(one)return value;values.push(value);}}return values;}else
return(this[0].value||"").replace(/\r/g,"");}return undefined;}if(value.constructor==Number)value+='';return this.each(function(){if(this.nodeType!=1)return;if(value.constructor==Array&&/radio|checkbox/.test(this.type))this.checked=(jQuery.inArray(this.value,value)>=0||jQuery.inArray(this.name,value)>=0);else if(jQuery.nodeName(this,"select")){var values=jQuery.makeArray(value);jQuery("option",this).each(function(){this.selected=(jQuery.inArray(this.value,values)>=0||jQuery.inArray(this.text,values)>=0);});if(!values.length)this.selectedIndex=-1;}else
this.value=value;});},html:function(value){return value==undefined?(this[0]?this[0].innerHTML:null):this.empty().append(value);},replaceWith:function(value){return this.after(value).remove();},eq:function(i){return this.slice(i,i+1);},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments));},map:function(callback){return this.pushStack(jQuery.map(this,function(elem,i){return callback.call(elem,i,elem);}));},andSelf:function(){return this.add(this.prevObject);},data:function(key,value){var parts=key.split(".");parts[1]=parts[1]?"."+parts[1]:"";if(value===undefined){var data=this.triggerHandler("getData"+parts[1]+"!",[parts[0]]);if(data===undefined&&this.length)data=jQuery.data(this[0],key);return data===undefined&&parts[1]?this.data(parts[0]):data;}else
return this.trigger("setData"+parts[1]+"!",[parts[0],value]).each(function(){jQuery.data(this,key,value);});},removeData:function(key){return this.each(function(){jQuery.removeData(this,key);});},domManip:function(args,table,reverse,callback){var clone=this.length>1,elems;return this.each(function(){if(!elems){elems=jQuery.clean(args,this.ownerDocument);if(reverse)elems.reverse();}var obj=this;if(table&&jQuery.nodeName(this,"table")&&jQuery.nodeName(elems[0],"tr"))obj=this.getElementsByTagName("tbody")[0]||this.appendChild(this.ownerDocument.createElement("tbody"));var scripts=jQuery([]);jQuery.each(elems,function(){var elem=clone?jQuery(this).clone(true)[0]:this;if(jQuery.nodeName(elem,"script"))scripts=scripts.add(elem);else{if(elem.nodeType==1)scripts=scripts.add(jQuery("script",elem).remove());callback.call(obj,elem);}});scripts.each(evalScript);});}};jQuery.fn.init.prototype=jQuery.fn;function evalScript(i,elem){if(elem.src)jQuery.ajax({url:elem.src,async:false,dataType:"script"});else
jQuery.globalEval(elem.text||elem.textContent||elem.innerHTML||"");if(elem.parentNode)elem.parentNode.removeChild(elem);}function now(){return+new Date;}jQuery.extend=jQuery.fn.extend=function(){var target=arguments[0]||{},i=1,length=arguments.length,deep=false,options;if(target.constructor==Boolean){deep=target;target=arguments[1]||{};i=2;}if(typeof target!="object"&&typeof target!="function")target={};if(length==i){target=this;--i;}for(;i<length;i++)if((options=arguments[i])!=null)for(var name in options){var src=target[name],copy=options[name];if(target===copy)continue;if(deep&&copy&&typeof copy=="object"&&!copy.nodeType)target[name]=jQuery.extend(deep,src||(copy.length!=null?[]:{}),copy);else if(copy!==undefined)target[name]=copy;}return target;};var expando="jQuery"+now(),uuid=0,windowData={},exclude=/z-?index|font-?weight|opacity|zoom|line-?height/i,defaultView=document.defaultView||{};jQuery.extend({noConflict:function(deep){window.$=_$;if(deep)window.jQuery=_jQuery;return jQuery;},isFunction:function(fn){return!!fn&&typeof fn!="string"&&!fn.nodeName&&fn.constructor!=Array&&/^[\s[]?function/.test(fn+"");},isXMLDoc:function(elem){return elem.documentElement&&!elem.body||elem.tagName&&elem.ownerDocument&&!elem.ownerDocument.body;},globalEval:function(data){data=jQuery.trim(data);if(data){var head=document.getElementsByTagName("head")[0]||document.documentElement,script=document.createElement("script");script.type="text/javascript";if(jQuery.browser.msie)script.text=data;else
script.appendChild(document.createTextNode(data));head.insertBefore(script,head.firstChild);head.removeChild(script);}},nodeName:function(elem,name){return elem.nodeName&&elem.nodeName.toUpperCase()==name.toUpperCase();},cache:{},data:function(elem,name,data){elem=elem==window?windowData:elem;var id=elem[expando];if(!id)id=elem[expando]=++uuid;if(name&&!jQuery.cache[id])jQuery.cache[id]={};if(data!==undefined)jQuery.cache[id][name]=data;return name?jQuery.cache[id][name]:id;},removeData:function(elem,name){elem=elem==window?windowData:elem;var id=elem[expando];if(name){if(jQuery.cache[id]){delete jQuery.cache[id][name];name="";for(name in jQuery.cache[id])break;if(!name)jQuery.removeData(elem);}}else{try{delete elem[expando];}catch(e){if(elem.removeAttribute)elem.removeAttribute(expando);}delete jQuery.cache[id];}},each:function(object,callback,args){var name,i=0,length=object.length;if(args){if(length==undefined){for(name in object)if(callback.apply(object[name],args)===false)break;}else
for(;i<length;)if(callback.apply(object[i++],args)===false)break;}else{if(length==undefined){for(name in object)if(callback.call(object[name],name,object[name])===false)break;}else
for(var value=object[0];i<length&&callback.call(value,i,value)!==false;value=object[++i]){}}return object;},prop:function(elem,value,type,i,name){if(jQuery.isFunction(value))value=value.call(elem,i);return value&&value.constructor==Number&&type=="curCSS"&&!exclude.test(name)?value+"px":value;},className:{add:function(elem,classNames){jQuery.each((classNames||"").split(/\s+/),function(i,className){if(elem.nodeType==1&&!jQuery.className.has(elem.className,className))elem.className+=(elem.className?" ":"")+className;});},remove:function(elem,classNames){if(elem.nodeType==1)elem.className=classNames!=undefined?jQuery.grep(elem.className.split(/\s+/),function(className){return!jQuery.className.has(classNames,className);}).join(" "):"";},has:function(elem,className){return jQuery.inArray(className,(elem.className||elem).toString().split(/\s+/))>-1;}},swap:function(elem,options,callback){var old={};for(var name in options){old[name]=elem.style[name];elem.style[name]=options[name];}callback.call(elem);for(var name in options)elem.style[name]=old[name];},css:function(elem,name,force){if(name=="width"||name=="height"){var val,props={position:"absolute",visibility:"hidden",display:"block"},which=name=="width"?["Left","Right"]:["Top","Bottom"];function getWH(){val=name=="width"?elem.offsetWidth:elem.offsetHeight;var padding=0,border=0;jQuery.each(which,function(){padding+=parseFloat(jQuery.curCSS(elem,"padding"+this,true))||0;border+=parseFloat(jQuery.curCSS(elem,"border"+this+"Width",true))||0;});val-=Math.round(padding+border);}if(jQuery(elem).is(":visible"))getWH();else
jQuery.swap(elem,props,getWH);return Math.max(0,val);}return jQuery.curCSS(elem,name,force);},curCSS:function(elem,name,force){var ret,style=elem.style;function color(elem){if(!jQuery.browser.safari)return false;var ret=defaultView.getComputedStyle(elem,null);return!ret||ret.getPropertyValue("color")=="";}if(name=="opacity"&&jQuery.browser.msie){ret=jQuery.attr(style,"opacity");return ret==""?"1":ret;}if(jQuery.browser.opera&&name=="display"){var save=style.outline;style.outline="0 solid black";style.outline=save;}if(name.match(/float/i))name=styleFloat;if(!force&&style&&style[name])ret=style[name];else if(defaultView.getComputedStyle){if(name.match(/float/i))name="float";name=name.replace(/([A-Z])/g,"-$1").toLowerCase();var computedStyle=defaultView.getComputedStyle(elem,null);if(computedStyle&&!color(elem))ret=computedStyle.getPropertyValue(name);else{var swap=[],stack=[],a=elem,i=0;for(;a&&color(a);a=a.parentNode)stack.unshift(a);for(;i<stack.length;i++)if(color(stack[i])){swap[i]=stack[i].style.display;stack[i].style.display="block";}ret=name=="display"&&swap[stack.length-1]!=null?"none":(computedStyle&&computedStyle.getPropertyValue(name))||"";for(i=0;i<swap.length;i++)if(swap[i]!=null)stack[i].style.display=swap[i];}if(name=="opacity"&&ret=="")ret="1";}else if(elem.currentStyle){var camelCase=name.replace(/\-(\w)/g,function(all,letter){return letter.toUpperCase();});ret=elem.currentStyle[name]||elem.currentStyle[camelCase];if(!/^\d+(px)?$/i.test(ret)&&/^\d/.test(ret)){var left=style.left,rsLeft=elem.runtimeStyle.left;elem.runtimeStyle.left=elem.currentStyle.left;style.left=ret||0;ret=style.pixelLeft+"px";style.left=left;elem.runtimeStyle.left=rsLeft;}}return ret;},clean:function(elems,context){var ret=[];context=context||document;if(typeof context.createElement=='undefined')context=context.ownerDocument||context[0]&&context[0].ownerDocument||document;jQuery.each(elems,function(i,elem){if(!elem)return;if(elem.constructor==Number)elem+='';if(typeof elem=="string"){elem=elem.replace(/(<(\w+)[^>]*?)\/>/g,function(all,front,tag){return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?all:front+"></"+tag+">";});var tags=jQuery.trim(elem).toLowerCase(),div=context.createElement("div");var wrap=!tags.indexOf("<opt")&&[1,"<select multiple='multiple'>","</select>"]||!tags.indexOf("<leg")&&[1,"<fieldset>","</fieldset>"]||tags.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"<table>","</table>"]||!tags.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!tags.indexOf("<td")||!tags.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||!tags.indexOf("<col")&&[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"]||jQuery.browser.msie&&[1,"div<div>","</div>"]||[0,"",""];div.innerHTML=wrap[1]+elem+wrap[2];while(wrap[0]--)div=div.lastChild;if(jQuery.browser.msie){var tbody=!tags.indexOf("<table")&&tags.indexOf("<tbody")<0?div.firstChild&&div.firstChild.childNodes:wrap[1]=="<table>"&&tags.indexOf("<tbody")<0?div.childNodes:[];for(var j=tbody.length-1;j>=0;--j)if(jQuery.nodeName(tbody[j],"tbody")&&!tbody[j].childNodes.length)tbody[j].parentNode.removeChild(tbody[j]);if(/^\s/.test(elem))div.insertBefore(context.createTextNode(elem.match(/^\s*/)[0]),div.firstChild);}elem=jQuery.makeArray(div.childNodes);}if(elem.length===0&&(!jQuery.nodeName(elem,"form")&&!jQuery.nodeName(elem,"select")))return;if(elem[0]==undefined||jQuery.nodeName(elem,"form")||elem.options)ret.push(elem);else
ret=jQuery.merge(ret,elem);});return ret;},attr:function(elem,name,value){if(!elem||elem.nodeType==3||elem.nodeType==8)return undefined;var notxml=!jQuery.isXMLDoc(elem),set=value!==undefined,msie=jQuery.browser.msie;name=notxml&&jQuery.props[name]||name;if(elem.tagName){var special=/href|src|style/.test(name);if(name=="selected"&&jQuery.browser.safari)elem.parentNode.selectedIndex;if(name in elem&&notxml&&!special){if(set){if(name=="type"&&jQuery.nodeName(elem,"input")&&elem.parentNode)throw"type property can't be changed";elem[name]=value;}if(jQuery.nodeName(elem,"form")&&elem.getAttributeNode(name))return elem.getAttributeNode(name).nodeValue;return elem[name];}if(msie&&notxml&&name=="style")return jQuery.attr(elem.style,"cssText",value);if(set)elem.setAttribute(name,""+value);var attr=msie&&notxml&&special?elem.getAttribute(name,2):elem.getAttribute(name);return attr===null?undefined:attr;}if(msie&&name=="opacity"){if(set){elem.zoom=1;elem.filter=(elem.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(value)+''=="NaN"?"":"alpha(opacity="+value*100+")");}return elem.filter&&elem.filter.indexOf("opacity=")>=0?(parseFloat(elem.filter.match(/opacity=([^)]*)/)[1])/100)+'':"";}name=name.replace(/-([a-z])/ig,function(all,letter){return letter.toUpperCase();});if(set)elem[name]=value;return elem[name];},trim:function(text){return(text||"").replace(/^\s+|\s+$/g,"");},makeArray:function(array){var ret=[];if(array!=null){var i=array.length;if(i==null||array.split||array.setInterval||array.call)ret[0]=array;else
while(i)ret[--i]=array[i];}return ret;},inArray:function(elem,array){for(var i=0,length=array.length;i<length;i++)if(array[i]===elem)return i;return-1;},merge:function(first,second){var i=0,elem,pos=first.length;if(jQuery.browser.msie){while(elem=second[i++])if(elem.nodeType!=8)first[pos++]=elem;}else
while(elem=second[i++])first[pos++]=elem;return first;},unique:function(array){var ret=[],done={};try{for(var i=0,length=array.length;i<length;i++){var id=jQuery.data(array[i]);if(!done[id]){done[id]=true;ret.push(array[i]);}}}catch(e){ret=array;}return ret;},grep:function(elems,callback,inv){var ret=[];for(var i=0,length=elems.length;i<length;i++)if(!inv!=!callback(elems[i],i))ret.push(elems[i]);return ret;},map:function(elems,callback){var ret=[];for(var i=0,length=elems.length;i<length;i++){var value=callback(elems[i],i);if(value!=null)ret[ret.length]=value;}return ret.concat.apply([],ret);}});var userAgent=navigator.userAgent.toLowerCase();jQuery.browser={version:(userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1],safari:/webkit/.test(userAgent),opera:/opera/.test(userAgent),msie:/msie/.test(userAgent)&&!/opera/.test(userAgent),mozilla:/mozilla/.test(userAgent)&&!/(compatible|webkit)/.test(userAgent)};var styleFloat=jQuery.browser.msie?"styleFloat":"cssFloat";jQuery.extend({boxModel:!jQuery.browser.msie||document.compatMode=="CSS1Compat",props:{"for":"htmlFor","class":"className","float":styleFloat,cssFloat:styleFloat,styleFloat:styleFloat,readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing"}});jQuery.each({parent:function(elem){return elem.parentNode;},parents:function(elem){return jQuery.dir(elem,"parentNode");},next:function(elem){return jQuery.nth(elem,2,"nextSibling");},prev:function(elem){return jQuery.nth(elem,2,"previousSibling");},nextAll:function(elem){return jQuery.dir(elem,"nextSibling");},prevAll:function(elem){return jQuery.dir(elem,"previousSibling");},siblings:function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);},children:function(elem){return jQuery.sibling(elem.firstChild);},contents:function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);}},function(name,fn){jQuery.fn[name]=function(selector){var ret=jQuery.map(this,fn);if(selector&&typeof selector=="string")ret=jQuery.multiFilter(selector,ret);return this.pushStack(jQuery.unique(ret));};});jQuery.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(name,original){jQuery.fn[name]=function(){var args=arguments;return this.each(function(){for(var i=0,length=args.length;i<length;i++)jQuery(args[i])[original](this);});};});jQuery.each({removeAttr:function(name){jQuery.attr(this,name,"");if(this.nodeType==1)this.removeAttribute(name);},addClass:function(classNames){jQuery.className.add(this,classNames);},removeClass:function(classNames){jQuery.className.remove(this,classNames);},toggleClass:function(classNames){jQuery.className[jQuery.className.has(this,classNames)?"remove":"add"](this,classNames);},remove:function(selector){if(!selector||jQuery.filter(selector,[this]).r.length){jQuery("*",this).add(this).each(function(){jQuery.event.remove(this);jQuery.removeData(this);});if(this.parentNode)this.parentNode.removeChild(this);}},empty:function(){jQuery(">*",this).remove();while(this.firstChild)this.removeChild(this.firstChild);}},function(name,fn){jQuery.fn[name]=function(){return this.each(fn,arguments);};});jQuery.each(["Height","Width"],function(i,name){var type=name.toLowerCase();jQuery.fn[type]=function(size){return this[0]==window?jQuery.browser.opera&&document.body["client"+name]||jQuery.browser.safari&&window["inner"+name]||document.compatMode=="CSS1Compat"&&document.documentElement["client"+name]||document.body["client"+name]:this[0]==document?Math.max(Math.max(document.body["scroll"+name],document.documentElement["scroll"+name]),Math.max(document.body["offset"+name],document.documentElement["offset"+name])):size==undefined?(this.length?jQuery.css(this[0],type):null):this.css(type,size.constructor==String?size:size+"px");};});function num(elem,prop){return elem[0]&&parseInt(jQuery.curCSS(elem[0],prop,true),10)||0;}var chars=jQuery.browser.safari&&parseInt(jQuery.browser.version)<417?"(?:[\\w*_-]|\\\\.)":"(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",quickChild=new RegExp("^>\\s*("+chars+"+)"),quickID=new RegExp("^("+chars+"+)(#)("+chars+"+)"),quickClass=new RegExp("^([#.]?)("+chars+"*)");jQuery.extend({expr:{"":function(a,i,m){return m[2]=="*"||jQuery.nodeName(a,m[2]);},"#":function(a,i,m){return a.getAttribute("id")==m[2];},":":{lt:function(a,i,m){return i<m[3]-0;},gt:function(a,i,m){return i>m[3]-0;},nth:function(a,i,m){return m[3]-0==i;},eq:function(a,i,m){return m[3]-0==i;},first:function(a,i){return i==0;},last:function(a,i,m,r){return i==r.length-1;},even:function(a,i){return i%2==0;},odd:function(a,i){return i%2;},"first-child":function(a){return a.parentNode.getElementsByTagName("*")[0]==a;},"last-child":function(a){return jQuery.nth(a.parentNode.lastChild,1,"previousSibling")==a;},"only-child":function(a){return!jQuery.nth(a.parentNode.lastChild,2,"previousSibling");},parent:function(a){return a.firstChild;},empty:function(a){return!a.firstChild;},contains:function(a,i,m){return(a.textContent||a.innerText||jQuery(a).text()||"").indexOf(m[3])>=0;},visible:function(a){return"hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden";},hidden:function(a){return"hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden";},enabled:function(a){return!a.disabled;},disabled:function(a){return a.disabled;},checked:function(a){return a.checked;},selected:function(a){return a.selected||jQuery.attr(a,"selected");},text:function(a){return"text"==a.type;},radio:function(a){return"radio"==a.type;},checkbox:function(a){return"checkbox"==a.type;},file:function(a){return"file"==a.type;},password:function(a){return"password"==a.type;},submit:function(a){return"submit"==a.type;},image:function(a){return"image"==a.type;},reset:function(a){return"reset"==a.type;},button:function(a){return"button"==a.type||jQuery.nodeName(a,"button");},input:function(a){return/input|select|textarea|button/i.test(a.nodeName);},has:function(a,i,m){return jQuery.find(m[3],a).length;},header:function(a){return/h\d/i.test(a.nodeName);},animated:function(a){return jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length;}}},parse:[/^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,/^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,new RegExp("^([:.#]*)("+chars+"+)")],multiFilter:function(expr,elems,not){var old,cur=[];while(expr&&expr!=old){old=expr;var f=jQuery.filter(expr,elems,not);expr=f.t.replace(/^\s*,\s*/,"");cur=not?elems=f.r:jQuery.merge(cur,f.r);}return cur;},find:function(t,context){if(typeof t!="string")return[t];if(context&&context.nodeType!=1&&context.nodeType!=9)return[];context=context||document;var ret=[context],done=[],last,nodeName;while(t&&last!=t){var r=[];last=t;t=jQuery.trim(t);var foundToken=false,re=quickChild,m=re.exec(t);if(m){nodeName=m[1].toUpperCase();for(var i=0;ret[i];i++)for(var c=ret[i].firstChild;c;c=c.nextSibling)if(c.nodeType==1&&(nodeName=="*"||c.nodeName.toUpperCase()==nodeName))r.push(c);ret=r;t=t.replace(re,"");if(t.indexOf(" ")==0)continue;foundToken=true;}else{re=/^([>+~])\s*(\w*)/i;if((m=re.exec(t))!=null){r=[];var merge={};nodeName=m[2].toUpperCase();m=m[1];for(var j=0,rl=ret.length;j<rl;j++){var n=m=="~"||m=="+"?ret[j].nextSibling:ret[j].firstChild;for(;n;n=n.nextSibling)if(n.nodeType==1){var id=jQuery.data(n);if(m=="~"&&merge[id])break;if(!nodeName||n.nodeName.toUpperCase()==nodeName){if(m=="~")merge[id]=true;r.push(n);}if(m=="+")break;}}ret=r;t=jQuery.trim(t.replace(re,""));foundToken=true;}}if(t&&!foundToken){if(!t.indexOf(",")){if(context==ret[0])ret.shift();done=jQuery.merge(done,ret);r=ret=[context];t=" "+t.substr(1,t.length);}else{var re2=quickID;var m=re2.exec(t);if(m){m=[0,m[2],m[3],m[1]];}else{re2=quickClass;m=re2.exec(t);}m[2]=m[2].replace(/\\/g,"");var elem=ret[ret.length-1];if(m[1]=="#"&&elem&&elem.getElementById&&!jQuery.isXMLDoc(elem)){var oid=elem.getElementById(m[2]);if((jQuery.browser.msie||jQuery.browser.opera)&&oid&&typeof oid.id=="string"&&oid.id!=m[2])oid=jQuery('[@id="'+m[2]+'"]',elem)[0];ret=r=oid&&(!m[3]||jQuery.nodeName(oid,m[3]))?[oid]:[];}else{for(var i=0;ret[i];i++){var tag=m[1]=="#"&&m[3]?m[3]:m[1]!=""||m[0]==""?"*":m[2];if(tag=="*"&&ret[i].nodeName.toLowerCase()=="object")tag="param";r=jQuery.merge(r,ret[i].getElementsByTagName(tag));}if(m[1]==".")r=jQuery.classFilter(r,m[2]);if(m[1]=="#"){var tmp=[];for(var i=0;r[i];i++)if(r[i].getAttribute("id")==m[2]){tmp=[r[i]];break;}r=tmp;}ret=r;}t=t.replace(re2,"");}}if(t){var val=jQuery.filter(t,r);ret=r=val.r;t=jQuery.trim(val.t);}}if(t)ret=[];if(ret&&context==ret[0])ret.shift();done=jQuery.merge(done,ret);return done;},classFilter:function(r,m,not){m=" "+m+" ";var tmp=[];for(var i=0;r[i];i++){var pass=(" "+r[i].className+" ").indexOf(m)>=0;if(!not&&pass||not&&!pass)tmp.push(r[i]);}return tmp;},filter:function(t,r,not){var last;while(t&&t!=last){last=t;var p=jQuery.parse,m;for(var i=0;p[i];i++){m=p[i].exec(t);if(m){t=t.substring(m[0].length);m[2]=m[2].replace(/\\/g,"");break;}}if(!m)break;if(m[1]==":"&&m[2]=="not")r=isSimple.test(m[3])?jQuery.filter(m[3],r,true).r:jQuery(r).not(m[3]);else if(m[1]==".")r=jQuery.classFilter(r,m[2],not);else if(m[1]=="["){var tmp=[],type=m[3];for(var i=0,rl=r.length;i<rl;i++){var a=r[i],z=a[jQuery.props[m[2]]||m[2]];if(z==null||/href|src|selected/.test(m[2]))z=jQuery.attr(a,m[2])||'';if((type==""&&!!z||type=="="&&z==m[5]||type=="!="&&z!=m[5]||type=="^="&&z&&!z.indexOf(m[5])||type=="$="&&z.substr(z.length-m[5].length)==m[5]||(type=="*="||type=="~=")&&z.indexOf(m[5])>=0)^not)tmp.push(a);}r=tmp;}else if(m[1]==":"&&m[2]=="nth-child"){var merge={},tmp=[],test=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(m[3]=="even"&&"2n"||m[3]=="odd"&&"2n+1"||!/\D/.test(m[3])&&"0n+"+m[3]||m[3]),first=(test[1]+(test[2]||1))-0,last=test[3]-0;for(var i=0,rl=r.length;i<rl;i++){var node=r[i],parentNode=node.parentNode,id=jQuery.data(parentNode);if(!merge[id]){var c=1;for(var n=parentNode.firstChild;n;n=n.nextSibling)if(n.nodeType==1)n.nodeIndex=c++;merge[id]=true;}var add=false;if(first==0){if(node.nodeIndex==last)add=true;}else if((node.nodeIndex-last)%first==0&&(node.nodeIndex-last)/first>=0)add=true;if(add^not)tmp.push(node);}r=tmp;}else{var fn=jQuery.expr[m[1]];if(typeof fn=="object")fn=fn[m[2]];if(typeof fn=="string")fn=eval("false||function(a,i){return "+fn+";}");r=jQuery.grep(r,function(elem,i){return fn(elem,i,m,r);},not);}}return{r:r,t:t};},dir:function(elem,dir){var matched=[],cur=elem[dir];while(cur&&cur!=document){if(cur.nodeType==1)matched.push(cur);cur=cur[dir];}return matched;},nth:function(cur,result,dir,elem){result=result||1;var num=0;for(;cur;cur=cur[dir])if(cur.nodeType==1&&++num==result)break;return cur;},sibling:function(n,elem){var r=[];for(;n;n=n.nextSibling){if(n.nodeType==1&&n!=elem)r.push(n);}return r;}});jQuery.event={add:function(elem,types,handler,data){if(elem.nodeType==3||elem.nodeType==8)return;if(jQuery.browser.msie&&elem.setInterval)elem=window;if(!handler.guid)handler.guid=this.guid++;if(data!=undefined){var fn=handler;handler=this.proxy(fn,function(){return fn.apply(this,arguments);});handler.data=data;}var events=jQuery.data(elem,"events")||jQuery.data(elem,"events",{}),handle=jQuery.data(elem,"handle")||jQuery.data(elem,"handle",function(){if(typeof jQuery!="undefined"&&!jQuery.event.triggered)return jQuery.event.handle.apply(arguments.callee.elem,arguments);});handle.elem=elem;jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");type=parts[0];handler.type=parts[1];var handlers=events[type];if(!handlers){handlers=events[type]={};if(!jQuery.event.special[type]||jQuery.event.special[type].setup.call(elem)===false){if(elem.addEventListener)elem.addEventListener(type,handle,false);else if(elem.attachEvent)elem.attachEvent("on"+type,handle);}}handlers[handler.guid]=handler;jQuery.event.global[type]=true;});elem=null;},guid:1,global:{},remove:function(elem,types,handler){if(elem.nodeType==3||elem.nodeType==8)return;var events=jQuery.data(elem,"events"),ret,index;if(events){if(types==undefined||(typeof types=="string"&&types.charAt(0)=="."))for(var type in events)this.remove(elem,type+(types||""));else{if(types.type){handler=types.handler;types=types.type;}jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");type=parts[0];if(events[type]){if(handler)delete events[type][handler.guid];else
for(handler in events[type])if(!parts[1]||events[type][handler].type==parts[1])delete events[type][handler];for(ret in events[type])break;if(!ret){if(!jQuery.event.special[type]||jQuery.event.special[type].teardown.call(elem)===false){if(elem.removeEventListener)elem.removeEventListener(type,jQuery.data(elem,"handle"),false);else if(elem.detachEvent)elem.detachEvent("on"+type,jQuery.data(elem,"handle"));}ret=null;delete events[type];}}});}for(ret in events)break;if(!ret){var handle=jQuery.data(elem,"handle");if(handle)handle.elem=null;jQuery.removeData(elem,"events");jQuery.removeData(elem,"handle");}}},trigger:function(type,data,elem,donative,extra){data=jQuery.makeArray(data);if(type.indexOf("!")>=0){type=type.slice(0,-1);var exclusive=true;}if(!elem){if(this.global[type])jQuery("*").add([window,document]).trigger(type,data);}else{if(elem.nodeType==3||elem.nodeType==8)return undefined;var val,ret,fn=jQuery.isFunction(elem[type]||null),event=!data[0]||!data[0].preventDefault;if(event){data.unshift({type:type,target:elem,preventDefault:function(){},stopPropagation:function(){},timeStamp:now()});data[0][expando]=true;}data[0].type=type;if(exclusive)data[0].exclusive=true;var handle=jQuery.data(elem,"handle");if(handle)val=handle.apply(elem,data);if((!fn||(jQuery.nodeName(elem,'a')&&type=="click"))&&elem["on"+type]&&elem["on"+type].apply(elem,data)===false)val=false;if(event)data.shift();if(extra&&jQuery.isFunction(extra)){ret=extra.apply(elem,val==null?data:data.concat(val));if(ret!==undefined)val=ret;}if(fn&&donative!==false&&val!==false&&!(jQuery.nodeName(elem,'a')&&type=="click")){this.triggered=true;try{elem[type]();}catch(e){}}this.triggered=false;}return val;},handle:function(event){var val,ret,namespace,all,handlers;event=arguments[0]=jQuery.event.fix(event||window.event);namespace=event.type.split(".");event.type=namespace[0];namespace=namespace[1];all=!namespace&&!event.exclusive;handlers=(jQuery.data(this,"events")||{})[event.type];for(var j in handlers){var handler=handlers[j];if(all||handler.type==namespace){event.handler=handler;event.data=handler.data;ret=handler.apply(this,arguments);if(val!==false)val=ret;if(ret===false){event.preventDefault();event.stopPropagation();}}}return val;},fix:function(event){if(event[expando]==true)return event;var originalEvent=event;event={originalEvent:originalEvent};var props="altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target timeStamp toElement type view wheelDelta which".split(" ");for(var i=props.length;i;i--)event[props[i]]=originalEvent[props[i]];event[expando]=true;event.preventDefault=function(){if(originalEvent.preventDefault)originalEvent.preventDefault();originalEvent.returnValue=false;};event.stopPropagation=function(){if(originalEvent.stopPropagation)originalEvent.stopPropagation();originalEvent.cancelBubble=true;};event.timeStamp=event.timeStamp||now();if(!event.target)event.target=event.srcElement||document;if(event.target.nodeType==3)event.target=event.target.parentNode;if(!event.relatedTarget&&event.fromElement)event.relatedTarget=event.fromElement==event.target?event.toElement:event.fromElement;if(event.pageX==null&&event.clientX!=null){var doc=document.documentElement,body=document.body;event.pageX=event.clientX+(doc&&doc.scrollLeft||body&&body.scrollLeft||0)-(doc.clientLeft||0);event.pageY=event.clientY+(doc&&doc.scrollTop||body&&body.scrollTop||0)-(doc.clientTop||0);}if(!event.which&&((event.charCode||event.charCode===0)?event.charCode:event.keyCode))event.which=event.charCode||event.keyCode;if(!event.metaKey&&event.ctrlKey)event.metaKey=event.ctrlKey;if(!event.which&&event.button)event.which=(event.button&1?1:(event.button&2?3:(event.button&4?2:0)));return event;},proxy:function(fn,proxy){proxy.guid=fn.guid=fn.guid||proxy.guid||this.guid++;return proxy;},special:{ready:{setup:function(){bindReady();return;},teardown:function(){return;}},mouseenter:{setup:function(){if(jQuery.browser.msie)return false;jQuery(this).bind("mouseover",jQuery.event.special.mouseenter.handler);return true;},teardown:function(){if(jQuery.browser.msie)return false;jQuery(this).unbind("mouseover",jQuery.event.special.mouseenter.handler);return true;},handler:function(event){if(withinElement(event,this))return true;event.type="mouseenter";return jQuery.event.handle.apply(this,arguments);}},mouseleave:{setup:function(){if(jQuery.browser.msie)return false;jQuery(this).bind("mouseout",jQuery.event.special.mouseleave.handler);return true;},teardown:function(){if(jQuery.browser.msie)return false;jQuery(this).unbind("mouseout",jQuery.event.special.mouseleave.handler);return true;},handler:function(event){if(withinElement(event,this))return true;event.type="mouseleave";return jQuery.event.handle.apply(this,arguments);}}}};jQuery.fn.extend({bind:function(type,data,fn){return type=="unload"?this.one(type,data,fn):this.each(function(){jQuery.event.add(this,type,fn||data,fn&&data);});},one:function(type,data,fn){var one=jQuery.event.proxy(fn||data,function(event){jQuery(this).unbind(event,one);return(fn||data).apply(this,arguments);});return this.each(function(){jQuery.event.add(this,type,one,fn&&data);});},unbind:function(type,fn){return this.each(function(){jQuery.event.remove(this,type,fn);});},trigger:function(type,data,fn){return this.each(function(){jQuery.event.trigger(type,data,this,true,fn);});},triggerHandler:function(type,data,fn){return this[0]&&jQuery.event.trigger(type,data,this[0],false,fn);},toggle:function(fn){var args=arguments,i=1;while(i<args.length)jQuery.event.proxy(fn,args[i++]);return this.click(jQuery.event.proxy(fn,function(event){this.lastToggle=(this.lastToggle||0)%i;event.preventDefault();return args[this.lastToggle++].apply(this,arguments)||false;}));},hover:function(fnOver,fnOut){return this.bind('mouseenter',fnOver).bind('mouseleave',fnOut);},ready:function(fn){bindReady();if(jQuery.isReady)fn.call(document,jQuery);else
jQuery.readyList.push(function(){return fn.call(this,jQuery);});return this;}});jQuery.extend({isReady:false,readyList:[],ready:function(){if(!jQuery.isReady){jQuery.isReady=true;if(jQuery.readyList){jQuery.each(jQuery.readyList,function(){this.call(document);});jQuery.readyList=null;}jQuery(document).triggerHandler("ready");}}});var readyBound=false;function bindReady(){if(readyBound)return;readyBound=true;if(document.addEventListener&&!jQuery.browser.opera)document.addEventListener("DOMContentLoaded",jQuery.ready,false);if(jQuery.browser.msie&&window==top)(function(){if(jQuery.isReady)return;try{document.documentElement.doScroll("left");}catch(error){setTimeout(arguments.callee,0);return;}jQuery.ready();})();if(jQuery.browser.opera)document.addEventListener("DOMContentLoaded",function(){if(jQuery.isReady)return;for(var i=0;i<document.styleSheets.length;i++)if(document.styleSheets[i].disabled){setTimeout(arguments.callee,0);return;}jQuery.ready();},false);if(jQuery.browser.safari){var numStyles;(function(){if(jQuery.isReady)return;if(document.readyState!="loaded"&&document.readyState!="complete"){setTimeout(arguments.callee,0);return;}if(numStyles===undefined)numStyles=jQuery("style, link[rel=stylesheet]").length;if(document.styleSheets.length!=numStyles){setTimeout(arguments.callee,0);return;}jQuery.ready();})();}jQuery.event.add(window,"load",jQuery.ready);}jQuery.each(("blur,focus,load,resize,scroll,unload,click,dblclick,"+"mousedown,mouseup,mousemove,mouseover,mouseout,change,select,"+"submit,keydown,keypress,keyup,error").split(","),function(i,name){jQuery.fn[name]=function(fn){return fn?this.bind(name,fn):this.trigger(name);};});var withinElement=function(event,elem){var parent=event.relatedTarget;while(parent&&parent!=elem)try{parent=parent.parentNode;}catch(error){parent=elem;}return parent==elem;};jQuery(window).bind("unload",function(){jQuery("*").add(document).unbind();});jQuery.fn.extend({_load:jQuery.fn.load,load:function(url,params,callback){if(typeof url!='string')return this._load(url);var off=url.indexOf(" ");if(off>=0){var selector=url.slice(off,url.length);url=url.slice(0,off);}callback=callback||function(){};var type="GET";if(params)if(jQuery.isFunction(params)){callback=params;params=null;}else{params=jQuery.param(params);type="POST";}var self=this;jQuery.ajax({url:url,type:type,dataType:"html",data:params,complete:function(res,status){if(status=="success"||status=="notmodified")self.html(selector?jQuery("<div/>").append(res.responseText.replace(/<script(.|\s)*?\/script>/g,"")).find(selector):res.responseText);self.each(callback,[res.responseText,status,res]);}});return this;},serialize:function(){return jQuery.param(this.serializeArray());},serializeArray:function(){return this.map(function(){return jQuery.nodeName(this,"form")?jQuery.makeArray(this.elements):this;}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password/i.test(this.type));}).map(function(i,elem){var val=jQuery(this).val();return val==null?null:val.constructor==Array?jQuery.map(val,function(val,i){return{name:elem.name,value:val};}):{name:elem.name,value:val};}).get();}});jQuery.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(i,o){jQuery.fn[o]=function(f){return this.bind(o,f);};});var jsc=now();jQuery.extend({get:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data=null;}return jQuery.ajax({type:"GET",url:url,data:data,success:callback,dataType:type});},getScript:function(url,callback){return jQuery.get(url,null,callback,"script");},getJSON:function(url,data,callback){return jQuery.get(url,data,callback,"json");},post:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data={};}return jQuery.ajax({type:"POST",url:url,data:data,success:callback,dataType:type});},ajaxSetup:function(settings){jQuery.extend(jQuery.ajaxSettings,settings);},ajaxSettings:{url:location.href,global:true,type:"GET",timeout:0,contentType:"application/x-www-form-urlencoded",processData:true,async:true,data:null,username:null,password:null,accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(s){s=jQuery.extend(true,s,jQuery.extend(true,{},jQuery.ajaxSettings,s));var jsonp,jsre=/=\?(&|$)/g,status,data,type=s.type.toUpperCase();if(s.data&&s.processData&&typeof s.data!="string")s.data=jQuery.param(s.data);if(s.dataType=="jsonp"){if(type=="GET"){if(!s.url.match(jsre))s.url+=(s.url.match(/\?/)?"&":"?")+(s.jsonp||"callback")+"=?";}else if(!s.data||!s.data.match(jsre))s.data=(s.data?s.data+"&":"")+(s.jsonp||"callback")+"=?";s.dataType="json";}if(s.dataType=="json"&&(s.data&&s.data.match(jsre)||s.url.match(jsre))){jsonp="jsonp"+jsc++;if(s.data)s.data=(s.data+"").replace(jsre,"="+jsonp+"$1");s.url=s.url.replace(jsre,"="+jsonp+"$1");s.dataType="script";window[jsonp]=function(tmp){data=tmp;success();complete();window[jsonp]=undefined;try{delete window[jsonp];}catch(e){}if(head)head.removeChild(script);};}if(s.dataType=="script"&&s.cache==null)s.cache=false;if(s.cache===false&&type=="GET"){var ts=now();var ret=s.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+ts+"$2");s.url=ret+((ret==s.url)?(s.url.match(/\?/)?"&":"?")+"_="+ts:"");}if(s.data&&type=="GET"){s.url+=(s.url.match(/\?/)?"&":"?")+s.data;s.data=null;}if(s.global&&!jQuery.active++)jQuery.event.trigger("ajaxStart");var remote=/^(?:\w+:)?\/\/([^\/?#]+)/;if(s.dataType=="script"&&type=="GET"&&remote.test(s.url)&&remote.exec(s.url)[1]!=location.host){var head=document.getElementsByTagName("head")[0];var script=document.createElement("script");script.src=s.url;if(s.scriptCharset)script.charset=s.scriptCharset;if(!jsonp){var done=false;script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){done=true;success();complete();head.removeChild(script);}};}head.appendChild(script);return undefined;}var requestDone=false;var xhr=window.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();if(s.username)xhr.open(type,s.url,s.async,s.username,s.password);else
xhr.open(type,s.url,s.async);try{if(s.data)xhr.setRequestHeader("Content-Type",s.contentType);if(s.ifModified)xhr.setRequestHeader("If-Modified-Since",jQuery.lastModified[s.url]||"Thu, 01 Jan 1970 00:00:00 GMT");xhr.setRequestHeader("X-Requested-With","XMLHttpRequest");xhr.setRequestHeader("Accept",s.dataType&&s.accepts[s.dataType]?s.accepts[s.dataType]+", */*":s.accepts._default);}catch(e){}if(s.beforeSend&&s.beforeSend(xhr,s)===false){s.global&&jQuery.active--;xhr.abort();return false;}if(s.global)jQuery.event.trigger("ajaxSend",[xhr,s]);var onreadystatechange=function(isTimeout){if(!requestDone&&xhr&&(xhr.readyState==4||isTimeout=="timeout")){requestDone=true;if(ival){clearInterval(ival);ival=null;}status=isTimeout=="timeout"&&"timeout"||!jQuery.httpSuccess(xhr)&&"error"||s.ifModified&&jQuery.httpNotModified(xhr,s.url)&&"notmodified"||"success";if(status=="success"){try{data=jQuery.httpData(xhr,s.dataType,s.dataFilter);}catch(e){status="parsererror";}}if(status=="success"){var modRes;try{modRes=xhr.getResponseHeader("Last-Modified");}catch(e){}if(s.ifModified&&modRes)jQuery.lastModified[s.url]=modRes;if(!jsonp)success();}else
jQuery.handleError(s,xhr,status);complete();if(s.async)xhr=null;}};if(s.async){var ival=setInterval(onreadystatechange,13);if(s.timeout>0)setTimeout(function(){if(xhr){xhr.abort();if(!requestDone)onreadystatechange("timeout");}},s.timeout);}try{xhr.send(s.data);}catch(e){jQuery.handleError(s,xhr,null,e);}if(!s.async)onreadystatechange();function success(){if(s.success)s.success(data,status);if(s.global)jQuery.event.trigger("ajaxSuccess",[xhr,s]);}function complete(){if(s.complete)s.complete(xhr,status);if(s.global)jQuery.event.trigger("ajaxComplete",[xhr,s]);if(s.global&&!--jQuery.active)jQuery.event.trigger("ajaxStop");}return xhr;},handleError:function(s,xhr,status,e){if(s.error)s.error(xhr,status,e);if(s.global)jQuery.event.trigger("ajaxError",[xhr,s,e]);},active:0,httpSuccess:function(xhr){try{return!xhr.status&&location.protocol=="file:"||(xhr.status>=200&&xhr.status<300)||xhr.status==304||xhr.status==1223||jQuery.browser.safari&&xhr.status==undefined;}catch(e){}return false;},httpNotModified:function(xhr,url){try{var xhrRes=xhr.getResponseHeader("Last-Modified");return xhr.status==304||xhrRes==jQuery.lastModified[url]||jQuery.browser.safari&&xhr.status==undefined;}catch(e){}return false;},httpData:function(xhr,type,filter){var ct=xhr.getResponseHeader("content-type"),xml=type=="xml"||!type&&ct&&ct.indexOf("xml")>=0,data=xml?xhr.responseXML:xhr.responseText;if(xml&&data.documentElement.tagName=="parsererror")throw"parsererror";if(filter)data=filter(data,type);if(type=="script")jQuery.globalEval(data);if(type=="json")data=eval("("+data+")");return data;},param:function(a){var s=[];if(a.constructor==Array||a.jquery)jQuery.each(a,function(){s.push(encodeURIComponent(this.name)+"="+encodeURIComponent(this.value));});else
for(var j in a)if(a[j]&&a[j].constructor==Array)jQuery.each(a[j],function(){s.push(encodeURIComponent(j)+"="+encodeURIComponent(this));});else
s.push(encodeURIComponent(j)+"="+encodeURIComponent(jQuery.isFunction(a[j])?a[j]():a[j]));return s.join("&").replace(/%20/g,"+");}});jQuery.fn.extend({show:function(speed,callback){return speed?this.animate({height:"show",width:"show",opacity:"show"},speed,callback):this.filter(":hidden").each(function(){this.style.display=this.oldblock||"";if(jQuery.css(this,"display")=="none"){var elem=jQuery("<"+this.tagName+" />").appendTo("body");this.style.display=elem.css("display");if(this.style.display=="none")this.style.display="block";elem.remove();}}).end();},hide:function(speed,callback){return speed?this.animate({height:"hide",width:"hide",opacity:"hide"},speed,callback):this.filter(":visible").each(function(){this.oldblock=this.oldblock||jQuery.css(this,"display");this.style.display="none";}).end();},_toggle:jQuery.fn.toggle,toggle:function(fn,fn2){return jQuery.isFunction(fn)&&jQuery.isFunction(fn2)?this._toggle.apply(this,arguments):fn?this.animate({height:"toggle",width:"toggle",opacity:"toggle"},fn,fn2):this.each(function(){jQuery(this)[jQuery(this).is(":hidden")?"show":"hide"]();});},slideDown:function(speed,callback){return this.animate({height:"show"},speed,callback);},slideUp:function(speed,callback){return this.animate({height:"hide"},speed,callback);},slideToggle:function(speed,callback){return this.animate({height:"toggle"},speed,callback);},fadeIn:function(speed,callback){return this.animate({opacity:"show"},speed,callback);},fadeOut:function(speed,callback){return this.animate({opacity:"hide"},speed,callback);},fadeTo:function(speed,to,callback){return this.animate({opacity:to},speed,callback);},animate:function(prop,speed,easing,callback){var optall=jQuery.speed(speed,easing,callback);return this[optall.queue===false?"each":"queue"](function(){if(this.nodeType!=1)return false;var opt=jQuery.extend({},optall),p,hidden=jQuery(this).is(":hidden"),self=this;for(p in prop){if(prop[p]=="hide"&&hidden||prop[p]=="show"&&!hidden)return opt.complete.call(this);if(p=="height"||p=="width"){opt.display=jQuery.css(this,"display");opt.overflow=this.style.overflow;}}if(opt.overflow!=null)this.style.overflow="hidden";opt.curAnim=jQuery.extend({},prop);jQuery.each(prop,function(name,val){var e=new jQuery.fx(self,opt,name);if(/toggle|show|hide/.test(val))e[val=="toggle"?hidden?"show":"hide":val](prop);else{var parts=val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),start=e.cur(true)||0;if(parts){var end=parseFloat(parts[2]),unit=parts[3]||"px";if(unit!="px"){self.style[name]=(end||1)+unit;start=((end||1)/e.cur(true))*start;self.style[name]=start+unit;}if(parts[1])end=((parts[1]=="-="?-1:1)*end)+start;e.custom(start,end,unit);}else
e.custom(start,val,"");}});return true;});},queue:function(type,fn){if(jQuery.isFunction(type)||(type&&type.constructor==Array)){fn=type;type="fx";}if(!type||(typeof type=="string"&&!fn))return queue(this[0],type);return this.each(function(){if(fn.constructor==Array)queue(this,type,fn);else{queue(this,type).push(fn);if(queue(this,type).length==1)fn.call(this);}});},stop:function(clearQueue,gotoEnd){var timers=jQuery.timers;if(clearQueue)this.queue([]);this.each(function(){for(var i=timers.length-1;i>=0;i--)if(timers[i].elem==this){if(gotoEnd)timers[i](true);timers.splice(i,1);}});if(!gotoEnd)this.dequeue();return this;}});var queue=function(elem,type,array){if(elem){type=type||"fx";var q=jQuery.data(elem,type+"queue");if(!q||array)q=jQuery.data(elem,type+"queue",jQuery.makeArray(array));}return q;};jQuery.fn.dequeue=function(type){type=type||"fx";return this.each(function(){var q=queue(this,type);q.shift();if(q.length)q[0].call(this);});};jQuery.extend({speed:function(speed,easing,fn){var opt=speed&&speed.constructor==Object?speed:{complete:fn||!fn&&easing||jQuery.isFunction(speed)&&speed,duration:speed,easing:fn&&easing||easing&&easing.constructor!=Function&&easing};opt.duration=(opt.duration&&opt.duration.constructor==Number?opt.duration:jQuery.fx.speeds[opt.duration])||jQuery.fx.speeds.def;opt.old=opt.complete;opt.complete=function(){if(opt.queue!==false)jQuery(this).dequeue();if(jQuery.isFunction(opt.old))opt.old.call(this);};return opt;},easing:{linear:function(p,n,firstNum,diff){return firstNum+diff*p;},swing:function(p,n,firstNum,diff){return((-Math.cos(p*Math.PI)/2)+0.5)*diff+firstNum;}},timers:[],timerId:null,fx:function(elem,options,prop){this.options=options;this.elem=elem;this.prop=prop;if(!options.orig)options.orig={};}});jQuery.fx.prototype={update:function(){if(this.options.step)this.options.step.call(this.elem,this.now,this);(jQuery.fx.step[this.prop]||jQuery.fx.step._default)(this);if(this.prop=="height"||this.prop=="width")this.elem.style.display="block";},cur:function(force){if(this.elem[this.prop]!=null&&this.elem.style[this.prop]==null)return this.elem[this.prop];var r=parseFloat(jQuery.css(this.elem,this.prop,force));return r&&r>-10000?r:parseFloat(jQuery.curCSS(this.elem,this.prop))||0;},custom:function(from,to,unit){this.startTime=now();this.start=from;this.end=to;this.unit=unit||this.unit||"px";this.now=this.start;this.pos=this.state=0;this.update();var self=this;function t(gotoEnd){return self.step(gotoEnd);}t.elem=this.elem;jQuery.timers.push(t);if(jQuery.timerId==null){jQuery.timerId=setInterval(function(){var timers=jQuery.timers;for(var i=0;i<timers.length;i++)if(!timers[i]())timers.splice(i--,1);if(!timers.length){clearInterval(jQuery.timerId);jQuery.timerId=null;}},13);}},show:function(){this.options.orig[this.prop]=jQuery.attr(this.elem.style,this.prop);this.options.show=true;this.custom(0,this.cur());if(this.prop=="width"||this.prop=="height")this.elem.style[this.prop]="1px";jQuery(this.elem).show();},hide:function(){this.options.orig[this.prop]=jQuery.attr(this.elem.style,this.prop);this.options.hide=true;this.custom(this.cur(),0);},step:function(gotoEnd){var t=now();if(gotoEnd||t>this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var done=true;for(var i in this.options.curAnim)if(this.options.curAnim[i]!==true)done=false;if(done){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(jQuery.css(this.elem,"display")=="none")this.elem.style.display="block";}if(this.options.hide)this.elem.style.display="none";if(this.options.hide||this.options.show)for(var p in this.options.curAnim)jQuery.attr(this.elem.style,p,this.options.orig[p]);}if(done)this.options.complete.call(this.elem);return false;}else{var n=t-this.startTime;this.state=n/this.options.duration;this.pos=jQuery.easing[this.options.easing||(jQuery.easing.swing?"swing":"linear")](this.state,n,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update();}return true;}};jQuery.extend(jQuery.fx,{speeds:{slow:600,fast:200,def:400},step:{scrollLeft:function(fx){fx.elem.scrollLeft=fx.now;},scrollTop:function(fx){fx.elem.scrollTop=fx.now;},opacity:function(fx){jQuery.attr(fx.elem.style,"opacity",fx.now);},_default:function(fx){fx.elem.style[fx.prop]=fx.now+fx.unit;}}});jQuery.fn.offset=function(){var left=0,top=0,elem=this[0],results;if(elem)with(jQuery.browser){var parent=elem.parentNode,offsetChild=elem,offsetParent=elem.offsetParent,doc=elem.ownerDocument,safari2=safari&&parseInt(version)<522&&!/adobeair/i.test(userAgent),css=jQuery.curCSS,fixed=css(elem,"position")=="fixed";if(elem.getBoundingClientRect){var box=elem.getBoundingClientRect();add(box.left+Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),box.top+Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));add(-doc.documentElement.clientLeft,-doc.documentElement.clientTop);}else{add(elem.offsetLeft,elem.offsetTop);while(offsetParent){add(offsetParent.offsetLeft,offsetParent.offsetTop);if(mozilla&&!/^t(able|d|h)$/i.test(offsetParent.tagName)||safari&&!safari2)border(offsetParent);if(!fixed&&css(offsetParent,"position")=="fixed")fixed=true;offsetChild=/^body$/i.test(offsetParent.tagName)?offsetChild:offsetParent;offsetParent=offsetParent.offsetParent;}while(parent&&parent.tagName&&!/^body|html$/i.test(parent.tagName)){if(!/^inline|table.*$/i.test(css(parent,"display")))add(-parent.scrollLeft,-parent.scrollTop);if(mozilla&&css(parent,"overflow")!="visible")border(parent);parent=parent.parentNode;}if((safari2&&(fixed||css(offsetChild,"position")=="absolute"))||(mozilla&&css(offsetChild,"position")!="absolute"))add(-doc.body.offsetLeft,-doc.body.offsetTop);if(fixed)add(Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));}results={top:top,left:left};}function border(elem){add(jQuery.curCSS(elem,"borderLeftWidth",true),jQuery.curCSS(elem,"borderTopWidth",true));}function add(l,t){left+=parseInt(l,10)||0;top+=parseInt(t,10)||0;}return results;};jQuery.fn.extend({position:function(){var left=0,top=0,results;if(this[0]){var offsetParent=this.offsetParent(),offset=this.offset(),parentOffset=/^body|html$/i.test(offsetParent[0].tagName)?{top:0,left:0}:offsetParent.offset();offset.top-=num(this,'marginTop');offset.left-=num(this,'marginLeft');parentOffset.top+=num(offsetParent,'borderTopWidth');parentOffset.left+=num(offsetParent,'borderLeftWidth');results={top:offset.top-parentOffset.top,left:offset.left-parentOffset.left};}return results;},offsetParent:function(){var offsetParent=this[0].offsetParent;while(offsetParent&&(!/^body|html$/i.test(offsetParent.tagName)&&jQuery.css(offsetParent,'position')=='static'))offsetParent=offsetParent.offsetParent;return jQuery(offsetParent);}});jQuery.each(['Left','Top'],function(i,name){var method='scroll'+name;jQuery.fn[method]=function(val){if(!this[0])return;return val!=undefined?this.each(function(){this==window||this==document?window.scrollTo(!i?val:jQuery(window).scrollLeft(),i?val:jQuery(window).scrollTop()):this[method]=val;}):this[0]==window||this[0]==document?self[i?'pageYOffset':'pageXOffset']||jQuery.boxModel&&document.documentElement[method]||document.body[method]:this[0][method];};});jQuery.each(["Height","Width"],function(i,name){var tl=i?"Left":"Top",br=i?"Right":"Bottom";jQuery.fn["inner"+name]=function(){return this[name.toLowerCase()]()+num(this,"padding"+tl)+num(this,"padding"+br);};jQuery.fn["outer"+name]=function(margin){return this["inner"+name]()+num(this,"border"+tl+"Width")+num(this,"border"+br+"Width")+(margin?num(this,"margin"+tl)+num(this,"margin"+br):0);};});})();

/*
 * Autocomplete - jQuery plugin 1.0.2
 *
 * Copyright (c) 2007 Dylan Verheul, Dan G. Switzer, Anjesh Tuladhar, JÃ¶rn Zaefferer
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id: jquery.autocomplete.js 5747 2008-06-25 18:30:55Z joern.zaefferer $
 *
 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';(3($){$.31.1o({12:3(b,d){5 c=Y b=="1w";d=$.1o({},$.D.1L,{11:c?b:14,w:c?14:b,1D:c?$.D.1L.1D:10,Z:d&&!d.1x?10:3U},d);d.1t=d.1t||3(a){6 a};d.1q=d.1q||d.1K;6 I.K(3(){1E $.D(I,d)})},M:3(a){6 I.X("M",a)},1y:3(a){6 I.15("1y",[a])},20:3(){6 I.15("20")},1Y:3(a){6 I.15("1Y",[a])},1X:3(){6 I.15("1X")}});$.D=3(o,r){5 t={2N:38,2I:40,2D:46,2x:9,2v:13,2q:27,2d:3x,2j:33,2o:34,2e:8};5 u=$(o).3f("12","3c").P(r.24);5 p;5 m="";5 n=$.D.2W(r);5 s=0;5 k;5 h={1z:B};5 l=$.D.2Q(r,o,1U,h);5 j;$.1T.2L&&$(o.2K).X("3S.12",3(){4(j){j=B;6 B}});u.X(($.1T.2L?"3Q":"3N")+".12",3(a){k=a.2F;3L(a.2F){Q t.2N:a.1d();4(l.L()){l.2y()}A{W(0,C)}N;Q t.2I:a.1d();4(l.L()){l.2u()}A{W(0,C)}N;Q t.2j:a.1d();4(l.L()){l.2t()}A{W(0,C)}N;Q t.2o:a.1d();4(l.L()){l.2s()}A{W(0,C)}N;Q r.19&&$.1p(r.R)==","&&t.2d:Q t.2x:Q t.2v:4(1U()){a.1d();j=C;6 B}N;Q t.2q:l.U();N;3A:1I(p);p=1H(W,r.1D);N}}).1G(3(){s++}).3v(3(){s=0;4(!h.1z){2k()}}).2i(3(){4(s++>1&&!l.L()){W(0,C)}}).X("1y",3(){5 c=(1n.7>1)?1n[1]:14;3 23(q,a){5 b;4(a&&a.7){16(5 i=0;i<a.7;i++){4(a[i].M.O()==q.O()){b=a[i];N}}}4(Y c=="3")c(b);A u.15("M",b&&[b.w,b.H])}$.K(1g(u.J()),3(i,a){1R(a,23,23)})}).X("20",3(){n.18()}).X("1Y",3(){$.1o(r,1n[1]);4("w"2G 1n[1])n.1f()}).X("1X",3(){l.1u();u.1u();$(o.2K).1u(".12")});3 1U(){5 b=l.26();4(!b)6 B;5 v=b.M;m=v;4(r.19){5 a=1g(u.J());4(a.7>1){v=a.17(0,a.7-1).2Z(r.R)+r.R+v}v+=r.R}u.J(v);1l();u.15("M",[b.w,b.H]);6 C}3 W(b,c){4(k==t.2D){l.U();6}5 a=u.J();4(!c&&a==m)6;m=a;a=1k(a);4(a.7>=r.22){u.P(r.21);4(!r.1C)a=a.O();1R(a,2V,1l)}A{1B();l.U()}};3 1g(b){4(!b){6[""]}5 d=b.1Z(r.R);5 c=[];$.K(d,3(i,a){4($.1p(a))c[i]=$.1p(a)});6 c}3 1k(a){4(!r.19)6 a;5 b=1g(a);6 b[b.7-1]}3 1A(q,a){4(r.1A&&(1k(u.J()).O()==q.O())&&k!=t.2e){u.J(u.J()+a.48(1k(m).7));$.D.1N(o,m.7,m.7+a.7)}};3 2k(){1I(p);p=1H(1l,47)};3 1l(){5 c=l.L();l.U();1I(p);1B();4(r.2U){u.1y(3(a){4(!a){4(r.19){5 b=1g(u.J()).17(0,-1);u.J(b.2Z(r.R)+(b.7?r.R:""))}A u.J("")}})}4(c)$.D.1N(o,o.H.7,o.H.7)};3 2V(q,a){4(a&&a.7&&s){1B();l.2T(a,q);1A(q,a[0].H);l.1W()}A{1l()}};3 1R(f,d,g){4(!r.1C)f=f.O();5 e=n.2S(f);4(e&&e.7){d(f,e)}A 4((Y r.11=="1w")&&(r.11.7>0)){5 c={45:+1E 44()};$.K(r.2R,3(a,b){c[a]=Y b=="3"?b():b});$.43({42:"41",3Z:"12"+o.3Y,2M:r.2M,11:r.11,w:$.1o({q:1k(f),3X:r.Z},c),3W:3(a){5 b=r.1r&&r.1r(a)||1r(a);n.1h(f,b);d(f,b)}})}A{l.2J();g(f)}};3 1r(c){5 d=[];5 b=c.1Z("\\n");16(5 i=0;i<b.7;i++){5 a=$.1p(b[i]);4(a){a=a.1Z("|");d[d.7]={w:a,H:a[0],M:r.1v&&r.1v(a,a[0])||a[0]}}}6 d};3 1B(){u.1e(r.21)}};$.D.1L={24:"3R",2H:"3P",21:"3O",22:1,1D:3M,1C:B,1a:C,1V:B,1j:10,Z:3K,2U:B,2R:{},1S:C,1K:3(a){6 a[0]},1q:14,1A:B,E:0,19:B,R:", ",1t:3(b,a){6 b.2C(1E 3J("(?![^&;]+;)(?!<[^<>]*)("+a.2C(/([\\^\\$\\(\\)\\[\\]\\{\\}\\*\\.\\+\\?\\|\\\\])/2A,"\\\\$1")+")(?![^<>]*>)(?![^&;]+;)","2A"),"<2z>$1</2z>")},1x:C,1s:3I};$.D.2W=3(g){5 h={};5 j=0;3 1a(s,a){4(!g.1C)s=s.O();5 i=s.3H(a);4(i==-1)6 B;6 i==0||g.1V};3 1h(q,a){4(j>g.1j){18()}4(!h[q]){j++}h[q]=a}3 1f(){4(!g.w)6 B;5 f={},2w=0;4(!g.11)g.1j=1;f[""]=[];16(5 i=0,30=g.w.7;i<30;i++){5 c=g.w[i];c=(Y c=="1w")?[c]:c;5 d=g.1q(c,i+1,g.w.7);4(d===B)1P;5 e=d.3G(0).O();4(!f[e])f[e]=[];5 b={H:d,w:c,M:g.1v&&g.1v(c)||d};f[e].1O(b);4(2w++<g.Z){f[""].1O(b)}};$.K(f,3(i,a){g.1j++;1h(i,a)})}1H(1f,25);3 18(){h={};j=0}6{18:18,1h:1h,1f:1f,2S:3(q){4(!g.1j||!j)6 14;4(!g.11&&g.1V){5 a=[];16(5 k 2G h){4(k.7>0){5 c=h[k];$.K(c,3(i,x){4(1a(x.H,q)){a.1O(x)}})}}6 a}A 4(h[q]){6 h[q]}A 4(g.1a){16(5 i=q.7-1;i>=g.22;i--){5 c=h[q.3F(0,i)];4(c){5 a=[];$.K(c,3(i,x){4(1a(x.H,q)){a[a.7]=x}});6 a}}}6 14}}};$.D.2Q=3(e,g,f,k){5 h={G:"3E"};5 j,y=-1,w,1m="",1M=C,F,z;3 2r(){4(!1M)6;F=$("<3D/>").U().P(e.2H).T("3C","3B").1J(2p.2n);z=$("<3z/>").1J(F).3y(3(a){4(V(a).2m&&V(a).2m.3w()==\'2l\'){y=$("1F",z).1e(h.G).3u(V(a));$(V(a)).P(h.G)}}).2i(3(a){$(V(a)).P(h.G);f();g.1G();6 B}).3t(3(){k.1z=C}).3s(3(){k.1z=B});4(e.E>0)F.T("E",e.E);1M=B}3 V(a){5 b=a.V;3r(b&&b.3q!="2l")b=b.3p;4(!b)6[];6 b}3 S(b){j.17(y,y+1).1e(h.G);2h(b);5 a=j.17(y,y+1).P(h.G);4(e.1x){5 c=0;j.17(0,y).K(3(){c+=I.1i});4((c+a[0].1i-z.1c())>z[0].3o){z.1c(c+a[0].1i-z.3n())}A 4(c<z.1c()){z.1c(c)}}};3 2h(a){y+=a;4(y<0){y=j.1b()-1}A 4(y>=j.1b()){y=0}}3 2g(a){6 e.Z&&e.Z<a?e.Z:a}3 2f(){z.2B();5 b=2g(w.7);16(5 i=0;i<b;i++){4(!w[i])1P;5 a=e.1K(w[i].w,i+1,b,w[i].H,1m);4(a===B)1P;5 c=$("<1F/>").3m(e.1t(a,1m)).P(i%2==0?"3l":"3k").1J(z)[0];$.w(c,"2c",w[i])}j=z.3j("1F");4(e.1S){j.17(0,1).P(h.G);y=0}4($.31.2b)z.2b()}6{2T:3(d,q){2r();w=d;1m=q;2f()},2u:3(){S(1)},2y:3(){S(-1)},2t:3(){4(y!=0&&y-8<0){S(-y)}A{S(-8)}},2s:3(){4(y!=j.1b()-1&&y+8>j.1b()){S(j.1b()-1-y)}A{S(8)}},U:3(){F&&F.U();j&&j.1e(h.G);y=-1},L:3(){6 F&&F.3i(":L")},3h:3(){6 I.L()&&(j.2a("."+h.G)[0]||e.1S&&j[0])},1W:3(){5 a=$(g).3g();F.T({E:Y e.E=="1w"||e.E>0?e.E:$(g).E(),2E:a.2E+g.1i,1Q:a.1Q}).1W();4(e.1x){z.1c(0);z.T({29:e.1s,3e:\'3d\'});4($.1T.3b&&Y 2p.2n.3T.29==="3a"){5 c=0;j.K(3(){c+=I.1i});5 b=c>e.1s;z.T(\'3V\',b?e.1s:c);4(!b){j.E(z.E()-28(j.T("32-1Q"))-28(j.T("32-39")))}}}},26:3(){5 a=j&&j.2a("."+h.G).1e(h.G);6 a&&a.7&&$.w(a[0],"2c")},2J:3(){z&&z.2B()},1u:3(){F&&F.37()}}};$.D.1N=3(b,a,c){4(b.2O){5 d=b.2O();d.36(C);d.35("2P",a);d.4c("2P",c);d.4b()}A 4(b.2Y){b.2Y(a,c)}A{4(b.2X){b.2X=a;b.4a=c}}b.1G()}})(49);',62,261,'|||function|if|var|return|length|||||||||||||||||||||||||data||active|list|else|false|true|Autocompleter|width|element|ACTIVE|value|this|val|each|visible|result|break|toLowerCase|addClass|case|multipleSeparator|moveSelect|css|hide|target|onChange|bind|typeof|max||url|autocomplete||null|trigger|for|slice|flush|multiple|matchSubset|size|scrollTop|preventDefault|removeClass|populate|trimWords|add|offsetHeight|cacheLength|lastWord|hideResultsNow|term|arguments|extend|trim|formatMatch|parse|scrollHeight|highlight|unbind|formatResult|string|scroll|search|mouseDownOnSelect|autoFill|stopLoading|matchCase|delay|new|li|focus|setTimeout|clearTimeout|appendTo|formatItem|defaults|needsInit|Selection|push|continue|left|request|selectFirst|browser|selectCurrent|matchContains|show|unautocomplete|setOptions|split|flushCache|loadingClass|minChars|findValueCallback|inputClass||selected||parseInt|maxHeight|filter|bgiframe|ac_data|COMMA|BACKSPACE|fillList|limitNumberOfItems|movePosition|click|PAGEUP|hideResults|LI|nodeName|body|PAGEDOWN|document|ESC|init|pageDown|pageUp|next|RETURN|nullData|TAB|prev|strong|gi|empty|replace|DEL|top|keyCode|in|resultsClass|DOWN|emptyList|form|opera|dataType|UP|createTextRange|character|Select|extraParams|load|display|mustMatch|receiveData|Cache|selectionStart|setSelectionRange|join|ol|fn|padding|||moveStart|collapse|remove||right|undefined|msie|off|auto|overflow|attr|offset|current|is|find|ac_odd|ac_even|html|innerHeight|clientHeight|parentNode|tagName|while|mouseup|mousedown|index|blur|toUpperCase|188|mouseover|ul|default|absolute|position|div|ac_over|substr|charAt|indexOf|180|RegExp|100|switch|400|keydown|ac_loading|ac_results|keypress|ac_input|submit|style|150|height|success|limit|name|port||abort|mode|ajax|Date|timestamp||200|substring|jQuery|selectionEnd|select|moveEnd'.split('|'),0,{}))

function unhideErrorDiv(elem)
{
  elem.style.display = 'block';
}

function deleteErrorDiv(obj)
{
  obj.parentNode.removeChild(obj);
}

function hideErrorDiv()
{
    unhideErrorDiv(document.getElementById('errorDivWrapper'));
  $('#errorDivWrapper').slideUp("slow", function() { deleteErrorDiv(document.getElementById('errorDivWrapper')); });
}

function errorAjax(xhr)
{
  displayError('Impossible de joindre le serveur');
}

function displayError(msg)
{
	if (document.getElementById('errorDiv'))
	{
		document.getElementById('errorDiv').innerHTML += '<br />' + msg;
	}	
	else
	{
		var div = document.createElement('div');
		var wrapper = document.createElement('div');
		
		div.id = 'errorDiv';
		wrapper.id = 'errorDivWrapper';
		wrapper.style.zIndex='10';
				
		div.innerHTML = msg;
		wrapper.appendChild(div);
		wrapper.style.display = 'none';
		document.body.appendChild(wrapper);
		
		var obj = document.getElementById('errorDivWrapper');
		var ie4=document.all;
		var ns6=document.getElementById&&!document.all;
		var ns4=document.layers

		// if (ie4)
			// obj.style.pixelTop=document.body.scrollTop;
		// else if (ns6)
			// obj.style.top=window.pageYOffset;
		// else if (ns4) 
			// eval(obj.top=eval(window.pageYOffset));
			
		if (navigator.appName=="Microsoft Internet Explorer") 
			var offsety = document.documentElement.scrollTop;
		else 
			var offsety = window.pageYOffset;			
		
		// alert(screen.availHeight+" - "+offsety);
		
		// obj.style.top = offsety;
		obj.style.top = offsety+'px';
						
		displayErrorDiv();
	}
}

function displayErrorDiv()
{
	unhideErrorDiv(document.getElementById('errorDivWrapper'));
	$('#errorDivWrapper').slideDown("slow");
	setTimeout("hideErrorDiv()", 5000);
}

//\/////
//\  overLIB 4.21 - You may not remove or change this notice.
//\  Copyright Erik Bosrup 1998-2004. All rights reserved.
//\
//\  Contributors are listed on the homepage.
//\  This file might be old, always check for the latest version at:
//\  http://www.bosrup.com/web/overlib/
//\
//\  Please read the license agreement (available through the link above)
//\  before using overLIB. Direct any licensing questions to erik@bosrup.com.
//\
//\  Do not sell this as your own work or remove this copyright notice. 
//\  For full details on copying or changing this script please read the
//\  license agreement at the link above. Please give credit on sites that
//\  use overLIB and submit changes of the script so other people can use
//\  them as well.
//   $Revision: 1.119 $                $Date: 2005/07/02 23:41:44 $
//\/////
//\mini

////////
// PRE-INIT
// Ignore these lines, configuration is below.
////////
var olLoaded = 0;var pmStart = 10000000; var pmUpper = 10001000; var pmCount = pmStart+1; var pmt=''; var pms = new Array(); var olInfo = new Info('4.21', 1);
var FREPLACE = 0; var FBEFORE = 1; var FAFTER = 2; var FALTERNATE = 3; var FCHAIN=4;
var olHideForm=0;  // parameter for hiding SELECT and ActiveX elements in IE5.5+ 
var olHautoFlag = 0;  // flags for over-riding VAUTO and HAUTO if corresponding
var olVautoFlag = 0;  // positioning commands are used on the command line
var hookPts = new Array(), postParse = new Array(), cmdLine = new Array(), runTime = new Array();
// for plugins
registerCommands('donothing,inarray,caparray,sticky,background,noclose,caption,left,right,center,offsetx,offsety,fgcolor,bgcolor,textcolor,capcolor,closecolor,width,border,cellpad,status,autostatus,autostatuscap,height,closetext,snapx,snapy,fixx,fixy,relx,rely,fgbackground,bgbackground,padx,pady,fullhtml,above,below,capicon,textfont,captionfont,closefont,textsize,captionsize,closesize,timeout,function,delay,hauto,vauto,closeclick,wrap,followmouse,mouseoff,closetitle,cssoff,compatmode,cssclass,fgclass,bgclass,textfontclass,captionfontclass,closefontclass');

////////
// DEFAULT CONFIGURATION
// Settings you want everywhere are set here. All of this can also be
// changed on your html page or through an overLIB call.
////////
if (typeof ol_fgcolor=='undefined') var ol_fgcolor="#F5F5F5";
if (typeof ol_bgcolor=='undefined') var ol_bgcolor="#666666";
if (typeof ol_textcolor=='undefined') var ol_textcolor="#444444";
if (typeof ol_capcolor=='undefined') var ol_capcolor="#FFFFFF";
if (typeof ol_closecolor=='undefined') var ol_closecolor="#EBEBEB";
if (typeof ol_textfont=='undefined') var ol_textfont="Arial, Helvetica, sans-serif";
if (typeof ol_captionfont=='undefined') var ol_captionfont="Arial, Helvetica, sans-serif";
if (typeof ol_closefont=='undefined') var ol_closefont="Arial, Helvetica, sans-serif";
if (typeof ol_textsize=='undefined') var ol_textsize="1";
if (typeof ol_captionsize=='undefined') var ol_captionsize="1";
if (typeof ol_closesize=='undefined') var ol_closesize="1";
if (typeof ol_width=='undefined') var ol_width="100";
if (typeof ol_border=='undefined') var ol_border="0";
if (typeof ol_cellpad=='undefined') var ol_cellpad=2;
if (typeof ol_offsetx=='undefined') var ol_offsetx=10;
if (typeof ol_offsety=='undefined') var ol_offsety=10;
if (typeof ol_text=='undefined') var ol_text="Default Text";
if (typeof ol_cap=='undefined') var ol_cap="";
if (typeof ol_sticky=='undefined') var ol_sticky=0;
if (typeof ol_background=='undefined') var ol_background="";
if (typeof ol_close=='undefined') var ol_close="Close";
if (typeof ol_hpos=='undefined') var ol_hpos=RIGHT;
if (typeof ol_status=='undefined') var ol_status="";
if (typeof ol_autostatus=='undefined') var ol_autostatus=0;
if (typeof ol_height=='undefined') var ol_height=-1;
if (typeof ol_snapx=='undefined') var ol_snapx=0;
if (typeof ol_snapy=='undefined') var ol_snapy=0;
if (typeof ol_fixx=='undefined') var ol_fixx=-1;
if (typeof ol_fixy=='undefined') var ol_fixy=-1;
if (typeof ol_relx=='undefined') var ol_relx=null;
if (typeof ol_rely=='undefined') var ol_rely=null;
if (typeof ol_fgbackground=='undefined') var ol_fgbackground="";
if (typeof ol_bgbackground=='undefined') var ol_bgbackground="";
if (typeof ol_padxl=='undefined') var ol_padxl=1;
if (typeof ol_padxr=='undefined') var ol_padxr=1;
if (typeof ol_padyt=='undefined') var ol_padyt=1;
if (typeof ol_padyb=='undefined') var ol_padyb=1;
if (typeof ol_fullhtml=='undefined') var ol_fullhtml=0;
if (typeof ol_vpos=='undefined') var ol_vpos=BELOW;
if (typeof ol_aboveheight=='undefined') var ol_aboveheight=0;
if (typeof ol_capicon=='undefined') var ol_capicon="";
if (typeof ol_frame=='undefined') var ol_frame=self;
if (typeof ol_timeout=='undefined') var ol_timeout=0;
if (typeof ol_function=='undefined') var ol_function=null;
if (typeof ol_delay=='undefined') var ol_delay=0;
if (typeof ol_hauto=='undefined') var ol_hauto=0;
if (typeof ol_vauto=='undefined') var ol_vauto=0;
if (typeof ol_closeclick=='undefined') var ol_closeclick=0;
if (typeof ol_wrap=='undefined') var ol_wrap=0;
if (typeof ol_followmouse=='undefined') var ol_followmouse=1;
if (typeof ol_mouseoff=='undefined') var ol_mouseoff=0;
if (typeof ol_closetitle=='undefined') var ol_closetitle='Close';
if (typeof ol_compatmode=='undefined') var ol_compatmode=0;
if (typeof ol_css=='undefined') var ol_css=CSSOFF;
if (typeof ol_fgclass=='undefined') var ol_fgclass="";
if (typeof ol_bgclass=='undefined') var ol_bgclass="";
if (typeof ol_textfontclass=='undefined') var ol_textfontclass="";
if (typeof ol_captionfontclass=='undefined') var ol_captionfontclass="";
if (typeof ol_closefontclass=='undefined') var ol_closefontclass="";

////////
// ARRAY CONFIGURATION
////////

// You can use these arrays to store popup text here instead of in the html.
if (typeof ol_texts=='undefined') var ol_texts = new Array("Text 0", "Text 1");
if (typeof ol_caps=='undefined') var ol_caps = new Array("Caption 0", "Caption 1");

////////
// END OF CONFIGURATION
// Don't change anything below this line, all configuration is above.
////////





////////
// INIT
////////
// Runtime variables init. Don't change for config!
var o3_text="";
var o3_cap="";
var o3_sticky=0;
var o3_background="";
var o3_close="Close";
var o3_hpos=RIGHT;
var o3_offsetx=2;
var o3_offsety=2;
var o3_fgcolor="";
var o3_bgcolor="";
var o3_textcolor="";
var o3_capcolor="";
var o3_closecolor="";
var o3_width=100;
var o3_border=1;
var o3_cellpad=2;
var o3_status="";
var o3_autostatus=0;
var o3_height=-1;
var o3_snapx=0;
var o3_snapy=0;
var o3_fixx=-1;
var o3_fixy=-1;
var o3_relx=null;
var o3_rely=null;
var o3_fgbackground="";
var o3_bgbackground="";
var o3_padxl=0;
var o3_padxr=0;
var o3_padyt=0;
var o3_padyb=0;
var o3_fullhtml=0;
var o3_vpos=BELOW;
var o3_aboveheight=0;
var o3_capicon="";
var o3_textfont="Verdana,Arial,Helvetica";
var o3_captionfont="Verdana,Arial,Helvetica";
var o3_closefont="Verdana,Arial,Helvetica";
var o3_textsize="1";
var o3_captionsize="1";
var o3_closesize="1";
var o3_frame=self;
var o3_timeout=0;
var o3_timerid=0;
var o3_allowmove=0;
var o3_function=null; 
var o3_delay=0;
var o3_delayid=0;
var o3_hauto=0;
var o3_vauto=0;
var o3_closeclick=0;
var o3_wrap=0;
var o3_followmouse=1;
var o3_mouseoff=0;
var o3_closetitle='';
var o3_compatmode=0;
var o3_css=CSSOFF;
var o3_fgclass="";
var o3_bgclass="";
var o3_textfontclass="";
var o3_captionfontclass="";
var o3_closefontclass="";

// Display state variables
var o3_x = 0;
var o3_y = 0;
var o3_showingsticky = 0;
var o3_removecounter = 0;

// Our layer
var over = null;
var fnRef, hoveringSwitch = false;
var olHideDelay;

// Decide browser version
var isMac = (navigator.userAgent.indexOf("Mac") != -1);
var olOp = (navigator.userAgent.toLowerCase().indexOf('opera') > -1 && document.createTextNode);  // Opera 7
var olNs4 = (navigator.appName=='Netscape' && parseInt(navigator.appVersion) == 4);
var olNs6 = (document.getElementById) ? true : false;
var olKq = (olNs6 && /konqueror/i.test(navigator.userAgent));
var olIe4 = (document.all) ? true : false;
var olIe5 = false; 
var olIe55 = false; // Added additional variable to identify IE5.5+
var docRoot = 'document.body';

// Resize fix for NS4.x to keep track of layer
if (olNs4) {
	var oW = window.innerWidth;
	var oH = window.innerHeight;
	window.onresize = function() { if (oW != window.innerWidth || oH != window.innerHeight) location.reload(); }
}

// Microsoft Stupidity Check(tm).
if (olIe4) {
	var agent = navigator.userAgent;
	if (/MSIE/.test(agent)) {
		var versNum = parseFloat(agent.match(/MSIE[ ](\d\.\d+)\.*/i)[1]);
		if (versNum >= 5){
			olIe5=true;
			olIe55=(versNum>=5.5&&!olOp) ? true : false;
			if (olNs6) olNs6=false;
		}
	}
	if (olNs6) olIe4 = false;
}

// Check for compatability mode.
if (document.compatMode && document.compatMode == 'CSS1Compat') {
	docRoot= ((olIe4 && !olOp) ? 'document.documentElement' : docRoot);
}

// Add window onload handlers to indicate when all modules have been loaded
// For Netscape 6+ and Mozilla, uses addEventListener method on the window object
// For IE it uses the attachEvent method of the window object and for Netscape 4.x
// it sets the window.onload handler to the OLonload_handler function for Bubbling
if(window.addEventListener) window.addEventListener("load",OLonLoad_handler,false);
else if (window.attachEvent) window.attachEvent("onload",OLonLoad_handler);

var capExtent;

////////
// PUBLIC FUNCTIONS
////////

// overlib(arg0,...,argN)
// Loads parameters into global runtime variables.
function overlib() {
	if (!olLoaded || isExclusive(overlib.arguments)) return true;
	if (olCheckMouseCapture) olMouseCapture();
	if (over) {
		over = (typeof over.id != 'string') ? o3_frame.document.all['overDiv'] : over;
		cClick();
	}

	// Load defaults to runtime.
  olHideDelay=0;
	o3_text=ol_text;
	o3_cap=ol_cap;
	o3_sticky=ol_sticky;
	o3_background=ol_background;
	o3_close=ol_close;
	o3_hpos=ol_hpos;
	o3_offsetx=ol_offsetx;
	o3_offsety=ol_offsety;
	o3_fgcolor=ol_fgcolor;
	o3_bgcolor=ol_bgcolor;
	o3_textcolor=ol_textcolor;
	o3_capcolor=ol_capcolor;
	o3_closecolor=ol_closecolor;
	o3_width=ol_width;
	o3_border=ol_border;
	o3_cellpad=ol_cellpad;
	o3_status=ol_status;
	o3_autostatus=ol_autostatus;
	o3_height=ol_height;
	o3_snapx=ol_snapx;
	o3_snapy=ol_snapy;
	o3_fixx=ol_fixx;
	o3_fixy=ol_fixy;
	o3_relx=ol_relx;
	o3_rely=ol_rely;
	o3_fgbackground=ol_fgbackground;
	o3_bgbackground=ol_bgbackground;
	o3_padxl=ol_padxl;
	o3_padxr=ol_padxr;
	o3_padyt=ol_padyt;
	o3_padyb=ol_padyb;
	o3_fullhtml=ol_fullhtml;
	o3_vpos=ol_vpos;
	o3_aboveheight=ol_aboveheight;
	o3_capicon=ol_capicon;
	o3_textfont=ol_textfont;
	o3_captionfont=ol_captionfont;
	o3_closefont=ol_closefont;
	o3_textsize=ol_textsize;
	o3_captionsize=ol_captionsize;
	o3_closesize=ol_closesize;
	o3_timeout=ol_timeout;
	o3_function=ol_function;
	o3_delay=ol_delay;
	o3_hauto=ol_hauto;
	o3_vauto=ol_vauto;
	o3_closeclick=ol_closeclick;
	o3_wrap=ol_wrap;	
	o3_followmouse=ol_followmouse;
	o3_mouseoff=ol_mouseoff;
	o3_closetitle=ol_closetitle;
	o3_css=ol_css;
	o3_compatmode=ol_compatmode;
	o3_fgclass=ol_fgclass;
	o3_bgclass=ol_bgclass;
	o3_textfontclass=ol_textfontclass;
	o3_captionfontclass=ol_captionfontclass;
	o3_closefontclass=ol_closefontclass;
	
	setRunTimeVariables();
	
	fnRef = '';
	
	// Special for frame support, over must be reset...
	o3_frame = ol_frame;
	
	if(!(over=createDivContainer())) return false;

	parseTokens('o3_', overlib.arguments);
	if (!postParseChecks()) return false;

	if (o3_delay == 0) {
		return runHook("olMain", FREPLACE);
 	} else {
		o3_delayid = setTimeout("runHook('olMain', FREPLACE)", o3_delay);
		return false;
	}
}

// Clears popups if appropriate
function nd(time) {
	if (olLoaded && !isExclusive()) {
		hideDelay(time);  // delay popup close if time specified

		if (o3_removecounter >= 1) { o3_showingsticky = 0 };
		
		if (o3_showingsticky == 0) {
			o3_allowmove = 0;
			if (over != null && o3_timerid == 0) runHook("hideObject", FREPLACE, over);
		} else {
			o3_removecounter++;
		}
	}
	
	return true;
}

// The Close onMouseOver function for stickies
function cClick() {
	if (olLoaded) {
		runHook("hideObject", FREPLACE, over);
		o3_showingsticky = 0;	
	}	
	return false;
}

// Method for setting page specific defaults.
function overlib_pagedefaults() {
	parseTokens('ol_', overlib_pagedefaults.arguments);
}


////////
// OVERLIB MAIN FUNCTION
////////

// This function decides what it is we want to display and how we want it done.
function olMain() {
	var layerhtml, styleType;
 	runHook("olMain", FBEFORE);
 	
	if (o3_background!="" || o3_fullhtml) {
		// Use background instead of box.
		layerhtml = runHook('ol_content_background', FALTERNATE, o3_css, o3_text, o3_background, o3_fullhtml);
	} else {
		// They want a popup box.
		styleType = (pms[o3_css-1-pmStart] == "cssoff" || pms[o3_css-1-pmStart] == "cssclass");

		// Prepare popup background
		if (o3_fgbackground != "") o3_fgbackground = "background=\""+o3_fgbackground+"\"";
		if (o3_bgbackground != "") o3_bgbackground = (styleType ? "background=\""+o3_bgbackground+"\"" : o3_bgbackground);

		// Prepare popup colors
		if (o3_fgcolor != "") o3_fgcolor = (styleType ? "bgcolor=\""+o3_fgcolor+"\"" : o3_fgcolor);
		if (o3_bgcolor != "") o3_bgcolor = (styleType ? "bgcolor=\""+o3_bgcolor+"\"" : o3_bgcolor);

		// Prepare popup height
		if (o3_height > 0) o3_height = (styleType ? "height=\""+o3_height+"\"" : o3_height);
		else o3_height = "";

		// Decide which kinda box.
		if (o3_cap=="") {
			// Plain
			layerhtml = runHook('ol_content_simple', FALTERNATE, o3_css, o3_text);
		} else {
			// With caption
			if (o3_sticky) {
				// Show close text
				layerhtml = runHook('ol_content_caption', FALTERNATE, o3_css, o3_text, o3_cap, o3_close);
			} else {
				// No close text
				layerhtml = runHook('ol_content_caption', FALTERNATE, o3_css, o3_text, o3_cap, "");
			}
		}
	}	

	// We want it to stick!
	if (o3_sticky) {
		if (o3_timerid > 0) {
			clearTimeout(o3_timerid);
			o3_timerid = 0;
		}
		o3_showingsticky = 1;
		o3_removecounter = 0;
	}

	// Created a separate routine to generate the popup to make it easier
	// to implement a plugin capability
	if (!runHook("createPopup", FREPLACE, layerhtml)) return false;

	// Prepare status bar
	if (o3_autostatus > 0) {
		o3_status = o3_text;
		if (o3_autostatus > 1) o3_status = o3_cap;
	}

	// When placing the layer the first time, even stickies may be moved.
	o3_allowmove = 0;

	// Initiate a timer for timeout
	if (o3_timeout > 0) {          
		if (o3_timerid > 0) clearTimeout(o3_timerid);
		o3_timerid = setTimeout("cClick()", o3_timeout);
	}

	// Show layer
	runHook("disp", FREPLACE, o3_status);
	runHook("olMain", FAFTER);

	return (olOp && event && event.type == 'mouseover' && !o3_status) ? '' : (o3_status != '');
}

////////
// LAYER GENERATION FUNCTIONS
////////
// These functions just handle popup content with tags that should adhere to the W3C standards specification.

// Makes simple table without caption
function ol_content_simple(text) {
	var cpIsMultiple = /,/.test(o3_cellpad);
	var txt = '<table width="'+o3_width+ '" border="0" cellpadding="'+o3_border+'" cellspacing="0" '+(o3_bgclass ? 'class="'+o3_bgclass+'"' : o3_bgcolor+' '+o3_height)+'><tr><td><table width="100%" border="0" '+((olNs4||!cpIsMultiple) ? 'cellpadding="'+o3_cellpad+'" ' : '')+'cellspacing="0" '+(o3_fgclass ? 'class="'+o3_fgclass+'"' : o3_fgcolor+' '+o3_fgbackground+' '+o3_height)+'><tr><td valign="TOP"'+(o3_textfontclass ? ' class="'+o3_textfontclass+'">' : ((!olNs4&&cpIsMultiple) ? ' style="'+setCellPadStr(o3_cellpad)+'">' : '>'))+(o3_textfontclass ? '' : wrapStr(0,o3_textsize,'text'))+text+(o3_textfontclass ? '' : wrapStr(1,o3_textsize))+'</td></tr></table></td></tr></table>';

	set_background("");
	return txt;
}

// Makes table with caption and optional close link
function ol_content_caption(text,title,close) {
	var nameId, txt, cpIsMultiple = /,/.test(o3_cellpad);
	var closing, closeevent;

	closing = "";
	closeevent = "onmouseover";
	if (o3_closeclick == 1) closeevent = (o3_closetitle ? "title='" + o3_closetitle +"'" : "") + " onclick";
	if (o3_capicon != "") {
	  nameId = ' hspace = \"5\"'+' align = \"middle\" alt = \"\"';
	  if (typeof o3_dragimg != 'undefined' && o3_dragimg) nameId =' hspace=\"5\"'+' name=\"'+o3_dragimg+'\" id=\"'+o3_dragimg+'\" align=\"middle\" alt=\"Drag Enabled\" title=\"Drag Enabled\"';
	  o3_capicon = '<img src=\"'+o3_capicon+'\"'+nameId+' />';
	}

	if (close != "")
		closing = '<td '+(!o3_compatmode && o3_closefontclass ? 'class="'+o3_closefontclass : 'align="RIGHT')+'"><a href="javascript:return '+fnRef+'cClick();"'+((o3_compatmode && o3_closefontclass) ? ' class="' + o3_closefontclass + '" ' : ' ')+closeevent+'="return '+fnRef+'cClick();">'+(o3_closefontclass ? '' : wrapStr(0,o3_closesize,'close'))+close+(o3_closefontclass ? '' : wrapStr(1,o3_closesize,'close'))+'</a></td>';
	txt = '<table width="'+o3_width+ '" border="0" cellpadding="'+o3_border+'" cellspacing="0" '+(o3_bgclass ? 'class="'+o3_bgclass+'"' : o3_bgcolor+' '+o3_bgbackground+' '+o3_height)+'><tr><td><table width="100%" border="0" cellpadding="2" cellspacing="0"><tr><td'+(o3_captionfontclass ? ' class="'+o3_captionfontclass+'">' : '>')+(o3_captionfontclass ? '' : '<b>'+wrapStr(0,o3_captionsize,'caption'))+o3_capicon+title+(o3_captionfontclass ? '' : wrapStr(1,o3_captionsize)+'</b>')+'</td>'+closing+'</tr></table><table width="100%" border="0" '+((olNs4||!cpIsMultiple) ? 'cellpadding="'+o3_cellpad+'" ' : '')+'cellspacing="0" '+(o3_fgclass ? 'class="'+o3_fgclass+'"' : o3_fgcolor+' '+o3_fgbackground+' '+o3_height)+'><tr><td valign="TOP"'+(o3_textfontclass ? ' class="'+o3_textfontclass+'">' :((!olNs4&&cpIsMultiple) ? ' style="'+setCellPadStr(o3_cellpad)+'">' : '>'))+(o3_textfontclass ? '' : wrapStr(0,o3_textsize,'text'))+text+(o3_textfontclass ? '' : wrapStr(1,o3_textsize)) + '</td></tr></table></td></tr></table>';

	set_background("");
	return txt;
}

// Sets the background picture,padding and lots more. :)
function ol_content_background(text,picture,hasfullhtml) {
	if (hasfullhtml) {
		txt=text;
	} else {
		txt='<table width="'+o3_width+'" border="0" cellpadding="0" cellspacing="0" height="'+o3_height+'"><tr><td colspan="3" height="'+o3_padyt+'"></td></tr><tr><td width="'+o3_padxl+'"></td><td valign="TOP" width="'+(o3_width-o3_padxl-o3_padxr)+(o3_textfontclass ? '" class="'+o3_textfontclass : '')+'">'+(o3_textfontclass ? '' : wrapStr(0,o3_textsize,'text'))+text+(o3_textfontclass ? '' : wrapStr(1,o3_textsize))+'</td><td width="'+o3_padxr+'"></td></tr><tr><td colspan="3" height="'+o3_padyb+'"></td></tr></table>';
	}

	set_background(picture);
	return txt;
}

// Loads a picture into the div.
function set_background(pic) {
	if (pic == "") {
		if (olNs4) {
			over.background.src = null; 
		} else if (over.style) {
			over.style.backgroundImage = "none";
		}
	} else {
		if (olNs4) {
			over.background.src = pic;
		} else if (over.style) {
			over.style.width=o3_width + 'px';
			over.style.backgroundImage = "url("+pic+")";
		}
	}
}

////////
// HANDLING FUNCTIONS
////////
var olShowId=-1;

// Displays the popup
function disp(statustext) {
	runHook("disp", FBEFORE);
	
	if (o3_allowmove == 0) {
		runHook("placeLayer", FREPLACE);
		(olNs6&&olShowId<0) ? olShowId=setTimeout("runHook('showObject', FREPLACE, over)", 1) : runHook("showObject", FREPLACE, over);
		o3_allowmove = (o3_sticky || o3_followmouse==0) ? 0 : 1;
	}
	
	runHook("disp", FAFTER);

	if (statustext != "") self.status = statustext;
}

// Creates the actual popup structure
function createPopup(lyrContent){
	runHook("createPopup", FBEFORE);
	
	if (o3_wrap) {
		var wd,ww,theObj = (olNs4 ? over : over.style);
		theObj.top = theObj.left = ((olIe4&&!olOp) ? 0 : -10000) + (!olNs4 ? 'px' : 0);
		layerWrite(lyrContent);
		wd = (olNs4 ? over.clip.width : over.offsetWidth);
		if (wd > (ww=windowWidth())) {
			lyrContent=lyrContent.replace(/\&nbsp;/g, ' ');
			o3_width=ww;
			o3_wrap=0;
		} 
	}

	layerWrite(lyrContent);
	
	// Have to set o3_width for placeLayer() routine if o3_wrap is turned on
	if (o3_wrap) o3_width=(olNs4 ? over.clip.width : over.offsetWidth);
	
	runHook("createPopup", FAFTER, lyrContent);

	return true;
}

// Decides where we want the popup.
function placeLayer() {
	var placeX, placeY, widthFix = 0;
	
	// HORIZONTAL PLACEMENT, re-arranged to work in Safari
	if (o3_frame.innerWidth) widthFix=18; 
	iwidth = windowWidth();

	// Horizontal scroll offset
	winoffset=(olIe4) ? eval('o3_frame.'+docRoot+'.scrollLeft') : o3_frame.pageXOffset;

	placeX = runHook('horizontalPlacement',FCHAIN,iwidth,winoffset,widthFix);

	// VERTICAL PLACEMENT, re-arranged to work in Safari
	if (o3_frame.innerHeight) {
		iheight=o3_frame.innerHeight;
	} else if (eval('o3_frame.'+docRoot)&&eval("typeof o3_frame."+docRoot+".clientHeight=='number'")&&eval('o3_frame.'+docRoot+'.clientHeight')) { 
		iheight=eval('o3_frame.'+docRoot+'.clientHeight');
	}			

	// Vertical scroll offset
	scrolloffset=(olIe4) ? eval('o3_frame.'+docRoot+'.scrollTop') : o3_frame.pageYOffset;
	placeY = runHook('verticalPlacement',FCHAIN,iheight,scrolloffset);

	// Actually move the object.
	repositionTo(over, placeX, placeY);
}

// Moves the layer
function olMouseMove(e) {
	var e = (e) ? e : event;

	if (e.pageX) {
		o3_x = e.pageX;
		o3_y = e.pageY;
	} else if (e.clientX) {
		o3_x = eval('e.clientX+o3_frame.'+docRoot+'.scrollLeft');
		o3_y = eval('e.clientY+o3_frame.'+docRoot+'.scrollTop');
	}
	
	if (o3_allowmove == 1) runHook("placeLayer", FREPLACE);

	// MouseOut handler
	if (hoveringSwitch && !olNs4 && runHook("cursorOff", FREPLACE)) {
		(olHideDelay ? hideDelay(olHideDelay) : cClick());
		hoveringSwitch = !hoveringSwitch;
	}
}

// Fake function for 3.0 users.
function no_overlib() { return ver3fix; }

// Capture the mouse and chain other scripts.
function olMouseCapture() {
	capExtent = document;
	var fN, str = '', l, k, f, wMv, sS, mseHandler = olMouseMove;
	var re = /function[ ]*(\w*)\(/;
	
	wMv = (!olIe4 && window.onmousemove);
	if (document.onmousemove || wMv) {
		if (wMv) capExtent = window;
		f = capExtent.onmousemove.toString();
		fN = f.match(re);
		if (fN == null) {
			str = f+'(e); ';
		} else if (fN[1] == 'anonymous' || fN[1] == 'olMouseMove' || (wMv && fN[1] == 'onmousemove')) {
			if (!olOp && wMv) {
				l = f.indexOf('{')+1;
				k = f.lastIndexOf('}');
				sS = f.substring(l,k);
				if ((l = sS.indexOf('(')) != -1) {
					sS = sS.substring(0,l).replace(/^\s+/,'').replace(/\s+$/,'');
					if (eval("typeof " + sS + " == 'undefined'")) window.onmousemove = null;
					else str = sS + '(e);';
				}
			}
			if (!str) {
				olCheckMouseCapture = false;
				return;
			}
		} else {
			if (fN[1]) str = fN[1]+'(e); ';
			else {
				l = f.indexOf('{')+1;
				k = f.lastIndexOf('}');
				str = f.substring(l,k) + '\n';
			}
		}
		str += 'olMouseMove(e); ';
		mseHandler = new Function('e', str);
	}

	capExtent.onmousemove = mseHandler;
	if (olNs4) capExtent.captureEvents(Event.MOUSEMOVE);
}

////////
// PARSING FUNCTIONS
////////

// Does the actual command parsing.
function parseTokens(pf, ar) {
	// What the next argument is expected to be.
	var v, i, mode=-1, par = (pf != 'ol_');	
	var fnMark = (par && !ar.length ? 1 : 0);

	for (i = 0; i < ar.length; i++) {
		if (mode < 0) {
			// Arg is maintext,unless its a number between pmStart and pmUpper
			// then its a command.
			if (typeof ar[i] == 'number' && ar[i] > pmStart && ar[i] < pmUpper) {
				fnMark = (par ? 1 : 0);
				i--;   // backup one so that the next block can parse it
			} else {
				switch(pf) {
					case 'ol_':
						ol_text = ar[i].toString();
						break;
					default:
						o3_text=ar[i].toString();  
				}
			}
			mode = 0;
		} else {
			// Note: NS4 doesn't like switch cases with vars.
			if (ar[i] >= pmCount || ar[i]==DONOTHING) { continue; }
			if (ar[i]==INARRAY) { fnMark = 0; eval(pf+'text=ol_texts['+ar[++i]+'].toString()'); continue; }
			if (ar[i]==CAPARRAY) { eval(pf+'cap=ol_caps['+ar[++i]+'].toString()'); continue; }
			if (ar[i]==STICKY) { if (pf!='ol_') eval(pf+'sticky=1'); continue; }
			if (ar[i]==BACKGROUND) { eval(pf+'background="'+ar[++i]+'"'); continue; }
			if (ar[i]==NOCLOSE) { if (pf!='ol_') opt_NOCLOSE(); continue; }
			if (ar[i]==CAPTION) { eval(pf+"cap='"+escSglQuote(ar[++i])+"'"); continue; }
			if (ar[i]==CENTER || ar[i]==LEFT || ar[i]==RIGHT) { eval(pf+'hpos='+ar[i]); if(pf!='ol_') olHautoFlag=1; continue; }
			if (ar[i]==OFFSETX) { eval(pf+'offsetx='+ar[++i]); continue; }
			if (ar[i]==OFFSETY) { eval(pf+'offsety='+ar[++i]); continue; }
			if (ar[i]==FGCOLOR) { eval(pf+'fgcolor="'+ar[++i]+'"'); continue; }
			if (ar[i]==BGCOLOR) { eval(pf+'bgcolor="'+ar[++i]+'"'); continue; }
			if (ar[i]==TEXTCOLOR) { eval(pf+'textcolor="'+ar[++i]+'"'); continue; }
			if (ar[i]==CAPCOLOR) { eval(pf+'capcolor="'+ar[++i]+'"'); continue; }
			if (ar[i]==CLOSECOLOR) { eval(pf+'closecolor="'+ar[++i]+'"'); continue; }
			if (ar[i]==WIDTH) { eval(pf+'width='+ar[++i]); continue; }
			if (ar[i]==BORDER) { eval(pf+'border='+ar[++i]); continue; }
			if (ar[i]==CELLPAD) { i=opt_MULTIPLEARGS(++i,ar,(pf+'cellpad')); continue; }
			if (ar[i]==STATUS) { eval(pf+"status='"+escSglQuote(ar[++i])+"'"); continue; }
			if (ar[i]==AUTOSTATUS) { eval(pf +'autostatus=('+pf+'autostatus == 1) ? 0 : 1'); continue; }
			if (ar[i]==AUTOSTATUSCAP) { eval(pf +'autostatus=('+pf+'autostatus == 2) ? 0 : 2'); continue; }
			if (ar[i]==HEIGHT) { eval(pf+'height='+pf+'aboveheight='+ar[++i]); continue; } // Same param again.
			if (ar[i]==CLOSETEXT) { eval(pf+"close='"+escSglQuote(ar[++i])+"'"); continue; }
			if (ar[i]==SNAPX) { eval(pf+'snapx='+ar[++i]); continue; }
			if (ar[i]==SNAPY) { eval(pf+'snapy='+ar[++i]); continue; }
			if (ar[i]==FIXX) { eval(pf+'fixx='+ar[++i]); continue; }
			if (ar[i]==FIXY) { eval(pf+'fixy='+ar[++i]); continue; }
			if (ar[i]==RELX) { eval(pf+'relx='+ar[++i]); continue; }
			if (ar[i]==RELY) { eval(pf+'rely='+ar[++i]); continue; }
			if (ar[i]==FGBACKGROUND) { eval(pf+'fgbackground="'+ar[++i]+'"'); continue; }
			if (ar[i]==BGBACKGROUND) { eval(pf+'bgbackground="'+ar[++i]+'"'); continue; }
			if (ar[i]==PADX) { eval(pf+'padxl='+ar[++i]); eval(pf+'padxr='+ar[++i]); continue; }
			if (ar[i]==PADY) { eval(pf+'padyt='+ar[++i]); eval(pf+'padyb='+ar[++i]); continue; }
			if (ar[i]==FULLHTML) { if (pf!='ol_') eval(pf+'fullhtml=1'); continue; }
			if (ar[i]==BELOW || ar[i]==ABOVE) { eval(pf+'vpos='+ar[i]); if (pf!='ol_') olVautoFlag=1; continue; }
			if (ar[i]==CAPICON) { eval(pf+'capicon="'+ar[++i]+'"'); continue; }
			if (ar[i]==TEXTFONT) { eval(pf+"textfont='"+escSglQuote(ar[++i])+"'"); continue; }
			if (ar[i]==CAPTIONFONT) { eval(pf+"captionfont='"+escSglQuote(ar[++i])+"'"); continue; }
			if (ar[i]==CLOSEFONT) { eval(pf+"closefont='"+escSglQuote(ar[++i])+"'"); continue; }
			if (ar[i]==TEXTSIZE) { eval(pf+'textsize="'+ar[++i]+'"'); continue; }
			if (ar[i]==CAPTIONSIZE) { eval(pf+'captionsize="'+ar[++i]+'"'); continue; }
			if (ar[i]==CLOSESIZE) { eval(pf+'closesize="'+ar[++i]+'"'); continue; }
			if (ar[i]==TIMEOUT) { eval(pf+'timeout='+ar[++i]); continue; }
			if (ar[i]==FUNCTION) { if (pf=='ol_') { if (typeof ar[i+1]!='number') { v=ar[++i]; ol_function=(typeof v=='function' ? v : null); }} else {fnMark = 0; v = null; if (typeof ar[i+1]!='number') v = ar[++i];  opt_FUNCTION(v); } continue; }
			if (ar[i]==DELAY) { eval(pf+'delay='+ar[++i]); continue; }
			if (ar[i]==HAUTO) { eval(pf+'hauto=('+pf+'hauto == 0) ? 1 : 0'); continue; }
			if (ar[i]==VAUTO) { eval(pf+'vauto=('+pf+'vauto == 0) ? 1 : 0'); continue; }
			if (ar[i]==CLOSECLICK) { eval(pf +'closeclick=('+pf+'closeclick == 0) ? 1 : 0'); continue; }
			if (ar[i]==WRAP) { eval(pf +'wrap=('+pf+'wrap == 0) ? 1 : 0'); continue; }
			if (ar[i]==FOLLOWMOUSE) { eval(pf +'followmouse=('+pf+'followmouse == 1) ? 0 : 1'); continue; }
			if (ar[i]==MOUSEOFF) { eval(pf +'mouseoff=('+pf+'mouseoff==0) ? 1 : 0'); v=ar[i+1]; if (pf != 'ol_' && eval(pf+'mouseoff') && typeof v == 'number' && (v < pmStart || v > pmUpper)) olHideDelay=ar[++i]; continue; }
			if (ar[i]==CLOSETITLE) { eval(pf+"closetitle='"+escSglQuote(ar[++i])+"'"); continue; }
			if (ar[i]==CSSOFF||ar[i]==CSSCLASS) { eval(pf+'css='+ar[i]); continue; }
			if (ar[i]==COMPATMODE) { eval(pf+'compatmode=('+pf+'compatmode==0) ? 1 : 0'); continue; }
			if (ar[i]==FGCLASS) { eval(pf+'fgclass="'+ar[++i]+'"'); continue; }
			if (ar[i]==BGCLASS) { eval(pf+'bgclass="'+ar[++i]+'"'); continue; }
			if (ar[i]==TEXTFONTCLASS) { eval(pf+'textfontclass="'+ar[++i]+'"'); continue; }
			if (ar[i]==CAPTIONFONTCLASS) { eval(pf+'captionfontclass="'+ar[++i]+'"'); continue; }
			if (ar[i]==CLOSEFONTCLASS) { eval(pf+'closefontclass="'+ar[++i]+'"'); continue; }
			i = parseCmdLine(pf, i, ar);
		}
	}

	if (fnMark && o3_function) o3_text = o3_function();
	
	if ((pf == 'o3_') && o3_wrap) {
		o3_width = 0;
		
		var tReg=/<.*\n*>/ig;
		if (!tReg.test(o3_text)) o3_text = o3_text.replace(/[ ]+/g, '&nbsp;');
		if (!tReg.test(o3_cap))o3_cap = o3_cap.replace(/[ ]+/g, '&nbsp;');
	}
	if ((pf == 'o3_') && o3_sticky) {
		if (!o3_close && (o3_frame != ol_frame)) o3_close = ol_close;
		if (o3_mouseoff && (o3_frame == ol_frame)) opt_NOCLOSE(' ');
	}
}


////////
// LAYER FUNCTIONS
////////

// Writes to a layer
function layerWrite(txt) {
	txt += "\n";
	if (olNs4) {
		var lyr = o3_frame.document.layers['overDiv'].document
		lyr.write(txt)
		lyr.close()
	} else if (typeof over.innerHTML != 'undefined') {
		if (olIe5 && isMac) over.innerHTML = '';
		over.innerHTML = txt;
	} else {
		range = o3_frame.document.createRange();
		range.setStartAfter(over);
		domfrag = range.createContextualFragment(txt);
		
		while (over.hasChildNodes()) {
			over.removeChild(over.lastChild);
		}
		
		over.appendChild(domfrag);
	}
}

// Make an object visible
function showObject(obj) {
	runHook("showObject", FBEFORE);

	var theObj=(olNs4 ? obj : obj.style);
	theObj.visibility = 'visible';

	runHook("showObject", FAFTER);
}

// Hides an object
function hideObject(obj) {
	runHook("hideObject", FBEFORE);

	var theObj=(olNs4 ? obj : obj.style);
	if (olNs6 && olShowId>0) { clearTimeout(olShowId); olShowId=0; }
	theObj.visibility = 'hidden';
	theObj.top = theObj.left = ((olIe4&&!olOp) ? 0 : -10000) + (!olNs4 ? 'px' : 0);

	if (o3_timerid > 0) clearTimeout(o3_timerid);
	if (o3_delayid > 0) clearTimeout(o3_delayid);

	o3_timerid = 0;
	o3_delayid = 0;
	self.status = "";

	if (obj.onmouseout||obj.onmouseover) {
		if (olNs4) obj.releaseEvents(Event.MOUSEOUT || Event.MOUSEOVER);
		obj.onmouseout = obj.onmouseover = null;
	}

	runHook("hideObject", FAFTER);
}

// Move a layer
function repositionTo(obj, xL, yL) {
	var theObj=(olNs4 ? obj : obj.style);
	theObj.left = xL + (!olNs4 ? 'px' : 0);
	theObj.top = yL + (!olNs4 ? 'px' : 0);
}

// Check position of cursor relative to overDiv DIVision; mouseOut function
function cursorOff() {
	var left = parseInt(over.style.left);
	var top = parseInt(over.style.top);
	var right = left + (over.offsetWidth >= parseInt(o3_width) ? over.offsetWidth : parseInt(o3_width));
	var bottom = top + (over.offsetHeight >= o3_aboveheight ? over.offsetHeight : o3_aboveheight);

	if (o3_x < left || o3_x > right || o3_y < top || o3_y > bottom) return true;

	return false;
}


////////
// COMMAND FUNCTIONS
////////

// Calls callme or the default function.
function opt_FUNCTION(callme) {
	o3_text = (callme ? (typeof callme=='string' ? (/.+\(.*\)/.test(callme) ? eval(callme) : callme) : callme()) : (o3_function ? o3_function() : 'No Function'));

	return 0;
}

// Handle hovering
function opt_NOCLOSE(unused) {
	if (!unused) o3_close = "";

	if (olNs4) {
		over.captureEvents(Event.MOUSEOUT || Event.MOUSEOVER);
		over.onmouseover = function () { if (o3_timerid > 0) { clearTimeout(o3_timerid); o3_timerid = 0; } }
		over.onmouseout = function (e) { if (olHideDelay) hideDelay(olHideDelay); else cClick(e); }
	} else {
		over.onmouseover = function () {hoveringSwitch = true; if (o3_timerid > 0) { clearTimeout(o3_timerid); o3_timerid =0; } }
	}

	return 0;
}

// Function to scan command line arguments for multiples
function opt_MULTIPLEARGS(i, args, parameter) {
  var k=i, re, pV, str='';

  for(k=i; k<args.length; k++) {
		if(typeof args[k] == 'number' && args[k]>pmStart) break;
		str += args[k] + ',';
	}
	if (str) str = str.substring(0,--str.length);

	k--;  // reduce by one so the for loop this is in works correctly
	pV=(olNs4 && /cellpad/i.test(parameter)) ? str.split(',')[0] : str;
	eval(parameter + '="' + pV + '"');

	return k;
}

// Remove &nbsp; in texts when done.
function nbspCleanup() {
	if (o3_wrap) {
		o3_text = o3_text.replace(/\&nbsp;/g, ' ');
		o3_cap = o3_cap.replace(/\&nbsp;/g, ' ');
	}
}

// Escape embedded single quotes in text strings
function escSglQuote(str) {
  return str.toString().replace(/'/g,"\\'");
}

// Onload handler for window onload event
function OLonLoad_handler(e) {
	var re = /\w+\(.*\)[;\s]+/g, olre = /overlib\(|nd\(|cClick\(/, fn, l, i;

	if(!olLoaded) olLoaded=1;

  // Remove it for Gecko based browsers
	if(window.removeEventListener && e.eventPhase == 3) window.removeEventListener("load",OLonLoad_handler,false);
	else if(window.detachEvent) { // and for IE and Opera 4.x but execute calls to overlib, nd, or cClick()
		window.detachEvent("onload",OLonLoad_handler);
		var fN = document.body.getAttribute('onload');
		if (fN) {
			fN=fN.toString().match(re);
			if (fN && fN.length) {
				for (i=0; i<fN.length; i++) {
					if (/anonymous/.test(fN[i])) continue;
					while((l=fN[i].search(/\)[;\s]+/)) != -1) {
						fn=fN[i].substring(0,l+1);
						fN[i] = fN[i].substring(l+2);
						if (olre.test(fn)) eval(fn);
					}
				}
			}
		}
	}
}

// Wraps strings in Layer Generation Functions with the correct tags
//    endWrap true(if end tag) or false if start tag
//    fontSizeStr - font size string such as '1' or '10px'
//    whichString is being wrapped -- 'text', 'caption', or 'close'
function wrapStr(endWrap,fontSizeStr,whichString) {
	var fontStr, fontColor, isClose=((whichString=='close') ? 1 : 0), hasDims=/[%\-a-z]+$/.test(fontSizeStr);
	fontSizeStr = (olNs4) ? (!hasDims ? fontSizeStr : '1') : fontSizeStr;
	if (endWrap) return (hasDims&&!olNs4) ? (isClose ? '</span>' : '</div>') : '</font>';
	else {
		fontStr='o3_'+whichString+'font';
		fontColor='o3_'+((whichString=='caption')? 'cap' : whichString)+'color';
		return (hasDims&&!olNs4) ? (isClose ? '<span style="font-family: '+quoteMultiNameFonts(eval(fontStr))+'; color: '+eval(fontColor)+'; font-size: '+fontSizeStr+';">' : '<div style="font-family: '+quoteMultiNameFonts(eval(fontStr))+'; color: '+eval(fontColor)+'; font-size: '+fontSizeStr+';">') : '<font face="'+eval(fontStr)+'" color="'+eval(fontColor)+'" size="'+(parseInt(fontSizeStr)>7 ? '7' : fontSizeStr)+'">';
	}
}

// Quotes Multi word font names; needed for CSS Standards adherence in font-family
function quoteMultiNameFonts(theFont) {
	var v, pM=theFont.split(',');
	for (var i=0; i<pM.length; i++) {
		v=pM[i];
		v=v.replace(/^\s+/,'').replace(/\s+$/,'');
		if(/\s/.test(v) && !/['"]/.test(v)) {
			v="\'"+v+"\'";
			pM[i]=v;
		}
	}
	return pM.join();
}

// dummy function which will be overridden 
function isExclusive(args) {
	return false;
}

// Sets cellpadding style string value
function setCellPadStr(parameter) {
	var Str='', j=0, ary = new Array(), top, bottom, left, right;

	Str+='padding: ';
	ary=parameter.replace(/\s+/g,'').split(',');

	switch(ary.length) {
		case 2:
			top=bottom=ary[j];
			left=right=ary[++j];
			break;
		case 3:
			top=ary[j];
			left=right=ary[++j];
			bottom=ary[++j];
			break;
		case 4:
			top=ary[j];
			right=ary[++j];
			bottom=ary[++j];
			left=ary[++j];
			break;
	}

	Str+= ((ary.length==1) ? ary[0] + 'px;' : top + 'px ' + right + 'px ' + bottom + 'px ' + left + 'px;');

	return Str;
}

// function will delay close by time milliseconds
function hideDelay(time) {
	if (time&&!o3_delay) {
		if (o3_timerid > 0) clearTimeout(o3_timerid);

		o3_timerid=setTimeout("cClick()",(o3_timeout=time));
	}
}

// Was originally in the placeLayer() routine; separated out for future ease
function horizontalPlacement(browserWidth, horizontalScrollAmount, widthFix) {
	var placeX, iwidth=browserWidth, winoffset=horizontalScrollAmount;
	var parsedWidth = parseInt(o3_width);

	if (o3_fixx > -1 || o3_relx != null) {
		// Fixed position
		placeX=(o3_relx != null ? ( o3_relx < 0 ? winoffset +o3_relx+ iwidth - parsedWidth - widthFix : winoffset+o3_relx) : o3_fixx);
	} else {  
		// If HAUTO, decide what to use.
		if (o3_hauto == 1) {
			if ((o3_x - winoffset) > (iwidth / 2)) {
				o3_hpos = LEFT;
			} else {
				o3_hpos = RIGHT;
			}
		}  		

		// From mouse
		if (o3_hpos == CENTER) { // Center
			placeX = o3_x+o3_offsetx-(parsedWidth/2);

			if (placeX < winoffset) placeX = winoffset;
		}

		if (o3_hpos == RIGHT) { // Right
			placeX = o3_x+o3_offsetx;

			if ((placeX+parsedWidth) > (winoffset+iwidth - widthFix)) {
				placeX = iwidth+winoffset - parsedWidth - widthFix;
				if (placeX < 0) placeX = 0;
			}
		}
		if (o3_hpos == LEFT) { // Left
			placeX = o3_x-o3_offsetx-parsedWidth;
			if (placeX < winoffset) placeX = winoffset;
		}  	

		// Snapping!
		if (o3_snapx > 1) {
			var snapping = placeX % o3_snapx;

			if (o3_hpos == LEFT) {
				placeX = placeX - (o3_snapx+snapping);
			} else {
				// CENTER and RIGHT
				placeX = placeX+(o3_snapx - snapping);
			}

			if (placeX < winoffset) placeX = winoffset;
		}
	}	

	return placeX;
}

// was originally in the placeLayer() routine; separated out for future ease
function verticalPlacement(browserHeight,verticalScrollAmount) {
	var placeY, iheight=browserHeight, scrolloffset=verticalScrollAmount;
	var parsedHeight=(o3_aboveheight ? parseInt(o3_aboveheight) : (olNs4 ? over.clip.height : over.offsetHeight));

	if (o3_fixy > -1 || o3_rely != null) {
		// Fixed position
		placeY=(o3_rely != null ? (o3_rely < 0 ? scrolloffset+o3_rely+iheight - parsedHeight : scrolloffset+o3_rely) : o3_fixy);
	} else {
		// If VAUTO, decide what to use.
		if (o3_vauto == 1) {
			if ((o3_y - scrolloffset) > (iheight / 2) && o3_vpos == BELOW && (o3_y + parsedHeight + o3_offsety - (scrolloffset + iheight) > 0)) {
				o3_vpos = ABOVE;
			} else if (o3_vpos == ABOVE && (o3_y - (parsedHeight + o3_offsety) - scrolloffset < 0)) {
				o3_vpos = BELOW;
			}
		}

		// From mouse
		if (o3_vpos == ABOVE) {
			if (o3_aboveheight == 0) o3_aboveheight = parsedHeight; 

			placeY = o3_y - (o3_aboveheight+o3_offsety);
			if (placeY < scrolloffset) placeY = scrolloffset;
		} else {
			// BELOW
			placeY = o3_y+o3_offsety;
		} 

		// Snapping!
		if (o3_snapy > 1) {
			var snapping = placeY % o3_snapy;  			

			if (o3_aboveheight > 0 && o3_vpos == ABOVE) {
				placeY = placeY - (o3_snapy+snapping);
			} else {
				placeY = placeY+(o3_snapy - snapping);
			} 			

			if (placeY < scrolloffset) placeY = scrolloffset;
		}
	}

	return placeY;
}

// checks positioning flags
function checkPositionFlags() {
	if (olHautoFlag) olHautoFlag = o3_hauto=0;
	if (olVautoFlag) olVautoFlag = o3_vauto=0;
	return true;
}

// get Browser window width
function windowWidth() {
	var w;
	if (o3_frame.innerWidth) w=o3_frame.innerWidth;
	else if (eval('o3_frame.'+docRoot)&&eval("typeof o3_frame."+docRoot+".clientWidth=='number'")&&eval('o3_frame.'+docRoot+'.clientWidth')) 
		w=eval('o3_frame.'+docRoot+'.clientWidth');
	return w;			
}

// create the div container for popup content if it doesn't exist
function createDivContainer(id,frm,zValue) {
	id = (id || 'overDiv'), frm = (frm || o3_frame), zValue = (zValue || 1000);
	var objRef, divContainer = layerReference(id);

	if (divContainer == null) {
		if (olNs4) {
			divContainer = frm.document.layers[id] = new Layer(window.innerWidth, frm);
			objRef = divContainer;
		} else {
			var body = (olIe4 ? frm.document.all.tags('BODY')[0] : frm.document.getElementsByTagName("BODY")[0]);
			if (olIe4&&!document.getElementById) {
				body.insertAdjacentHTML("beforeEnd",'<div id="'+id+'"></div>');
				divContainer=layerReference(id);
			} else {
				divContainer = frm.document.createElement("DIV");
				divContainer.id = id;
				body.appendChild(divContainer);
			}
			objRef = divContainer.style;
		}

		objRef.position = 'absolute';
		objRef.visibility = 'hidden';
		objRef.zIndex = zValue;
		
		//julien
		objRef.border = "1px solid #666666";
		
		if (olIe4&&!olOp) objRef.left = objRef.top = '0px';
		else objRef.left = objRef.top =  -10000 + (!olNs4 ? 'px' : 0);
	}

	return divContainer;
}

// get reference to a layer with ID=id
function layerReference(id) {
	return (olNs4 ? o3_frame.document.layers[id] : (document.all ? o3_frame.document.all[id] : o3_frame.document.getElementById(id)));
}
////////
//  UTILITY FUNCTIONS
////////

// Checks if something is a function.
function isFunction(fnRef) {
	var rtn = true;

	if (typeof fnRef == 'object') {
		for (var i = 0; i < fnRef.length; i++) {
			if (typeof fnRef[i]=='function') continue;
			rtn = false;
			break;
		}
	} else if (typeof fnRef != 'function') {
		rtn = false;
	}
	
	return rtn;
}

// Converts an array into an argument string for use in eval.
function argToString(array, strtInd, argName) {
	var jS = strtInd, aS = '', ar = array;
	argName=(argName ? argName : 'ar');
	
	if (ar.length > jS) {
		for (var k = jS; k < ar.length; k++) aS += argName+'['+k+'], ';
		aS = aS.substring(0, aS.length-2);
	}
	
	return aS;
}

// Places a hook in the correct position in a hook point.
function reOrder(hookPt, fnRef, order) {
	var newPt = new Array(), match, i, j;

	if (!order || typeof order == 'undefined' || typeof order == 'number') return hookPt;
	
	if (typeof order=='function') {
		if (typeof fnRef=='object') {
			newPt = newPt.concat(fnRef);
		} else {
			newPt[newPt.length++]=fnRef;
		}
		
		for (i = 0; i < hookPt.length; i++) {
			match = false;
			if (typeof fnRef == 'function' && hookPt[i] == fnRef) {
				continue;
			} else {
				for(j = 0; j < fnRef.length; j++) if (hookPt[i] == fnRef[j]) {
					match = true;
					break;
				}
			}
			if (!match) newPt[newPt.length++] = hookPt[i];
		}

		newPt[newPt.length++] = order;

	} else if (typeof order == 'object') {
		if (typeof fnRef == 'object') {
			newPt = newPt.concat(fnRef);
		} else {
			newPt[newPt.length++] = fnRef;
		}
		
		for (j = 0; j < hookPt.length; j++) {
			match = false;
			if (typeof fnRef == 'function' && hookPt[j] == fnRef) {
				continue;
			} else {
				for (i = 0; i < fnRef.length; i++) if (hookPt[j] == fnRef[i]) {
					match = true;
					break;
				}
			}
			if (!match) newPt[newPt.length++]=hookPt[j];
		}

		for (i = 0; i < newPt.length; i++) hookPt[i] = newPt[i];
		newPt.length = 0;
		
		for (j = 0; j < hookPt.length; j++) {
			match = false;
			for (i = 0; i < order.length; i++) {
				if (hookPt[j] == order[i]) {
					match = true;
					break;
				}
			}
			if (!match) newPt[newPt.length++] = hookPt[j];
		}
		newPt = newPt.concat(order);
	}

	hookPt = newPt;

	return hookPt;
}

////////
//  PLUGIN ACTIVATION FUNCTIONS
////////

// Runs plugin functions to set runtime variables.
function setRunTimeVariables(){
	if (typeof runTime != 'undefined' && runTime.length) {
		for (var k = 0; k < runTime.length; k++) {
			runTime[k]();
		}
	}
}

// Runs plugin functions to parse commands.
function parseCmdLine(pf, i, args) {
	if (typeof cmdLine != 'undefined' && cmdLine.length) { 
		for (var k = 0; k < cmdLine.length; k++) { 
			var j = cmdLine[k](pf, i, args);
			if (j >- 1) {
				i = j;
				break;
			}
		}
	}

	return i;
}

// Runs plugin functions to do things after parse.
function postParseChecks(pf,args){
	if (typeof postParse != 'undefined' && postParse.length) {
		for (var k = 0; k < postParse.length; k++) {
			if (postParse[k](pf,args)) continue;
			return false;  // end now since have an error
		}
	}
	return true;
}


////////
//  PLUGIN REGISTRATION FUNCTIONS
////////

// Registers commands and creates constants.
function registerCommands(cmdStr) {
	if (typeof cmdStr!='string') return;

	var pM = cmdStr.split(',');
	pms = pms.concat(pM);

	for (var i = 0; i< pM.length; i++) {
		eval(pM[i].toUpperCase()+'='+pmCount++);
	}
}

// Registers no-parameter commands
function registerNoParameterCommands(cmdStr) {
	if (!cmdStr && typeof cmdStr != 'string') return;
	pmt=(!pmt) ? cmdStr : pmt + ',' + cmdStr;
}

// Register a function to hook at a certain point.
function registerHook(fnHookTo, fnRef, hookType, optPm) {
	var hookPt, last = typeof optPm;
	
	if (fnHookTo == 'plgIn'||fnHookTo == 'postParse') return;
	if (typeof hookPts[fnHookTo] == 'undefined') hookPts[fnHookTo] = new FunctionReference();

	hookPt = hookPts[fnHookTo];

	if (hookType != null) {
		if (hookType == FREPLACE) {
			hookPt.ovload = fnRef;  // replace normal overlib routine
			if (fnHookTo.indexOf('ol_content_') > -1) hookPt.alt[pms[CSSOFF-1-pmStart]]=fnRef; 

		} else if (hookType == FBEFORE || hookType == FAFTER) {
			var hookPt=(hookType == 1 ? hookPt.before : hookPt.after);

			if (typeof fnRef == 'object') {
				hookPt = hookPt.concat(fnRef);
			} else {
				hookPt[hookPt.length++] = fnRef;
			}

			if (optPm) hookPt = reOrder(hookPt, fnRef, optPm);

		} else if (hookType == FALTERNATE) {
			if (last=='number') hookPt.alt[pms[optPm-1-pmStart]] = fnRef;
		} else if (hookType == FCHAIN) {
			hookPt = hookPt.chain; 
			if (typeof fnRef=='object') hookPt=hookPt.concat(fnRef); // add other functions 
			else hookPt[hookPt.length++]=fnRef;
		}

		return;
	}
}

// Register a function that will set runtime variables.
function registerRunTimeFunction(fn) {
	if (isFunction(fn)) {
		if (typeof fn == 'object') {
			runTime = runTime.concat(fn);
		} else {
			runTime[runTime.length++] = fn;
		}
	}
}

// Register a function that will handle command parsing.
function registerCmdLineFunction(fn){
	if (isFunction(fn)) {
		if (typeof fn == 'object') {
			cmdLine = cmdLine.concat(fn);
		} else {
			cmdLine[cmdLine.length++] = fn;
		}
	}
}

// Register a function that does things after command parsing. 
function registerPostParseFunction(fn){
	if (isFunction(fn)) {
		if (typeof fn == 'object') {
			postParse = postParse.concat(fn);
		} else {
			postParse[postParse.length++] = fn;
		}
	}
}

////////
//  PLUGIN REGISTRATION FUNCTIONS
////////

// Runs any hooks registered.
function runHook(fnHookTo, hookType) {
	var l = hookPts[fnHookTo], k, rtnVal = null, optPm, arS, ar = runHook.arguments;

	if (hookType == FREPLACE) {
		arS = argToString(ar, 2);

		if (typeof l == 'undefined' || !(l = l.ovload)) rtnVal = eval(fnHookTo+'('+arS+')');
		else rtnVal = eval('l('+arS+')');

	} else if (hookType == FBEFORE || hookType == FAFTER) {
		if (typeof l != 'undefined') {
			l=(hookType == 1 ? l.before : l.after);
	
			if (l.length) {
				arS = argToString(ar, 2);
				for (var k = 0; k < l.length; k++) eval('l[k]('+arS+')');
			}
		}
	} else if (hookType == FALTERNATE) {
		optPm = ar[2];
		arS = argToString(ar, 3);

		if (typeof l == 'undefined' || (l = l.alt[pms[optPm-1-pmStart]]) == 'undefined') {
			rtnVal = eval(fnHookTo+'('+arS+')');
		} else {
			rtnVal = eval('l('+arS+')');
		}
	} else if (hookType == FCHAIN) {
		arS=argToString(ar,2);
		l=l.chain;

		for (k=l.length; k > 0; k--) if((rtnVal=eval('l[k-1]('+arS+')'))!=void(0)) break;
	}

	return rtnVal;
}

////////
// OBJECT CONSTRUCTORS
////////

// Object for handling hooks.
function FunctionReference() {
	this.ovload = null;
	this.before = new Array();
	this.after = new Array();
	this.alt = new Array();
	this.chain = new Array();
}

// Object for simple access to the overLIB version used.
// Examples: simpleversion:351 major:3 minor:5 revision:1
function Info(version, prerelease) {
	this.version = version;
	this.prerelease = prerelease;

	this.simpleversion = Math.round(this.version*100);
	this.major = parseInt(this.simpleversion / 100);
	this.minor = parseInt(this.simpleversion / 10) - this.major * 10;
	this.revision = parseInt(this.simpleversion) - this.major * 100 - this.minor * 10;
	this.meets = meets;
}

// checks for Core Version required
function meets(reqdVersion) {
	return (!reqdVersion) ? false : this.simpleversion >= Math.round(100*parseFloat(reqdVersion));
}


////////
// STANDARD REGISTRATIONS
////////
registerHook("ol_content_simple", ol_content_simple, FALTERNATE, CSSOFF);
registerHook("ol_content_caption", ol_content_caption, FALTERNATE, CSSOFF);
registerHook("ol_content_background", ol_content_background, FALTERNATE, CSSOFF);
registerHook("ol_content_simple", ol_content_simple, FALTERNATE, CSSCLASS);
registerHook("ol_content_caption", ol_content_caption, FALTERNATE, CSSCLASS);
registerHook("ol_content_background", ol_content_background, FALTERNATE, CSSCLASS);
registerPostParseFunction(checkPositionFlags);
registerHook("hideObject", nbspCleanup, FAFTER);
registerHook("horizontalPlacement", horizontalPlacement, FCHAIN);
registerHook("verticalPlacement", verticalPlacement, FCHAIN);
if (olNs4||(olIe5&&isMac)||olKq) olLoaded=1;
registerNoParameterCommands('sticky,autostatus,autostatuscap,fullhtml,hauto,vauto,closeclick,wrap,followmouse,mouseoff,compatmode');
///////
// ESTABLISH MOUSECAPTURING
///////

// Capture events, alt. diffuses the overlib function.
var olCheckMouseCapture=true;
if ((olNs4 || olNs6 || olIe4)) {
	olMouseCapture();
} else {
	overlib = no_overlib;
	nd = no_overlib;
	ver3fix = true;
}


function formpop()
{
	SPPLUS = window.open('','SPPLUS','width=750,height=560,status=1');
	if (SPPLUS && !SPPLUS.closed)
	SPPLUS.focus();
	return true;
}

//Ajoute une case parcourir limité a 5
function ajouteFichier(div)
{
	var max=5;
	var maListe = document.getElementById(div);

	var tabEnfant=Array();
	var compteur=0;
	if (maListe.hasChildNodes())
	{
		var collEnfants = maListe.childNodes;
		for (var i = 0; i < collEnfants.length; i++)
		{
			if(collEnfants[i].tagName=="DIV")
				compteur++;
		}
		
	}
	
	if(compteur<(max))
	{
		//alert(compteur);
		var span = document.createElement('div');
		var input = document.createElement('input');

		span.id='fic'+compteur;
		input.setAttribute('type','file');
		input.id='upfile_'+compteur;
		input.name='upfile_'+compteur;

		span.appendChild(input);
		span.innerHTML=span.innerHTML+"<span style='padding-top: 8px'><a href='javascript: supprFichierParcourir(\""+div+"\","+compteur+");' class='lien_10_bleu_souligne'>Supprimer</a></span>";
		maListe.appendChild(span);
	}

	if(compteur==(max))
	{
		displayError('Impossible d\'envoyer plus de 5 fichiers simultanement');
	}

}

function ajouteFichierPrivate(div)
{
	var max=5;
	var maListe = document.getElementById(div);

	var tabEnfant=Array();
	var compteur=0;
	if (maListe.hasChildNodes())
	{
		var collEnfants = maListe.childNodes;
		for (var i = 0; i < collEnfants.length; i++)
		{
			if(collEnfants[i].tagName=="DIV")
				compteur++;
		}
	}
	if(compteur<(max))
	{
		//alert(compteur);
		var span = document.createElement('div');
		var input = document.createElement('input');

		//On agrandit la zone d'affichage
		if(navigator.userAgent.indexOf("MSIE 7")!=-1)
		{
			document.getElementById('blocBasGauchePrivate').style.height = document.getElementById('blocBasGauchePrivate').offsetHeight + 20 + "px";
			document.getElementById('blocBasDroitPrivate').style.height = document.getElementById('blocBasDroitPrivate').offsetHeight + 20 + "px";
			document.getElementById('blocBasDroitPrivate').style.marginTop = -200 - (20*compteur) + "px";
			document.getElementById('suiteSeparateurPrivate').style.height = document.getElementById('suiteSeparateurPrivate').offsetHeight + 20 + "px";
			document.getElementById('separateurPrivate').style.marginTop = -200 - (20*compteur) + "px";
		}
		else if(navigator.userAgent.indexOf("MSIE 6")!= -1)
		{
			document.getElementById('blocBasGauchePrivate').style.height = document.getElementById('blocBasGauchePrivate').offsetHeight + 20 + "px";
			document.getElementById('blocBasDroitPrivate').style.height = document.getElementById('blocBasDroitPrivate').offsetHeight + 20 + "px";
			document.getElementById('blocBasDroitPrivate').style.marginTop = -200 - (20*compteur) + "px";
			document.getElementById('suiteSeparateurPrivate').style.height = document.getElementById('suiteSeparateurPrivate').offsetHeight + 20 + "px";
			document.getElementById('separateurPrivate').style.marginTop = -200 - (20*compteur) + "px";
		}
		else
		{
			document.getElementById('blocBasGauchePrivate').style.height = document.getElementById('blocBasGauchePrivate').offsetHeight + 20 + "px";
			document.getElementById('blocBasDroitPrivate').style.height = document.getElementById('blocBasDroitPrivate').offsetHeight + 20 + "px";
			document.getElementById('blocBasDroitPrivate').style.marginTop = -200 - (20*compteur) + "px";
			document.getElementById('separateurPrivate').style.marginTop = -200 - (20*compteur) + "px";
			document.getElementById('suiteSeparateurPrivate').style.height = document.getElementById('suiteSeparateurPrivate').offsetHeight + 20 + "px";
		}
		
		
		span.setAttribute('id','fic'+compteur);
		
		input.setAttribute('type','file');
		input.setAttribute('id','upfile_'+compteur);
		input.setAttribute('name','upfile_'+compteur);
		
		span.appendChild(input);
		var supprFichier = document.createElement('div');
		supprFichier.setAttribute("class","supprFichier");
		supprFichier.setAttribute("className","supprFichier");
		
		var lien = document.createElement('a');
		lien.setAttribute("class","lien_11_bleu");
		lien.setAttribute("className","lien_11_bleu");
		lien.setAttribute("href","javascript: supprFichierParcourirPrivate(\""+div+"\","+compteur+");");
		
		var textLien = document.createTextNode("Supprimer");
		lien.appendChild(textLien);
		
		supprFichier.appendChild(lien);
		
		span.appendChild(supprFichier);
		
		//span.innerHTML=span.innerHTML+"<div class='supprFichier'><a class='lien_11_bleu' href='javascript: supprFichierParcourirPrivate(\""+div+"\","+compteur+");'>Supprimer</a></div>";
		maListe.appendChild(span);
	}

	if(compteur==(max))
		displayError('Impossible d\'envoyer plus de 5 fichiers simultanement');
}

function arrondir(nb,dec)
{
	var mul = 1;
	for (i=0;i<dec;i++)
		mul *= 10;
	var res = Math.floor(Math.abs(x=nb)*mul+0.5)/mul;
 	if (nb < 0) 
		res = -res;
 	return res;
}

//Supprime une case parcourir
function supprFichierParcourir(div, id)
{
	var maListe = document.getElementById(div);
	var span = document.getElementById('fic'+id);
	maListe.removeChild(span);
}

function supprFichierParcourirPrivate(div, id)
{
	var maListe = document.getElementById(div);
	var span = document.getElementById('fic'+id);
	maListe.removeChild(span);
	
	
	var marginTop = document.getElementById('separateurPrivate').style.marginTop;
	var tableauSeparateur = marginTop.split('px');
	
	var marginTopDroit = document.getElementById('blocBasDroitPrivate').style.marginTop;
	var tableauSeparateurDroit = marginTop.split('px');
	
	if(navigator.userAgent.indexOf("MSIE 7")!=-1)
	{
		document.getElementById('blocBasGauchePrivate').style.height = document.getElementById('blocBasGauchePrivate').offsetHeight - 20 + "px";
		document.getElementById('suiteSeparateurPrivate').style.height = document.getElementById('suiteSeparateurPrivate').offsetHeight - 20 + "px";
		document.getElementById('separateurPrivate').style.marginTop = parseInt(tableauSeparateur[0]) + 20 + "px";
		document.getElementById('blocBasDroitPrivate').style.marginTop = parseInt(tableauSeparateurDroit[0]) + 20 + "px";
		document.getElementById('blocBasDroitPrivate').style.height = document.getElementById('blocBasDroitPrivate').offsetHeight - 20 + "px";
	}
	else if(navigator.userAgent.indexOf("MSIE 6")!= -1)
	{
		document.getElementById('blocBasGauchePrivate').style.height = document.getElementById('blocBasGauchePrivate').offsetHeight - 20 + "px";
		document.getElementById('suiteSeparateurPrivate').style.height = document.getElementById('suiteSeparateurPrivate').offsetHeight - 20 + "px";
		document.getElementById('separateurPrivate').style.marginTop = parseInt(tableauSeparateur[0]) + 20 + "px";
		document.getElementById('blocBasDroitPrivate').style.marginTop = parseInt(tableauSeparateurDroit[0]) + 20 + "px";
		document.getElementById('blocBasDroitPrivate').style.height = document.getElementById('blocBasDroitPrivate').offsetHeight - 20 + "px";
	}
	else
	{
		document.getElementById('blocBasGauchePrivate').style.height = document.getElementById('blocBasGauchePrivate').offsetHeight - 20 + "px";
		document.getElementById('blocBasDroitPrivate').style.height = document.getElementById('blocBasDroitPrivate').offsetHeight - 20 + "px";
		document.getElementById('blocBasDroitPrivate').style.marginTop = parseInt(tableauSeparateurDroit[0]) + 20 + "px";
		document.getElementById('separateurPrivate').style.marginTop = parseInt(tableauSeparateur[0]) + 20 + "px";
		document.getElementById('suiteSeparateurPrivate').style.height = document.getElementById('suiteSeparateurPrivate').offsetHeight - 20 + "px";
	}
}

function initPass()
{
	$.post('index.php?controller=zonepublic&action=initPass',
		{mdp1: document.getElementById('input_mdp1').value, mdp2: document.getElementById('input_mdp2').value, ctrl:  document.getElementById('controle').value},
		function(data) { verifPass(data); });
  }
  
  function verifPass(xhr)
  {

	var retour = xhr;
	var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		switch(xhr)
		{
			case 'erreur_mdp':
				displayError('Les mots de passe saisis ne sont pas identiques');
				break;
				
			case 'erreur_compte':
				displayError('Compte introuvable');
				break;
		}
	}
	else
	{
		//Effect.Fade('overlay', {duration: 0.0});
		$("#popUpBox").fadeTo("fast",0,function () { supprOverlay(); });
		div = document.getElementById('popUpBox');
		div.parentNode.removeChild(div);
		masqueAnim();
		popBox('view/popup_confirmation.php?mail='+xhr);
	}
  }
  
  function autoLogin(mail,redir)
  {
	$.post('index.php?controller=zonepublic&action=autoLogin2',
		{mail:  mail},
		function () {
			if(redir == 'credit')
				var txt = "index.php?controller=zoneprivee&contain=buyCredit";
			else if(redir == 'abo')
				var txt = "index.php?controller=zoneprivee&contain=buyAbonnement";
			else
				var txt = "index.php?controller=zoneprivee&action=index";
				
			document.location.href=txt;
		});
  }
  
  function changerLien()
  {
	var cryptage=document.getElementById('privateCryptage');
	var accuse=document.getElementById('privateAccuse');
	
	var resultatCryptage="";
	var resultatAccuse="";
	
	if(cryptage.checked==true)
		resultatCryptage="cryptage=1";
	else
		resultatCryptage="cryptage=0";
		
	if(accuse.checked==true)
		resultatAccuse="accuse=1";
	else
		resultatAccuse="accuse=0";
		
	return 'view/popup_upload_private.php?'+resultatCryptage+'&'+resultatAccuse;
  
  }
  
function afficheChamp() 
{
	var cryptage=document.getElementById('privateCryptage');

	if(cryptage.checked==true)
	{
		document.getElementById("champPassFichierPrivate").style.visibility="visible";
		document.getElementById("champPassFichierPrivate").style.display="inline";
	}
	else
	{
		document.getElementById("champPassFichierPrivate").style.visibility="hidden";
		document.getElementById("champPassFichierPrivate").style.display="none";
	}
}

function afficheChampPopup() 
{
	var cryptage=document.getElementById('cryptagePrivatePopup');

	if(cryptage.checked==true)
	{
		document.getElementById("champPassFichierPrivatePopup").style.visibility="visible";
		document.getElementById("champPassFichierPrivatePopup").style.display="inline";
		agrandirPopupUpload('+');
	}
	else
	{
		document.getElementById("champPassFichierPrivatePopup").style.visibility="hidden";
		document.getElementById("champPassFichierPrivatePopup").style.display="none";
		agrandirPopupUpload('-');
	}
	
}

function afficheChampPopupRenvoi() 
{
	var cryptage=document.getElementById('cryptagePrivatePopup');

	if(cryptage.checked==true)
	{	
		document.getElementById("champPassFichierPrivatePopup").style.visibility="visible";
		document.getElementById("champPassFichierPrivatePopup").style.display="inline";
		agrandirPopupUploadRenvoi('+');
	}
	else
	{
		document.getElementById("champPassFichierPrivatePopup").style.visibility="hidden";
		document.getElementById("champPassFichierPrivatePopup").style.display="none";
		agrandirPopupUploadRenvoi('-');
	}
	
}

function afficheChampPopupRenvoiEnvoyer() 
{
	var cryptage=document.getElementById('cryptagePrivatePopup');

	if(cryptage.checked==true)
	{
		document.getElementById("champPassFichierPrivatePopup").style.visibility="visible";
		document.getElementById("champPassFichierPrivatePopup").style.display="inline";
	}
	else
	{
		document.getElementById("champPassFichierPrivatePopup").style.visibility="hidden";
		document.getElementById("champPassFichierPrivatePopup").style.display="none";
	}
	
}

function transfertContact(mail)
{
	var longueur=mail.length;
	
	if(longueur > 0 && mail!="")
	{	
		document.getElementById('destinataireEnvoi_1').value=document.getElementById('destinataireEnvoi_1').value+mail+",";
	}
}

var marginTopBasIE7 = 470;
var marginTopCoinBasGaucheIE7 = 470;
var marginTopCoinBasDroitIE7 = 470;


var marginTopBasSafari = 467;
var marginTopCoinBasGaucheSafari= 467;
var marginTopCoinBasDroitSafari = 467;

function transfert2Contact2(mail)
{
	var tab = mail.split('|');
	
	for(var i = 0; i < tab.length; i++)
		transfertContact2(tab[i]);
}

function transfertContact2(mail)
{
	var divPrinc = document.getElementById('inputDestinataire');
	
	if(divPrinc.hasChildNodes())
	{
		var enfants = divPrinc.childNodes;
		var compteurElement = 1;
		var vide = false;
		var temp = '';

		for (var i = 0; i < enfants.length; i++)
		{
			if(enfants[i].tagName=='DIV')
			{
				var enfants2 = enfants[i].childNodes;
				
				for (var j = 0; j < enfants2.length; j++)
				{
					if(enfants2[j].tagName=='INPUT')
					{			
						if(enfants2[j].value==mail)
							return false;
									
						if(enfants2[j].id.search(/destinataireEnvoi/)!=-1)
						{	
							if(enfants2[j].id!='destinataireEnvoi_1')
							{
								if(enfants[i].value == "")
								{
									divPrinc.removeChild(enfants[i]);
								}
													
								compteurElement++;
							}
							
							if(enfants2[j].value == "")
							{
								vide = true;
								temp = compteurElement;
							}
						}	 
					}
				}
			}
		}
		
		var passe =  'false';
		
		if(vide == false)
		{
			var inc = compteurElement;
			
			var link2 = document.createElement('a');
			var img = document.createElement('img');
						
			img.setAttribute('src','styles/default/graphs/bouton_supprimer_contact.gif');
			link2.setAttribute('href','javascript:supprimeChamp("'+inc+'");');
			link2.appendChild(img);
			
			document.getElementById('caseDestinataireEnvoi_'+inc).appendChild(link2);
	
			var newDiv = document.createElement('div');
			var newInput = document.createElement('input');
			
			compteurElement++;
			
			newDiv.setAttribute('id','caseDestinataireEnvoi_'+compteurElement);
			newDiv.style.paddingBottom = "2px";
			
			newInput.setAttribute('id', 'destinataireEnvoi_'+compteurElement);
			newInput.setAttribute('name', 'destinataireEnvoi_'+compteurElement);
			newInput.setAttribute('type','text');
			newInput.style.width = '165px';
						
			newDiv.appendChild(newInput);

			divPrinc.appendChild(newDiv);
			
			autoCompletion2(compteurElement);
			
			document.getElementById('destinataireEnvoi_'+compteurElement).value = mail;
			
			passe = 'false';
		}

		var newDiv = document.createElement('div');
		var newInput = document.createElement('input');
		
		compteurElement++;
		
		newDiv.setAttribute('id','caseDestinataireEnvoi_'+compteurElement);
		newDiv.style.paddingBottom = "2px";
		
		newInput.setAttribute('id', 'destinataireEnvoi_'+compteurElement);
		newInput.setAttribute('name', 'destinataireEnvoi_'+compteurElement);
		newInput.setAttribute('type','text');
		newInput.style.width = '165px';
		
		newDiv.appendChild(newInput);

		divPrinc.appendChild(newDiv);
		
		autoCompletion2(compteurElement);
		
		
		if(passe=='false')
		{
			document.getElementById('popup_upload_private').style.height = document.getElementById('popup_upload_private').offsetHeight + 26 +"px";
		
			document.getElementById('popupUploadPrivateDroit').style.height = document.getElementById('popupUploadPrivateDroit').offsetHeight + 26 +"px";
			document.getElementById('popupUploadPrivateGauche').style.height = document.getElementById('popupUploadPrivateGauche').offsetHeight + 26 +"px";
			
			if(navigator.userAgent.indexOf("MSIE 7")!=-1)
			{
				document.getElementById('popupUploadPrivateBas').style.marginTop = marginTopBasIE7 + 26 +"px";
				document.getElementById('popupUploadPrivateCoinBG').style.marginTop = marginTopCoinBasGaucheIE7 + 26 +"px";
				document.getElementById('popupUploadPrivateCoinBD').style.marginTop = marginTopCoinBasDroitIE7 + 26 +"px";
				
				marginTopBasIE7 = marginTopBasIE7 +26;
				marginTopCoinBasGaucheIE7 = marginTopCoinBasGaucheIE7 +26;
				marginTopCoinBasDroitIE7 = marginTopCoinBasDroitIE7 +26;
			}
			else if(navigator.userAgent.indexOf("Safari")!=-1)
			{
				document.getElementById('popupUploadPrivateBas').style.marginTop = marginTopBasSafari + 26 +"px";
				document.getElementById('popupUploadPrivateCoinBG').style.marginTop = marginTopCoinBasGaucheSafari + 26 +"px";
				document.getElementById('popupUploadPrivateCoinBD').style.marginTop = marginTopCoinBasDroitSafari + 26 +"px";
				
				marginTopBasSafari = marginTopBasSafari +26;
				marginTopCoinBasGaucheSafari = marginTopCoinBasGaucheSafari +26;
				marginTopCoinBasDroitSafari = marginTopCoinBasDroitSafari +26;
			}
		}
		else
		{
			document.getElementById('popup_upload_private').style.height = document.getElementById('popup_upload_private').offsetHeight + 30 +"px";
		
			document.getElementById('popupUploadPrivateDroit').style.height = document.getElementById('popupUploadPrivateDroit').offsetHeight + 30 +"px";
			document.getElementById('popupUploadPrivateGauche').style.height = document.getElementById('popupUploadPrivateGauche').offsetHeight + 30 +"px";
		
			if(navigator.userAgent.indexOf("MSIE 7")!=-1)
			{
				document.getElementById('popupUploadPrivateBas').style.marginTop = marginTopBasIE7 + 30 +"px";
				document.getElementById('popupUploadPrivateCoinBG').style.marginTop = marginTopCoinBasGaucheIE7 + 30 +"px";
				document.getElementById('popupUploadPrivateCoinBD').style.marginTop = marginTopCoinBasDroitIE7 + 30 +"px";
				
				marginTopBasIE7 = marginTopBasIE7 +30;
				marginTopCoinBasGaucheIE7 = marginTopCoinBasGaucheIE7 +30;
				marginTopCoinBasDroitIE7 = marginTopCoinBasDroitIE7 +30;
			}
			else if(navigator.userAgent.indexOf("Safari")!=-1)
			{
				document.getElementById('popupUploadPrivateBas').style.marginTop = marginTopBasSafari + 25 +"px";
				document.getElementById('popupUploadPrivateCoinBG').style.marginTop = marginTopCoinBasGaucheSafari + 25 +"px";
				document.getElementById('popupUploadPrivateCoinBD').style.marginTop = marginTopCoinBasDroitSafari + 25 +"px";
				
				marginTopBasSafari = marginTopBasSafari + 25;
				marginTopCoinBasGaucheSafari = marginTopCoinBasGaucheSafari + 25;
				marginTopCoinBasDroitSafari = marginTopCoinBasDroitSafari + 25;
			}
				
			
		}
		
		
		if(passe=='false')
		{				
			document.getElementById('destinataireEnvoi_'+(compteurElement-1)).setAttribute('value',mail);
			var link2 = document.createElement('a');
			var img = document.createElement('img');
						
			img.setAttribute('src','styles/default/graphs/bouton_supprimer_contact.gif');
			
			link2.setAttribute('href','javascript:supprimeChamp("'+(compteurElement-1)+'");');
			link2.appendChild(img);
			
			document.getElementById('caseDestinataireEnvoi_'+(compteurElement-1)).appendChild(link2);
		
			document.getElementById('caseDestinataireEnvoi_'+(compteurElement-1)).style.paddingBottom = "2px";
			
		}
	}
}

function ajouteChamp()
{
	var divPrinc = document.getElementById('inputDestinataire');
	
	if(divPrinc.hasChildNodes())
	{
		var enfants = divPrinc.childNodes;
		var compteurElement = 1;

		for (var i = 0; i < enfants.length; i++)
		{
			if(enfants[i].tagName=='DIV')
			{
				var enfants2 = enfants[i].childNodes;
				
				for (var j = 0; j < enfants2.length; j++)
				{
						
					if(enfants2[j].tagName=='INPUT')
					{			
						if(enfants2[j].value=="")
							return false;
					
						if(enfants2[j].id.search(/destinataireEnvoi/)!=-1)
						{	
							if(enfants2[j].id!='destinataireEnvoi_1')
							{
								if(enfants[i].value == "")
								{
									divPrinc.removeChild(enfants[i]);
								}
								
								compteurElement++;
							}
							
						}
					}
				}
			}
		}
		
		var newDiv = document.createElement('div');
		var newInput = document.createElement('input');
		
		compteurElement++;
		
		newDiv.setAttribute('id','caseDestinataireEnvoi_'+compteurElement);
		
		newInput.setAttribute('id', 'destinataireEnvoi_'+compteurElement);
		newInput.setAttribute('name', 'destinataireEnvoi_'+compteurElement);
		newInput.setAttribute('type','text');
		newInput.style.width = '165px';
		
		newDiv.style.paddingBottom = "5px";
		
		var link2 = document.createElement('a');
		var img = document.createElement('img');
		var br = document.createElement('br');
		
		img.style.marginTop = '3px';
		img.setAttribute('src','styles/default/graphs/bouton_supprimer_contact.gif');
		
		link2.setAttribute('href','javascript:supprimeChamp("'+(compteurElement-1)+'");');
		//link2.setAttribute('onclick','supprimeChamp("'+(compteurElement-1)+'");');
		link2.appendChild(img);
		
		document.getElementById('caseDestinataireEnvoi_'+(compteurElement-1)).appendChild(link2);
		document.getElementById('caseDestinataireEnvoi_'+(compteurElement-1)).appendChild(br);
		
		newDiv.appendChild(newInput);

		divPrinc.appendChild(newDiv);
		
		autoCompletion2(compteurElement);	

		document.getElementById('popup_upload_private').style.height = document.getElementById('popup_upload_private').offsetHeight + 26 +"px";
		
		document.getElementById('popupUploadPrivateDroit').style.height = document.getElementById('popupUploadPrivateDroit').offsetHeight + 26 +"px";
		document.getElementById('popupUploadPrivateGauche').style.height = document.getElementById('popupUploadPrivateGauche').offsetHeight + 26 +"px";
		
		if(navigator.userAgent.indexOf("MSIE 7")!=-1)
		{
			document.getElementById('popupUploadPrivateBas').style.marginTop = marginTopBasIE7 + 22 +"px";
			document.getElementById('popupUploadPrivateCoinBG').style.marginTop = marginTopCoinBasGaucheIE7 + 22 +"px";
			document.getElementById('popupUploadPrivateCoinBD').style.marginTop = marginTopCoinBasDroitIE7 + 22 +"px";
			
			marginTopBasIE7 = marginTopBasIE7 +22;
			marginTopCoinBasGaucheIE7 = marginTopCoinBasGaucheIE7 +22;
			marginTopCoinBasDroitIE7 = marginTopCoinBasDroitIE7 +22;
		}
		else if(navigator.userAgent.indexOf("Safari")!=-1)
		{
			document.getElementById('popupUploadPrivateBas').style.marginTop = marginTopBasSafari + 22 +"px";
			document.getElementById('popupUploadPrivateCoinBG').style.marginTop = marginTopCoinBasGaucheSafari + 22 +"px";
			document.getElementById('popupUploadPrivateCoinBD').style.marginTop = marginTopCoinBasDroitSafari + 22 +"px";
			
			marginTopBasSafari = marginTopBasSafari +22;
			marginTopCoinBasGaucheSafari = marginTopCoinBasGaucheSafari +22;
			marginTopCoinBasDroitSafari = marginTopCoinBasDroitSafari +22;
		}
	}
}

function ajouteChampRenvoi()
{
	var divPrinc = document.getElementById('inputDestRenvoi');
	
	if(divPrinc.hasChildNodes())
	{
		var enfants = divPrinc.childNodes;
		var compteurElement = 1;

		for (var i = 0; i < enfants.length; i++)
		{
			if(enfants[i].tagName=='DIV')
			{
				var enfants2 = enfants[i].childNodes;
				
				for (var j = 0; j < enfants2.length; j++)
				{
						
					if(enfants2[j].tagName=='INPUT')
					{			
						if(enfants2[j].value=="")
							return false;
					
						if(enfants2[j].id.search(/destinatairePrivateRenvoi/)!=-1)
						{	
							if(enfants2[j].id!='destinatairePrivateRenvoi_1')
							{
								if(enfants[i].value == "")
								{
									divPrinc.removeChild(enfants[i]);
								}
								
								compteurElement++;
							}
							
						}
					}
				}
			}
		}
		
		var newDiv = document.createElement('div');
		var newInput = document.createElement('input');
		
		compteurElement++;
		
		newDiv.setAttribute('id','caseDestinatairePrivateRenvoi_'+compteurElement);
		
		newInput.setAttribute('id', 'destinatairePrivateRenvoi_'+compteurElement);
		newInput.setAttribute('name', 'destinatairePrivateRenvoi_'+compteurElement);
		newInput.setAttribute('type','text');
		newInput.style.width = '160px';
		
		newDiv.style.paddingBottom = "5px";
		
		var link2 = document.createElement('a');
		var img = document.createElement('img');
		var br = document.createElement('br');
		
		img.setAttribute('src','styles/default/graphs/bouton_supprimer_contact.gif');
		
		link2.setAttribute('href','javascript:supprimeChamp("'+(compteurElement-1)+'");');
		//link2.setAttribute('onclick','supprimeChamp("'+(compteurElement-1)+'");');
		link2.appendChild(img);
		
		document.getElementById('caseDestinatairePrivateRenvoi_'+(compteurElement-1)).appendChild(link2);
		document.getElementById('caseDestinatairePrivateRenvoi_'+(compteurElement-1)).appendChild(br);
		
		newDiv.appendChild(newInput);

		divPrinc.appendChild(newDiv);
		
		autoCompletionRenvoi(compteurElement);	
		
		document.getElementById('popup_renvoi').style.height = document.getElementById('popup_renvoi').offsetHeight + 22 +"px";
	
		document.getElementById('popupRenvoiDroit').style.height = document.getElementById('popupRenvoiDroit').offsetHeight + 22 +"px";
		document.getElementById('popupRenvoiGauche').style.height = document.getElementById('popupRenvoiGauche').offsetHeight + 22 +"px";
			
		document.getElementById('popupRenvoiBas').style.marginTop = marginTopBasPopupRenvoiFF + 22 + "px";
		document.getElementById('popupRenvoiCoinBG').style.marginTop = marginTopBGPopupRenvoiFF + 22 + "px";
		document.getElementById('popupRenvoiCoinBD').style.marginTop = marginTopBDPopupRenvoiFF + 22 + "px";
	
		marginTopBasPopupRenvoiFF = marginTopBasPopupRenvoiFF+22;
		marginTopBGPopupRenvoiFF = marginTopBGPopupRenvoiFF+22;
		marginTopBDPopupRenvoiFF = marginTopBDPopupRenvoiFF+22;
		
		if(navigator.userAgent.indexOf("MSIE 7")!=-1)
		{
			document.getElementById('popupRenvoiBas').style.marginTop = marginTopBasPopupRenvoiIE7 + 0 +"px";
			document.getElementById('popupRenvoiCoinBG').style.marginTop = marginTopBGPopupRenvoiIE7 + 0 +"px";
			document.getElementById('popupRenvoiCoinBD').style.marginTop = marginTopBDPopupRenvoiIE7 + 0 +"px";
			
			marginTopBasPopupRenvoiIE7 = marginTopBasPopupRenvoiIE7 +0;
			marginTopBGPopupRenvoiIE7 = marginTopBGPopupRenvoiIE7 +0;
			marginTopBDPopupRenvoiIE7 = marginTopBDPopupRenvoiIE7 +0;
		}
		else if(navigator.userAgent.indexOf("Safari")!=-1)
		{
			document.getElementById('popupUploadPrivateBas').style.marginTop = marginTopBasPopupRenvoiSafari + 22 +"px";
			document.getElementById('popupUploadPrivateCoinBG').style.marginTop = marginTopBGPopupRenvoiSafari + 22 +"px";
			document.getElementById('popupUploadPrivateCoinBD').style.marginTop = marginTopBDPopupRenvoiSafari + 22 +"px";
			
			marginTopBasPopupRenvoiSafari = marginTopBasPopupRenvoiSafari +22;
			marginTopBGPopupRenvoiSafari = marginTopBGPopupRenvoiSafari +22;
			marginTopBDPopupRenvoiSafari = marginTopBDPopupRenvoiSafari +22;
		}
		else if(navigator.userAgent.indexOf("Mozilla")!=-1 && navigator.userAgent.indexOf("Macintosh")!=-1)
		{
			document.getElementById('popupRenvoiBas').style.marginTop = marginTopBasPopupRenvoiFFMac + 22 + "px";
			document.getElementById('popupRenvoiCoinBG').style.marginTop = marginTopBGPopupRenvoiFFMac + 22 + "px";
			document.getElementById('popupRenvoiCoinBD').style.marginTop = marginTopBDPopupRenvoiFFMac + 22 + "px";
			
			marginTopBasPopupRenvoiFFMac = marginTopBasPopupRenvoiFFMac+22;
			marginTopBGPopupRenvoiFFMac = marginTopBGPopupRenvoiFFMac+22;
			marginTopBDPopupRenvoiFFMac = marginTopBDPopupRenvoiFFMac+22;
		}
		else if(navigator.userAgent.indexOf("MSIE 6")!=-1)
		{
			document.getElementById('popupRenvoiDroit').style.height = document.getElementById('popupRenvoiDroit').offsetHeight + 12 +"px";
			document.getElementById('popupRenvoiGauche').style.height = document.getElementById('popupRenvoiGauche').offsetHeight + 12 +"px";
			
			document.getElementById('popupRenvoiBas').style.marginTop = marginTopBasPopupRenvoiIE6 + 12 + "px";
			document.getElementById('popupRenvoiCoinBG').style.marginTop = marginTopBGPopupRenvoiIE6 + 12 + "px";
			document.getElementById('popupRenvoiCoinBD').style.marginTop = marginTopBDPopupRenvoiIE6 + 12 + "px";
			
			marginTopBasPopupRenvoiIE6 = marginTopBasPopupRenvoiIE6+12;
			marginTopBGPopupRenvoiIE6 = marginTopBGPopupRenvoiIE6+12;
			marginTopBDPopupRenvoiIE6 = marginTopBDPopupRenvoiIE6+12;
		}
	}
}

function ajouteChampRenvoiEnvoyer()
{
	var divPrinc = document.getElementById('inputDestRenvoi');
	
	if(divPrinc.hasChildNodes())
	{
		var enfants = divPrinc.childNodes;
		var compteurElement = 1;

		for (var i = 0; i < enfants.length; i++)
		{
			if(enfants[i].tagName=='DIV')
			{
				var enfants2 = enfants[i].childNodes;
				
				for (var j = 0; j < enfants2.length; j++)
				{
						
					if(enfants2[j].tagName=='INPUT')
					{			
						if(enfants2[j].value=="")
							return false;
					
						if(enfants2[j].id.search(/destinatairePrivateRenvoi/)!=-1)
						{	
							if(enfants2[j].id!='destinatairePrivateRenvoi_1')
							{
								if(enfants[i].value == "")
								{
									divPrinc.removeChild(enfants[i]);
								}
								
								compteurElement++;
							}
							
						}
					}
				}
			}
		}
		
		var newDiv = document.createElement('div');
		var newInput = document.createElement('input');
		
		compteurElement++;
		
		newDiv.setAttribute('id','caseDestinatairePrivateRenvoi_'+compteurElement);
		
		newInput.setAttribute('id', 'destinatairePrivateRenvoi_'+compteurElement);
		newInput.setAttribute('name', 'destinatairePrivateRenvoi_'+compteurElement);
		newInput.setAttribute('type','text');
		newInput.style.width = '165px';
		newInput.style.border = "1px solid black";
		
		newDiv.style.paddingBottom = "5px";
		
		var link2 = document.createElement('a');
		var img = document.createElement('img');
		var br = document.createElement('br');
		
		img.setAttribute('src','styles/default/graphs/bouton_supprimer_contact.gif');
		
		link2.setAttribute('href','javascript:supprimeChampRenvoiEnvoyer("'+(compteurElement-1)+'");');
		link2.appendChild(img);
		
		document.getElementById('caseDestinatairePrivateRenvoi_'+(compteurElement-1)).appendChild(link2);
		document.getElementById('caseDestinatairePrivateRenvoi_'+(compteurElement-1)).appendChild(br);
		
		newDiv.appendChild(newInput);

		divPrinc.appendChild(newDiv);
		
		autoCompletionRenvoi(compteurElement);
	}
}

function supprimeChamp(indice)
{
	var suppr = document.getElementById('caseDestinataireEnvoi_'+indice);
	var divPrinc = document.getElementById('inputDestinataire');
	
	divPrinc.removeChild(suppr);

	var compteur = 1;

	if(divPrinc.hasChildNodes())
	{
		var enfants = divPrinc.childNodes;
		var compteurElement = 1;

		for (var i = 0; i < enfants.length; i++)
		{
			if(enfants[i].tagName=='DIV')
			{
				enfants[i].setAttribute('id','caseDestinataireEnvoi_'+compteur);
				var enfants2 = enfants[i].childNodes;
				
				for (var j = 0; j < enfants2.length; j++)
				{
					if(enfants2[j].tagName=='INPUT')
					{			
						enfants2[j].setAttribute('id','destinataireEnvoi_'+compteur);
						enfants2[j].setAttribute('name','destinataireEnvoi_'+compteur);
					}
					
					if(enfants2[j].tagName=='A')
					{			
						//enfants2[j].setAttribute('onclick','supprimeChamp("'+compteur+'");');
						enfants2[j].setAttribute('href','javascript: supprimeChamp("'+compteur+'");');
					}
				}
				
				compteur++;
			}
		}
	}
	
	
	document.getElementById('popup_upload_private').style.height = document.getElementById('popup_upload_private').offsetHeight - 23 +"px";
	
	document.getElementById('popupUploadPrivateDroit').style.height = document.getElementById('popupUploadPrivateDroit').offsetHeight - 23 +"px";
	document.getElementById('popupUploadPrivateGauche').style.height = document.getElementById('popupUploadPrivateGauche').offsetHeight - 23 +"px";
	
	if(navigator.userAgent.indexOf("MSIE 7")!=-1)
	{
		document.getElementById('popupUploadPrivateBas').style.marginTop = marginTopBasIE7 - 23 +"px";
		document.getElementById('popupUploadPrivateCoinBG').style.marginTop = marginTopCoinBasGaucheIE7 - 23 +"px";
		document.getElementById('popupUploadPrivateCoinBD').style.marginTop = marginTopCoinBasDroitIE7 - 23 +"px";
		
		marginTopBasIE7 = marginTopBasIE7 - 23;
		marginTopCoinBasGaucheIE7 = marginTopCoinBasGaucheIE7 - 23;
		marginTopCoinBasDroitIE7 = marginTopCoinBasDroitIE7 - 23;
	}
	else if(navigator.userAgent.indexOf("Safari")!=-1)
	{
		document.getElementById('popupUploadPrivateBas').style.marginTop = marginTopBasSafari - 23 +"px";
		document.getElementById('popupUploadPrivateCoinBG').style.marginTop = marginTopCoinBasGaucheSafari - 23 +"px";
		document.getElementById('popupUploadPrivateCoinBD').style.marginTop = marginTopCoinBasDroitSafari - 23 +"px";
		
		marginTopBasSafari = marginTopBasSafari -23;
		marginTopCoinBasGaucheSafari = marginTopCoinBasGaucheSafari -23;
		marginTopCoinBasDroitSafari = marginTopCoinBasDroitSafari -23;
	}
}

function supprimeChampRenvoi(indice)
{
	var suppr = document.getElementById('caseDestinatairePrivateRenvoi_'+indice);
	var divPrinc = document.getElementById('inputDestRenvoi');
	
	divPrinc.removeChild(suppr);

	var compteur = 1;

	if(divPrinc.hasChildNodes())
	{
		var enfants = divPrinc.childNodes;
		var compteurElement = 1;

		for (var i = 0; i < enfants.length; i++)
		{
			if(enfants[i].tagName=='DIV')
			{
				enfants[i].setAttribute('id','caseDestinatairePrivateRenvoi_'+compteur);
				var enfants2 = enfants[i].childNodes;
				
				for (var j = 0; j < enfants2.length; j++)
				{
					if(enfants2[j].tagName=='INPUT')
					{			
						enfants2[j].setAttribute('id','destinatairePrivateRenvoi_'+compteur);
						enfants2[j].setAttribute('name','destinatairePrivateRenvoi_'+compteur);
					}
					
					if(enfants2[j].tagName=='A')
					{			
						//enfants2[j].setAttribute('onclick','supprimeChamp("'+compteur+'");');
						enfants2[j].setAttribute('href','javascript: supprimeChampRenvoi("'+compteur+'");');
					}
				}
				
				compteur++;
			}
		}
	}
	
	document.getElementById('popup_renvoi').style.height = document.getElementById('popup_renvoi').offsetHeight - 23 +"px";

	document.getElementById('popupRenvoiDroit').style.height = document.getElementById('popupRenvoiDroit').offsetHeight - 23 +"px";
	document.getElementById('popupRenvoiGauche').style.height = document.getElementById('popupRenvoiGauche').offsetHeight - 23 +"px";
	
	document.getElementById('popupRenvoiBas').style.marginTop = marginTopBasPopupRenvoiFF - 23 + "px";
	document.getElementById('popupRenvoiCoinBG').style.marginTop = marginTopBGPopupRenvoiFF - 23 + "px";
	document.getElementById('popupRenvoiCoinBD').style.marginTop = marginTopBDPopupRenvoiFF - 23 + "px";
	
	marginTopBasPopupRenvoiFF = marginTopBasPopupRenvoiFF-23;
	marginTopBGPopupRenvoiFF = marginTopBGPopupRenvoiFF-23;
	marginTopBDPopupRenvoiFF = marginTopBDPopupRenvoiFF-23;
	
	if(navigator.userAgent.indexOf("MSIE 7")!=-1)
	{
		document.getElementById('popupRenvoiBas').style.marginTop = marginTopBasPopupRenvoiIE7 - 0 +"px";
		document.getElementById('popupRenvoiCoinBG').style.marginTop = marginTopBGPopupRenvoiIE7 - 0 +"px";
		document.getElementById('popupRenvoiCoinBD').style.marginTop = marginTopBDPopupRenvoiIE7 - 0 +"px";
				
		marginTopBasPopupRenvoiIE7 = marginTopBasPopupRenvoiIE7 - 0;
		marginTopBGPopupRenvoiIE7 = marginTopBGPopupRenvoiIE7 - 0;
		marginTopBDPopupRenvoiIE7 = marginTopBDPopupRenvoiIE7 - 0;
	}
	else if(navigator.userAgent.indexOf("Safari")!=-1)
	{
		document.getElementById('popupRenvoiBas').style.marginTop = marginTopBasPopupRenvoiSafari - 23 +"px";
		document.getElementById('popupRenvoiCoinBG').style.marginTop = marginTopBGPopupRenvoiSafari - 23 +"px";
		document.getElementById('popupRenvoiCoinBD').style.marginTop = marginTopBDPopupRenvoiSafari - 23 +"px";
		
		marginTopBasPopupRenvoiSafari = marginTopBasPopupRenvoiSafari -23;
		marginTopBGPopupRenvoiSafari = marginTopBGPopupRenvoiSafari -23;
		marginTopBDPopupRenvoiSafari = marginTopBDPopupRenvoiSafari -23;
	}
	else if(navigator.userAgent.indexOf("Mozilla")!=-1 && navigator.userAgent.indexOf("Macintosh")!=-1)
	{
		document.getElementById('popupRenvoiBas').style.marginTop = marginTopBasPopupRenvoiFFMac - 23 + "px";
		document.getElementById('popupRenvoiCoinBG').style.marginTop = marginTopBGPopupRenvoiFFMac - 23 + "px";
		document.getElementById('popupRenvoiCoinBD').style.marginTop = marginTopBDPopupRenvoiFFMac - 23 + "px";
		
		marginTopBasPopupRenvoiFFMac = marginTopBasPopupRenvoiFFMac-23;
		marginTopBGPopupRenvoiFFMac = marginTopBGPopupRenvoiFFMac-23;
		marginTopBDPopupRenvoiFFMac = marginTopBDPopupRenvoiFFMac-23;
	}
	else if(navigator.userAgent.indexOf("MSIE 6")!=-1)
	{
		document.getElementById('popup_renvoi').style.height = document.getElementById('popup_renvoi').offsetHeight - 23 +"px";
		document.getElementById('popupRenvoiDroit').style.height = document.getElementById('popupRenvoiDroit').offsetHeight - 23 +"px";
		document.getElementById('popupRenvoiGauche').style.height = document.getElementById('popupRenvoiGauche').offsetHeight - 23 +"px";
		
		document.getElementById('popupRenvoiBas').style.marginTop = marginTopBasPopupRenvoiIE6 - 0 + "px";
		document.getElementById('popupRenvoiCoinBG').style.marginTop = marginTopBGPopupRenvoiIE6 - 0 + "px";
		document.getElementById('popupRenvoiCoinBD').style.marginTop = marginTopBDPopupRenvoiIE6 - 0 + "px";
		
		marginTopBasPopupRenvoiIE6 = marginTopBasPopupRenvoiIE6-0;
		marginTopBGPopupRenvoiIE6 = marginTopBGPopupRenvoiIE6-0;
		marginTopBDPopupRenvoiIE6 = marginTopBDPopupRenvoiIE6-0;
	}
}

function supprimeChampRenvoiEnvoyer(indice)
{
	var suppr = document.getElementById('caseDestinatairePrivateRenvoi_'+indice);
	var divPrinc = document.getElementById('inputDestRenvoi');
	
	divPrinc.removeChild(suppr);

	var compteur = 1;

	if(divPrinc.hasChildNodes())
	{
		var enfants = divPrinc.childNodes;
		var compteurElement = 1;

		for (var i = 0; i < enfants.length; i++)
		{
			if(enfants[i].tagName=='DIV')
			{
				enfants[i].setAttribute('id','caseDestinatairePrivateRenvoi_'+compteur);
				var enfants2 = enfants[i].childNodes;
				
				for (var j = 0; j < enfants2.length; j++)
				{
					if(enfants2[j].tagName=='INPUT')
					{			
						enfants2[j].setAttribute('id','destinatairePrivateRenvoi_'+compteur);
						enfants2[j].setAttribute('name','destinatairePrivateRenvoi_'+compteur);
					}
					
					if(enfants2[j].tagName=='A')
					{			
						//enfants2[j].setAttribute('onclick','supprimeChamp("'+compteur+'");');
						enfants2[j].setAttribute('href','javascript: supprimeChampRenvoiEnvoyer("'+compteur+'");');
					}
				}
				
				compteur++;
			}
		}
	}
}

function transfertContactRenvoi(mail)
{
	var longueur=mail.length;
	
	if(longueur > 0 && mail!="")
	{	
		document.getElementById('destinatairePrivateRenvoi').value=document.getElementById('destinatairePrivateRenvoi').value+mail+",";
	}
}


var marginTopBasPopupRenvoiFF = 258;
var marginTopBGPopupRenvoiFF = 258;
var marginTopBDPopupRenvoiFF = 258;

var marginTopBasPopupRenvoiIE7 = 0;
var marginTopBGPopupRenvoiIE7 = 0;
var marginTopBDPopupRenvoiIE7 = 0;


var marginTopBasPopupRenvoiSafari = 252;
var marginTopBGPopupRenvoiSafari= 252;
var marginTopBDPopupRenvoiSafari = 252;

var marginTopBasPopupRenvoiFFMac = 244;
var marginTopBGPopupRenvoiFFMac = 244;
var marginTopBDPopupRenvoiFFMac = 244;

var marginTopBasPopupRenvoiIE6 = -4;
var marginTopBGPopupRenvoiIE6 = -4;
var marginTopBDPopupRenvoiIE6 = -4;

function transfert2ContactRenvoi2(mail)
{
	var tab = mail.split('|');
	
	for(var i = 0; i < tab.length; i++)
		transfertContactRenvoi2(tab[i]);
}

function transfertContactRenvoi2(mail)
{
	var divPrinc = document.getElementById('inputDestRenvoi');
	
	if(divPrinc.hasChildNodes())
	{
		var enfants = divPrinc.childNodes;
		var compteurElement = 1;
		var vide = false;
		var temp = '';

		for (var i = 0; i < enfants.length; i++)
		{
			if(enfants[i].tagName=='DIV')
			{
				var enfants2 = enfants[i].childNodes;
				
				for (var j = 0; j < enfants2.length; j++)
				{
					if(enfants2[j].tagName=='INPUT')
					{			
						if(enfants2[j].value==mail)
							return false;
									
						if(enfants2[j].id.search(/destinatairePrivateRenvoi/)!=-1)
						{	
							if(enfants2[j].id!='destinatairePrivateRenvoi_1')
							{
								if(enfants[i].value == "")
								{
									divPrinc.removeChild(enfants[i]);
								}
													
								compteurElement++;
							}
							
							if(enfants2[j].value == "")
							{
								vide = true;
								temp = compteurElement;
							}
						}	 
					}
				}
			}
		}
		
		var passe =  'false';
	
		if(vide == false)
		{
			var inc = compteurElement;
			
			var link2 = document.createElement('a');
			var img = document.createElement('img');
						
			img.setAttribute('src','styles/default/graphs/bouton_supprimer_contact.gif');
			
			link2.setAttribute('href','javascript:supprimeChampRenvoi("'+inc+'");');
						
			link2.appendChild(img);
			
			document.getElementById('caseDestinatairePrivateRenvoi_'+inc).appendChild(link2);
	
			var newDiv = document.createElement('div');
			var newInput = document.createElement('input');
			
			compteurElement++;
			
			newDiv.setAttribute('id','caseDestinatairePrivateRenvoi_'+compteurElement);
			newDiv.style.paddingBottom = "2px";
			
			newInput.setAttribute('id', 'destinatairePrivateRenvoi_'+compteurElement);
			newInput.setAttribute('name', 'destinatairePrivateRenvoi_'+compteurElement);
			newInput.setAttribute('type','text');
			newInput.style.width = '165px';
				
			newDiv.appendChild(newInput);

			divPrinc.appendChild(newDiv);
			
			autoCompletion2(compteurElement);
			
			document.getElementById('destinatairePrivateRenvoi_'+compteurElement).value = mail;
			
			passe = 'false';
		}
		
		var newDiv = document.createElement('div');
		var newInput = document.createElement('input');
		
		compteurElement++;
		
		newDiv.setAttribute('id','caseDestinatairePrivateRenvoi_'+compteurElement);
		newDiv.style.paddingBottom = "2px";
		
		newInput.setAttribute('id', 'destinatairePrivateRenvoi_'+compteurElement);
		newInput.setAttribute('name', 'destinatairePrivateRenvoi_'+compteurElement);
		newInput.setAttribute('type','text');
		newInput.style.width = '165px';
		
		newDiv.appendChild(newInput);

		divPrinc.appendChild(newDiv);
		
		autoCompletionRenvoi(compteurElement);
		

		if(passe=='false')
		{
			document.getElementById('popup_renvoi').style.height = document.getElementById('popup_renvoi').offsetHeight + 22 +"px";
		
			document.getElementById('popupRenvoiDroit').style.height = document.getElementById('popupRenvoiDroit').offsetHeight + 22 +"px";
			document.getElementById('popupRenvoiGauche').style.height = document.getElementById('popupRenvoiGauche').offsetHeight + 22 +"px";
			
			document.getElementById('popupRenvoiBas').style.marginTop = marginTopBasPopupRenvoiFF + 22 + "px";
			document.getElementById('popupRenvoiCoinBG').style.marginTop = marginTopBGPopupRenvoiFF + 22 + "px";
			document.getElementById('popupRenvoiCoinBD').style.marginTop = marginTopBDPopupRenvoiFF + 22 + "px";
			
			marginTopBasPopupRenvoiFF = marginTopBasPopupRenvoiFF+22;
			marginTopBGPopupRenvoiFF = marginTopBGPopupRenvoiFF+22;
			marginTopBDPopupRenvoiFF = marginTopBDPopupRenvoiFF+22;
			
			if(navigator.userAgent.indexOf("MSIE 7")!=-1)
			{
				document.getElementById('popupRenvoiBas').style.marginTop = marginTopBasPopupRenvoiIE7 + 0 +"px";
				document.getElementById('popupRenvoiCoinBG').style.marginTop = marginTopBGPopupRenvoiIE7 + 0 +"px";
				document.getElementById('popupRenvoiCoinBD').style.marginTop = marginTopBDPopupRenvoiIE7 + 0 +"px";
				
				marginTopBasPopupRenvoiIE7 = marginTopBasPopupRenvoiIE7 +0;
				marginTopBGPopupRenvoiIE7 = marginTopBGPopupRenvoiIE7 +0;
				marginTopBDPopupRenvoiIE7 = marginTopBDPopupRenvoiIE7 +0;
			}
			else if(navigator.userAgent.indexOf("Safari")!=-1)
			{
				document.getElementById('popupRenvoiBas').style.marginTop = marginTopBasPopupRenvoiSafari + 22 +"px";
				document.getElementById('popupRenvoiCoinBG').style.marginTop = marginTopBGPopupRenvoiSafari + 22 +"px";
				document.getElementById('popupRenvoiCoinBD').style.marginTop = marginTopBDPopupRenvoiSafari + 22 +"px";
				
				marginTopBasPopupRenvoiSafari = marginTopBasPopupRenvoiSafari +22;
				marginTopBGPopupRenvoiSafari = marginTopBGPopupRenvoiSafari +22;
				marginTopBDPopupRenvoiSafari = marginTopBDPopupRenvoiSafari +22;
			}
			else if(navigator.userAgent.indexOf("Mozilla")!=-1 && navigator.userAgent.indexOf("Macintosh")!=-1)
			{
				document.getElementById('popupRenvoiBas').style.marginTop = marginTopBasPopupRenvoiFFMac + 22 + "px";
				document.getElementById('popupRenvoiCoinBG').style.marginTop = marginTopBGPopupRenvoiFFMac + 22 + "px";
				document.getElementById('popupRenvoiCoinBD').style.marginTop = marginTopBDPopupRenvoiFFMac + 22 + "px";
				
				marginTopBasPopupRenvoiFFMac = marginTopBasPopupRenvoiFFMac+22;
				marginTopBGPopupRenvoiFFMac = marginTopBGPopupRenvoiFFMac+22;
				marginTopBDPopupRenvoiFFMac = marginTopBDPopupRenvoiFFMac+22;
			
			}
			else if(navigator.userAgent.indexOf("MSIE 6")!=-1)
			{
				document.getElementById('popupRenvoiDroit').style.height = document.getElementById('popupRenvoiDroit').offsetHeight + 0 +"px";
				document.getElementById('popupRenvoiGauche').style.height = document.getElementById('popupRenvoiGauche').offsetHeight + 0 +"px";
				
				document.getElementById('popupRenvoiBas').style.marginTop = marginTopBasPopupRenvoiIE6 + 0 + "px";
				document.getElementById('popupRenvoiCoinBG').style.marginTop = marginTopBGPopupRenvoiIE6 + 0 + "px";
				document.getElementById('popupRenvoiCoinBD').style.marginTop = marginTopBDPopupRenvoiIE6 + 0 + "px";
				
				marginTopBasPopupRenvoiIE6 = marginTopBasPopupRenvoiIE6+0;
				marginTopBGPopupRenvoiIE6 = marginTopBGPopupRenvoiIE6+0;
				marginTopBDPopupRenvoiIE6 = marginTopBDPopupRenvoiIE6+0;
			}
		}
		else
		{
			document.getElementById('popup_renvoi').style.height = document.getElementById('popup_renvoi').offsetHeight + 30 +"px";
		
			document.getElementById('popupRenvoiDroit').style.height = document.getElementById('popupRenvoiDroit').offsetHeight + 30 +"px";
			document.getElementById('popupRenvoiGauche').style.height = document.getElementById('popupRenvoiGauche').offsetHeight + 30 +"px";
				
			document.getElementById('popupRenvoiBas').style.marginTop = marginTopBasPopupRenvoiFF + 30 + "px";
			document.getElementById('popupRenvoiCoinBG').style.marginTop = marginTopBGPopupRenvoiFF + 30 + "px";
			document.getElementById('popupRenvoiCoinBD').style.marginTop = marginTopBDPopupRenvoiFF + 30 + "px";
		
			marginTopBasPopupRenvoiFF = marginTopBasPopupRenvoiFF+30;
			marginTopBGPopupRenvoiFF = marginTopBGPopupRenvoiFF+30;
			marginTopBDPopupRenvoiFF = marginTopBDPopupRenvoiFF+30;
		
			if(navigator.userAgent.indexOf("MSIE 7")!=-1)
			{
				document.getElementById('popupRenvoiBas').style.marginTop = marginTopBasPopupRenvoiIE7 + 0 +"px";
				document.getElementById('popupRenvoiCoinBG').style.marginTop = marginTopBGPopupRenvoiIE7 + 0 +"px";
				document.getElementById('popupRenvoiCoinBD').style.marginTop = marginTopBDPopupRenvoiIE7 + 0 +"px";
				
				marginTopBasPopupRenvoiIE7 = marginTopBasPopupRenvoiIE7 +0;
				marginTopBGPopupRenvoiIE7 = marginTopBGPopupRenvoiIE7 +0;
				marginTopBDPopupRenvoiIE7 = marginTopBDPopupRenvoiIE7 +0;
			}
			else if(navigator.userAgent.indexOf("Safari")!=-1)
			{
				document.getElementById('popupRenvoiBas').style.marginTop = marginTopBasPopupRenvoiSafari + 30 +"px";
				document.getElementById('popupRenvoiCoinBG').style.marginTop = marginTopBGPopupRenvoiSafari + 30 +"px";
				document.getElementById('popupRenvoiCoinBD').style.marginTop = marginTopBDPopupRenvoiSafari + 30 +"px";
				
				marginTopBasPopupRenvoiSafari = marginTopBasPopupRenvoiSafari +30;
				marginTopBGPopupRenvoiSafari = marginTopBGPopupRenvoiSafari +30;
				marginTopBDPopupRenvoiSafari = marginTopBDPopupRenvoiSafari +30;
			}
			else if(navigator.userAgent.indexOf("Mozilla")!=-1 && navigator.userAgent.indexOf("Macintosh")!=-1)
			{
				document.getElementById('popupRenvoiBas').style.marginTop = marginTopBasPopupRenvoiFFMac + 30 + "px";
				document.getElementById('popupRenvoiCoinBG').style.marginTop = marginTopBGPopupRenvoiFFMac + 30 + "px";
				document.getElementById('popupRenvoiCoinBD').style.marginTop = marginTopBDPopupRenvoiFFMac + 30 + "px";
				
				marginTopBasPopupRenvoiFFMac = marginTopBasPopupRenvoiFFMac+30;
				marginTopBGPopupRenvoiFFMac = marginTopBGPopupRenvoiFFMac+30;
				marginTopBDPopupRenvoiFFMac = marginTopBDPopupRenvoiFFMac+30;
			}
			else if(navigator.userAgent.indexOf("MSIE 6")!=-1)
			{
				document.getElementById('popupRenvoiDroit').style.height = document.getElementById('popupRenvoiDroit').offsetHeight + 21 +"px";
				document.getElementById('popupRenvoiGauche').style.height = document.getElementById('popupRenvoiGauche').offsetHeight + 21 +"px";
				
				document.getElementById('popupRenvoiBas').style.marginTop = marginTopBasPopupRenvoiIE6 + 0 + "px";
				document.getElementById('popupRenvoiCoinBG').style.marginTop = marginTopBGPopupRenvoiIE6 + 0 + "px";
				document.getElementById('popupRenvoiCoinBD').style.marginTop = marginTopBDPopupRenvoiIE6 + 0 + "px";
				
				marginTopBasPopupRenvoiIE6 = marginTopBasPopupRenvoiIE6+0;
				marginTopBGPopupRenvoiIE6 = marginTopBGPopupRenvoiIE6+0;
				marginTopBDPopupRenvoiIE6 = marginTopBDPopupRenvoiIE6+0;
			}
		}
		
		
		if(passe=='false')
		{
			document.getElementById('destinatairePrivateRenvoi_'+(compteurElement-1)).setAttribute('value',mail);
			var link2 = document.createElement('a');
			var img = document.createElement('img');
						
			img.setAttribute('src','styles/default/graphs/bouton_supprimer_contact.gif');
			
			link2.setAttribute('href','javascript:supprimeChampRenvoi("'+(compteurElement-1)+'");');
			link2.appendChild(img);
			
			document.getElementById('caseDestinatairePrivateRenvoi_'+(compteurElement-1)).appendChild(link2);
			document.getElementById('caseDestinatairePrivateRenvoi_'+(compteurElement-1)).style.paddingBottom = "2px";
			
		}
	}
}

function transfertContactRenvoiEnvoyer2(mail)
{
	var tab = mail.split('|');
	
	for(var i = 0; i < tab.length; i++)
		transfertContactRenvoiEnvoyer(tab[i]);
}

function transfertContactRenvoiEnvoyer(mail)
{
	var divPrinc = document.getElementById('inputDestRenvoi');
	
	if(divPrinc.hasChildNodes())
	{
		var enfants = divPrinc.childNodes;
		var compteurElement = 1;
		var vide = false;
		var temp = '';

		for (var i = 0; i < enfants.length; i++)
		{
			if(enfants[i].tagName=='DIV')
			{
				var enfants2 = enfants[i].childNodes;
				
				for (var j = 0; j < enfants2.length; j++)
				{
					if(enfants2[j].tagName=='INPUT')
					{			
						if(enfants2[j].value==mail)
							return false;
									
						if(enfants2[j].id.search(/destinatairePrivateRenvoi/)!=-1)
						{	
							if(enfants2[j].id!='destinatairePrivateRenvoi_1')
							{
								if(enfants[i].value == "")
								{
									divPrinc.removeChild(enfants[i]);
								}
													
								compteurElement++;
							}
							
							if(enfants2[j].value == "")
							{
								vide = true;
								temp = compteurElement;
							}
						}	 
					}
				}
			}
		}
		
		var passe =  'false';
		
		if(vide == false)
		{
			var inc = compteurElement;
			
			var link2 = document.createElement('a');
			var img = document.createElement('img');
						
			img.setAttribute('src','styles/default/graphs/bouton_supprimer_contact.gif');
			link2.setAttribute('href','javascript:supprimeChampRenvoiEnvoyer("'+inc+'");');
			link2.appendChild(img);
			
			document.getElementById('caseDestinatairePrivateRenvoi_'+inc).appendChild(link2);
	
			var newDiv = document.createElement('div');
			var newInput = document.createElement('input');
			
			compteurElement++;
			
			newDiv.setAttribute('id','caseDestinatairePrivateRenvoi_'+compteurElement);
			newDiv.style.paddingBottom = "2px";
			
			newInput.setAttribute('id', 'destinatairePrivateRenvoi_'+compteurElement);
			newInput.setAttribute('name', 'destinatairePrivateRenvoi_'+compteurElement);
			newInput.setAttribute('type','text');
			newInput.style.width = '165px';
			newInput.style.border = "1px solid black";
						
			newDiv.appendChild(newInput);

			divPrinc.appendChild(newDiv);
			
			autoCompletionRenvoi(compteurElement);
			
			document.getElementById('destinatairePrivateRenvoi_'+compteurElement).value = mail;
			
			passe = 'false';
		}
		
		//~ if(document.getElementById('destinatairePrivateRenvoi_1').value=="")
		//~ {
			//~ document.getElementById('destinatairePrivateRenvoi_1').value = mail;
			
			//~ document.getElementById('caseDestinatairePrivateRenvoi_1').style.paddingBottom = '5px';
			
			//~ var br = document.createElement('br');
			//~ var link2 = document.createElement('a');
			//~ var img = document.createElement('img');
			//~ var br = document.createElement('br');
			
			//~ img.setAttribute('src','styles/default/graphs/bouton_supprimer_contact.gif');
			
			//~ link2.setAttribute('href','javascript:supprimeChampRenvoiEnvoyer("1");');
						
			//~ link2.appendChild(img);
			
			//~ document.getElementById('caseDestinatairePrivateRenvoi_1').appendChild(link2);
			//~ document.getElementById('caseDestinatairePrivateRenvoi_1').appendChild(br);
			
			//~ passe = 'true';
		//~ }

		var newDiv = document.createElement('div');
		var newInput = document.createElement('input');
		
		compteurElement++;
		
		newDiv.setAttribute('id','caseDestinatairePrivateRenvoi_'+compteurElement);
		newDiv.style.paddingBottom = "2px";
		
		newInput.setAttribute('id', 'destinatairePrivateRenvoi_'+compteurElement);
		newInput.setAttribute('name', 'destinatairePrivateRenvoi_'+compteurElement);
		newInput.setAttribute('type','text');
		newInput.style.width = '165px';
		newInput.style.border = "1px solid black";
		
		newDiv.appendChild(newInput);

		divPrinc.appendChild(newDiv);
		
		autoCompletionRenvoi(compteurElement);
				
		if(passe=='false')
		{
			document.getElementById('destinatairePrivateRenvoi_'+(compteurElement-1)).setAttribute('value',mail);
			var link2 = document.createElement('a');
			var img = document.createElement('img');
			
			
			img.setAttribute('src','styles/default/graphs/bouton_supprimer_contact.gif');
			
			link2.setAttribute('href','javascript: supprimeChampRenvoiEnvoyer("'+(compteurElement-1)+'");');
			link2.appendChild(img);
			
			document.getElementById('caseDestinatairePrivateRenvoi_'+(compteurElement-1)).appendChild(link2);
			document.getElementById('caseDestinatairePrivateRenvoi_'+(compteurElement-1)).paddingBottom = "2px";
			
		}
	}
}

function verifForm()
{
	var cgu = document.getElementById('cgu');
	
	if(cgu.checked==false)
	{
		displayError('Vous devez respecter les conditions g&eacute;n&eacute;rales d\'utilisation');
	}
	else
	{	
		var url = changerLien();
		var pass = document.getElementById("passFichier").value;
		popBox(url+"&pwd="+pass);
	}
}

function recupChamp()
{
	var test= document.getElementById('upfile_0');
}

function ajouteContact()
{
	$.post('index.php?controller=zoneprivee&action=verifAjoutContact',
	{nom:   document.getElementById('nomContact').value, prenom: document.getElementById('prenomContact').value, societe: document.getElementById('societeContact').value, email: document.getElementById('emailContact').value},
	function (data) { proceedAjoutContact(data); });
}

function backgroundAccueil()
{
	document.getElementById('menuAccueil').style.backgroundImage ='url("styles/default/graphs/bloc_menu_sel.jpg")';
}

function proceedAjoutContact(xhr)
{
	var retour = xhr;
	var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		if(xhr=='erreur_mail')
			displayError('L\'adresse mail n\'est pas correcte.');
	}
	else
	{
		
		if(xhr=='ok')
			$.post('index.php?controller=zoneprivee&action=genereListe','', function (data) { genereNewListe(data,'nom','ASC'); });
	}
}

function supprContact(idContact, idClient)
{
	$.post('index.php?controller=zoneprivee&action=supprContact',
	{ idcontact: idContact, idclient: idClient },
	function (data) { proceedSupprContact(data); });
}

function proceedSupprContact(xhr)
{

	var retour = xhr;
	var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		if(xhr=='erreur_client')
			displayError('Vous n\'etes pas autorisé a supprimer ce contact');
	}
	else
	{
		if(xhr=='ok')
		{
			$.post('index.php?controller=zoneprivee&action=genereListe','',
			function(data) { genereNewListe(data,'nom','ASC'); });
			closeBox();
		}
	}
	
}

function genereNewListe(xhr,champ,ordre)
{
	switch(champ)
	{
		case 'prenom':
			if(ordre == 'ASC')
				document.getElementById('listeContact').innerHTML='<div id="contenuListeContact" style="position:absolute; top:0;"><table border="0" cellpadding="0" cellspacing="0" width="434"><tr class="headerTabHisto"><td align="center" onclick="trieContact(\'nom\',\'ASC\');" style="cursor: pointer;">Nom(s)</td><td align="center" onclick="trieContact(\'prenom\',\'DESC\');" style="height: 22px; cursor: pointer;">Pr&eacute;nom(s)</td><td align="center" onclick="trieContact(\'societe\',\'ASC\');" style="height: 22px; cursor: pointer;">Soci&eacute;t&eacute;(s)</td><td align="center" onclick="trieContact(\'email\',\'ASC\');" style="height: 22px; cursor: pointer;">Email(s)</td><td colspan="2">&nbsp;</td></tr>'+xhr+'</table></div>';
			else
				document.getElementById('listeContact').innerHTML='<div id="contenuListeContact" style="position:absolute; top:0;"><table border="0" cellpadding="0" cellspacing="0" width="434"><tr class="headerTabHisto"><td align="center" onclick="trieContact(\'nom\',\'ASC\');" style="cursor: pointer;">Nom(s)</td><td align="center" onclick="trieContact(\'prenom\',\'ASC\');" style="height: 22px; cursor: pointer;">Pr&eacute;nom(s)</td><td align="center" onclick="trieContact(\'societe\',\'ASC\');" style="height: 22px; cursor: pointer;">Soci&eacute;t&eacute;(s)</td><td align="center" onclick="trieContact(\'email\',\'ASC\');" style="height: 22px; cursor: pointer;">Email(s)</td><td colspan="2">&nbsp;</td></tr>'+xhr+'</table></div>';
		break;
		
		case 'email':
			if(ordre == 'ASC')
				document.getElementById('listeContact').innerHTML='<div id="contenuListeContact" style="position:absolute; top:0;"><table border="0" cellpadding="0" cellspacing="0" width="434"><tr class="headerTabHisto"><td align="center" onclick="trieContact(\'nom\',\'ASC\');" style="cursor: pointer;">Nom(s)</td><td align="center" onclick="trieContact(\'prenom\',\'ASC\');" style="height: 22px; cursor: pointer;">Pr&eacute;nom(s)</td><td align="center" onclick="trieContact(\'societe\',\'ASC\');" style="height: 22px; cursor: pointer;">Soci&eacute;t&eacute;(s)</td><td align="center" onclick="trieContact(\'email\',\'DESC\');" style="height: 22px; cursor: pointer;">Email(s)</td><td colspan="2">&nbsp;</td></tr>'+xhr+'</table></div>';
			else
				document.getElementById('listeContact').innerHTML='<div id="contenuListeContact" style="position:absolute; top:0;"><table border="0" cellpadding="0" cellspacing="0" width="434"><tr class="headerTabHisto"><td align="center" onclick="trieContact(\'nom\',\'ASC\');" style="cursor: pointer;">Nom(s)</td><td align="center" onclick="trieContact(\'prenom\',\'ASC\');" style="height: 22px; cursor: pointer;">Pr&eacute;nom(s)</td><td align="center" onclick="trieContact(\'societe\',\'ASC\');" style="height: 22px; cursor: pointer;">Soci&eacute;t&eacute;(s)</td><td align="center" onclick="trieContact(\'email\',\'ASC\');" style="height: 22px; cursor: pointer;">Email(s)</td><td colspan="2">&nbsp;</td></tr>'+xhr+'</table></div>';
		break;
		
		case 'societe':
			if(ordre == 'ASC')
				document.getElementById('listeContact').innerHTML='<div id="contenuListeContact" style="position:absolute; top:0;"><table border="0" cellpadding="0" cellspacing="0" width="434"><tr class="headerTabHisto"><td align="center" onclick="trieContact(\'nom\',\'ASC\');" style="cursor: pointer;">Nom(s)</td><td align="center" onclick="trieContact(\'prenom\',\'ASC\');" style="height: 22px; cursor: pointer;">Pr&eacute;nom(s)</td><td align="center" onclick="trieContact(\'societe\',\'DESC\');" style="height: 22px; cursor: pointer;">Soci&eacute;t&eacute;(s)</td><td align="center" onclick="trieContact(\'email\',\'ASC\');" style="height: 22px; cursor: pointer;">Email(s)</td><td colspan="2">&nbsp;</td></tr>'+xhr+'</table></div>';
			else
				document.getElementById('listeContact').innerHTML='<div id="contenuListeContact" style="position:absolute; top:0;"><table border="0" cellpadding="0" cellspacing="0" width="434"><tr class="headerTabHisto"><td align="center" onclick="trieContact(\'nom\',\'ASC\');" style="cursor: pointer;">Nom(s)</td><td align="center" onclick="trieContact(\'prenom\',\'ASC\');" style="height: 22px; cursor: pointer;">Pr&eacute;nom(s)</td><td align="center" onclick="trieContact(\'societe\',\'ASC\');" style="height: 22px; cursor: pointer;">Soci&eacute;t&eacute;(s)</td><td align="center" onclick="trieContact(\'email\',\'ASC\');" style="height: 22px; cursor: pointer;">Email(s)</td><td colspan="2">&nbsp;</td></tr>'+xhr+'</table></div>';
		break;
		
		default:
			if(ordre == 'ASC')
				document.getElementById('listeContact').innerHTML='<div id="contenuListeContact" style="position:absolute; top:0;"><table border="0" cellpadding="0" cellspacing="0" width="434"><tr class="headerTabHisto"><td align="center" onclick="trieContact(\'nom\',\'DESC\');" style="cursor: pointer;">Nom(s)</td><td align="center onclick="trieContact(\'prenom\',\'ASC\');" style="height: 22px; cursor: pointer;">Pr&eacute;nom(s)</td><td align="center" onclick="trieContact(\'societe\',\'ASC\');" style="height: 22px; cursor: pointer;">Soci&eacute;t&eacute;(s)</td><td align="center" onclick="trieContact(\'email\',\'ASC\');" style="height: 22px; cursor: pointer;">Email(s)</td><td colspan="2">&nbsp;</td></tr>'+xhr+'</table></div>';
			else
				document.getElementById('listeContact').innerHTML='<div id="contenuListeContact" style="position:absolute; top:0;"><table border="0" cellpadding="0" cellspacing="0" width="434"><tr class="headerTabHisto"><td align="center" onclick="trieContact(\'nom\',\'ASC\');" style="cursor: pointer;">Nom(s)</td><td align="center" onclick="trieContact(\'prenom\',\'ASC\');" style="height: 22px; cursor: pointer;">Pr&eacute;nom(s)</td><td align="center" onclick="trieContact(\'societe\',\'ASC\');" style="height: 22px; cursor: pointer;">Soci&eacute;t&eacute;(s)</td><td align="center" onclick="trieContact(\'email\',\'ASC\');" style="height: 22px; cursor: pointer;">Email(s)</td><td colspan="2">&nbsp;</td></tr>'+xhr+'</table></div>';
		break;
	}
	
	videChampsContact();
	document.getElementById('linkAjouterContact').href='javascript: ajouteContact();';
}	

function modifContact(idContact, idClient)
{
	$.post('index.php?controller=zoneprivee&action=modifContact',
	{idcontact: idContact, idclient: idClient},
	function(data) { proceedModifContact(data); });
}

function proceedModifContact(xhr)
{
	var retour = xhr;
	var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		if(xhr=='erreur_client')
			displayError('Vous n\'etes pas autorisé a supprimer ce contact');
	}
	else
	{
		var res = xhr;
		var tab = res.split(',');
		var nom= tab[0];
		var prenom = tab[1];
		var societe = tab[2];
		var mail = tab[3];
		var idcontact= tab[4];
		var idclient= tab[5];
		
		document.getElementById('nomContact').value=nom;
		document.getElementById('prenomContact').value=prenom;
		document.getElementById('societeContact').value=societe;
		document.getElementById('emailContact').value=mail;
		
		document.getElementById('linkAjouterContact').href="javascript: modificationContact("+idcontact+","+idclient+");";
	
	}
}

function modificationContact(idContact, idClient)
{
	$.post('index.php?controller=zoneprivee&action=verifModifContact',
	{ nom: document.getElementById('nomContact').value, prenom: document.getElementById('prenomContact').value, societe: document.getElementById('societeContact').value, email: document.getElementById('emailContact').value, idclient: idClient, idcontact: idContact },
	function(data) { proceedModificationContact(data); });
}

function proceedModificationContact(xhr)
{
	var retour = xhr;
	var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		if(xhr=='erreur_mail')
			displayError('L\'adresse mail n\'est pas correcte.');
	}
	else
	{
		
		if(xhr=='ok')
			$.post('index.php?controller=zoneprivee&action=genereListe','',function(data) { genereNewListe(data,'nom','ASC'); });
	}
}

function videChampsContact()
{
	document.getElementById('nomContact').value="";
	document.getElementById('prenomContact').value="";
	document.getElementById('societeContact').value="";
	document.getElementById('emailContact').value="";
}

function afficheImportContact()
{
	var adresse = document.getElementById('emailImportContact').value;
	var domaine = document.getElementById('domaine').value;
	
	if(adresse.length==0)
		displayError('Veuillez saisir une adresse');
	else if(domaine==-1||domaine=="")
		displayError('Veuillez s&eacute;lectionnez un domaine');
	else
	{
		if(navigator.userAgent.indexOf("MSIE 6")!=-1)
			masqueSelect('domaineContact');
			
		popBox('view/popupImportContact.php?addr='+adresse+'&domaine='+domaine);
	}
}


function masqueSelect(id)
{
	document.getElementById(id).style.display='none';
}

function afficheSelect(id)
{
	document.getElementById(id).style.display='block';
}

function traitementImport()
{
	document.getElementById('popup_import_contact').style.cursor="wait";
	
	$.post('index.php?controller=zoneprivee&action=traitementImportContact',
	{adresse: document.getElementById('adresseImportContact').value, domaine: document.getElementById('domaineImportContact').value, pass: document.getElementById('passwordImportContact').value},
	function(data) { proceedTraitementImport(data); });
}

function proceedTraitementImport(xhr)
{
	var retour = xhr;
	var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		if(xhr=='erreur_identifiant')
			displayError('Les identifiants ne sont pas corrects');
		else if(xhr=='erreur_import')
			displayError('Erreur lors de l\'importation des contacts');
	}
	else
	{
		document.getElementById('popup_import_contact').style.cursor="default";
		afficheImportContactPostTraitement(xhr);
	}
}

function afficheImportContactPostTraitement(xhr)
{
	var div = document.getElementById('listeImportContactPopup');
	div.innerHTML="<table border='0' cellpadding='0' cellspacing='1' style='font-family: Arial, Helvetica, sans-serif;color: #444444;font-size: 11px;'>"+xhr+"</table>";
	
	var divParent=document.getElementById('popup_import_contact');
	var divLien = document.createElement('div');
	divLien.style.marginTop="30px";
	divLien.style.paddingLeft="20px";
	divLien.innerHTML="<a href='javascript: validImportContact();'><img src='styles/default/graphs/bouton_ajouter_contact_popup.gif' alt='' width='188' height='31' /></a>";
	divParent.appendChild(divLien);
}

function validImportContact()
{
	var email = document.getElementsByName('email[]');
	var selcontacts = document.getElementsByName('selcontacts[]');
	var i=0;
	var tabContact=new Array();
	var compteur=0;
	
	
	for(i=0;i<selcontacts.length;i++)
	{
		if(selcontacts[i].checked==true)
		{
			tabContact[compteur]=email[i].value;
			compteur++;		
		}
	}
	
	$.post('index.php?controller=zoneprivee&action=existeContactImport',
	{contact: tabContact},
	function(data) { proceedValidImportContact(data); });
}

function proceedValidImportContact(xhr)
{
	genereNewListe(xhr,'nom','ASC');
	closeBox();
}


function afficheFichier(ordre,valeur)
{
	$.post('index.php?controller=zoneprivee&action=afficheListeFichier',
	{ordre: ordre, valeur: valeur},
	function(data) { proceedAfficheFichier(data,ordre); });
}

function proceedAfficheFichier(xhr, ordre)
{	
	var link;
	var image;
	
	if(ordre=="ordre_decroissant")
	{
		link="javascript: afficheFichier('ordre_croissant');";
		image="styles/default/graphs/decroissant.gif";

				
	}
	else
	{
		link="javascript: afficheFichier('ordre_decroissant');";
		image="styles/default/graphs/croissant.gif";
	}
	
	document.getElementById('listeFichiers').innerHTML='<div id="contenuListeFichier" style="position:absolute; top:0;"><table border="0" cellpadding="0" cellspacing="0" width="680"><tr class="headerTabHisto"><td align="center" id="celluleFichier" style="height: 22px;" colspan="2">Fichier(s)</td><td align="center" style="height: 22px;"><a href="javascript: void(0);" class="lien_12_gras_blanc" onmouseover="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'show\');" onmouseout="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'hide\');">Cat&eacute;gorie(s)&nbsp;<img src="styles/default/graphs/croissant.gif" alt="" width="9" height="10" /></a></td><td align="center" style="height: 22px;">Destinataire(s)</td><td align="center" style="height: 22px;">Poid(s)</td><td align="center" style="height: 22px;">Date(s) d\'envoi<span id="imgDate"><a id="linkOrdreDate" href="'+link+'"><img id="imgTriDate" src="'+image+'" width="9" height="10" alt="" /></a></span></td><td align="center" style="height: 22px;">Expiration</td><td align="center" style="height: 22px;">T&eacute;l&eacute;chargé(s)</td><td align="center" style="height: 22px;">Protégé(s)</td><td align="center" style="height: 22px;">&nbsp;</td></tr>'+xhr+'</table></div><div id="listeCategoriesPrivate" style="visibility: hidden;" onmouseover="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'show\');" onmouseout="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'hide\');"></div>';
	afficheListeCategorie();
}

function afficheListeCategorie()
{
	var container = document.getElementById('listeFichiers');
	var div=document.getElementById('listeCategoriesPrivate');

	div.style.marginTop=(15-container.offsetHeight)+"px";
	
	$.post('index.php?controller=zoneprivee&action=afficheListeCategorie','',function(data) { proceedAfficheListeCategorie(data); });
}

function proceedAfficheListeCategorie(xhr)
{
	var div=document.getElementById("listeCategoriesPrivate");
	var cellule = document.getElementById('celluleFichier');
	div.style.marginLeft= cellule.offsetWidth+5+"px";
	div.innerHTML=xhr;
}

function verifCategorie()
{
	var cat = document.getElementById('catFichierPopup');
	
	if(cat.lenght==0 || cat.value=="")
	{
		displayError('Veuillez saisir une categorie');
	}
	else
	{
		$.post('index.php?controller=zoneprivee&action=verifCategorie',
		{categorie: cat.value},
		function(data) { proceedVerifCategorie(data); });
	}
}

function proceedVerifCategorie(xhr)
{
	var retour = xhr;
	var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		if(xhr=='erreur_existant')
			displayError('Cat&eacute;gorie deja existante');
	}
	else
	{
		closeBox();
	}
}

function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}


function supprFichier(idFichier, idClient)
{
	$.post('index.php?controller=zoneprivee&action=supprFichier',
	{idfichier: idFichier,idclient: idClient},
	function(data) { proceedSupprFichier(data); });
}

function proceedSupprFichier(xhr)
{

	var retour = xhr;
	var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		if(xhr=='erreur_client')
			displayError('Vous n\'etes pas autorisé a supprimer ce fichier');
	}
	else
	{
		if(xhr=='ok')
		{
			$.post('index.php?controller=zoneprivee&action=afficheListeFichier',
			{ordre: "ordre_croissant"},
			function(data) { genereListeFichier(data); });
			closeBox();
		}
	}
}

function genereListeFichier(xhr)
{
	//document.getElementById('listeFichiers').innerHTML='<div id="contenuListeFichier" style="position:absolute; top:0;"><table border="0" cellpadding="0" cellspacing="0" width="680"><tr class="headerTabHisto"><td align="center" colspan="2">Fichier(s)</td><td align="center"><a href="javascript: void(0);" class="lien_12_gras_blanc" onmouseover="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'show\');" onmouseout="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'hide\');">Cat&eacute;gorie(s)&nbsp;<img src="styles/default/graphs/croissant.gif" alt="" width="9" height="10" /></a></td><td align="center">Destinataire(s)</td><td align="center">Poid(s)</td><td align="center">Date(s) d\'envoi<span id="imgDate"><a id="linkOrdreDate" href="javascript: afficheFichier(\'ordre_decroissant\');"><img id="imgTriDate" src="styles/default/graphs/croissant.gif" width="9" height="10" alt="" /></a></span></td><td align="center">T&eacute;l&eacute;chargé(s)</td><td align="center">Protégé(s)</td><td>&nbsp;</td></tr>'+xhr.responseText+'</table></div><div id="listeCategoriesPrivate" style="visibility: hidden;" onmouseover="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'show\');" onmouseout="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'hide\');"></div>';
	document.getElementById('listeFichiers').innerHTML='<div id="contenuListeFichier" style="position:absolute; top:0;"><table border="0" cellpadding="0" cellspacing="0" width="680"><tr class="headerTabHisto"><td align="center" id="celluleFichier" style="height: 22px;" colspan="2"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'nom\',\'DESC\');">Fichier(s)</a></td><td align="center" style="height: 22px;"><a href="javascript: void(0);" class="lien_12_gras_blanc" onmouseover="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'show\');" onmouseout="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'hide\');">Cat&eacute;gorie(s)&nbsp;<img src="styles/default/graphs/croissant.gif" alt="" width="9" height="10" /></a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'destinataire\',\'ASC\');">Destinataire(s)</a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'poids\',\'ASC\');">Poid(s)</a></td><td align="center" style="height: 22px;">Date(s) d\'envoi<span id="imgDate"><a id="linkOrdreDate" href="javascript: afficheFichier(\'ordre_decroissant\');"><img id="imgTriDate" src="styles/default/graphs/croissant.gif" width="9" height="10" alt="" /></a></span></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'expiration\',\'ASC\');">Expiration</a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'download\',\'ASC\');">T&eacute;l&eacute;charg&eacute;(s)</a></td><td align="center" style="height: 22px;">Prot&eacute;g&eacute;(s)</td><td>&nbsp;</td></tr>'+xhr+'</table></div><div id="listeCategoriesPrivate" style="visibility: hidden;" onmouseover="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'show\');" onmouseout="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'hide\');"></div>';
	afficheListeCategorie();
}

function saisiSemiAutomatique(elem,obj)
{
	var valeur = elem.value;
	
	$.post('index.php?controller=zoneprivee&action=saisiSemiAuto',
	{recherche: valeur},
	function(data) { proceedSaisiSemiAutomatique(data, obj); });
}

function proceedSaisiSemiAutomatique(xhr, elem)
{
	var div = document.createElement('div');
	div.id="divSemiAuto";
	div.innerHTML="";
	div.innerHTML=xhr;
	div.className="saisiSemiAuto";
	
	elem.appendChild(div);
}


function affichePopupRenvoi(nom)
{
	popBox("view/popup_renvoi.php?id="+nom);
}


function traitementRenvoi()
{
	var id = document.getElementById('idFichierRenvoi').value;
	var sujet = document.getElementById('sujetRenvoi').value;
	var message = document.getElementById('messageRenvoi').value;
	var destinataires = recupDestRenvoi();
	var cryptage = document.getElementById('cryptagePrivatePopup').checked;
	var accuse = document.getElementById('accusePrivatePopup').checked;
	var password = document.getElementById('passFichierPopup').value;
	
	$.post('index.php?controller=zoneprivee&action=traitementRenvoi',
	{idfic: id, sujet: sujet, message: message, destinataires: destinataires, cryptage: cryptage, accuse: accuse, password: password},
	function(data) { proceedtraitementRenvoi(data); });
}

function traitementRenvoiEnvoyer(pack)
{
	var id = document.getElementById('idFichierRenvoi').value;
	var sujet = document.getElementById('sujetRenvoi').value;
	var message = document.getElementById('messageRenvoi').value;
	var destinataires = recupDestRenvoi();
	var cryptage = document.getElementById('cryptagePrivatePopup').checked;
	var accuse = document.getElementById('accusePrivatePopup').checked;
	var password = document.getElementById('passFichierPopup').value;
	
	var nbCredit = 0;
	
	
	if(pack == 2)
	{
		$.post('index.php?controller=zoneprivee&action=traitementRenvoi',
		{idfic: id, sujet: sujet, message: message, destinataires: destinataires, cryptage: cryptage, accuse: accuse, password: password},
		function(data) { proceedtraitementRenvoiEnvoyer(data); });
	}
	else
	{
		if(document.getElementById('valOption1'))
			if(document.getElementById('valOption1').value == '1')
				nbCredit++;
		
		if(document.getElementById('valOption2'))
			if(document.getElementById('valOption2').value == '1')
				nbCredit++;

		$.post('index.php?controller=zoneprivee&action=checkCreditEnvoi',
			function(data) {
				if(data >= nbCredit)
				{
					$.post('index.php?controller=zoneprivee&action=traitementRenvoi',
					{idfic: id, sujet: sujet, message: message, destinataires: destinataires, cryptage: cryptage, accuse: accuse, password: password},
					function(data) { proceedtraitementRenvoiEnvoyer(data); });
				}
				else
					displayError('Vous n\'avez pas assez de cr&eacute;dits pour effectuer cet envoi.');
			});
	}
}

function recupDestRenvoi()
{
	var divPrinc = document.getElementById('inputDestRenvoi');
	var listeDestinataire = "";

	if(divPrinc.hasChildNodes())
	{
		var enfants = divPrinc.childNodes;
		var compteurElement = 1;

		for (var i = 0; i < enfants.length; i++)
		{
			if(enfants[i].tagName=='DIV')
			{
				var enfants2 = enfants[i].childNodes;
				
				for (var j = 0; j < enfants2.length; j++)
				{
					if(enfants2[j].tagName=='INPUT')
					{			
						if(enfants2[j].value!="")
							listeDestinataire = listeDestinataire + enfants2[j].value+ ",";
					}
				}
			}
		}
	}
	
	return listeDestinataire;		
}

function proceedtraitementRenvoi(xhr)
{
	var retour = xhr;
	var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		if(xhr=='erreur_destinataire')
			displayError('L\'une des adresses mails de destination n\'est pas correcte.');
	}
	else
	{
		closeBox();
		displayError('Votre fichier a bien &eacute;t&eacute; renvoy&eacute;');
	}
}

function proceedtraitementRenvoiEnvoyer(xhr)
{
	var retour = xhr;
	var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		if(xhr=='erreur_destinataire')
			displayError('L\'une des adresses mails de destination n\'est pas correcte.');
	}
	else
		displayError('Votre fichier a bien &eacute;t&eacute; renvoy&eacute;');
}

function afficheHisto(ordre)
{
	$.post('index.php?controller=zoneprivee&action=afficheListeHisto',
	{ordre: ordre},
	function(data) { proceedAfficheHisto(data, ordre); });
}

function proceedAfficheHisto(xhr, ordre)
{	
	var link;
	var image;
	
	if(ordre=="ordre_decroissant")
	{
		link="javascript: afficheHisto('ordre_croissant');";
		image="styles/default/graphs/decroissant.gif";

				
	}
	else
	{
		link="javascript: afficheHisto('ordre_decroissant');";
		image="styles/default/graphs/croissant.gif";
	}
	
	document.getElementById('listeHisto').innerHTML='<div id="contenuListeHisto" style="position:absolute; top:0;"><table border="0" cellpadding="0" cellspacing="0" width="680"><tr class="headerTabHisto"><td align="center" colspan="2">Fichier(s)</td><td align="center">Destinataire(s)</td><td align="center">Poid(s)</td><td align="center">Date(s) d\'envoi<span id="imgDate"><a id="linkOrdreDate" href="'+link+'"><img id="imgTriDate" src="'+image+'" width="9" height="10" alt="" /></a></span></td><td align="center">T&eacute;l&eacute;chargé(s)</td><td align="center">Protégé(s)</td><td align="center">&nbsp;</td></tr>'+xhr+'</table></div>';
}

function activeRenouvellement(ordre)
{
	$.post('index.php?controller=zoneprivee&action=activeRenouvellement',
	{ordre: ordre},
	function(data) { proceedActiveRenouvellement(data); });
}

function proceedActiveRenouvellement(xhr)
{	
	document.getElementById('listeCompte').innerHTML='<table border="0" cellpadding="0" cellspacing="0" width="694"><tr class="headerTabHisto"><td align="center">Type de compte</td><td align="center">Souscription le</td><td align="center">Durée</td><td align="center">Renouvellement auto</td><td align="center">Renouveller</td><td align="center">Mois</td><td align="center">Date</td><td align="center">&nbsp;</td><td align="center">&nbsp;</td></tr>'+xhr+'</table>';
}


function renvoiPassword()
{
	var mail = document.getElementById('mailPopupPassPerdu').value;
	
	$.post('index.php?controller=zonepublic&action=renvoiPassword',
	{mail: mail},
	function(data) { proceedRenvoiPassword(data); });
}

function proceedRenvoiPassword(xhr)
{
	var retour = xhr;
	var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		if(xhr=='erreur_inexistant')
			displayError('Adresse mail introuvable');
	}
	else
	{	
		var div = document.getElementById('popUpBox');
		$('#popUpBox').load('view/popup_confirmationPrivate.php?mail='+xhr);
	}
}

function inscriptionCpt(zone)
{
	if(zone=="public")
	{
		var div = document.getElementById('popUpBox');
		$('#popUpBox').load('view/popup_inscription.php');
	}
	else
	{
		var div = document.getElementById('popUpBox');
		$('#popUpBox').load('view/popup_inscription_private.php');
	}
}

function valideInscription()
{
	var nom = document.getElementById('inscriptionNom').value;
	var prenom = document.getElementById('inscriptionPrenom').value;
	var email = document.getElementById('inscriptionMail').value;
	var societe = document.getElementById('inscriptionSociete').value;
	var prix = document.getElementById('prixInscription').value;
	var offre = document.getElementById('offreInscription').value;
	var cgv = document.getElementById('cgv_inscription_check').checked;
	
	var dataDonnees = nom+","+prenom+","+email+","+societe+","+prix+","+offre;

	$.post('index.php?controller=zonepublic&action=inscription',
	{mail: email, cgv: cgv},
	function(data) { proceedValideInscription(data, dataDonnees); });
}

function proceedValideInscription(xhr, data)
{
	var retour = xhr;
	var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		switch(xhr)
		{
			case 'erreur_mail':
				displayError('Adresse mail non valide');
				break;
		
			case 'erreur_cgv':
				displayError('Vous devez accepter les conditions g&eacute;n&eacute;rales de ventes');
				break;
			
			case 'erreur_existant':
				displayError('Client dej&agrave; existant. Veuillez vous connectez &agrave; votre espace client');
				break;
		}
	}
	else
	{
	
		
		var res = data;
		var tab = res.split(',');
		var nom = tab[0];
		var prenom = tab[1];
		var email = tab[2];
		var societe = tab[3];
		var prix = tab[4];
		var offre = tab[5];
		
		var div = document.getElementById('popUpBox');
		div.style.left = (document.body.clientWidth - __POPUP_WIDTH__ ) / 2 + "px";
		div.style.top = "5px";
		$('#popUpBox').load('view/popup_commande.php?nom='+nom+'&prenom='+prenom+'&email='+email+'&societe='+societe+'&prix='+prix+'&offre='+offre);
	}

}

function valideCommande()
{
	var pays = document.getElementById('pays_commande').value;
	var type = document.getElementById('type_client_commande').value;
	var societe = document.getElementById('societe_commande').value;
	var titrem = document.getElementById('titre_m').checked;
	var titremme = document.getElementById('titre_mme').checked;
	var titremlle = document.getElementById('titre_mlle').checked;
	var nom = document.getElementById('nom_commande').value;
	var prenom = document.getElementById('prenom_commande').value;
	var email = document.getElementById('email_commande').value;
	var adresse = document.getElementById('adresse_commande').value;
	var adresse2 = document.getElementById('adresse2_commande').value;
	var cp = document.getElementById('cp_commande').value;
	var ville = document.getElementById('ville_commande').value;
	var indTel= document.getElementById('ind_tel_commande').value;
	var indFax= document.getElementById('ind_fax_commande').value;
	var indPortable= document.getElementById('ind_portable_commande').value;
	var tel= document.getElementById('tel_commande').value;
	var fax= document.getElementById('fax_commande').value;
	var portable= document.getElementById('portable_commande').value;
	var siret= document.getElementById('siret_commande').value;
	var ape= document.getElementById('ape_commande').value;
	var tva= document.getElementById('codeTva_commande').value;
	var estCoche = document.getElementById('tva_commande').checked;
	var ht= document.getElementById('montantHTCommande').value;
	var tauxtva= document.getElementById('tvaCommande').value;
	var typepaiement = document.getElementById('listePaiement_popupCommande').value;
	var codePromo = document.getElementById('code_promo').value;
	
	var titre;
		
	if(titrem==true)
		titre="M";
	else if(titremme==true)
		titre="Mme";
	else
		titre="Mlle";
	
	
	if(estCoche=='false')
		tva="";
	
	$.post('index.php?controller=zonepublic&action=commande',
	{pays: pays, type: type, societe: societe, titre: titre, nom: nom, prenom: prenom, email: email, adresse: adresse, adresse2: adresse2, cp: cp, ville: ville, indtel: indTel, indfax: indFax, indportable: indPortable, te: tel, fax: fax, portable: portable, siret: siret, ape: ape, tva: tva, ht: ht, txtva: tauxtva, typepaiement: typepaiement, codepromo: codePromo},
	function(data) { proceedValideCommande(data); });
}

function proceedValideCommande(xhr)
{
	var retour = xhr;
	var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		if(xhr=='erreur_pays')
			displayError('Veuillez s&eacute;lectionnez un pays');
		else if(xhr=='erreur_type')
			displayError('Veuillez s&eacute;lectionnez un type de client');
		else if(xhr=='erreur_societe')
			displayError('Veuillez saisir une soci&eacute;t&eacute;');
		else if(xhr=='erreur_titre')
			displayError('Veuillez choisir un titre');
		else if(xhr=='erreur_nom')
			displayError('Veuillez saisir un nom');
		else if(xhr=='erreur_prenom')
			displayError('Veuillez saisir un pr&eacute;nom');
		else if(xhr=='erreur_mail')
			displayError('Veuillez saisir un mail valide');
		else if(xhr=='erreur_adresse')
			displayError('Veuillez saisir une adresse');
		else if(xhr=='erreur_cp')
			displayError('Veuillez saisir un code postal');
		else if(xhr=='erreur_ville')
			displayError('Veuillez saisir une ville');
		else if(xhr=='erreur_indtel')
			displayError('Veuillez saisir un indicatif t&eacute;l&eacute;phonique');
		else if(xhr=='erreur_tel')
			displayError('Veuillez saisir un num&eacute;ro de t&eacute;l&eacute;phone');
		else if(xhr=='erreur_typePaiement')
			displayError('Veuillez saisir un num&eacute;ro de t&eacute;l&eacute;phone');
	}
	else
	{		
		var div = document.getElementById('popUpBox');
		$('#popUpBox').load('view/popup_valide_commande.php?cmd='+xhr);
	}
	
	
}

function actualiseIndicatif(pays)
{
	$.post('index.php?controller=zonepublic&action=actualiseIndicatif',
	{pays: pays},
	function(data) { proceedActualiseIndicatif(data); });
}

function proceedActualiseIndicatif(xhr)
{
	var indicatif_telephone = document.getElementById('ind_tel_commande');
	var indicatif_fax = document.getElementById('ind_fax_commande');
	var indicatif_portable = document.getElementById('ind_portable_commande');
	
	indicatif_telephone.value=xhr;
	indicatif_fax.value=xhr;
	indicatif_portable.value=xhr;
}

function actualiseTva(pays, type_client, tva)
{
	$.post('index.php?controller=zonepublic&action=actualiseTva',
	{pays: pays, type_client: type_client, tva: tva},
	function(data) { proceedActualiseTva(data); });
}


function proceedActualiseTva(xhr)
{
	var tauxtva = document.getElementById('tvaRate');
	var ttc= document.getElementById('prix_commande_ttc');
		
	var ht = document.getElementById('montantHTCommande').value;	
	var tvaglobale = document.getElementById('tvaCommande');
	var ttcglobale=  document.getElementById('montantTTCCommande');
	
	var retour = xhr;

	tauxtva.innerHTML="("+rrondir(((retour-1)*100),2)+"%)";
	ttc.innerHTML= arrondir((ht*retour),2)+"&nbsp;&euro;";
	
	tvaglobale.value = retour;
	ttcglobale.value =  arrondir((ht*retour),2);
}

function afficheMasqueTva()
{
	var span = document.getElementById('spanCodeTva_commande');
	
	if(span.style.visibility=="visible")
		span.style.visibility="hidden";
	else
		span.style.visibility="visible";
}

function inscriptionCptPrivate()
{
	masqueAnim();
	popBox('view/popup_inscription_private.php');
}

function valideInscriptionPrivate()
{
	var nom = document.getElementById('inscriptionNom').value;
	var prenom = document.getElementById('inscriptionPrenom').value;
	var email = document.getElementById('inscriptionMail').value;
	var societe = document.getElementById('inscriptionSociete').value;
	var prix = document.getElementById('prixInscription').value;
	var offre = document.getElementById('offreInscription').value;
	var cgv = document.getElementById('cgv_inscription_check').checked;
	
	var dataDonnees=nom+","+prenom+","+email+","+societe+","+prix+","+offre;

	$.post('index.php?controller=zoneprivee&action=inscription',
	{mail: email, cgv: cgv},
	function(data) { proceedValideInscriptionPrivate(data, dataDonnees); });
}

function proceedValideInscriptionPrivate(xhr, data)
{
	var retour = xhr;
	var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		if(xhr=='erreur_mail')
			displayError('Adresse mail non valide');
		
		if(xhr=='erreur_cgv')
			displayError('Vous devez accepter les conditions g&eacute;n&eacute;rales de ventes');
			
	}
	else
	{
		var res = data;
		var tab = res.split(',');
		var nom = tab[0];
		var prenom = tab[1];
		var email = tab[2];
		var societe = tab[3];
		var prix = tab[4];
		var offre = tab[5];
		
		//Effect.Fade('overlay', {duration: 0.0});
		$("#popUpBox").fadeTo("fast",0,function () { supprOverlay(); });
		div = document.getElementById('popUpBox');
		div.parentNode.removeChild(div)
		masqueAnim();
		popBox('view/popup_commande_private.php?nom='+nom+'&prenom='+prenom+'&email='+email+'&societe='+societe+'&prix='+prix+'&offre='+offre);
	}

}

function valideCommandePrivate()
{
	var pays = document.getElementById('pays_commande').value;
	var type = document.getElementById('type_client_commande').value;
	var societe = document.getElementById('societe_commande').value;
	var titrem = document.getElementById('titre_m').checked;
	var titremme = document.getElementById('titre_mme').checked;
	var titremlle = document.getElementById('titre_mlle').checked;
	var nom = document.getElementById('nom_commande').value;
	var prenom = document.getElementById('prenom_commande').value;
	var email = document.getElementById('email_commande').value;
	var adresse = document.getElementById('adresse_commande').value;
	var adresse2 = document.getElementById('adresse2_commande').value;
	var cp = document.getElementById('cp_commande').value;
	var ville = document.getElementById('ville_commande').value;
	var indTel= document.getElementById('ind_tel_commande').value;
	var indFax= document.getElementById('ind_fax_commande').value;
	var indPortable= document.getElementById('ind_portable_commande').value;
	var tel= document.getElementById('tel_commande').value;
	var fax= document.getElementById('fax_commande').value;
	var portable= document.getElementById('portable_commande').value;
	var siret= document.getElementById('siret_commande').value;
	var ape= document.getElementById('ape_commande').value;
	var tva= document.getElementById('codeTva_commande').value;
	var estCoche = document.getElementById('tva_commande').checked;
	var ht= document.getElementById('montantHTCommande').value;
	var tauxtva= document.getElementById('tvaCommande').value;
	var typepaiement = document.getElementById('listePaiement_popupCommande').value;
	var codePromo = document.getElementById('code_promo').value;
	var titre;

	
	if(titrem==true)
		titre="M";
	else if(titremme==true)
		titre="Mme";
	else
		titre="Mlle";
	
	
	if(estCoche=='false')
		tva="";

	$.post('index.php?controller=zoneprivee&action=commande',
	{pays: pays, type: type, societe: societe, titre: titre, nom: nom, prenom: prenom, email: email, adresse: adresse, adresse2: adresse2, cp: cp, ville: ville, indtel: indTel, indfax: indFax, indportable: indPortable, tel: tel, fax: fax, portable: portable, siret: siret, ape: ape, tva: tva,  ht: ht, txtva: tauxtva, typepaiement: typepaiement, codepromo: codePromo},
	function(data) { proceedValideCommandePrivate(data); });
}

function proceedValideCommandePrivate(xhr)
{
	var retour = xhr;
	var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		if(xhr=='erreur_pays')
			displayError('Veuillez s&eacute;lectionnez un pays');
		else if(xhr=='erreur_type')
			displayError('Veuillez s&eacute;lectionnez un type de client');
		else if(xhr=='erreur_societe')
			displayError('Veuillez saisir une soci&eacute;t&eacute;');
		else if(xhr=='erreur_titre')
			displayError('Veuillez choisir un titre');
		else if(xhr=='erreur_nom')
			displayError('Veuillez saisir un nom');
		else if(xhr=='erreur_prenom')
			displayError('Veuillez saisir un pr&eacute;nom');
		else if(xhr=='erreur_mail')
			displayError('Veuillez saisir un mail valide');
		else if(xhr=='erreur_adresse')
			displayError('Veuillez saisir une adresse');
		else if(xhr=='erreur_cp')
			displayError('Veuillez saisir un code postal');
		else if(xhr=='erreur_ville')
			displayError('Veuillez saisir une ville');
		else if(xhr=='erreur_indtel')
			displayError('Veuillez saisir un indicatif t&eacute;l&eacute;phonique');
		else if(xhr=='erreur_tel')
			displayError('Veuillez saisir un num&eacute;ro de t&eacute;l&eacute;phone');
		else if(xhr=='erreur_typePaiement')
			displayError('Veuillez saisir un num&eacute;ro de t&eacute;l&eacute;phone');
			
	}
	else
	{
		//Effect.Fade('overlay', {duration: 0.0});
		$("#popUpBox").fadeTo("fast",0,function () { supprOverlay(); });
		div = document.getElementById('popUpBox');
		div.parentNode.removeChild(div);
		masqueAnim();
		popBox('view/popup_valide_commande_private.php?cmd='+xhr);
	}
}

function actualiseIndicatifPrivate(pays)
{

	$.post('index.php?controller=zoneprivee&action=actualiseIndicatif',
	{pays: pays},
	function(data) { proceedActualiseIndicatifPrivate(data); });
}

function proceedActualiseIndicatifPrivate(xhr)
{
	var indicatif_telephone = document.getElementById('ind_tel_commande');
	var indicatif_fax = document.getElementById('ind_fax_commande');
	var indicatif_portable = document.getElementById('ind_portable_commande');
	
	indicatif_telephone.value=xhr;
	indicatif_fax.value=xhr;
	indicatif_portable.value=xhr;
}

function actualiseTvaPrivate(pays, type_client, tva)
{
	$.post('index.php?controller=zoneprivee&action=actualiseTva',
	{pays: pays,type_client: type_client, tva: tva},
	function(data) { proceedActualiseTvaPrivate(data); });
}

function proceedActualiseTvaPrivate(xhr)
{
	var tauxtva = document.getElementById('tvaRate');
	var ttc= document.getElementById('prix_commande_ttc');
	
	var ht = document.getElementById('montantHTCommande').value;	
	var tvaglobale = document.getElementById('tvaCommande');
	var ttcglobale=  document.getElementById('montantTTCCommande');
	
	var retour = xhr;

	tauxtva.innerHTML="("+arrondir(((retour-1)*100),2)+"%)";
	ttc.innerHTML= arrondir((ht*retour),2)+"&nbsp;&euro;";
	
	tvaglobale.value = retour;
	ttcglobale.value =  arrondir((ht*retour),2);
}

function afficheMasqueTvaPrivate()
{
	var span = document.getElementById('spanCodeTva_commande');
	
	if(span.style.visibility=="visible")
		span.style.visibility="hidden";
	else
		span.style.visibility="visible";
}

function afficheChampEtsProfil(valeurEts, valeurPays)
{
	$.post('index.php?controller=zonepublic&action=paysUE',
	{pays: valeurPays},
	function(data) { proceedAfficheChampEtsProfil(data,valeurEts,valeurPays); });
}

function proceedAfficheChampEtsProfil(UE, valeurEts, valeurPays)
{
	if(valeurEts=='3' && valeurPays=='FR')
	{
		if (navigator.appName == "Microsoft Internet Explorer") 
		{
			document.getElementById('numSiretCommande').style.display="inline";
			document.getElementById('numApeCommande').style.display="inline";
			document.getElementById('numTvaCommande').style.display="inline";
			document.getElementById('societeCommande').style.display="inline";			
		}
		else
		{
			document.getElementById('numSiretCommande').style.display="table-row";
			document.getElementById('numApeCommande').style.display="table-row";
			document.getElementById('numTvaCommande').style.display="table-row";
			document.getElementById('societeCommande').style.display="table-row";	
		}
	}
	else if(valeurEts=='3' && UE=='1')
	{
		if (navigator.appName == "Microsoft Internet Explorer") 
		{
			document.getElementById('numSiretCommande').style.display="none";
			document.getElementById('numApeCommande').style.display="none";
			document.getElementById('numTvaCommande').style.display="inline";
			document.getElementById('societeCommande').style.display="inline";			
		}
		else
		{
			document.getElementById('numSiretCommande').style.display="none";
			document.getElementById('numApeCommande').style.display="none";
			document.getElementById('numTvaCommande').style.display="table-row";
			document.getElementById('societeCommande').style.display="table-row";	
		}
	}
	else if(valeurEts=='3')
	{
		if (navigator.appName == "Microsoft Internet Explorer") 
		{
			document.getElementById('numSiretCommande').style.display="none";
			document.getElementById('numApeCommande').style.display="none";
			document.getElementById('numTvaCommande').style.display="none";
			document.getElementById('societeCommande').style.display="inline";			
		}
		else
		{
			document.getElementById('numSiretCommande').style.display="none";
			document.getElementById('numApeCommande').style.display="none";
			document.getElementById('numTvaCommande').style.display="none";
			document.getElementById('societeCommande').style.display="table-row";	
		}
	}
	else
	{
		document.getElementById('numSiretCommande').style.display="none";
		document.getElementById('numApeCommande').style.display="none";
		document.getElementById('numTvaCommande').style.display="none";
		document.getElementById('societeCommande').style.display="none";
	}
}

function afficheChampEts(valeurEts, valeurPays)
{
	$.post('index.php?controller=zonepublic&action=paysUE',
	{pays: valeurPays},
	function(data) { proceedAfficheChampEts(data,valeurEts,valeurPays); });
}

function proceedAfficheChampEts(UE, valeurEts, valeurPays)
{
	if(valeurEts=='3' && valeurPays=='FR')
	{
		if (navigator.appName == "Microsoft Internet Explorer") 
		{
			document.getElementById('numSiretCommande').style.display="inline";
			document.getElementById('numApeCommande').style.display="inline";
			document.getElementById('numTvaCommande').style.display="inline";
			document.getElementById('societeCommande').style.display="inline";			
		}
		else
		{
			document.getElementById('numSiretCommande').style.display="table-row";
			document.getElementById('numApeCommande').style.display="table-row";
			document.getElementById('numTvaCommande').style.display="table-row";
			document.getElementById('societeCommande').style.display="table-row";	
		}
		document.getElementById('popupCommandeDroit').style.height="708px";
		document.getElementById('popupCommandeGauche').style.height="710px";
		document.getElementById('popupCommandeCoinBG').style.marginTop="708px";
		document.getElementById('popupCommandeBas').style.marginTop="708px";
		document.getElementById('popupCommandeCoinBD').style.marginTop="708px";
		document.getElementById('popup_commande').style.height="708px";
	}
	else if(valeurEts=='3' && UE=='1')
	{
		if (navigator.appName == "Microsoft Internet Explorer") 
		{
			document.getElementById('numSiretCommande').style.display="none";
			document.getElementById('numApeCommande').style.display="none";
			document.getElementById('numTvaCommande').style.display="inline";
			document.getElementById('societeCommande').style.display="inline";			
		}
		else
		{
			document.getElementById('numSiretCommande').style.display="none";
			document.getElementById('numApeCommande').style.display="none";
			document.getElementById('numTvaCommande').style.display="table-row";
			document.getElementById('societeCommande').style.display="table-row";	
		}
		document.getElementById('popupCommandeDroit').style.height="708px";
		document.getElementById('popupCommandeGauche').style.height="710px";
		document.getElementById('popupCommandeCoinBG').style.marginTop="708px";
		document.getElementById('popupCommandeBas').style.marginTop="708px";
		document.getElementById('popupCommandeCoinBD').style.marginTop="708px";
		document.getElementById('popup_commande').style.height="708px";
	
	}
	else if(valeurEts=='3')
	{
		if (navigator.appName == "Microsoft Internet Explorer") 
		{
			document.getElementById('numSiretCommande').style.display="none";
			document.getElementById('numApeCommande').style.display="none";
			document.getElementById('numTvaCommande').style.display="none";
			document.getElementById('societeCommande').style.display="inline";			
		}
		else
		{
			document.getElementById('numSiretCommande').style.display="none";
			document.getElementById('numApeCommande').style.display="none";
			document.getElementById('numTvaCommande').style.display="none";
			document.getElementById('societeCommande').style.display="table-row";	
		}
		document.getElementById('popupCommandeDroit').style.height="708px";
		document.getElementById('popupCommandeGauche').style.height="710px";
		document.getElementById('popupCommandeCoinBG').style.marginTop="708px";
		document.getElementById('popupCommandeBas').style.marginTop="708px";
		document.getElementById('popupCommandeCoinBD').style.marginTop="708px";
		document.getElementById('popup_commande').style.height="708px";
	}
	else
	{
		document.getElementById('numSiretCommande').style.display="none";
		document.getElementById('numApeCommande').style.display="none";
		document.getElementById('numTvaCommande').style.display="none";
		document.getElementById('societeCommande').style.display="none";
		
		document.getElementById('popupCommandeDroit').style.height="658px";
		document.getElementById('popupCommandeGauche').style.height="660px";
		document.getElementById('popupCommandeCoinBG').style.marginTop="658px";
		document.getElementById('popupCommandeBas').style.marginTop="658px";
		document.getElementById('popupCommandeCoinBD').style.marginTop="658px";
		document.getElementById('popup_commande').style.height="658px";
	}
}

function downloadFichier(idFic)
{
	//window.location.replace(idFic);
	window.open(idFic, 'Téléchargement');
}

function agrandirPopupUploadRenvoi(param)
{
	if(param=="+")
	{
		if(navigator.userAgent.indexOf("MSIE 7")!=-1)
		{
			document.getElementById('popup_renvoi').style.height = document.getElementById('popup_renvoi').offsetHeight + 17 + "px";
			document.getElementById('popupRenvoiDroit').style.height = document.getElementById('popupRenvoiDroit').offsetHeight + 17 + "px";
			document.getElementById('popupRenvoiGauche').style.height = document.getElementById('popupRenvoiGauche').offsetHeight + 17 + "px";
		}
		else if(navigator.userAgent.indexOf("Safari") != -1) 
		{
			document.getElementById('popupRenvoiBas').style.marginTop = 499 + "px";
			document.getElementById('popupRenvoiCoinBD').style.marginTop = 499 + "px";
			document.getElementById('popupRenvoiCoinBG').style.marginTop = 499 + "px";
			document.getElementById('popup_renvoi').style.height = document.getElementById('popup_renvoi').offsetHeight + 17 + "px";
			document.getElementById('popupRenvoiDroit').style.height = document.getElementById('popupRenvoiDroit').offsetHeight + 19 + "px";
			document.getElementById('popupRenvoiGauche').style.height = document.getElementById('popupRenvoiGauche').offsetHeight + 19 + "px";
		}
		else if(navigator.userAgent.indexOf("MSIE 6")!=-1)
		{
			
		}
		else
		{
			document.getElementById('popupRenvoiBas').style.marginTop = 505 + "px";
			document.getElementById('popupRenvoiCoinBD').style.marginTop = 505 + "px";
			document.getElementById('popupRenvoiCoinBG').style.marginTop = 505 + "px";
			document.getElementById('popup_renvoi').style.height = document.getElementById('popup_renvoi').offsetHeight + 17 + "px";
			document.getElementById('popupRenvoiDroit').style.height = document.getElementById('popupRenvoiDroit').offsetHeight + 17 + "px";
			document.getElementById('popupRenvoiGauche').style.height = document.getElementById('popupRenvoiGauche').offsetHeight + 17 + "px";
		}
	}
	else
	{
		if(navigator.userAgent.indexOf("MSIE 7")!=-1)
		{
			document.getElementById('popup_renvoi').style.height = document.getElementById('popup_renvoi').offsetHeight - 17 + "px";
			document.getElementById('popupRenvoiDroit').style.height = document.getElementById('popupRenvoiDroit').offsetHeight - 17 + "px";
			document.getElementById('popupRenvoiGauche').style.height = document.getElementById('popupRenvoiGauche').offsetHeight - 17 + "px";
		}
		else if( navigator.userAgent.indexOf("Safari") != -1) 
		{
			document.getElementById('popupRenvoiBas').style.marginTop = 482 + "px";
			document.getElementById('popupRenvoiCoinBD').style.marginTop = 482 + "px";
			document.getElementById('popupRenvoiCoinBG').style.marginTop = 482 + "px";
			document.getElementById('popup_renvoi').style.height = document.getElementById('popup_renvoi').offsetHeight - 17 + "px";
			document.getElementById('popupRenvoiDroit').style.height = document.getElementById('popupRenvoiDroit').offsetHeight - 19 + "px";
			document.getElementById('popupRenvoiGauche').style.height = document.getElementById('popupRenvoiGauche').offsetHeight - 19 + "px";
		}
		else if(navigator.userAgent.indexOf("MSIE 6")!= -1)
		{
			
		}
		else
		{
			document.getElementById('popupRenvoiBas').style.marginTop = 488 + "px";
			document.getElementById('popupRenvoiCoinBD').style.marginTop = 488 + "px";
			document.getElementById('popupRenvoiCoinBG').style.marginTop = 488 + "px";
			document.getElementById('popup_renvoi').style.height = document.getElementById('popup_renvoi').offsetHeight - 17 + "px";
			document.getElementById('popupRenvoiDroit').style.height = document.getElementById('popupRenvoiDroit').offsetHeight - 17 + "px";
			document.getElementById('popupRenvoiGauche').style.height = document.getElementById('popupRenvoiGauche').offsetHeight - 17 + "px";
		}
	}
}

function agrandirPopupUpload(param)
{
	if(param=="+")
	{
		if(navigator.userAgent.indexOf("MSIE 7")!=-1)
		{	
			if(document.getElementById('popupUploadPrivateBas').style.marginTop == '')
				document.getElementById('popupUploadPrivateBas').style.marginTop = 500 + "px";
			else
				document.getElementById('popupUploadPrivateBas').style.marginTop = document.getElementById('popupUploadPrivateBas').style.marginTop + 30 + "px";
				
			if(document.getElementById('popupUploadPrivateCoinBD').style.marginTop == '')
				document.getElementById('popupUploadPrivateCoinBD').style.marginTop = 500 + "px";
			else
				document.getElementById('popupUploadPrivateCoinBD').style.marginTop = document.getElementById('popupUploadPrivateCoinBD').style.marginTop + 30 + "px";
			
			if(document.getElementById('popupUploadPrivateCoinBG').style.marginTop == '')
				document.getElementById('popupUploadPrivateCoinBG').style.marginTop = 500 + "px";
			else
				document.getElementById('popupUploadPrivateCoinBG').style.marginTop = document.getElementById('popupUploadPrivateCoinBG').style.marginTop + 30 + "px";
				
			document.getElementById('popup_upload_private').style.height = document.getElementById('popup_upload_private').offsetHeight + 30 + "px";
			document.getElementById('popupUploadPrivateDroit').style.height = document.getElementById('popupUploadPrivateDroit').offsetHeight + 30 + "px";
			document.getElementById('popupUploadPrivateGauche').style.height = document.getElementById('popupUploadPrivateGauche').offsetHeight + 30 + "px";
		}
		else if(navigator.userAgent.indexOf("Safari") != -1) 
		{
			document.getElementById('popupUploadPrivateBas').style.marginTop = 487 + "px";
			document.getElementById('popupUploadPrivateCoinBD').style.marginTop = 487 + "px";
			document.getElementById('popupUploadPrivateCoinBG').style.marginTop = 487 + "px";
			document.getElementById('popup_upload_private').style.height = document.getElementById('popup_upload_private').offsetHeight + 17 + "px";
			document.getElementById('popupUploadPrivateDroit').style.height = document.getElementById('popupUploadPrivateDroit').offsetHeight + 19 + "px";
			document.getElementById('popupUploadPrivateGauche').style.height = document.getElementById('popupUploadPrivateGauche').offsetHeight + 19 + "px";
		}
		else if(navigator.userAgent.indexOf("MSIE 6")!=-1)
		{
			document.getElementById('popupUploadPrivateDroit').style.height = document.getElementById('popupUploadPrivateDroit').offsetHeight + 35 + "px";
			document.getElementById('popupUploadPrivateGauche').style.height = document.getElementById('popupUploadPrivateGauche').offsetHeight + 35 + "px";
			document.getElementById('popup_upload_private').style.height = document.getElementById('popup_upload_private').offsetHeight + 35 + "px";
		}
		else
		{
			document.getElementById('popup_upload_private').style.height = document.getElementById('popup_upload_private').offsetHeight + 32 + "px";
			document.getElementById('popupUploadPrivateDroit').style.height = document.getElementById('popupUploadPrivateDroit').offsetHeight + 32 + "px";
			document.getElementById('popupUploadPrivateGauche').style.height = document.getElementById('popupUploadPrivateGauche').offsetHeight + 32 + "px";
		}
	}
	else
	{
		if(navigator.userAgent.indexOf("MSIE 7")!=-1)
		{
			//~ document.getElementById('popupUploadPrivateBas').style.marginTop = 470 + "px";
			//~ document.getElementById('popupUploadPrivateCoinBD').style.marginTop = 470 + "px";
			//~ document.getElementById('popupUploadPrivateCoinBG').style.marginTop = 470 + "px";
			
			var temp1 = document.getElementById('popupUploadPrivateBas').style.marginTop.split('px');
			var temp2 = document.getElementById('popupUploadPrivateCoinBD').style.marginTop.split('px');
			var temp3 = document.getElementById('popupUploadPrivateCoinBG').style.marginTop.split('px');
						
			document.getElementById('popupUploadPrivateBas').style.marginTop = temp1[0] - 30 + "px";
			document.getElementById('popupUploadPrivateCoinBD').style.marginTop = temp2[0] - 30 + "px";
			document.getElementById('popupUploadPrivateCoinBG').style.marginTop = temp3[0] - 30 + "px";
			
			document.getElementById('popup_upload_private').style.height = document.getElementById('popup_upload_private').offsetHeight - 30 + "px";
			document.getElementById('popupUploadPrivateDroit').style.height = document.getElementById('popupUploadPrivateDroit').offsetHeight - 30 + "px";
			document.getElementById('popupUploadPrivateGauche').style.height = document.getElementById('popupUploadPrivateGauche').offsetHeight - 30 + "px";
		}
		else if( navigator.userAgent.indexOf("Safari") != -1) 
		{
			document.getElementById('popupUploadPrivateBas').style.marginTop = 467 + "px";
			document.getElementById('popupUploadPrivateCoinBD').style.marginTop = 467 + "px";
			document.getElementById('popupUploadPrivateCoinBG').style.marginTop = 467 + "px";
			document.getElementById('popup_upload_private').style.height = document.getElementById('popup_upload_private').offsetHeight - 17 + "px";
			document.getElementById('popupUploadPrivateDroit').style.height = document.getElementById('popupUploadPrivateDroit').offsetHeight - 19 + "px";
			document.getElementById('popupUploadPrivateGauche').style.height = document.getElementById('popupUploadPrivateGauche').offsetHeight - 19 + "px";
		}
		else if(navigator.userAgent.indexOf("MSIE 6")!= -1)
		{
			document.getElementById('popup_upload_private').style.height = document.getElementById('popup_upload_private').offsetHeight - 35 + "px";
			document.getElementById('popupUploadPrivateDroit').style.height = document.getElementById('popupUploadPrivateDroit').offsetHeight - 35 + "px";
			document.getElementById('popupUploadPrivateGauche').style.height = document.getElementById('popupUploadPrivateGauche').offsetHeight - 35 + "px";
		}
		else
		{
			document.getElementById('popup_upload_private').style.height = document.getElementById('popup_upload_private').offsetHeight - 32 + "px";
			document.getElementById('popupUploadPrivateDroit').style.height = document.getElementById('popupUploadPrivateDroit').offsetHeight - 32 + "px";
			document.getElementById('popupUploadPrivateGauche').style.height = document.getElementById('popupUploadPrivateGauche').offsetHeight - 32 + "px";
		}
	}
}

function agrandirPopupRenvoi(param)
{
	if(param=="+")
	{
		if(navigator.userAgent.indexOf("MSIE 7")!=-1)
		{
			//~ document.getElementById('popupRenvoiBas').style.marginTop = 510 + "px";
			//~ document.getElementById('popupRenvoiCoinBD').style.marginTop = 510 + "px";
			//~ document.getElementById('popupRenvoiCoinBG').style.marginTop = 510 + "px";
			document.getElementById('popup_renvoi').style.height = document.getElementById('popup_renvoi').offsetHeight + 10 + "px";
			document.getElementById('popupRenvoiDroit').style.height = document.getElementById('popupRenvoiDroit').offsetHeight + 10 + "px";
			document.getElementById('popupRenvoiGauche').style.height = document.getElementById('popupRenvoiGauche').offsetHeight + 10 + "px";
		}
		else if(navigator.userAgent.indexOf("Safari") != -1) 
		{
			document.getElementById('popupRenvoiBas').style.marginTop = 511 + "px";
			document.getElementById('popupRenvoiCoinBD').style.marginTop = 511 + "px";
			document.getElementById('popupRenvoiCoinBG').style.marginTop = 511 + "px";
			document.getElementById('popup_renvoi').style.height = document.getElementById('popup_renvoi').offsetHeight + 30 + "px";
			document.getElementById('popupRenvoiDroit').style.height = document.getElementById('popupRenvoiDroit').offsetHeight + 32 + "px";
			document.getElementById('popupRenvoiGauche').style.height = document.getElementById('popupRenvoiGauche').offsetHeight + 32 + "px";
		}
		else if(navigator.userAgent.indexOf("MSIE 6")!=-1)
		{
			document.getElementById('popupRenvoiDroit').style.height = document.getElementById('popupRenvoiDroit').offsetHeight + 35 + "px";
			document.getElementById('popupRenvoiGauche').style.height = document.getElementById('popupRenvoiGauche').offsetHeight + 35 + "px";
			document.getElementById('popup_renvoi').style.height = document.getElementById('popup_renvoi').offsetHeight + 35 + "px";
		}
		else
		{
			document.getElementById('popup_renvoi').style.height = document.getElementById('popup_renvoi').offsetHeight + 32 + "px";
			document.getElementById('popupRenvoiDroit').style.height = document.getElementById('popupRenvoiDroit').offsetHeight + 32 + "px";
			document.getElementById('popupRenvoiGauche').style.height = document.getElementById('popupRenvoiGauche').offsetHeight + 32 + "px";
		}
	}
	else
	{
		if(navigator.userAgent.indexOf("MSIE 7")!=-1)
		{
			//~ document.getElementById('popupRenvoiBas').style.marginTop = 470 + "px";
			//~ document.getElementById('popupRenvoiCoinBD').style.marginTop = 470 + "px";
			//~ document.getElementById('popupRenvoiCoinBG').style.marginTop = 470 + "px";
			document.getElementById('popup_renvoi').style.height = document.getElementById('popup_renvoi').offsetHeight - 10 + "px";
			document.getElementById('popupRenvoiDroit').style.height = document.getElementById('popupRenvoiDroit').offsetHeight - 10 + "px";
			document.getElementById('popupRenvoiGauche').style.height = document.getElementById('popupRenvoiGauche').offsetHeight - 10 + "px";
		}
		else if( navigator.userAgent.indexOf("Safari") != -1) 
		{
			document.getElementById('popupRenvoiBas').style.marginTop = 482 + "px";
			document.getElementById('popupRenvoiCoinBD').style.marginTop = 482 + "px";
			document.getElementById('popupRenvoiCoinBG').style.marginTop = 482 + "px";
			document.getElementById('popup_renvoi').style.height = document.getElementById('popup_renvoi').offsetHeight - 30 + "px";
			document.getElementById('popupRenvoiDroit').style.height = document.getElementById('popupRenvoiDroit').offsetHeight - 32 + "px";
			document.getElementById('popupRenvoiGauche').style.height = document.getElementById('popupRenvoiGauche').offsetHeight - 32 + "px";
		}
		else if(navigator.userAgent.indexOf("MSIE 6")!= -1)
		{
			document.getElementById('popup_renvoi').style.height = document.getElementById('popup_renvoi').offsetHeight - 35 + "px";
			document.getElementById('popupRenvoiDroit').style.height = document.getElementById('popupRenvoiDroit').offsetHeight - 35 + "px";
			document.getElementById('popupRenvoiGauche').style.height = document.getElementById('popupRenvoiGauche').offsetHeight - 35 + "px";
		}
		else
		{
			document.getElementById('popup_renvoi').style.height = document.getElementById('popup_renvoi').offsetHeight - 32 + "px";
			document.getElementById('popupRenvoiDroit').style.height = document.getElementById('popupRenvoiDroit').offsetHeight - 32 + "px";
			document.getElementById('popupRenvoiGauche').style.height = document.getElementById('popupRenvoiGauche').offsetHeight - 32 + "px";
		}
	}
}

function extraire(variable,separateur,indice)
{
	var champ;
	for (i=0;i<indice;i++)
	{
		if (variable.indexOf(separateur)==-1)
				champ = variable;
			else
				champ = variable.substring(0,variable.indexOf(separateur));
				
			variable = variable.substring(variable.indexOf(separateur)+1);		
	}
		
	if (champ == "undefined")
		return variable.substring(0,variable.indexOf(separateur));
	else
		return champ;
}

function changePass()
{
	var newPass1 = document.getElementById('input_mdp1').value;
	var newPass2 = document.getElementById('input_mdp2').value;
	var oldPass = document.getElementById('input_mdpOld').value;
	
	$.post('index.php?controller=zoneprivee&action=changePass',
	{newpass: newPass1, newpassverif: newPass2, oldPass: oldPass},
	function(data) { proceedChangePass(data); });
}

function proceedChangePass(xhr)
{
	var retour = xhr;
	var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		if(xhr=='erreur_oldpass')
			displayError('L\'ancien mot de passe n\'est pas correct.');
			
		if(xhr=='erreur_newpass')
			displayError('Les mots de passe saisis ne sont pas identiques.');
	}
	else
	{	
		//Effect.Fade('overlay', {to:0, duration: 0.0});
		$("#popUpBox").fadeTo("fast",0,function () { supprOverlay(); });
		div = document.getElementById('popUpBox');
		div.parentNode.removeChild(div);
		popBox('view/popup_confirmationPass.php');
	}
}
/**************************************************************************************************************************************************************************************************
******************************************************************************** PARTIE EDITION ************************************************************************************************
**************************************************************************************************************************************************************************************************/

/*
** Edition en cours : permet de n'avoir qu'une seule boite de dialogue ouverte.
** sauvegardeEffectuée : permet d'éviter d'envoyer 2 requetes en validant.
*/

var editionEnCours = false;
var sauvegardeEffectuee = false;


/*******************************************************
********************************************************
*** Renvoie un objet XmlHTTPRequest
********************************************************
*******************************************************/


function getXMLHTTP()
{
    var xhr = null;
    if(window.XMLHttpRequest)
    { // Firefox et autres
        xhr = new XMLHttpRequest();
    }
    else if(window.ActiveXObject)
    { // Internet Explorer
        try
        {
            xhr = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(e)
        {
            try
            {
                xhr = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(e1)
            {
                xhr = null;
            }
        }
    }
    else
    { // XMLHttpRequest non supporté par le navigateur
        alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
    }

    return xhr;
}

/*******************************************************
********************************************************
*** Ferme le mode d'édition et sauvegarde la valeur.
********************************************************
*******************************************************/

function closeEditModeExp(xhr, obj, txt)
{
  if (xhr.readyState == 4)
  {
    if (xhr.status == 200)
    {
      var response = xhr.responseText;

      if (response!='')
      {
	if(txt=='-1')
		txt=response;
        obj.removeChild(obj.firstChild);
        var regexp = new RegExp('\n', 'g');
        txt = txt.replace(regexp, '<br/>');
        obj.innerHTML = txt;
        sauvegardeEffectuee = true;
        editionEnCours = false;
      }
      else
      {
        alert('Sauvegarde impossible.' + response);
      }
    }
    else
    {
      alert('Sauvegarde impossible.' + xhr.status);
    }
  }
}

/*******************************************************
********************************************************
*** Envoie la requete ajax lors de la fermeture de la
*** boite d'édition.
********************************************************
*******************************************************/
/*
	-id : id de l'enregistrement dans la base
	-nom : nom du champs à modifier dans la base
	-txt : nouvelle valeur à modifier
	-mode : nom de la table*/

function saveModificationExp(id, nom, txt, obj, mode,expirationOld)
{
  if (sauvegardeEffectuee == true)
  {
    return false;
  }
  var xhr = getXMLHTTP();

  var data = 'id=' + id + '&nom=' + nom + '&txt=' + escape(txt) + '&mode=' + mode + '&expirationold=' + expirationOld;

  xhr.open('POST', 'index.php?controller=zoneprivee&action=changeExpirationFichier', true);
  xhr.onreadystatechange = function() { closeEditModeExp(xhr, obj, txt) };
  xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  xhr.send(data);
}

/*******************************************************
********************************************************
*** Recupere la touche appuyée (evenement onKeyDown)
********************************************************
*******************************************************/

function getKeyCode(evenement)
{
    for (prop in evenement)
    {
        if(prop == 'which')
        {
            return evenement.which;
        }
    }

    return evenement.keyCode;
}

/*******************************************************
********************************************************
*** Core de la fonction d'edition
********************************************************
*******************************************************/

function editSupportsNews(id, obj, nom, mode, type, contenuDate, expirationOld)
{
   // on n'ouvre pas plus d'une boite simultanément.
  if (editionEnCours == false)
    editionEnCours = true;
  else
    return false;
  sauvegardeEffectuee = false;
  if (obj.innerText)            //récupération de la valeur du champ
	{
  	txt = obj.innerText;
  	obj.innerText = '';
	}
	else
	{
  	txt = obj.textContent;
  	obj.textContent = '';
	}
	
	switch(type)
	{
		case 'select':
		{
			var input = document.createElement('select');
			input.setAttribute('id','liste');
			var dateJour = new Date();
			var fullDate = dateJour.getTime();
			var retour="";
			var i=0;
			var compteurDisabled = 0;
			
			for (i=1;;i++)
			{

				libDate = extraire(contenuDate,"|",i);
				
				if (libDate=='')
					break;
				
				input.options[i-1] = new Option(libDate,libDate);
				
				var day = libDate.substring(0,2);
				var month = libDate.substring(3,5);
				var year = libDate.substring(6,10);
				var d = new Date();
				d.setDate(day);
				d.setMonth(month-1);
				d.setFullYear(year); 
				var libDateTime = d.getTime();
				var compare = fullDate - libDateTime;
				var authorized = '1';
				var isSelected = '0';
				
				if(compare>0)
				{
					authorized='0';
					input.options[i-1].setAttribute("disabled","disabled");
					compteurDisabled++;
				}
				
				if(authorized=='1')
					if(expirationOld==libDate)
					{
						input.options[i-1] .selected = true;
						isSelected = '1';
					}
			}
			var longueur = input.options.length;
			
			break;
		}
	}
	
  //fonction appelée losque l'édition perdra le focus.
  input.onblur= function() {
	if(compteurDisabled==longueur)
		valeurRenvoi='-1';
	else	
		valeurRenvoi=input.value;
    saveModificationExp(id, nom, valeurRenvoi, obj, mode,expirationOld);
    delete input;
  };
  //fonction appelée losque l'utilisateur valide sa saisie.
    input.onkeydown = function (event)
    {
      if (!event && window.event)
      {
        event = window.event; //IE style.
      }
      if (getKeyCode(event) == 13)
      {
      	if(compteurDisabled==longueur)
		valeurRenvoi='-1';
	else	
		valeurRenvoi=input.value;
        saveModificationExp(id, nom, valeurRenvoi, obj, mode,expirationOld);
        delete input;
      }
    };
  // on ajoute l'input au DOM et on lui donne le focus.
  obj.appendChild(input);
  ativaOptionsDisabled();
  input.focus();
}

function ativaOptionsDisabled(){
    var sels = document.getElementsByTagName('select');
    for(var i=0; i < sels.length; i++){
	sels[i].onchange= function(){ //pra se mudar pro desabilitado
		if(this.options[this.selectedIndex]. disabled){
			var initial_index = this.selectedIndex
			var found = false
			while (this.selectedIndex < this.options.length - 1) {
				this.selectedIndex++
				if (!this.options[this.selectedIndex]. disabled) {
					found = true
					break;
				}
			}
			if (!found) {
				this.selectedIndex = initial_index
				while (this.selectedIndex > 0) {
					this.selectedIndex--
					if (!this.options[this.selectedIndex]. disabled) {
						found = true
						break;
					}
				}
			}
			if (!found)
				this.selectedIndex = -1
		}
	}
	if(sels[i].options[sels[i].selectedIndex].disabled){
	    //se o selecionado atual é desabilitado chamo o onchange
	    sels[i].onchange();
	}    
	for(var j=0; j < sels[i].options.length; j++){ //colocando o estilo
	    if(sels[i].options[j].disabled){
		sels[i].options[j].style.color = '#CCC';
	    }
	}
    }
}

function afficheRenouvellement()
{
	$.post('index.php?controller=zoneprivee&action=afficheRenouvellement','',function(data) { proceedAfficheRenouvellement(data); });
}

function proceedAfficheRenouvellement(xhr)
{
	var resultat = xhr.split('|');
	
	displayOpacifier();
	var div = document.createElement('div');
	
	div.style.zIndex='4';
	div.id = 'popUpBox';
	
	centerPopUp(div);
	
	document.body.appendChild(div);
	
	div.innerHTML=resultat[1];
}

function formpopperso()
{
	var xhrObject;
	var data;
	
	// pour Firefox
	if(window.XMLHttpRequest)
		xhrObject = new XMLHttpRequest();

	// pour IE entre autres
	else if(window.ActiveXObject)
		xhrObject = new ActiveXObject("Microsoft.XMLHTTP"); 
	else
	{
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
		return; 
	}

	data = "";

	xhrObject.open("POST", "index.php?controller=zoneprivee&action=createRenouvellement", true);

	xhrObject.onreadystatechange = function()
	{
		
		if(xhrObject.readyState == 4)
		{
			var idCommande = xhrObject.responseText;
			document.getElementById('idCommande').value=idCommande;
			document.getElementById('reference').value=idCommande;
			
			SPPLUS = window.open('','SPPLUS','width=750,height=560,status=1');
			document.TheForm.submit();
			if (SPPLUS && !SPPLUS.closed)
			SPPLUS.focus();
			return true;
		}
	}
	// envoi de l'entete
	xhrObject.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 
	// envoi des données en méthode POST
	xhrObject.send(data);
}

function createFacture()
{
	$.post('index.php?controller=zoneprivee&action=createRenouvellement','',function(data) { proceedCreateFacture(data); });
}

function proceedCreateFacture(xhr)
{
	var idCommande = xhr;
	document.getElementById('idCommande').value=idCommande;
	document.getElementById('reference').value=idCommande;
}

function enregistrerProfil()
{
	var pays = document.getElementById('pays_commande').value;
	var type = document.getElementById('type_client_commande').value;
	var societe = document.getElementById('societe_commande').value;
	var titreM = document.getElementById('titre_m').checked;
	var titreMme = document.getElementById('titre_mme').checked;
	var titreMlle = document.getElementById('titre_mlle').checked;
	var nom = document.getElementById('nom_commande').value;
	var prenom = document.getElementById('prenom_commande').value;
	var email = document.getElementById('email_commande').value;
	var adresse = document.getElementById('adresse_commande').value;
	var adressebis = document.getElementById('adresse2_commande').value;
	var cp = document.getElementById('cp_commande').value;
	var ville = document.getElementById('ville_commande').value;
	var indTel = document.getElementById('ind_tel_commande').value;
	var telephone = document.getElementById('tel_commande').value;
	var indFax = document.getElementById('ind_fax_commande').value;
	var fax = document.getElementById('fax_commande').value;
	var indPort = document.getElementById('ind_portable_commande').value;
	var portable = document.getElementById('portable_commande').value;
	var siret = document.getElementById('siret_commande').value;
	var ape = document.getElementById('ape_commande').value;
	var tva = document.getElementById('codeTva_commande').value;
	
	if(titreM==true)
		titre="M";
	else if(titreMme==true)
		titre="Mme";
	else
		titre="Mlle";
	
	$.post('index.php?controller=zoneprivee&action=enregistrerProfil',
	{pays: pays, type: type, societe: societe, titre: titre, nom: nom, prenom: prenom, email: email, adresse: adresse, adressebis: adressebis, cp: cp, ville: ville, indtel: indTel, telephone: telephone, indfax: indFax, fax: fax, indport: indPort, portable: portable, siret: siret, ape: ape, tva: tva},
	function(data) { proceedEnregistrerProfil(data); });
}

function proceedEnregistrerProfil(xhr)
{
	var retour = xhr;
	var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		if(xhr=='erreur_telephone')
			displayError('Le num&eacute;ro de t&eacute;l&eacute;phone n\'est pas correct');
		
		if(xhr=='erreur_fax')
			displayError('Le num&eacute;ro de fax n\'est pas correct');
			
		if(xhr=='erreur_portable')
			displayError('Le num&eacute;ro de mobile n\'est pas correct');
			
		if(xhr=='erreur_cp')
			displayError('Le code postal n\'est pas correct');
			
		if(xhr=='erreur_mail')
			displayError('L\'adresse mail n\'est pas correcte');
	}
	else
	{
		displayError('Profil modifi&eacute;');
	}
}

function resizeProfil(typeCli)
{
	var isEntrprise;
	
	if(typeCli=="3" || typeCli=="7" || typeCli=="9")
		isEntreprise=true;
	else
		isEntreprise=false;
	
	if(document.getElementById('popup_profil'))
	{
		if(navigator.userAgent.indexOf("MSIE 7")!=-1)
		{
			if(isEntreprise==false)
			{
				document.getElementById('popup_profil').style.height = "358px";
				document.getElementById('popupProfilDroit').style.height = "358px";
				document.getElementById('popupProfilGauche').style.height = "358px";
			}
			else
			{
				document.getElementById('popup_profil').style.height = "438px";
				document.getElementById('popupProfilDroit').style.height = "438px";
				document.getElementById('popupProfilGauche').style.height = "438px";
			}
		}
		else
		{
			if(isEntreprise==false)
			{				
				if(navigator.userAgent.indexOf("Safari") != -1) 
				{
					document.getElementById('popup_profil').style.height = "418px";
					document.getElementById('popupProfilDroit').style.height = "418px";
					document.getElementById('popupProfilGauche').style.height = "418px";
					
					document.getElementById('popupProfilBas').style.marginTop = "418px";
					document.getElementById('popupProfilCoinBG').style.marginTop = "418px";
					document.getElementById('popupProfilCoinBD').style.marginTop = "418px";		
				}
				else
				{
					document.getElementById('popup_profil').style.height = "418px";
					document.getElementById('popupProfilDroit').style.height = "418px";
					document.getElementById('popupProfilGauche').style.height = "418px";
				}
			}
			else
			{
				if(navigator.userAgent.indexOf("Safari") != -1) 
				{
					
					document.getElementById('popupProfilBas').style.marginTop = "508px";
					document.getElementById('popupProfilCoinBG').style.marginTop = "508px";
					document.getElementById('popupProfilCoinBD').style.marginTop = "508px";

					document.getElementById('popup_profil').style.height = "508px";
					document.getElementById('popupProfilDroit').style.height = "508px";
					document.getElementById('popupProfilGauche').style.height = "508px";
				}
				else
				{
					document.getElementById('popup_profil').style.height = "498px";
					document.getElementById('popupProfilDroit').style.height = "498px";
					document.getElementById('popupProfilGauche').style.height = "498px";
				}
			}
		}
	}
	else
	{
		if(navigator.userAgent.indexOf("MSIE 7")!=-1)
		{
			if(isEntreprise==false)
			{
				document.getElementById('popup_profilG').style.height = "358px";
				document.getElementById('popupProfilDroitG').style.height = "358px";
				document.getElementById('popupProfilGaucheG').style.height = "358px";
			}
			else
			{
				document.getElementById('popup_profilG').style.height = "438px";
				document.getElementById('popupProfilDroitG').style.height = "438px";
				document.getElementById('popupProfilGaucheG').style.height = "438px";
			}
		}
		else
		{
			if(isEntreprise==false)
			{
				
				if(navigator.userAgent.indexOf("Safari") != -1) 
				{
					
					document.getElementById('popup_profilG').style.height = "418px";
					document.getElementById('popupProfilDroitG').style.height = "418px";
					document.getElementById('popupProfilGaucheG').style.height = "418px";
					
					document.getElementById('popupProfilBasG').style.marginTop = "418px";
					document.getElementById('popupProfilCoinBGG').style.marginTop = "418px";
					document.getElementById('popupProfilCoinBDG').style.marginTop = "418px";
				}
				else
				{
					document.getElementById('popup_profilG').style.height = "418px";
					document.getElementById('popupProfilDroitG').style.height = "418px";
					document.getElementById('popupProfilGaucheG').style.height = "418px";
				}
			}
			else
			{
				if(navigator.userAgent.indexOf("Safari") != -1) 
				{
					document.getElementById('popupProfilBasG').style.marginTop = "508px";
					document.getElementById('popupProfilCoinBGG').style.marginTop = "508px";
					document.getElementById('popupProfilCoinBDG').style.marginTop = "508px";
				
					document.getElementById('popup_profilG').style.height = "508px";
					document.getElementById('popupProfilDroitG').style.height = "508px";
					document.getElementById('popupProfilGaucheG').style.height = "508px";
				}
				else
				{
					document.getElementById('popup_profilG').style.height = "498px";
					document.getElementById('popupProfilDroitG').style.height = "498px";
					document.getElementById('popupProfilGaucheG').style.height = "498px";
				}
			}
		}
	}
}

function supprimeHistoFic(idFichier, idContact)
{
	$.post('index.php?controller=zoneprivee&action=supprimeHistoFic',
	{idfichier: idFichier, idcontact: idContact},
	function(data) { proceedSupprimeHistoFic(data); });
}

function proceedSupprimeHistoFic(xhr)
{
	var retour = xhr;
	var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		if(xhr=='erreur_nonautorise')
			displayError('Vous n\'etes pas autorisé &agrave; effectuer cette op&eacute;ration');
	}
	else
	{
		closeBox();
		afficheHisto('ordre_decroissant');
	}
}

function supprimeHistoFicComplet(idFichier)
{
	$.post('index.php?controller=zoneprivee&action=supprimeHistoFic',
	{idfichier: idFichier, idcontact: "all"},
	function(data) { proceedSupprimeHistoFicGlobal(data); });
}

function proceedSupprimeHistoFicGlobal(xhr)
{
	var retour = xhr;
	var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		if(xhr=='erreur_nonautorise')
			displayError('Vous n\'etes pas autorisé &agrave; effectuer cette op&eacute;ration');
	}
	else
	{
		closeBox();
		
		$.post('index.php?controller=zoneprivee&action=refreshLastUpload','',function(data) { proceedRefreshLastUpload(data); });
	}
}

function proceedRefreshLastUpload(xhr)
{
	document.getElementById('tabRecap').innerHTML = xhr;
}

function inscriptionCompteEssai()
{
	var mail = document.getElementById('mailCompteEssai').value;
	var type = document.getElementById('type').value;
	var choixCompte="";
	choixCompte="gratuit";
	
	$.post('index.php?controller=zonepublic&action=inscriptionCompteEssai',
	{mail: mail, choixcompte: choixCompte},
	function(data) { proceedInscriptionCompteEssai(data,mail,choixCompte,type); });
}

function proceedInscriptionCompteEssai(xhr,mail,choixcompte,type)
{
	var retour = xhr;
	var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		if(xhr=='erreur_mail')
			displayError('Veuillez saisir une adresse email valide');	
		
		if(xhr=='erreur_mail_existant')
			displayError('Cette adresse email est déja utilisée pour un compte. Veuillez vous connecter avec vos identifiants');
	}
	else
	{	
		if(choixcompte == "gratuit")
		{
			closeBox();
			displayError('Un email avec vos identifiants de connexion vient de vous &ecirc;tre envoy&eacute;.');	
			autoLogin(mail,type);
		}
	}
}

function recupDest()
{
	var divPrinc = document.getElementById('inputDestinataire');
	var listeDestinataire = "";

	if(divPrinc.hasChildNodes())
	{
		var enfants = divPrinc.childNodes;
		var compteurElement = 1;

		for (var i = 0; i < enfants.length; i++)
		{
			if(enfants[i].tagName=='DIV')
			{
				var enfants2 = enfants[i].childNodes;
				
				for (var j = 0; j < enfants2.length; j++)
				{
					if(enfants2[j].tagName=='INPUT')
					{			
						if(enfants2[j].value!="")
							listeDestinataire = listeDestinataire + enfants2[j].value+ ",";
					}
				}
			}
		}
	}
	
	return listeDestinataire;		
}

function valideRenouvellement()
{
	var montantHTCommandeRenouvellement = document.getElementById('montantHTCommandeRenouvellement').value;
	var tvaCommandeRenouvellement = document.getElementById('tvaCommandeRenouvellement').value;
	var montantTTCCommandeRenouvellement = document.getElementById('montantTTCCommandeRenouvellement').value;
	var modePaiement = document.getElementById('listePaiementRenouvellement').value;
	var codePromo = document.getElementById('code_promo').value;
	
	$.post('index.php?controller=zoneprivee&action=createRenouvellement',
	{montantHT: montantHTCommandeRenouvellement, tva: tvaCommandeRenouvellement, montantTTC: montantTTCCommandeRenouvellement, modepaiement: modePaiement, codepromo: codePromo},
	function(data) { proceedValideRenouvellement(data); });
}

function proceedValideRenouvellement(xhr)
{
	var div = document.getElementById('popUpBox');
	$('#popUpBox').load('view/popup_valide_renouvellement.php?cmd='+xhr);
}

function annuleCommande(idCommande)
{
	$.post('index.php?controller=zoneprivee&action=annuleCommande',
	{idCommande: idCommande},
	function(data) { proceedAnnuleCommande(data); });
}

function proceedAnnuleCommande(xhr)
{
	document.getElementById('contenuListeCompte').innerHTML = "<table border='0' cellpadding='0' cellspacing='0' width='674'><tr class='headerTabHisto'><td align='center'>Type de compte</td><td align='center'>Statut</td><td align='center'>P&eacute;riode d\'abonnement</td><td align='center'>Dur&eacute;e</td><td align='center' colspan='2'>Factures</td></tr>"+xhr+"</table>";
}

function proceedPayeRenouvellement(xhr,idCommande)
{
	if(xhr=='CB')
	{
		popBox('view/popup_valide_renouvellement.php?cmd='+idCommande);
	}
	else
		popBox('view/popup_valide_renouvellement_compte.php?cmd='+idCommande);
}

function payeRenouvellement(idCommande)
{
	$.post('index.php?controller=zoneprivee&action=payeRenouvellement',
	{idCommande: idCommande},
	function(data) { proceedPayeRenouvellement(data, idCommande); });
}

function trieListeFichier(champ,ordre)
{
	$.post('index.php?controller=zoneprivee&action=trieListeFichier',
	{ordre: ordre, champ: champ},
	function(data) { proceedTrieListeFichier(data, champ, ordre); });
}

function proceedTrieListeFichier(xhr, champ, ordre)
{	
	//afficheListeCategorie();
	if(ordre=='ASC')
	{
		if(champ=='nom')
			document.getElementById('listeFichiers').innerHTML='<div id="contenuListeFichier" style="position:absolute; top:0;"><table border="0" cellpadding="0" cellspacing="0" width="680"><tr class="headerTabHisto"><td align="center" id="celluleFichier" style="height: 22px;" colspan="2"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'nom\',\'DESC\');">Fichier(s)</a></td><td align="center" style="height: 22px;"><a href="javascript: void(0);" class="lien_12_gras_blanc" onmouseover="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'show\');" onmouseout="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'hide\');">Cat&eacute;gorie(s)&nbsp;<img src="styles/default/graphs/croissant.gif" alt="" width="9" height="10" /></a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'destinataire\',\'ASC\');">Destinataire(s)</a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'poids\',\'ASC\');">Poid(s)</a></td><td align="center" style="height: 22px;">Date(s) d\'envoi<span id="imgDate"><a id="linkOrdreDate" href="javascript: afficheFichier(\'ordre_decroissant\');"><img id="imgTriDate" src="styles/default/graphs/croissant.gif" width="9" height="10" alt="" /></a></span></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'expiration\',\'ASC\');">Expiration</a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'download\',\'ASC\');">T&eacute;l&eacute;charg&eacute;(s)</a></td><td align="center" style="height: 22px;">Prot&eacute;g&eacute;(s)</td><td>&nbsp;</td></tr>'+xhr+'</table></div>';
		else if(champ=='destinataire')
			document.getElementById('listeFichiers').innerHTML='<div id="contenuListeFichier" style="position:absolute; top:0;"><table border="0" cellpadding="0" cellspacing="0" width="680"><tr class="headerTabHisto"><td align="center" id="celluleFichier" style="height: 22px;" colspan="2"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'nom\',\'ASC\');">Fichier(s)</a></td><td align="center" style="height: 22px;"><a href="javascript: void(0);" class="lien_12_gras_blanc" onmouseover="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'show\');" onmouseout="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'hide\');">Cat&eacute;gorie(s)&nbsp;<img src="styles/default/graphs/croissant.gif" alt="" width="9" height="10" /></a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'destinataire\',\'DESC\');">Destinataire(s)</a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'poids\',\'ASC\');">Poid(s)</a></td><td align="center" style="height: 22px;">Date(s) d\'envoi<span id="imgDate"><a id="linkOrdreDate" href="javascript: afficheFichier(\'ordre_decroissant\');"><img id="imgTriDate" src="styles/default/graphs/croissant.gif" width="9" height="10" alt="" /></a></span></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'expiration\',\'ASC\');">Expiration</a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'download\',\'ASC\');">T&eacute;l&eacute;charg&eacute;(s)</a></td><td align="center" style="height: 22px;">Prot&eacute;g&eacute;(s)</td><td>&nbsp;</td></tr>'+xhr+'</table></div>';
		else if(champ=='poids')
			document.getElementById('listeFichiers').innerHTML='<div id="contenuListeFichier" style="position:absolute; top:0;"><table border="0" cellpadding="0" cellspacing="0" width="680"><tr class="headerTabHisto"><td align="center" id="celluleFichier" style="height: 22px;" colspan="2"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'nom\',\'ASC\');">Fichier(s)</a></td><td align="center" style="height: 22px;"><a href="javascript: void(0);" class="lien_12_gras_blanc" onmouseover="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'show\');" onmouseout="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'hide\');">Cat&eacute;gorie(s)&nbsp;<img src="styles/default/graphs/croissant.gif" alt="" width="9" height="10" /></a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'destinataire\',\'ASC\');">Destinataire(s)</a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'poids\',\'DESC\');">Poid(s)</a></td><td align="center" style="height: 22px;">Date(s) d\'envoi<span id="imgDate"><a id="linkOrdreDate" href="javascript: afficheFichier(\'ordre_decroissant\');"><img id="imgTriDate" src="styles/default/graphs/croissant.gif" width="9" height="10" alt="" /></a></span></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'expiration\',\'ASC\');">Expiration</a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'download\',\'ASC\');">T&eacute;l&eacute;charg&eacute;(s)</a></td><td align="center" style="height: 22px;">Prot&eacute;g&eacute;(s)</td><td>&nbsp;</td></tr>'+xhr+'</table></div>';
		else if(champ=='expiration')
			document.getElementById('listeFichiers').innerHTML='<div id="contenuListeFichier" style="position:absolute; top:0;"><table border="0" cellpadding="0" cellspacing="0" width="680"><tr class="headerTabHisto"><td align="center" id="celluleFichier" style="height: 22px;" colspan="2"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'nom\',\'ASC\');">Fichier(s)</a></td><td align="center" style="height: 22px;"><a href="javascript: void(0);" class="lien_12_gras_blanc" onmouseover="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'show\');" onmouseout="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'hide\');">Cat&eacute;gorie(s)&nbsp;<img src="styles/default/graphs/croissant.gif" alt="" width="9" height="10" /></a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'destinataire\',\'ASC\');">Destinataire(s)</a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'poids\',\'ASC\');">Poid(s)</a></td><td align="center" style="height: 22px;">Date(s) d\'envoi<span id="imgDate"><a id="linkOrdreDate" href="javascript: afficheFichier(\'ordre_decroissant\');"><img id="imgTriDate" src="styles/default/graphs/croissant.gif" width="9" height="10" alt="" /></a></span></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'expiration\',\'DESC\');">Expiration</a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'download\',\'ASC\');">T&eacute;l&eacute;charg&eacute;(s)</a></td><td align="center" style="height: 22px;">Prot&eacute;g&eacute;(s)</td><td>&nbsp;</td></tr>'+xhr+'</table></div>';
		else if(champ=='download')
			document.getElementById('listeFichiers').innerHTML='<div id="contenuListeFichier" style="position:absolute; top:0;"><table border="0" cellpadding="0" cellspacing="0" width="680"><tr class="headerTabHisto"><td align="center" id="celluleFichier" style="height: 22px;" colspan="2"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'nom\',\'ASC\');">Fichier(s)</a></td><td align="center" style="height: 22px;"><a href="javascript: void(0);" class="lien_12_gras_blanc" onmouseover="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'show\');" onmouseout="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'hide\');">Cat&eacute;gorie(s)&nbsp;<img src="styles/default/graphs/croissant.gif" alt="" width="9" height="10" /></a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'destinataire\',\'ASC\');">Destinataire(s)</a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'poids\',\'ASC\');">Poid(s)</a></td><td align="center" style="height: 22px;">Date(s) d\'envoi<span id="imgDate"><a id="linkOrdreDate" href="javascript: afficheFichier(\'ordre_decroissant\');"><img id="imgTriDate" src="styles/default/graphs/croissant.gif" width="9" height="10" alt="" /></a></span></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'expiration\',\'ASC\');">Expiration</a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'download\',\'DESC\');">T&eacute;l&eacute;charg&eacute;(s)</a></td><td align="center" style="height: 22px;">Prot&eacute;g&eacute;(s)</td><td>&nbsp;</td></tr>'+xhr+'</table></div>';
	}
	else
	{
		if(champ=='nom')
			document.getElementById('listeFichiers').innerHTML='<div id="contenuListeFichier" style="position:absolute; top:0;"><table border="0" cellpadding="0" cellspacing="0" width="680"><tr class="headerTabHisto"><td align="center" id="celluleFichier" style="height: 22px;" colspan="2"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'nom\',\'ASC\');">Fichier(s)</a></td><td align="center" style="height: 22px;"><a href="javascript: void(0);" class="lien_12_gras_blanc" onmouseover="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'show\');" onmouseout="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'hide\');">Cat&eacute;gorie(s)&nbsp;<img src="styles/default/graphs/croissant.gif" alt="" width="9" height="10" /></a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'destinataire\',\'DESC\');">Destinataire(s)</a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'poids\',\'DESC\');">Poid(s)</a></td><td align="center" style="height: 22px;">Date(s) d\'envoi<span id="imgDate"><a id="linkOrdreDate" href="javascript: afficheFichier(\'ordre_decroissant\');"><img id="imgTriDate" src="styles/default/graphs/croissant.gif" width="9" height="10" alt="" /></a></span></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'expiration\',\'DESC\');">Expiration</a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'download\',\'DESC\');">T&eacute;l&eacute;charg&eacute;(s)</a></td><td align="center" style="height: 22px;">Prot&eacute;g&eacute;(s)</td><td>&nbsp;</td></tr>'+xhr+'</table></div>';
		else if(champ=='destinataire')
			document.getElementById('listeFichiers').innerHTML='<div id="contenuListeFichier" style="position:absolute; top:0;"><table border="0" cellpadding="0" cellspacing="0" width="680"><tr class="headerTabHisto"><td align="center" id="celluleFichier" style="height: 22px;" colspan="2"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'nom\',\'DESC\');">Fichier(s)</a></td><td align="center" style="height: 22px;"><a href="javascript: void(0);" class="lien_12_gras_blanc" onmouseover="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'show\');" onmouseout="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'hide\');">Cat&eacute;gorie(s)&nbsp;<img src="styles/default/graphs/croissant.gif" alt="" width="9" height="10" /></a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'destinataire\',\'ASC\');">Destinataire(s)</a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'poids\',\'DESC\');">Poid(s)</a></td><td align="center" style="height: 22px;">Date(s) d\'envoi<span id="imgDate"><a id="linkOrdreDate" href="javascript: afficheFichier(\'ordre_decroissant\');"><img id="imgTriDate" src="styles/default/graphs/croissant.gif" width="9" height="10" alt="" /></a></span></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'expiration\',\'DESC\');">Expiration</a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'download\',\'DESC\');">T&eacute;l&eacute;charg&eacute;(s)</a></td><td align="center" style="height: 22px;">Prot&eacute;g&eacute;(s)</td><td>&nbsp;</td></tr>'+xhr+'</table></div>';
		else if(champ=='poids')
			document.getElementById('listeFichiers').innerHTML='<div id="contenuListeFichier" style="position:absolute; top:0;"><table border="0" cellpadding="0" cellspacing="0" width="680"><tr class="headerTabHisto"><td align="center" id="celluleFichier" style="height: 22px;" colspan="2"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'nom\',\'DESC\');">Fichier(s)</a></td><td align="center" style="height: 22px;"><a href="javascript: void(0);" class="lien_12_gras_blanc" onmouseover="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'show\');" onmouseout="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'hide\');">Cat&eacute;gorie(s)&nbsp;<img src="styles/default/graphs/croissant.gif" alt="" width="9" height="10" /></a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'destinataire\',\'DESC\');">Destinataire(s)</a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'poids\',\'ASC\');">Poid(s)</a></td><td align="center" style="height: 22px;">Date(s) d\'envoi<span id="imgDate"><a id="linkOrdreDate" href="javascript: afficheFichier(\'ordre_decroissant\');"><img id="imgTriDate" src="styles/default/graphs/croissant.gif" width="9" height="10" alt="" /></a></span></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'expiration\',\'DESC\');">Expiration</a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'download\',\'DESC\');">T&eacute;l&eacute;charg&eacute;(s)</a></td><td align="center" style="height: 22px;">Prot&eacute;g&eacute;(s)</td><td>&nbsp;</td></tr>'+xhr+'</table></div>';
		else if(champ=='expiration')
			document.getElementById('listeFichiers').innerHTML='<div id="contenuListeFichier" style="position:absolute; top:0;"><table border="0" cellpadding="0" cellspacing="0" width="680"><tr class="headerTabHisto"><td align="center" id="celluleFichier" style="height: 22px;" colspan="2"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'nom\',\'DESC\');">Fichier(s)</a></td><td align="center" style="height: 22px;"><a href="javascript: void(0);" class="lien_12_gras_blanc" onmouseover="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'show\');" onmouseout="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'hide\');">Cat&eacute;gorie(s)&nbsp;<img src="styles/default/graphs/croissant.gif" alt="" width="9" height="10" /></a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'destinataire\',\'DESC\');">Destinataire(s)</a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'poids\',\'DESC\');">Poid(s)</a></td><td align="center" style="height: 22px;">Date(s) d\'envoi<span id="imgDate"><a id="linkOrdreDate" href="javascript: afficheFichier(\'ordre_decroissant\');"><img id="imgTriDate" src="styles/default/graphs/croissant.gif" width="9" height="10" alt="" /></a></span></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'expiration\',\'ASC\');">Expiration</a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'download\',\'DESC\');">T&eacute;l&eacute;charg&eacute;(s)</a></td><td align="center" style="height: 22px;">Prot&eacute;g&eacute;(s)</td><td>&nbsp;</td></tr>'+xhr+'</table></div>';
		else if(champ=='download')
			document.getElementById('listeFichiers').innerHTML='<div id="contenuListeFichier" style="position:absolute; top:0;"><table border="0" cellpadding="0" cellspacing="0" width="680"><tr class="headerTabHisto"><td align="center" id="celluleFichier" style="height: 22px;" colspan="2"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'nom\',\'DESC\');">Fichier(s)</a></td><td align="center" style="height: 22px;"><a href="javascript: void(0);" class="lien_12_gras_blanc" onmouseover="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'show\');" onmouseout="MM_showHideLayers(\'listeCategoriesPrivate\',\'\',\'hide\');">Cat&eacute;gorie(s)&nbsp;<img src="styles/default/graphs/croissant.gif" alt="" width="9" height="10" /></a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'destinataire\',\'DESC\');">Destinataire(s)</a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'poids\',\'DESC\');">Poid(s)</a></td><td align="center" style="height: 22px;">Date(s) d\'envoi<span id="imgDate"><a id="linkOrdreDate" href="javascript: afficheFichier(\'ordre_decroissant\');"><img id="imgTriDate" src="styles/default/graphs/croissant.gif" width="9" height="10" alt="" /></a></span></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'expiration\',\'DESC\');">Expiration</a></td><td align="center" style="height: 22px;"><a href="javascript:;" class="lien_12_gras_blanc" onclick="trieListeFichier(\'download\',\'ASC\');">T&eacute;l&eacute;charg&eacute;(s)</a></td><td align="center" style="height: 22px;">Prot&eacute;g&eacute;(s)</td><td>&nbsp;</td></tr>'+xhr+'</table></div>';
	}
}

function trieContact(champ, ordre)
{
	$.post('index.php?controller=zoneprivee&action=trieContact',
	{ordre: ordre, champ: champ},
	function (data) { genereNewListe(data,champ,ordre); });
}

function genereHeaderTableContact(borneMin, borneMax, page, champ, ordre)
{
	var retour = $.ajax({
				type: "POST",
				url: 'index.php?controller=zoneprivee&action=genereHeaderTableContact',
				data: {borneMin: borneMin, borneMax: borneMax, champ: champ, ordre: ordre, page: page},
				async: false}
			).responseText;

	return retour;
}

function affichePageContact(borneMin, borneMax, page, champ, ordre)
{
	document.getElementById('tableauContact').innerHTML = "<div style='width: 100%; text-align: center;'><img src='styles/default/graphs/ajax-loader.gif' style='width: 50px; height: 50px;' /></div>";
	
	$.post(
		'index.php?controller=zoneprivee&action=affichePageContact',
		{borneMin: borneMin, borneMax: borneMax, champ: champ, ordre: ordre},
		function (data) {
			var contenu = '';
			
			contenu = genereHeaderTableContact(borneMin, borneMax, page, champ, ordre);
			contenu += data+'</table>';
						
			document.getElementById('tableauContact').innerHTML = contenu;
			
			affichePaginationContact(page,champ,ordre);
		});
}

function affichePaginationContact(page,champ,ordre)
{
	$.post(
		'index.php?controller=zoneprivee&action=affichePaginationContact',
		{page: page, champ: champ, ordre: ordre},
		function (data) {
			document.getElementById('paginationContact').innerHTML = data;
		});
}

function addContact()
{
	document.getElementById('divAjoutContact').innerHTML = '<a href="index.php?controller=zoneprivee&contain=afficheContact" class="lien_12_noir" style="text-decoration: underline;">Retour &agrave; la liste</a>';
	
	$.post(
		'index.php?controller=zoneprivee&action=addContact','',
		function (data) {
			document.getElementById('tableauContact').innerHTML = data;
			document.getElementById('paginationContact').innerHTML = "";
		});
}

function ajouteContactListe()
{
	$.post('index.php?controller=zoneprivee&action=verifAjoutContact',
	{nom:   document.getElementById('nom').value, prenom: document.getElementById('prenom').value, societe: document.getElementById('societe').value, email: document.getElementById('email').value, groupe: document.getElementById('groupe').value},
	function (data) {proceedAjouteContactListe(data); });
}

function proceedAjouteContactListe(xhr)
{
	var retour = xhr;
	var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		if(xhr=='erreur_mail')
			displayError('L\'adresse mail n\'est pas correcte.');
	}
	else
	{
		
		if(xhr=='ok')
		{
			document.getElementById('divAjoutContact').innerHTML = '<a href="javascript:;" onclick="addContact();" class="lien_12_noir" style="text-decoration: underline;">Ajouter un contact</a>';
			affichePageContact('0', '15', '1','nom','ASC');
		}
	}
}

function modifieContact(idcontact, idclient)
{
	document.getElementById('divAjoutContact').innerHTML = '<a href="index.php?controller=zoneprivee&contain=afficheContact" class="lien_12_noir" style="text-decoration: underline;">Retour &agrave; la liste</a>';

	$.post('index.php?controller=zoneprivee&action=modifContact',
	{idcontact: idcontact, idclient: idclient},
	function (data) {proceedModifieContact(data); });
}

function proceedModifieContact(xhr)
{
	var retour = xhr;
	var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		if(xhr=='erreur_client')
			displayError('Vous n\'etes pas autorisé a supprimer ce contact');
	}
	else
	{
		var res = xhr;
		var tab = res.split(',');
		var nom= tab[0];
		var prenom = tab[1];
		var societe = tab[2];
		var email = tab[3];
		var idcontact= tab[4];
		var idclient= tab[5];
		
		$.post('index.php?controller=zoneprivee&action=modifieContact',
		{nom: nom, prenom: prenom, societe: societe, email: email, idcontact: idcontact},
		function (data) { 
			document.getElementById('tableauContact').innerHTML = data;
			document.getElementById('paginationContact').innerHTML = '';
		});
	}
}

function modificationContactListe(idContact, idClient)
{
	$.post('index.php?controller=zoneprivee&action=verifModifContact',
	{ nom: document.getElementById('nom').value, prenom: document.getElementById('prenom').value, societe: document.getElementById('societe').value, email: document.getElementById('email').value, idclient: idClient, idcontact: idContact },
	function(data) { proceedModificationContactListe(data); });
}

function proceedModificationContactListe(xhr)
{
	var retour = xhr;
	var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		if(xhr=='erreur_mail')
			displayError('L\'adresse email n\'est pas correcte.');
	}
	else
	{
		
		if(xhr=='ok')
		{
			affichePageContact('0', '15', '1','nom','ASC');
			document.getElementById('divAjoutContact').innerHTML = '<a href="javascript:;" onclick="addContact();" class="lien_12_noir" style="text-decoration: underline;">Ajouter un contact</a>';
		}
	}
}

function supprContactListe(idContact, idClient)
{
	$.post('index.php?controller=zoneprivee&action=supprContact',
	{ idcontact: idContact, idclient: idClient },
	function (data) { proceedSupprContactListe(data); });
}

function proceedSupprContactListe(xhr)
{

	var retour = xhr;
	var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		if(xhr=='erreur_client')
			displayError('Vous n\'etes pas autorisé a supprimer ce contact');
	}
	else
	{
		if(xhr=='ok')
		{
			affichePageContact('0', '15', '1','nom','ASC');
			closeBox();
		}
	}
	
}

function ajouteOptionRenew(idOption,mois)
{
	var checked = document.getElementById('option'+idOption).checked;
	
	$.post('index.php?controller=zoneprivee&action=ajouteOptionRenew',
	{ idOption: idOption, mois: mois },
	function (data) { 
		if(checked == true)
		{
			document.getElementById('prixOption'+idOption).innerHTML = data+"&euro;";
			document.getElementById('listeOption').value += idOption+'|';
			actualiseMontantRenew(data); 
		}
		else
		{
			document.getElementById('prixOption'+idOption).innerHTML = '';
			actualiseMontantRenew('-'+data); 
			
			var listeOption = document.getElementById('listeOption').value.split('|');
			var i = 0;
			var newListe = '';
			
			for(i=0;i < listeOption.length; i++)
			{
				if(listeOption[i] != idOption && listeOption[i]!= '')
					newListe += listeOption[i]+'|';
			}
			
			document.getElementById('listeOption').value = newListe;
		}
	});
}


function actualiseMontantRenew(montant)
{
	var montantHT = parseFloat(document.getElementById('montantHTCommandeRenouvellement').value);
	var tauxTva = parseFloat(document.getElementById('tvaCommandeRenouvellement').value);
	var montantTTC = parseFloat(document.getElementById('montantTTCCommandeRenouvellement').value);
	var montantTva = '';
	
	montantHT = montantHT+parseFloat(montant);
	montantTTC = montantHT*tauxTva;
	montantTva = (tauxTva-1)*montantHT;
	
	document.getElementById('montantHTCommandeRenouvellement').value = Math.round(montantHT*100)/100;
	document.getElementById('montantTTCCommandeRenouvellement').value = Math.round(montantTTC*100)/100;
	document.getElementById('montantTvaRenew').innerHTML = Math.round(montantTva*100)/100+" &euro;";
	document.getElementById('prix_commande_ttc').innerHTML = Math.round(montantTTC*100)/100+" &euro;";
}

function ajouteOption(idOption,mois)
{
	var checked = document.getElementById('option'+idOption).checked;
	
	$.post('index.php?controller=zoneprivee&action=ajouteOptionRenew',
	{ idOption: idOption,mois: mois },
	function (data) { 
		if(checked == true)
		{
			document.getElementById('prixOption'+idOption).innerHTML = data+"&euro;";
			document.getElementById('listeOption').value += idOption+'|';
			actualiseMontantOption(data); 
		}
		else
		{
			document.getElementById('prixOption'+idOption).innerHTML = '';
			actualiseMontantOption('-'+data); 
			
			var listeOption = document.getElementById('listeOption').value.split('|');
			var i = 0;
			var newListe = '';
			
			for(i=0;i < listeOption.length; i++)
			{
				if(listeOption[i] != idOption && listeOption[i]!= '')
					newListe += listeOption[i]+'|';
			}
			
			document.getElementById('listeOption').value = newListe;
		}
	});
}


function actualiseMontantOption(montant)
{
	var montantHT = parseFloat(document.getElementById('montantHTCommandeOption').value);
	var tauxTva = parseFloat(document.getElementById('tvaCommandeOption').value);
	var montantTTC = parseFloat(document.getElementById('montantTTCCommandeOption').value);
	var montantTva = '';
	
	montantHT = montantHT+parseFloat(montant);
	montantTTC = montantHT*tauxTva;
	montantTva = (tauxTva-1)*montantHT;
	
	document.getElementById('montantHTCommandeOption').value = Math.round(montantHT*100)/100;
	document.getElementById('montantTTCCommandeOption').value = Math.round(montantTTC*100)/100;
	document.getElementById('montantTvaOption').innerHTML = Math.round(montantTva*100)/100+" &euro;";
	document.getElementById('prix_commande_ttc').innerHTML = Math.round(montantTTC*100)/100+" &euro;";
}

function ajouteOptionUpgrade(idOption,mois)
{
	var checked = document.getElementById('option'+idOption).checked;
	
	$.post('index.php?controller=zoneprivee&action=ajouteOptionRenew',
	{ idOption: idOption,mois: mois },
	function (data) { 
		if(checked == true)
		{
			document.getElementById('prixOption'+idOption).innerHTML = data+"&euro;";
			document.getElementById('listeOption').value += idOption+'|';
			actualiseMontantUpgrade(data); 
		}
		else
		{
			document.getElementById('prixOption'+idOption).innerHTML = '';
			actualiseMontantUpgrade('-'+data); 
			
			var listeOption = document.getElementById('listeOption').value.split('|');
			var i = 0;
			var newListe = '';
			
			for(i=0;i < listeOption.length; i++)
			{
				if(listeOption[i] != idOption && listeOption[i]!= '')
					newListe += listeOption[i]+'|';
			}
			
			document.getElementById('listeOption').value = newListe;
		}
	});
}


function actualiseMontantUpgrade(montant)
{
	var montantHT = parseFloat(document.getElementById('montantHTCommande').value);
	var tauxTva = parseFloat(document.getElementById('tvaCommande').value);
	var montantTTC = parseFloat(document.getElementById('montantTTCCommande').value);
	var montantTva = '';
	
	montantHT = montantHT+parseFloat(montant);
	montantTTC = montantHT*tauxTva;
	montantTva = (tauxTva-1)*montantHT;
	
	document.getElementById('montantHTCommande').value = Math.round(montantHT*100)/100;
	document.getElementById('montantTTCCommande').value = Math.round(montantTTC*100)/100;
	document.getElementById('montantTva').innerHTML = Math.round(montantTva*100)/100+" &euro;";
	document.getElementById('prix_commande_ttc').innerHTML = Math.round(montantTTC*100)/100+" &euro;";
}

function valideRenouvellement2()
{
	var montantHTCommandeRenouvellement = document.getElementById('montantHTCommandeRenouvellement').value;
	var tvaCommandeRenouvellement = document.getElementById('tvaCommandeRenouvellement').value;
	var montantTTCCommandeRenouvellement = document.getElementById('montantTTCCommandeRenouvellement').value;
	var modePaiement = document.getElementById('listePaiementRenouvellement').value;
	var codePromo = document.getElementById('code_promo').value;
	var listeOption = document.getElementById('listeOption').value;
	
	$.post('index.php?controller=zoneprivee&action=createRenouvellement',
	{montantHT: montantHTCommandeRenouvellement, tva: tvaCommandeRenouvellement, montantTTC: montantTTCCommandeRenouvellement, modepaiement: modePaiement, codepromo: codePromo, listeOption: listeOption},
	function(data) { 
			$.post('index.php?controller=zoneprivee&action=paiementRenew',
			{ idCmd: data },
			function(data) { document.getElementById('blocHautPrivate').innerHTML = data; });
	});
}

function valideOption()
{
	var montantHTCommandeOption= document.getElementById('montantHTCommandeOption').value;
	var tvaCommandeOption = document.getElementById('tvaCommandeOption').value;
	var montantTTCCommandeOption = document.getElementById('montantTTCCommandeOption').value;
	var modePaiement = document.getElementById('listePaiementOption').value;
	var codePromo = document.getElementById('code_promo').value;
	var listeOption = document.getElementById('listeOption').value;
	
	$.post('index.php?controller=zoneprivee&action=createCommandeOption',
	{montantHT: montantHTCommandeOption, tva: tvaCommandeOption, montantTTC: montantTTCCommandeOption, modepaiement: modePaiement, codepromo: codePromo, listeOption: listeOption},
	function(data) { 
			$.post('index.php?controller=zoneprivee&action=paiementOption',
			{ idCmd: data },
			function(data) { document.getElementById('zoneAffiche').innerHTML = data; });
	});
}

function cacheBas()
{
	if(navigator.userAgent.indexOf("MSIE 7") != -1)
	{		
		var domaine = new String (document.location);
		// alert(domaine.search('afficheFichiers'));
		if(domaine.search('afficheFichiers') == -1 && domaine.search('affciheHisto') > -1)
			document.getElementById('contenuPrivate').removeChild(document.getElementById('contenuBasPrivate'));
		else			
			document.getElementById('contenuBasPrivate').innerHTML = '';
			
		document.getElementById('blocMenu').style.height=document.getElementById('blocMenu').offsetHeight+252+"px";
		document.getElementById('blocMenu').style.zIndex = '2';
		document.getElementById('blocHautPrivate').style.marginTop = "-509px";
		document.getElementById('blocHautPrivate').style.height=document.getElementById('blocHautPrivate').offsetHeight;
		document.getElementById('blocHautPrivate').style.height = "509px";
	}
	else if(navigator.userAgent.indexOf("Safari")!=-1)
	{
		document.getElementById('contenuBasPrivate').innerHTML = '';
		document.getElementById('blocMenu').style.height=document.getElementById('blocMenu').offsetHeight+252+"px";
		document.getElementById('contenuBasPrivate').style.background = '#F5F5F5';
		document.getElementById('blocMenu').style.zIndex = '2';
		document.getElementById('blocHautPrivate').style.height = 509+"px";
	}
	else if(navigator.userAgent.indexOf("MSIE 6")!= -1)
	{
		var domaine = new String (document.location);
		
		if(domaine.search('envoiFichier') > -1)
		{
			document.getElementById('contenuPrivate').removeChild(document.getElementById('contenuBasPrivate'));
			document.getElementById('contenuPrivate').style.background = '#F5F5F5';
			document.getElementById('divEnvoiFichier').style.height = "523px";
			document.getElementById('blocMenu').style.height=document.getElementById('blocMenu').offsetHeight+267+"px";
			document.getElementById('divEnvoiFichier').style.marginTop = "-267px";
		}
		else
		{
			if(!domaine.search('afficheFichiers') == -1)
				document.getElementById('contenuPrivate').removeChild(document.getElementById('contenuBasPrivate'));
		
			if(domaine.search('afficheFichiers') > -1 || domaine.search('buyCredit') > -1 || domaine.search('buyAbonnement') > -1)
				document.getElementById('blocHautPrivate').style.height = "524px";
		
			document.getElementById('contenuBasPrivate').innerHTML = '';
			document.getElementById('contenuPrivate').style.background = '#F5F5F5';
			document.getElementById('blocMenu').style.height=document.getElementById('blocMenu').offsetHeight+267+"px";
			document.getElementById('blocHautPrivate').style.marginTop = "-524px";
		}
	}
	else
	{	
		document.getElementById('contenuBasPrivate').innerHTML = '';
		document.getElementById('blocMenu').style.height=document.getElementById('blocMenu').offsetHeight+252+"px";
		document.getElementById('contenuBasPrivate').style.background = '#F5F5F5';
		document.getElementById('blocMenu').style.zIndex = '2';
		document.getElementById('blocHautPrivate').style.height=document.getElementById('blocHautPrivate').offsetHeight;
		document.getElementById('blocHautPrivate').style.height=document.getElementById('blocHautPrivate').offsetHeight+252+"px";
	}
}

function cacheBasDropBox()
{
	if(navigator.userAgent.indexOf("MSIE 7") != -1)
	{
		document.getElementById('blocMenuDropBox').style.height=document.getElementById('blocMenuDropBox').offsetHeight+190+"px";
		document.getElementById('blocMenuDropBox').style.zIndex = '2';
		document.getElementById('blocHautPrivateDropBox').style.marginTop = "-507px";
		document.getElementById('blocHautPrivateDropBox').style.height=document.getElementById('blocHautPrivateDropBox').offsetHeight;
		document.getElementById('blocHautPrivateDropBox').style.height = "507px";
	}
	else if(navigator.userAgent.indexOf("Safari")!=-1)
	{
		document.getElementById('blocMenuDropBox').style.height=document.getElementById('blocMenuDropBox').offsetHeight+200+"px";
		document.getElementById('blocMenuDropBox').style.zIndex = '2';
		document.getElementById('blocHautPrivateDropBox').style.height = 516+"px";
	}
	else if(navigator.userAgent.indexOf("MSIE 6")!= -1)
	{
		document.getElementById('blocMenuDropBox').style.height=document.getElementById('blocMenuDropBox').offsetHeight+190+"px";
		document.getElementById('blocMenuDropBox').style.zIndex = '2';
		document.getElementById('blocHautPrivateDropBox').style.marginTop = "-507px";
		document.getElementById('blocHautPrivateDropBox').style.height=document.getElementById('blocHautPrivateDropBox').offsetHeight;
		document.getElementById('blocHautPrivateDropBox').style.height = "507px";
	}
	else
	{
		document.getElementById('blocMenuDropBox').style.height=document.getElementById('blocMenuDropBox').offsetHeight+190+"px";
		document.getElementById('blocMenuDropBox').style.zIndex = '2';
		document.getElementById('blocHautPrivateDropBox').style.height=document.getElementById('blocHautPrivateDropBox').offsetHeight;
		document.getElementById('blocHautPrivateDropBox').style.height=document.getElementById('blocHautPrivateDropBox').offsetHeight+190+"px";
	}
}

function ajouteFichierPrivateEnvoyer(div)
{
	var max=5;
	var maListe = document.getElementById(div);

	var tabEnfant=Array();
	var compteur=0;
	if (maListe.hasChildNodes())
	{
		var collEnfants = maListe.childNodes;
		for (var i = 0; i < collEnfants.length; i++)
		{
			if(collEnfants[i].tagName=="DIV")
				compteur++;
		}
	}
	if(compteur<(max))
	{
		//alert(compteur);
		var span = document.createElement('div');
		var input = document.createElement('input');
		
		span.setAttribute('id','fic'+compteur);
		
		input.setAttribute('type','file');
		input.setAttribute('id','upfile_'+compteur);
		input.setAttribute('name','upfile_'+compteur);
		input.setAttribute('onchange','valideUpload("upfile_'+compteur+'");');
		input.onchange = function () { valideUpload("upfile_"+compteur); };
		
		span.appendChild(input);
		var supprFichier = document.createElement('div');
		supprFichier.setAttribute("class","supprFichierEnvoyer");
		supprFichier.setAttribute("className","supprFichierEnvoyer");
		supprFichier.className = "supprFichierEnvoyer";
		
		var lien = document.createElement('a');
		lien.setAttribute("class","lien_11_bleu_fonce");
		lien.setAttribute("className","lien_11_bleu_fonce");
		lien.className = "lien_11_bleu_fonce";
		lien.setAttribute("href","javascript: supprFichierParcourirPrivateEnvoyer(\""+div+"\","+compteur+");");
		
		var textLien = document.createTextNode("Supprimer");
		lien.appendChild(textLien);
		
		supprFichier.appendChild(lien);
		
		span.appendChild(supprFichier);
	
		maListe.appendChild(span);
	}

	if(compteur==(max))
		displayError('Impossible d\'envoyer plus de 5 fichiers simultanement');
}

function supprFichierParcourirPrivateEnvoyer(div, id)
{
	var maListe = document.getElementById(div);
	var span = document.getElementById('fic'+id);
	maListe.removeChild(span);
}


function ajouteChampEnvoyer()
{
	var divPrinc = document.getElementById('inputDestinataire');
	
	if(divPrinc.hasChildNodes())
	{
		var enfants = divPrinc.childNodes;
		var compteurElement = 1;

		for (var i = 0; i < enfants.length; i++)
		{		
			if(enfants[i].tagName=='DIV')
			{
				var enfants2 = enfants[i].childNodes;
				
				for (var j = 0; j < enfants2.length; j++)
				{
					if(enfants2[j].tagName=='INPUT')
					{		
						if(enfants2[j].value=="")
							return false;
					
						if(enfants2[j].id.search(/destinataireEnvoi/)!=-1)
						{	
							if(enfants2[j].id!='destinataireEnvoi_1')
							{
								if(enfants[i].value == "")
								{
									divPrinc.removeChild(enfants[i]);
								}
								
								compteurElement++;
							}
							
						}
					}
				}
			}
		}
				
		var newDiv = document.createElement('div');
		var newInput = document.createElement('input');
		
		compteurElement++;
		
		newDiv.setAttribute('id','caseDestinataireEnvoi_'+compteurElement);
		
		newInput.setAttribute('id', 'destinataireEnvoi_'+compteurElement);
		newInput.setAttribute('name', 'destinataireEnvoi_'+compteurElement);
		newInput.setAttribute('type','text');
		newInput.style.width = '165px';
		newInput.style.border = '1px solid black';
		
		newDiv.style.paddingTop = "5px";
		
		var link2 = document.createElement('a');
		var img = document.createElement('img');
		//var br = document.createElement('br');
				
		img.setAttribute('src','styles/default/graphs/bouton_supprimer_contact.gif');
		
		link2.setAttribute('href','javascript:supprimeChampEnvoyer("'+(compteurElement-1)+'");');
		//link2.setAttribute('onclick','supprimeChamp("'+(compteurElement-1)+'");');
		link2.appendChild(img);
		
		document.getElementById('caseDestinataireEnvoi_'+(compteurElement-1)).appendChild(link2);
		//document.getElementById('caseDestinataireEnvoi_'+(compteurElement-1)).parentNode.appendChild(br);
				
		newDiv.appendChild(newInput);

		divPrinc.appendChild(newDiv);
		
		autoCompletion2(compteurElement);	
		
	}
}


function supprimeChampEnvoyer(indice)
{
	var suppr = document.getElementById('caseDestinataireEnvoi_'+indice);
	var divPrinc = document.getElementById('inputDestinataire');
	
	divPrinc.removeChild(suppr);

	var compteur = 1;

	if(divPrinc.hasChildNodes())
	{
		var enfants = divPrinc.childNodes;
		var compteurElement = 1;

		for (var i = 0; i < enfants.length; i++)
		{
			if(enfants[i].tagName=='DIV')
			{
				enfants[i].setAttribute('id','caseDestinataireEnvoi_'+compteur);
				
				if(compteur == 1)
					enfants[i].style.paddingTop = '0px';
				
				var enfants2 = enfants[i].childNodes;
				
				for (var j = 0; j < enfants2.length; j++)
				{
					if(enfants2[j].tagName=='INPUT')
					{			
						enfants2[j].setAttribute('id','destinataireEnvoi_'+compteur);
						enfants2[j].setAttribute('name','destinataireEnvoi_'+compteur);
					}
					
					if(enfants2[j].tagName=='A')
					{			
						//enfants2[j].setAttribute('onclick','supprimeChamp("'+compteur+'");');
						enfants2[j].setAttribute('href','javascript: supprimeChampEnvoyer("'+compteur+'");');
					}
				}
				
				compteur++;
			}
		}
	}
}

function transfertContact2Envoyer2(mail)
{
	var tab = mail.split('|');
	
	for(var i = 0; i < tab.length; i++)
		transfertContact2Envoyer(tab[i]);
}

function transfertContact2Envoyer(mail)
{
	var divPrinc = document.getElementById('inputDestinataire');
	
	if(divPrinc.hasChildNodes())
	{
		var enfants = divPrinc.childNodes;
		var compteurElement = 1;
		var vide = false;
		var temp = '';

		for (var i = 0; i < enfants.length; i++)
		{
			if(enfants[i].tagName=='DIV')
			{
				var enfants2 = enfants[i].childNodes;
				
				for (var j = 0; j < enfants2.length; j++)
				{
					if(enfants2[j].tagName=='INPUT')
					{			
						if(enfants2[j].value==mail)
							return false;
									
						if(enfants2[j].id.search(/destinataireEnvoi/)!=-1)
						{	
							if(enfants2[j].id!='destinataireEnvoi_1')
							{
								if(enfants[i].value == "")
								{
									divPrinc.removeChild(enfants[i]);
								}
													
								compteurElement++;
							}
							
							if(enfants2[j].value == "")
							{
								vide = true;
								temp = compteurElement;
							}
						}	 
					}
				}
			}
		}
				
		var passe =  'false';		

		if(vide == false)
		{
			var inc = compteurElement;
			
			var link2 = document.createElement('a');
			var img = document.createElement('img');
						
			img.setAttribute('src','styles/default/graphs/bouton_supprimer_contact.gif');
			
			link2.setAttribute('href','javascript:supprimeChampEnvoyer("'+inc+'");');
						
			link2.appendChild(img);
			
			document.getElementById('caseDestinataireEnvoi_'+inc).appendChild(link2);
		}

		if(vide == false)
		{		
			var newDiv = document.createElement('div');
			var newInput = document.createElement('input');
			
			compteurElement++;
			
			newDiv.setAttribute('id','caseDestinataireEnvoi_'+compteurElement);
			newDiv.style.paddingTop = "5px";
			
			newInput.setAttribute('id', 'destinataireEnvoi_'+compteurElement);
			newInput.setAttribute('name', 'destinataireEnvoi_'+compteurElement);
			newInput.setAttribute('type','text');
			newInput.style.width = '165px';
			newInput.style.border = '1px solid black';
			
			newDiv.appendChild(newInput);

			divPrinc.appendChild(newDiv);
			
			autoCompletion2(compteurElement);
			
			document.getElementById('destinataireEnvoi_'+compteurElement).value = mail;
			
			passe = 'false';
		}
	
		var newDiv = document.createElement('div');
		var newInput = document.createElement('input');
		
		compteurElement++;
		
		newDiv.setAttribute('id','caseDestinataireEnvoi_'+compteurElement);
		newDiv.style.paddingTop = "5px";
		
		newInput.setAttribute('id', 'destinataireEnvoi_'+compteurElement);
		newInput.setAttribute('name', 'destinataireEnvoi_'+compteurElement);
		newInput.setAttribute('type','text');
		newInput.style.width = '165px';
		newInput.style.border = '1px solid black';
		
		newDiv.appendChild(newInput);

		divPrinc.appendChild(newDiv);
		
		autoCompletion2(compteurElement);
			
		if(passe=='false')
		{				
			document.getElementById('destinataireEnvoi_'+(compteurElement-1)).setAttribute('value',mail);
			var link2 = document.createElement('a');
			var img = document.createElement('img');
					
			img.setAttribute('src','styles/default/graphs/bouton_supprimer_contact.gif');
			
			link2.setAttribute('href','javascript:supprimeChampEnvoyer("'+(compteurElement-1)+'");');
			link2.appendChild(img);
			
			document.getElementById('caseDestinataireEnvoi_'+(compteurElement-1)).appendChild(link2);
		}
	}
}

function afficheChampPopupEnvoyer() 
{
	var cryptage=document.getElementById('cryptagePrivatePopup');

	if(cryptage.checked==true)
	{
		document.getElementById("champPassFichierPrivatePopupEnvoyer").style.visibility="visible";
		document.getElementById("champPassFichierPrivatePopupEnvoyer").style.display="inline";
	}
	else
	{
		document.getElementById("champPassFichierPrivatePopupEnvoyer").style.visibility="hidden";
		document.getElementById("champPassFichierPrivatePopupEnvoyer").style.display="none";
	}
	
}

function recupDestEnvoyer()
{
	var divPrinc = document.getElementById('inputDestinataire');
	var listeDestinataire = "";

	if(divPrinc.hasChildNodes())
	{
		var enfants = divPrinc.childNodes;
		var compteurElement = 1;

		for (var i = 0; i < enfants.length; i++)
		{
			if(enfants[i].tagName=='DIV')
			{
				var enfants2 = enfants[i].childNodes;
				
				for (var j = 0; j < enfants2.length; j++)
				{
					if(enfants2[j].tagName=='INPUT')
					{			
						if(enfants2[j].value!="")
							listeDestinataire = listeDestinataire + enfants2[j].value+ ",";
					}
				}
			}
		}
	}
	
	return listeDestinataire;		
}

function checkFormEnvoyer2()
{
	var nbCredit = 0;

	if(document.getElementById('flagTaille'))
		if(document.getElementById('flagTaille').value == 1)
			nbCredit++;
			
	if(document.getElementById('vieFichierUpload').value > 7)
		nbCredit++;
		
	if(document.getElementById('valOption1'))
		if(document.getElementById('valOption1').value == 1)
			nbCredit++;
	
	if(document.getElementById('valOption2'))
		if(document.getElementById('valOption2').value == 1)
			nbCredit++;

	$.post('index.php?controller=zoneprivee&action=checkCreditEnvoi',
		function(data) {
			if(data >= nbCredit)
				initUploadPrivateEnvoyer();
			else
				displayError('Vous n\'avez pas assez de cr&eacute;dits pour effectuer cet envoi.');
		});
}

function checkFormEnvoyer()
{
	initUploadPrivateEnvoyer();
}

function affichePaginationHisto(compteur)
{
	var divPrinc = document.getElementById('paginationHisto');

	if(divPrinc.hasChildNodes())
	{
		var enfants = divPrinc.childNodes;
		var compteurElement = 1;

		for (var i = 0; i < enfants.length; i++)
		{
			if(enfants[i].tagName=='SPAN')
			{
				if(enfants[i].id == "pag"+compteur)
				{
					enfants[i].style.visibility = "visible";
					enfants[i].style.display = "block";
				}
				else
				{
					enfants[i].style.visibility = "hidden";
					enfants[i].style.display = "none";
				}
			}
		}
	}
}

function affichePageHisto(borneMin, borneMax, page, ordre)
{
	document.getElementById("contenuListeHisto").style.top = "0px";
	
	document.getElementById('contenuListeHisto').innerHTML = "<div style='margin-left: 325px; text-align: center;'><img src='styles/default/graphs/ajax-loader.gif' style='width: 50px; height: 50px;' /></div>";

	$.post('index.php?controller=zoneprivee&action=affichePageHisto',
	{borneMin: borneMin, borneMax: borneMax, ordre: ordre},
	function(data) { 
		document.getElementById('contenuListeHisto').innerHTML = '<table border="0" cellpadding="0" cellspacing="0" width="680">'+
													'<tr class="headerTabHisto">'+
														'<td align="center" colspan="2" style="height: 22px;">Fichier(s)</td>'+
														'<td align="center" style="height: 22px;">Destinataire(s)</td>'+
														'<td align="center" style="height: 22px;">Poid(s)</td>'+
														'<td align="center" style="height: 22px;">Date(s) d\'envoi<span id="imgDate"><a id="linkOrdreDate" href="javascript: afficheHisto(\'ordre_croissant\');"><img id="imgTriDate" src="styles/default/graphs/decroissant.gif" width="9" height="10" alt="" /></a></span></td>'+
														'<td align="center" style="height: 22px;">T&eacute;l&eacute;charg&eacute;(s)</td>'+
														'<td align="center" style="height: 22px;">Prot&eacute;g&eacute;(s)</td>'+
														'<td align="center" style="height: 22px;">&nbsp;</td>'+
													'</tr>'+data+
												'</table>';
		
		generePaginationHisto(document.getElementById('option_pagination').value,page,ordre);
	});
}

function generePaginationHisto(diviseur,page,ordre)
{
	$.post('index.php?controller=zoneprivee&action=generePaginationHisto',
		{diviseur: diviseur, page: page, ordre: ordre},
		function(data) { 
			document.getElementById('paginationHisto').innerHTML = data;
		});
}

function goEtapeSuivanteCommande()
{
	var listeOption = document.getElementById('listeOption').value;
	var codePromo = document.getElementById('code_promo').value;
	var modePaiement = document.getElementById('listePaiement_popupCommande').value;
	var montantHT = document.getElementById('montantHTCommande').value;
	var tauxTva = document.getElementById('tvaCommande').value;
	
	if(modePaiement != '-1')
	{
		$.post('index.php?controller=zoneprivee&action=afficheEtapeSuivanteCommande',
		{listeOption: listeOption, codePromo: codePromo, modePaiement: modePaiement, montantHT: montantHT, tauxTva:tauxTva},
		function(data) { 
			document.getElementById('blocHautPrivate').innerHTML = data;
		});
	}
	else
		displayError('Veuillez choisir un mode de paiement.');
}

function valideCommandePrivateListe()
{
	var pays = document.getElementById('pays_commande').value;
	var type = document.getElementById('type_client_commande').value;
	var societe = document.getElementById('societe_commande').value;
	var titrem = document.getElementById('titre_m').checked;
	var titremme = document.getElementById('titre_mme').checked;
	var titremlle = document.getElementById('titre_mlle').checked;
	var nom = document.getElementById('nom_commande').value;
	var prenom = document.getElementById('prenom_commande').value;
	var email = document.getElementById('email_commande').value;
	var adresse = document.getElementById('adresse_commande').value;
	var adresse2 = document.getElementById('adresse2_commande').value;
	var cp = document.getElementById('cp_commande').value;
	var ville = document.getElementById('ville_commande').value;
	var indTel= document.getElementById('ind_tel_commande').value;
	var indFax= document.getElementById('ind_fax_commande').value;
	var indPortable= document.getElementById('ind_portable_commande').value;
	var tel= document.getElementById('tel_commande').value;
	var fax= document.getElementById('fax_commande').value;
	var portable= document.getElementById('portable_commande').value;
	var siret= document.getElementById('siret_commande').value;
	var ape= document.getElementById('ape_commande').value;
	var tva= document.getElementById('codeTva_commande').value;
	var estCoche = document.getElementById('tva_commande').checked;
	var ht= document.getElementById('montantHTCommande').value;
	var tauxtva= document.getElementById('tvaCommande').value;
	var typepaiement = document.getElementById('listePaiement_popupCommande').value;
	var codePromo = document.getElementById('code_promo').value;
	var listeOption = document.getElementById('listeOption').value;
	var titre;

	
	if(titrem==true)
		titre="M";
	else if(titremme==true)
		titre="Mme";
	else
		titre="Mlle";
	
	
	if(estCoche=='false')
		tva="";

	$.post('index.php?controller=zoneprivee&action=commande',
	{pays: pays, type: type, societe: societe, titre: titre, nom: nom, prenom: prenom, email: email, adresse: adresse, adresse2: adresse2, cp: cp, ville: ville, indtel: indTel, indfax: indFax, indportable: indPortable, tel: tel, fax: fax, portable: portable, siret: siret, ape: ape, tva: tva,  ht: ht, txtva: tauxtva, typepaiement: typepaiement, codepromo: codePromo, listeOption: listeOption},
	function(data) { proceedValideCommandePrivateListe(data); });
}

function proceedValideCommandePrivateListe(xhr)
{
	var retour = xhr;
	var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		if(xhr=='erreur_pays')
			displayError('Veuillez s&eacute;lectionnez un pays');
		else if(xhr=='erreur_type')
			displayError('Veuillez s&eacute;lectionnez un type de client');
		else if(xhr=='erreur_societe')
			displayError('Veuillez saisir une soci&eacute;t&eacute;');
		else if(xhr=='erreur_titre')
			displayError('Veuillez choisir un titre');
		else if(xhr=='erreur_nom')
			displayError('Veuillez saisir un nom');
		else if(xhr=='erreur_prenom')
			displayError('Veuillez saisir un pr&eacute;nom');
		else if(xhr=='erreur_mail')
			displayError('Veuillez saisir un mail valide');
		else if(xhr=='erreur_adresse')
			displayError('Veuillez saisir une adresse');
		else if(xhr=='erreur_cp')
			displayError('Veuillez saisir un code postal');
		else if(xhr=='erreur_ville')
			displayError('Veuillez saisir une ville');
		else if(xhr=='erreur_indtel')
			displayError('Veuillez saisir un indicatif t&eacute;l&eacute;phonique');
		else if(xhr=='erreur_tel')
			displayError('Veuillez saisir un num&eacute;ro de t&eacute;l&eacute;phone');
		else if(xhr=='erreur_typePaiement')
			displayError('Veuillez saisir un num&eacute;ro de t&eacute;l&eacute;phone');
			
	}
	else
	{
		$.post('index.php?controller=zoneprivee&action=paiementCommande',
		{ cmd: xhr },
		function(data) { document.getElementById('blocHautPrivate').innerHTML = data; });
	}
}

function getCookieVal(offset)
{
	var endstr=document.cookie.indexOf (";", offset);
	
	if (endstr==-1) endstr=document.cookie.length;
		return unescape(document.cookie.substring(offset, endstr));
}

function LireCookie(nom)
{
	var arg=nom+"=";
	var alen=arg.length;
	var clen=document.cookie.length;
	var i=0;
	
	while (i<clen)
	{
		var j=i+alen;
		
		if (document.cookie.substring(i, j)==arg)
			return getCookieVal(j);
		
		i=document.cookie.indexOf(" ",i)+1;
		
		if (i==0) break;
	}
	
	return null;
}

function gestionGroupe()
{
	$.post('index.php?controller=zoneprivee&action=gestionGroupe',
		function(data) { 
			document.getElementById('divAjoutContact').innerHTML = '';
			document.getElementById('divGestionGroupe').innerHTML = '';
			document.getElementById('titrePageContact').innerHTML = '';
			document.getElementById('paginationContact').innerHTML = '';
			document.getElementById('tableauContact').innerHTML = data;
			listeGroupe();
	});
}

function ajouteGroupe()
{
	$.post('index.php?controller=zoneprivee&action=ajouteGroupe',
		function(data) { 
			document.getElementById('afficheGroupe').innerHTML = data;
	});
}

function envoiContactListe()
{
	var valeur = $('#liste_contact').val();
	
	if(valeur != null)
	{
		for(var i=0; i < valeur.length; i++)
		{
			var text = $('#liste_contact option[value="'+valeur[i]+'"]').text();
		
			var newOption =  new Option(text,valeur[i],false,false);
			document.getElementById('liste_partage').options[document.getElementById('liste_partage').length] = newOption;
			
			for(var j=0;j<document.getElementById('liste_contact').length;j++)
			{
				if(document.getElementById('liste_contact').options[j].value == valeur[i])
					document.getElementById('liste_contact').options[j] = null;
			}
		}
	}
}

function renvoiContactListe()
{
	var valeur = $('#liste_partage').val();
	
	if(valeur != null)
	{
		for(var i=0; i < valeur.length; i++)
		{
			var text = $('#liste_partage option[value="'+valeur[i]+'"]').text();
		
			var newOption =  new Option(text,valeur[i],false,false);
			document.getElementById('liste_contact').options[document.getElementById('liste_contact').length] = newOption;
			
			for(var j=0;j<document.getElementById('liste_partage').length;j++)
			{
				if(document.getElementById('liste_partage').options[j].value == valeur[i])
					document.getElementById('liste_partage').options[j] = null;
			}
		}
	}
}

function valideAjouteGroupe()
{
	var nom = document.getElementById('nom_grp').value;
	var listePartage = '';	
	
	if(nom == '')
		displayError('Veuillez saisir le nom d\'un groupe.');
	else
	{
		for(var i=0;i<document.getElementById('liste_partage').length;i++)
		{
			listePartage += document.getElementById('liste_partage').options[i].value+"|";
		}

		$.post('index.php?controller=zoneprivee&action=valideAjouteGroupe',
				{nom: nom, listeContact: listePartage},
				function(data) {
					proceedValideAjouteGroupe(data); 
		});
	}
}

function proceedValideAjouteGroupe(xhr)
{
	var retour = xhr;
	var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		switch(xhr)
		{
			case 'erreur_nom':
				displayError('Groupe existant');
				break;
		}
	}
	else
		displayError('Groupe cr&eacute;&eacute;.');
}

function listeGroupe()
{
	$.post('index.php?controller=zoneprivee&action=listeGroupe',
		function(data) { 
			document.getElementById('afficheGroupe').innerHTML = data;
	});
}

function supprimeGroupe(idGroupe)
{
	if(confirm('Etes vous sur de vouloir supprimer ce groupe ?'))
	{
		$.post('index.php?controller=zoneprivee&action=supprimeGroupe',
				{id: idGroupe},
				function(data) {
					listeGroupe(); 
		});
	}
}

function modifieGroupe(idGroupe)
{
	$.post('index.php?controller=zoneprivee&action=modifieGroupe',
				{id: idGroupe},
				function(data) {
					document.getElementById('afficheGroupe').innerHTML = data;
				}
		);
}

function valideModifGroupe(idGroupe)
{
	var nom = document.getElementById('nom_grp').value;
	var listePartage = '';	

	if(nom == '')
		displayError('Veuillez saisir le nom d\'un groupe.');
	else
	{
		for(var i=0;i<document.getElementById('liste_partage').length;i++)
			listePartage += document.getElementById('liste_partage').options[i].value+"|";
				
		$.post('index.php?controller=zoneprivee&action=valideModifGroupe',
					{nom: nom, listeContact: listePartage, id: idGroupe},
					function(data) {
						proceedValideModifGroupe(data); 
			});
	}
}

function proceedValideModifGroupe(xhr)
{
	var retour = xhr;
	var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		switch(xhr)
		{
			case 'erreur_nom':
				displayError('Groupe existant');
				break;
		}
	}
	else
		displayError('Groupe modifi&eacute;.');
}

function valideGroupeContact(id)
{
	var valeur = document.getElementById('grp'+id).value;
	
	if(valeur == 0)
	{
		document.getElementById('caseGrp'+id).innerHTML = '<img src="styles/default/graphs/mini-ajax-loader.gif" />';
		
		$.post('index.php?controller=zoneprivee&action=supprimeContactGroupe',
			{id: id},
			function(data) {
				document.getElementById('caseGrp'+id).innerHTML = '<img src="styles/default/graphs/accept.png" />';
			});
	}
	else if(valeur == 'ajout')
	{
		$.post('index.php?controller=zoneprivee&action=gestionGroupe',
			function(data) { 
				document.getElementById('divAjoutContact').innerHTML = '';
				document.getElementById('divGestionGroupe').innerHTML = '';
				document.getElementById('titrePageContact').innerHTML = '';
				document.getElementById('paginationContact').innerHTML = '';
				document.getElementById('tableauContact').innerHTML = data;
				
				$.post('index.php?controller=zoneprivee&action=ajouteGroupe',
					{id: id},
					function(data) { 
						document.getElementById('afficheGroupe').innerHTML = data;
				});
			});
	}
	else if(valeur != '-1')
	{
		document.getElementById('caseGrp'+id).innerHTML = '<img src="styles/default/graphs/mini-ajax-loader.gif" />';
		
		$.post('index.php?controller=zoneprivee&action=ajouteContactGroupe',
			{id: id, valeur: valeur},
			function(data) {
				document.getElementById('caseGrp'+id).innerHTML = '<img src="styles/default/graphs/accept.png" />';
			});
	}
}

function valideAuthDropBox()
{
	if(document.getElementById('email_contact').value== '')
		displayError('Veuillez saisir une adresse email.');
	else
	{
		$.post('index.php?controller=dropbox&action=valideAuthDropBox',
			{email: document.getElementById('email').value, contact: document.getElementById('email_contact').value},
			function(data) {
				window.location.href = 'index.php?controller=dropbox&mail='+document.getElementById('email').value;
			});
	}
}

function valideUpload(id)
{
	var el = document.getElementById(id);
	
	if(!document.getElementById('load'+id))
	{
		var node = document.createElement('span');
		node.setAttribute('id','nodeTxt');
		node.innerHTML = '&nbsp;';
	
		var img = document.createElement('img');
		img.setAttribute('src', 'styles/default/graphs/mini-ajax-loader.gif');
		img.setAttribute('id','load'+id);
		img.style.verticalAlign = 'middle';
		
		el.parentNode.insertBefore(node, el.nextSibling);
		node.parentNode.insertBefore(img, node.nextSibling);
		
	}

	$.post('index.php?controller=zoneprivee&action=genereParam',
		function(data) {
			var tab = data.split('|');
		
			var path = tab[0];
			var action = tab[1];
		
			createProgressBar();

			document.form_upload.action = action;

			document.form_upload.submit();
			
			var req = false;
			req = createRequestObject();
			
			if(req)
			{
				if(LireCookie('dropBox') == '1')
					req.open("GET", "../../ajaxProxy.php?url=" + path + "&rnd_id=" + Math.random(), true);
				else
					req.open("GET", "ajaxProxy.php?url=" + path + "&rnd_id=" + Math.random(), true);
					
				req.onreadystatechange = function(){ proceedValideUpload(req,id,node); };
				req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				req.send(null);
			}
		});
}

function proceedValideUpload(req,id,elem)
{
	if(req.readyState == 4)
	{
		if(req.status == 200)
		{
			var xml = req.responseXML;
						
			 if (navigator.appName == "Microsoft Internet Explorer") 
			 {
				try{xml = new ActiveXObject("msxml2.xmldom" )}catch(e){err=e.message} 
				try{xml = new ActiveXObject("Microsoft.xmldom")}catch(e){err=e.message} 
				try{xml = new ActiveXObject("MSXML.xmldom" )}catch(e){err=e.message} 
				try{xml = new ActiveXObject("MSXML3.xmldom" )}catch(e){err=e.message} 
				if(!xml){ alert("ERREUR : "+err); return } 
				xml.loadXML(req.responseText);
			}
			else
				var xml = req.responseXML;
				
			stopUpload();
			
			var img = document.getElementById('load'+id);
			
			if(xml.getElementsByTagName('error_status').item(0).firstChild.nodeValue == 1)
			{
				img.setAttribute('src', 'styles/default/graphs/images/error.png');
				
				var link = document.createElement('a');
				link.setAttribute('id','testId');
				
				var el = document.getElementById(id);
				var msg =  new String (xml.getElementsByTagName('error_msg').item(0).firstChild.nodeValue);
				var reg=new RegExp("(ERROR)", "g");
				msg = msg.replace(reg,"Erreur");
				
				if(!document.getElementById('flagTaille'))
				{
					var flag = document.createElement('input');
					flag.setAttribute('type','hidden');
					flag.setAttribute('name','flagTaille');
					flag.setAttribute('id','flagTaille');
				}
				else
					var flag = document.getElementById('flagTaille');
				
				
				if(msg.search('Votre fichier ne peut pas dépasser') > -1)
				{
					$.post('index.php?controller=zoneprivee&action=checkCreditEnvoi',
						function(data) {
							if(data > 0)
							{
								link.setAttribute('href','index.php?controller=zoneprivee&contain=afficheComparatif');
								link.setAttribute('onmouseover', function() { return overlib("Cet envoi n&eacute;cessite l\'utilisation d\'un crédit.<br><br>Cette somme sera automatiquement d&eacute;bit&eacute;e.",WIDTH, 300); });
								link.onmouseover = function() { return overlib("Cet envoi n&eacute;cessite l\'utilisation d\'un crédit.<br><br>Cette somme sera automatiquement d&eacute;bit&eacute;e.",WIDTH, 300); };
							}
							else
							{
								link.setAttribute('href','index.php?controller=zoneprivee&contain=afficheComparatif');
								link.setAttribute('onmouseover',function() { return overlib("Cet envoi n&eacute;cessite l\'utilisation d\'un crédit.<br><br>Cliquez ici pour achetez des crédits",WIDTH, 300); });
								link.onmouseover = function() { return overlib("Cet envoi n&eacute;cessite l\'utilisation d\'un crédit.<br><br>Cliquez ici pour achetez des crédits",WIDTH, 300); };
							}
						});
					
					flag.setAttribute('value','1');					
				}
				else
				{
					link.setAttribute('onmouseover','return overlib("'+msg+'",WIDTH, 200);');
					link.onmouseover = function() { return overlib(msg,WIDTH, 200); };
					flag.setAttribute('value','0');
				}
							
				if(!document.getElementById('flagTaille'))
					document.body.appendChild(flag);
				
				link.setAttribute('onmouseout','return nd();');
				link.appendChild(img);
			
				elem.parentNode.insertBefore(link, elem.nextSibling);
			}
			else
				img.setAttribute('src', 'styles/default/graphs/images/accept.png');
		}
	}
}

function etapeAchatCredit()
{
	var compte = document.getElementById('rechargement_compte').checked;
	var contact = document.getElementById('rechargement_contact').checked;
	var valeurContact = document.getElementById('liste_contact').value;
	var groupe = document.getElementById('rechargement_groupe').checked;
	var valeurGroupe = document.getElementById('liste_groupe').value;
	
	var type = '';
	var valeur = '';
	
	var listeOffre = document.getElementById('listeOffre').value;
	var tab = listeOffre.split('|');
	var erreurOffre = true;
	var offreChoisie = 0;
		
	for(var i = 0;i < tab.length;i++)
	{
		if(tab[i] != '')
		{
			var offre = document.getElementById('credit'+tab[i]).checked;
			
			if(offre == true)
			{
				erreurOffre = false;
				offreChoisie = tab[i];
			}
		}
	}
	
	if(compte == false && contact == false && groupe == false)
	{
		displayError('Veuillez choisir un type de rechargement.');
		return;
	}
		
	if(erreurOffre == true)
	{
		displayError('Veuillez choisir une offre.');
		return;
	}
		
	if(contact == true)
	{
		if(valeurContact <= 0)
		{
			displayError('Veuillez choisir un contact.');
			return;
		}
		
		type = 'contact';
		valeur = valeurContact;
	}
	else if( groupe == true)
	{
		if(valeurGroupe <= 0)
		{
			displayError('Veuillez choisir un groupe.');
			return;
		}
	
		type = 'groupe';
		valeur = valeurGroupe;
	}
	else
	{
		type = 'compte';
		valeur = '';
	}

	document.getElementById('zoneAchatCredit').innerHTML = '<div style="width: 100%; text-align: center;"><img src="styles/default/graphs/ajax-loader.gif" style="width: 50px; height: 50px;" /></div>';

	$.post('index.php?controller=zoneprivee&action=etapeAchatCredit',
	{type: type, valeur: valeur, offre: offreChoisie},
	function(data) {
		document.getElementById('zoneAchatCredit').innerHTML = data;
	});
}

function valideAchatCredit()
{
	var offre = document.getElementById('offre').value;
	var type = document.getElementById('type').value;
	var valeur = document.getElementById('valeur').value;
	
	var type_paiement = document.getElementById('liste_paiement').value;
	
	if(type_paiement <= '-1')
	{
		displayError('Veuillez choisir un mode de paiement.');
		return;
	}
	
	document.getElementById('zoneAchatCredit').innerHTML = '<div style="width: 100%; text-align: center;"><img src="styles/default/graphs/ajax-loader.gif" style="width: 50px; height: 50px;" /></div>';
	
	$.post('index.php?controller=zoneprivee&action=valideAchatCredit',
	{type: type, valeur: valeur, offre: offre, type_paiement: type_paiement},
	function(data) {
		document.getElementById('zoneAchatCredit').innerHTML = data;
	});
	
}

function etapeAchatAbonnement()
{
	var compte = document.getElementById('rechargement_compte').checked;
	var contact = document.getElementById('rechargement_contact').checked;
	var valeurContact = document.getElementById('liste_contact').value;
		
	var type = '';
	var valeur = '';
	
		
	if(compte == false && contact == false && groupe == false)
	{
		displayError('Veuillez choisir un type de rechargement.');
		return;
	}
	if(contact == true)
	{
		if(valeurContact <= 0)
		{
			displayError('Veuillez choisir un contact.');
			return;
		}
		
		type = 'contact';
		valeur = valeurContact;
	}
	else
	{
		type = 'compte';
		valeur = '';
	}

	document.getElementById('zoneAchatAbonnement').innerHTML = '<div style="width: 100%; text-align: center;"><img src="styles/default/graphs/ajax-loader.gif" style="width: 50px; height: 50px;" /></div>';

	$.post('index.php?controller=zoneprivee&action=etapeAchatAbonnement',
	{type: type, valeur: valeur},
	function(data) {
		var res = data.split('|');
	
		if(res[0] == 'link')
			window.location.href = res[1];
		else
			document.getElementById('zoneAchatAbonnement').innerHTML = data;
		
	});
}

function valideAcheteAbonnement()
{
	var valeur = document.getElementById('valeur').value;
	var modePaiement = document.getElementById('listePaiementRenouvellement').value;
	var codePromo = document.getElementById('code_promo').value;
	var type = document.getElementById('type').value;
	
	$.post('index.php?controller=zoneprivee&action=valideAcheteAbonnement',
		{modePaiement: modePaiement, valeur: valeur, codePromo: codePromo, type: type},
		function(data) {
			document.getElementById('zoneAchatAbonnement').innerHTML = data;
		});
}

function checkDureeEnvoi(duree,id)
{
	if(duree > 7)
	{
		if(!document.getElementById('textExpiration'))
		{
			var span = document.createElement('span');
			span.innerHTML = 'L\'expiration de ce fichier coutera 1 cr&eacute;dit.';
			span.style.paddingLeft = '10px';	
			span.setAttribute('id','textExpiration');
			span.setAttribute('class','texte_11_gris');
			span.className = 'texte_11_gris';
			
			document.getElementById(id).parentNode.insertBefore(span, document.getElementById(id).nextSibling);
		}
	}
	else
	{
		if(document.getElementById('textExpiration'))
			document.getElementById(id).parentNode.removeChild(document.getElementById('textExpiration'));
	}
}

function afficheMsgCredit(check,el,num,br,pack)
{
	if(!br)
		br = '';

	if(document.getElementById(check).checked)
	{
		if(!document.getElementById('txtOption'+num))
		{
			if(!pack || pack == 1)
			{
				var span = document.createElement('span');
				span.innerHTML = br + 'Cette option coutera 1 cr&eacute;dit.';
				span.style.paddingLeft = '10px';	
				span.setAttribute('id','txtOption'+num);
			
				document.getElementById(el).parentNode.insertBefore(span, document.getElementById(el).nextSibling);
			}
			
			if(!document.getElementById('valOption'+num))
			{
				var newInput = document.createElement('input');
				newInput.setAttribute('type','hidden');
				newInput.setAttribute('id','valOption'+num);
				newInput.setAttribute('name','valOption'+num);
				newInput.setAttribute('value','1');
			
				document.body.appendChild(newInput);
			}
			else
				document.getElementById('valOption'+num).setAttribute('value','1');
		}
	}
	else
	{
		if(document.getElementById('valOption'+num))
			document.getElementById('valOption'+num).setAttribute('value','0');
	
		if(document.getElementById('txtOption'+num))
			document.getElementById(el).parentNode.removeChild(document.getElementById('txtOption'+num));
	}
}

function beforeInitUploadPrivate()
{
	var nbCredit = 0;
	
	if(document.getElementById('vieFichierUpload').value > 7)
		nbCredit++;
	
	if(document.getElementById('valOption1'))
		if(document.getElementById('valOption1').value == '1')
			nbCredit++;
	
	if(document.getElementById('valOption2'))
		if(document.getElementById('valOption2').value == '1')
			nbCredit++;
	
	$.post('index.php?controller=zoneprivee&action=checkCreditEnvoi',
		function(data) {
			if(data >= nbCredit)
				initUploadPrivate();
			else
				displayError('Vous n\'avez pas assez de cr&eacute;dits pour effectuer cet envoi.');
		});	
}

function resizePopup()
{
	if(document.getElementById("accusePrivatePopup").checked)
		agrandirPopupUpload('+');
	else
		agrandirPopupUpload('-');
}

function resizePopupRenvoi()
{
	if(document.getElementById("accusePrivatePopup").checked)
		agrandirPopupRenvoi('+');
	else
		agrandirPopupRenvoi('-');
}

function chargeTextMsgDropbox(email, value, url)
{
	var text = $('#listeDest option[value="'+value+'"]').text();

	document.getElementById('msg_invitation').innerHTML = "Bonjour,\n\n"+email+" vous invite à lui envoyer un fichier (jusqu\'à 2Go).\nPour ce faire, vous devez simplement cliquer sur le lien ci-dessous et indiquer votre adresse e-mail "+text+" :\n"+url;
}

function copyToClipboardIE1(sText)
{
   // Le contenu actuel du presse-papier sera écrasé par la valeur de sText.
   window.clipboardData.setData('Text', sText);
   // On ne veut pas suivre le lien après le clic.
   return false;
}

function copyToClipboardFF(sText)
{
   try
   {
      // On test si la configuration permet l'accès au presse-papier.
      netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
   }
   catch (e)
   {
		return false;
   }
   // Initialisation du composant fournit par Mozilla.
   var gClipboardHelper =
      Components.classes["@mozilla.org/widget/clipboardhelper;1"]
      .getService(Components.interfaces.nsIClipboardHelper);
   // Copie du texte dans le presse papier.
   gClipboardHelper.copyString(sText);
   // On ne veut pas suivre le lien après le clic.
   return false;
}

function copyToClipboard(sText)
{
   // Cas où on a accès à l'objet clipboardData.
   if (window.clipboardData)
   {
      return copyToClipboardIE1(sText);
   }
   // Cas où on peut tester la configuration de Firefox sur
   else if (typeof(netscape) == 'object' && typeof(Components) == 'object')
   {
      return copyToClipboardFF(sText);
   }
   
   return false;
}

function supprimeCompte()
{
	if(confirm('Etes-vous certain de vouloir supprimer votre compte et l\'intégralité de son contenu ?'))
	{
		$.post('index.php?controller=zoneprivee&action=supprimeCompte',
			function(data) {
				popBox('view/popup_confirmation_suppr.php');
			});
	}
}

/*
** Edition en cours : permet de n'avoir qu'une seule boite de dialogue ouverte.
** sauvegardeEffectuée : permet d'éviter d'envoyer 2 requetes en validant.
*/

var editionEnCours = false;
var sauvegardeEffectuee = false;


/*******************************************************
********************************************************
*** Recupere la lageur du texte
********************************************************
*******************************************************/

function getTextWidth(texte)
{
	//Valeur par défaut : 150 pixels
	var largeur = 150;

	if(trim(texte) == "")
	{
		return largeur;
	}

	//Création d'un span caché que l'on "mesurera"
	var span = document.createElement("span");
	span.style.visibility = "hidden";
	span.style.position = "absolute";

	//Ajout du texte dans le span puis du span dans le corps de la page
	span.appendChild(document.createTextNode(texte));
	document.body.appendChild(span);

	//Largeur du texte
	largeur = span.offsetWidth;

	//Suppression du span
	document.body.removeChild(span);
	span = null;

	return largeur;
}

/*******************************************************
********************************************************
*** Renvoie un objet XmlHTTPRequest
********************************************************
*******************************************************/


function getXMLHTTP()
{
    var xhr = null;
    if(window.XMLHttpRequest)
    { // Firefox et autres
        xhr = new XMLHttpRequest();
    }
    else if(window.ActiveXObject)
    { // Internet Explorer
        try
        {
            xhr = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(e)
        {
            try
            {
                xhr = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(e1)
            {
                xhr = null;
            }
        }
    }
    else
    { // XMLHttpRequest non supporté par le navigateur
        alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
    }

    return xhr;
}

/*******************************************************
********************************************************
*** Ferme le mode d'édition et sauvegarde la valeur.
********************************************************
*******************************************************/

function closeEditMode(xhr, obj, txt)
{
  if (xhr.readyState == 4)
  {
    if (xhr.status == 200)
    {
      var response = xhr.responseText;

	//alert(response);
      if (response == 'ok')
      {
        obj.removeChild(obj.firstChild);
        var regexp = new RegExp('\n', 'g');
        txt = txt.replace(regexp, '<br/>');
        /*if (obj.innerText)
        {
          obj.innerText= txt;
        }
        else
        {
          obj.textContent = txt;
        }*/
        obj.innerHTML = txt;
        sauvegardeEffectuee = true;
        editionEnCours = false;
	var completeDiv = document.getElementById('completeDiv');
	document.body.removeChild(completeDiv);
	afficheListeCategorie();
      }
      else
      {
		if(xhr.responseText=='erreur_existant')
		{
			displayError('Categorie existante');
		}
      }
    }
    else
    {
      alert('Sauvegarde impossible.' + xhr.status);
    }
  }
}

/*******************************************************
********************************************************
*** Envoie la requete ajax lors de la fermeture de la
*** boite d'édition.
********************************************************
*******************************************************/
/*
	-id : id de l'enregistrement dans la base
	-nom : nom du champs à modifier dans la base
	-txt : nouvelle valeur à modifier
	-mode : nom de la table*/

function saveModification(obj, valeur, idFic)
{
  if (sauvegardeEffectuee == true)
  {
    return false;
  }
  var xhr = getXMLHTTP();

  var data = 'categorie=' + valeur + '&idfichier=' + idFic;

  xhr.open('POST', 'index.php?controller=zoneprivee&action=verifCategorie', true);
  xhr.onreadystatechange = function() { closeEditMode(xhr, obj, valeur) };
  xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  xhr.send(data);
}

/*******************************************************
********************************************************
*** Recupere la touche appuyée (evenement onKeyDown)
********************************************************
*******************************************************/

function getKeyCode(evenement)
{
    for (prop in evenement)
    {
        if(prop == 'which')
        {
            return evenement.which;
        }
    }

    return evenement.keyCode;
}

/*******************************************************
********************************************************
*** Core de la fonction d'edition
********************************************************
*******************************************************/

function editSupports(obj, idFic)
{
/*alert("id : "+id);
alert("obj : "+obj);
alert("nom : "+nom);
alert("mode : "+mode);
alert("type : "+type);
alert("position : "+position);
alert("ordre : "+ordre);*/
   // on n'ouvre pas plus d'une boite simultanément.
  if (editionEnCours == false)
    editionEnCours = true;
  else
    return false;
  sauvegardeEffectuee = false;
  if (obj.innerText)            //récupération de la valeur du champ
	{
  	txt = obj.innerText;
  	obj.innerText = '';
	}
	else
	{
  	txt = obj.textContent;
  	obj.textContent = '';
	}
	
	var input = document.createElement('input');
	input.style.width  = getTextWidth(txt) + 15 + "px";
	input.className="inputCat";
	input.id="catSaisi";
	input.setAttribute("autocomplete","off");
	initAutoComplete(input);
	//input.onkeypress=alert('toto');


   input.value = txt;
  //fonction appelée losque l'édition perdra le focus.
  /*input.onblur = function() {
    saveModification(obj, input.value,idFic);
    delete input;
  };*/
  //fonction appelée losque l'utilisateur valide sa saisie.

    input.onkeydown = function (event)
    {
      if (!event && window.event)
      {
        event = window.event; //IE style.
      }
      if (getKeyCode(event) == 13)
      {
        saveModification(obj, input.value, idFic);
        delete input;
      }
    };

  // on ajoute l'input au DOM et on lui donne le focus.
  obj.appendChild(input);
  input.focus();
}

function trim(s) {
    return s.replace(/^\s+/, '').replace(/\s+$/, '');
}


var upload_range;
function displayPopUpBeforeUpload()
{
  popBox('view/popup.html');
}

function proceedInitUpload(xhr)
{
 var retour = xhr;
 var resultat = retour.search(/erreur/);
 var hauteurDroit;
 var hauteurGauche;
 var hauteurGlobale;

	if(resultat != -1)
	{
		switch(xhr)
		{
			case 'erreur_mail':
				displayError('Votre email n\'est pas correct');
				break;
				
			case 'erreur_destinataire':
				displayError('Un ou des emails des destinataires ne sont pas corrects');
				break;
				
			case 'erreur_mail_existant':
				//displayError('Ce mail est déjà utilisé pour un compte. Veuillez vous connectez à votre espace client.');
				
				if(document.getElementById('erreur_mail').innerHTML=="")
				{
					hauteurDroit = document.getElementById('popupDroit').offsetHeight +30;
					hauteurGauche = document.getElementById('popupGauche').offsetHeight +30;
					hauteurGlobale = document.getElementById('popup').offsetHeight +30;
					
					document.getElementById('popupDroit').style.height=hauteurDroit + "px";
					document.getElementById('popupGauche').style.height=hauteurGauche+"px";
					document.getElementById('popup').style.height=hauteurGlobale+"px";
					
					document.getElementById('erreur_mail').innerHTML="E-mail est d&eacute;j&agrave; enregistr&eacute;e. Connectez-vous dans votre Espace client.";
				}
				break;
		}
	}
	else
	{
		//On connait maintenant le serveur pour l'upload :
		var res = xhr;
		var tab = res.split(',');
		var url = tab[0];
		var id = tab[1];
		var idClient = tab[2];
		
		var inputIdClient = document.createElement('input');
		
		inputIdClient.type = 'hidden';
		inputIdClient.id = 'idClientUpload';
		inputIdClient.value = idClient;
		
		document.body.appendChild(inputIdClient);
		
		//if(navigator.userAgent.indexOf("Safari") != -1) 
		//	document.form_upload.target = '_self';
		
		document.form_upload.action = 'https://' + url + '/cgi-bin/uu_upload.pl?tmp_sid=' + id;
		path_to_ini_status_script = "http://" + url + '/cgi-bin/uu_ini_status.pl?tmp_sid=' + id;
		uploadFiles(url, upload_range);
	}
}

function initUpload()
{

   	var maListe = document.getElementById('upload_slots');
	 var erreur=0;
	var compteur=0;
	if (maListe.hasChildNodes())
	{
		var collEnfants = maListe.childNodes;
		for (var i = 0; i < collEnfants.length; i++)
		{
			if(collEnfants[i].tagName=="DIV")
				compteur++;
		}
	}

	upload_range=compteur;

	if(checkFileNameFormat())
		erreur=1;

	if(checkDisallowFileExtensions())
		erreur=2;
		
	if(checkAllowFileExtensions())
		erreur=3;
		
	if(checkNullFileCount())
		erreur=4;
		
	if(checkDuplicateFileCount())
		erreur=5;

	if(erreur>0)
	{
		switch(erreur)
		{
			case 1:
				alert("Désolé le format de fichier est incorrect. Assurez vous que le fichier respecte le format suivant : \n\n1. Le nom du fichier ne doit pas éxcéder 128 caractères\n2. Le format doit etre du type \"nomfichier.extension\" ou \"nomfichier\"\n3. Les caractères autorisés sont 1-9, a-z, A-Z, '_', '-'\n");
				break;
				
			case 2:
				alert('Désolé les fichiers avec cette extension ne sont pas autorisés.');
				break;
				
			case 3:
				alert('Désolé les fichiers avec cette extension ne sont pas autorisés.');
				break;
				
			case 4:
				alert("Merci de choisir un fichier.");
				break;
				
			case 5:
				alert("Merci de ne pas envoyer 2 fichiers identiques.");
				break;
		}
	}
	else
	{
		createProgressBar();
		
		//envoyer la requete pour sauvegarder les infos
		$.post('index.php?controller=zonepublic&action=initUpload',
		{dest: document.getElementById('destinataire').value, mail: document.getElementById('emailUpload').value, sujet: document.getElementById('sujet').value, message: document.getElementById('message').value, expiration: document.getElementById('vieFichierUpload').value},
		function(data) { proceedInitUpload(data); });
	}
}

function sendFile()
{
  document.form_upload.submit();
}

function createProgressBar()
{
	var div = document.createElement('div');
	div.id="progressBarDiv";
	div.style.align="center";
	div.innerHTML="";
	div.innerHTML='<div class="info" id="progress_info"></div><div id="progress_bar" style="display:none" align="center"><div class="bar1" id="upload_status_wrap" align="center" valign="middle"><div class="bar2" id="upload_status" valign="middle"></div></div><br><table class="data" cellpadding="3" cellspacing="1" align="center"><tr><td align="left"><b>Pourcentage compl&eacute;t&eacute;:</b></td><td align="center"><span id="percent">0%</span></td></tr><tr><td align="left"><b>Ko transmis :</b></td><td align="center"><span id="current">0</span> / <span id="total_kbytes"></span> Ko</td></tr><tr><td align="left"><b>Fichiers t&eacute;l&eacute;charg&eacute;s :</b></td><td align="center"><span id="uploaded_files">0</span> sur <span id="total_uploads"></span></td></tr><tr><td align="left"><b>Temps restant estim&eacute; :</b></td><td align="center"><span id="remain">0</span></td></tr></table></div><div id="upload_div" style="display:block; width:400; height:205; overflow:hidden;"><iframe name="upload_iframe" frameborder=0 width="400" height="0"></iframe></div>';
	document.body.appendChild(div);
}

 function proceedInitUploadPrivateEnvoyer(xhr)
{
	var retour = xhr;
	var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		switch(xhr)
		{
			case 'erreur_destinataire':
				displayError('Un ou des emails des destinataires ne sont pas corrects');
				break;
		}
	}
	else
	{
		//On connait maintenant le serveur pour l'upload :
		var res = xhr;
		var tab = res.split(',');
		var url = tab[0];
		var id = tab[1];
		var conf = tab[2];
		
		//if(navigator.userAgent.indexOf("Safari") != -1) 
		//	document.form_upload.target = '_self';
		
		document.form_upload.action = 'https://' + url + '/cgi-bin/uu_upload.pl?tmp_sid=' + id +'&config_file=' + conf;
		path_to_ini_status_script = "http://" + url + '/cgi-bin/uu_ini_status.pl?tmp_sid=' + id +'&config_file=' + conf;
		
		popBoxLight();
		
		uploadFiles(url, upload_range);
	}
}

 function proceedInitUploadPrivate(xhr)
{
 var retour = xhr;
 var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		switch(xhr)
		{
				
			case 'erreur_destinataire':
				displayError('Un ou des emails des destinataires ne sont pas corrects');
				break;
		}
	}
	else
	{
		//On connait maintenant le serveur pour l'upload :
		var res = xhr;
		var tab = res.split(',');
		var url = tab[0];
		var id = tab[1];
		var conf = tab[2];
		
		//if(navigator.userAgent.indexOf("Safari") != -1) 
		//	document.form_upload.target = '_self';
		
		document.form_upload.action = 'https://' + url + '/cgi-bin/uu_upload.pl?tmp_sid=' + id +'&config_file=' + conf;
		path_to_ini_status_script = "http://" + url + '/cgi-bin/uu_ini_status.pl?tmp_sid=' + id +'&config_file=' + conf;
			
		uploadFiles(url, upload_range);
	}
}

 function proceedInitUploadPrivateDropBox(xhr)
{
 var retour = xhr;
 var resultat = retour.search(/erreur/);

	if(resultat != -1)
	{
		switch(xhr)
		{
				
			case 'erreur_destinataire':
				displayError('Un ou des emails des destinataires ne sont pas corrects');
				break;
		}
	}
	else
	{
		//On connait maintenant le serveur pour l'upload :
		var res = xhr;
		var tab = res.split(',');
		var url = tab[0];
		var id = tab[1];
		var conf = tab[2];
		
		//if(navigator.userAgent.indexOf("Safari") != -1) 
		//	document.form_upload.target = '_self';
		
		document.form_upload.action = 'https://' + url + '/cgi-bin/uu_upload.pl?tmp_sid=' + id +'&config_file=' + conf;
		path_to_ini_status_script = "http://" + url + '/cgi-bin/uu_ini_status.pl?tmp_sid=' + id +'&config_file=' + conf;
		
		popBoxLight();
		
		uploadFiles(url, upload_range);
	}
}

function initUploadDropbox()
{
	var maListe = document.getElementById('upload_slots');
	var erreur=0;
	var compteur=0;
	if (maListe.hasChildNodes())
	{
		var collEnfants = maListe.childNodes;
		for (var i = 0; i < collEnfants.length; i++)
		{
			if(collEnfants[i].tagName=="DIV")
				compteur++;
		}
	}
	
	upload_range=compteur;

	if(checkFileNameFormat())
		erreur=1;

	if(checkDisallowFileExtensions())
		erreur=2;
		
	if(checkAllowFileExtensions())
		erreur=3;
		
	if(checkNullFileCount())
		erreur=4;
		
	if(checkDuplicateFileCount())
		erreur=5;

	if(erreur>0)
	{
		switch(erreur)
		{
			case 1:
				alert("Désolé le format de fichier est incorrect. Assurez vous que le fichier respecte le format suivant : \n\n1. Le nom du fichier ne doit pas éxcéder 128 caractères\n2. Le format doit etre du type \"nomfichier.extension\" ou \"nomfichier\"\n3. Les caractères autorisés sont 1-9, a-z, A-Z, '_', '-'\n");
				break;
				
			case 2:
				alert('Désolé les fichiers avec cette extension ne sont pas autorisés.');
				break;
				
			case 3:
				alert('Désolé les fichiers avec cette extension ne sont pas autorisés.');
				break;
				
			case 4:
				alert("Merci de choisir un fichier.");
				break;
				
			case 5:
				alert("Merci de ne pas envoyer 2 fichiers identiques.");
				break;
		}
	}
	else
	{	
		var listingDestinataire = recupDestEnvoyer();
		createProgressBar();
		//envoyer la requete pour sauvegarder les infos
		
		$.post('../../index.php?controller=dropbox&action=initUpload',
		{dest: listingDestinataire, sujet: document.getElementById('sujetPrivate').value, message: document.getElementById('messagePrivate').value, cryptage: document.getElementById('cryptagePrivatePopup').checked, accuse: document.getElementById('accusePrivatePopup').checked, expiration: document.getElementById('vieFichierUpload').value, pwd: document.getElementById('passFichierPopup').value},
		function(data) { proceedInitUploadPrivateDropBox(data); });
	}
}

function initUploadPrivateEnvoyer()
{	
   	var maListe = document.getElementById('upload_slots');
	var erreur=0;
	var compteur=0;
	if (maListe.hasChildNodes())
	{
		var collEnfants = maListe.childNodes;
		for (var i = 0; i < collEnfants.length; i++)
		{
			if(collEnfants[i].tagName=="DIV")
				compteur++;
		}
	}
	
	upload_range=compteur;

	if(checkFileNameFormat())
		erreur=1;

	if(checkDisallowFileExtensions())
		erreur=2;
		
	if(checkAllowFileExtensions())
		erreur=3;
		
	if(checkNullFileCount())
		erreur=4;
		
	if(checkDuplicateFileCount())
		erreur=5;

	if(erreur>0)
	{
		switch(erreur)
		{
			case 1:
				alert("Désolé le format de fichier est incorrect. Assurez vous que le fichier respecte le format suivant : \n\n1. Le nom du fichier ne doit pas éxcéder 128 caractères\n2. Le format doit etre du type \"nomfichier.extension\" ou \"nomfichier\"\n3. Les caractères autorisés sont 1-9, a-z, A-Z, '_', '-'\n");
				break;
				
			case 2:
				alert('Désolé les fichiers avec cette extension ne sont pas autorisés.');
				break;
				
			case 3:
				alert('Désolé les fichiers avec cette extension ne sont pas autorisés.');
				break;
				
			case 4:
				alert("Merci de choisir un fichier.");
				break;
				
			case 5:
				alert("Merci de ne pas envoyer 2 fichiers identiques.");
				break;
		}
	}
	else
	{
		var listingDestinataire = recupDestEnvoyer();
		createProgressBar();
		//envoyer la requete pour sauvegarder les infos
		
		$.post('index.php?controller=zoneprivee&action=initUpload',
		{dest: listingDestinataire, sujet: document.getElementById('sujetPrivate').value, message: document.getElementById('messagePrivate').value, cryptage: document.getElementById('cryptagePrivatePopup').checked, accuse: document.getElementById('accusePrivatePopup').checked, expiration: document.getElementById('vieFichierUpload').value, pwd: document.getElementById('passFichierPopup').value},
		function(data) { 
			proceedInitUploadPrivateEnvoyer(data);
		});
	}
 }
 
 function initUploadPrivateDossier(idDossier,pack)
{	
	var nbCredit = 0;

	if(document.getElementById('vieFichierUpload').value > 7)
		nbCredit++;

	$.post('index.php?controller=zoneprivee&action=checkCreditEnvoi',
		function(data) {
			if(data >= nbCredit || pack == 2)
			{
				var maListe = document.getElementById('upload_slots');
				var erreur=0;
				var compteur=0;
				if (maListe.hasChildNodes())
				{
					var collEnfants = maListe.childNodes;
					for (var i = 0; i < collEnfants.length; i++)
					{
						if(collEnfants[i].tagName=="DIV")
							compteur++;
					}
				}
				
				upload_range=compteur;

				if(checkFileNameFormat())
					erreur=1;

				if(checkDisallowFileExtensions())
					erreur=2;
					
				if(checkAllowFileExtensions())
					erreur=3;
					
				if(checkNullFileCount())
					erreur=4;
					
				if(checkDuplicateFileCount())
					erreur=5;

				if(erreur>0)
				{
					switch(erreur)
					{
						case 1:
							alert("Désolé le format de fichier est incorrect. Assurez vous que le fichier respecte le format suivant : \n\n1. Le nom du fichier ne doit pas éxcéder 128 caractères\n2. Le format doit etre du type \"nomfichier.extension\" ou \"nomfichier\"\n3. Les caractères autorisés sont 1-9, a-z, A-Z, '_', '-'\n");
							break;
							
						case 2:
							alert('Désolé les fichiers avec cette extension ne sont pas autorisés.');
							break;
							
						case 3:
							alert('Désolé les fichiers avec cette extension ne sont pas autorisés.');
							break;
							
						case 4:
							alert("Merci de choisir un fichier.");
							break;
							
						case 5:
							alert("Merci de ne pas envoyer 2 fichiers identiques.");
							break;
					}
				}
				else
				{
					popBoxLight();
				
					createProgressBar();
					//envoyer la requete pour sauvegarder les infos
					
					$.post('index.php?controller=zoneprivee&action=initUploadDossier',
					{expiration: document.getElementById('vieFichierUpload').value, idDossier: idDossier},
					function(data) { proceedInitUploadPrivateDossier(data); });
				}
			}
			else
				displayError('Vous n\'avez pas assez de cr&eacute;dits pour effectuer cet envoi.');
		}
	);
 }
 
 function proceedInitUploadPrivateDossier(xhr)
{
	//On connait maintenant le serveur pour l'upload :
	var res = xhr;
	var tab = res.split(',');
	var url = tab[0];
	var id = tab[1];
	var conf = tab[2];
	
	//if(navigator.userAgent.indexOf("Safari") != -1) 
	//	document.form_upload.target = '_self';
	
	document.form_upload.action = 'https://' + url + '/cgi-bin/uu_upload.pl?tmp_sid=' + id +'&config_file=' + conf;
	path_to_ini_status_script = "http://" + url + '/cgi-bin/uu_ini_status.pl?tmp_sid=' + id +'&config_file=' + conf;
		
	uploadFiles(url, upload_range);
}

function initUploadPrivate()
{

   	var maListe = document.getElementById('upload_slots');
	var erreur=0;
	var compteur=0;
	if (maListe.hasChildNodes())
	{
		var collEnfants = maListe.childNodes;
		for (var i = 0; i < collEnfants.length; i++)
		{
			if(collEnfants[i].tagName=="DIV")
				compteur++;
		}
	}
	
	upload_range=compteur;

	if(checkFileNameFormat())
		erreur=1;

	if(checkDisallowFileExtensions())
		erreur=2;
		
	if(checkAllowFileExtensions())
		erreur=3;
		
	if(checkNullFileCount())
		erreur=4;
		
	if(checkDuplicateFileCount())
		erreur=5;

	if(erreur>0)
	{
		switch(erreur)
		{
			case 1:
				alert("Désolé le format de fichier est incorrect. Assurez vous que le fichier respecte le format suivant : \n\n1. Le nom du fichier ne doit pas éxcéder 128 caractères\n2. Le format doit etre du type \"nomfichier.extension\" ou \"nomfichier\"\n3. Les caractères autorisés sont 1-9, a-z, A-Z, '_', '-'\n");
				break;
				
			case 2:
				alert('Désolé les fichiers avec cette extension ne sont pas autorisés.');
				break;
				
			case 3:
				alert('Désolé les fichiers avec cette extension ne sont pas autorisés.');
				break;
				
			case 4:
				alert("Merci de choisir un fichier.");
				break;
				
			case 5:
				alert("Merci de ne pas envoyer 2 fichiers identiques.");
				break;
		}
	}
	else
	{
		var listingDestinataire = recupDest();
		createProgressBar();
		//envoyer la requete pour sauvegarder les infos
		
		$.post('index.php?controller=zoneprivee&action=initUpload',
		{dest: listingDestinataire, sujet: document.getElementById('sujetPrivate').value, message: document.getElementById('messagePrivate').value, cryptage: document.getElementById('cryptagePrivatePopup').checked, accuse: document.getElementById('accusePrivatePopup').checked, expiration: document.getElementById('vieFichierUpload').value, pwd: document.getElementById('passFichierPopup').value},
		function(data) { proceedInitUploadPrivate(data); });
	}
 }

//******************************************************************************************************
//   ATTENTION: THIS FILE HEADER MUST REMAIN INTACT. DO NOT DELETE OR MODIFY THIS FILE HEADER.
//
//   Name: uu_file_upload.js
//   Revision: 2.1
//   Date: 25/05/2007 11:09PM
//   Link: http://uber-uploader.sourceforge.net
//   Initial Developer: Peter Schmandra  http://www.webdice.org
//
//   Licence:
//   The contents of this file are subject to the Mozilla Public
//   License Version 1.1 (the "License"); you may not use this file
//   except in compliance with the License. You may obtain a copy of
//   the License at http://www.mozilla.org/MPL/
//
//   Software distributed under the License is distributed on an "AS
//   IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
//   implied. See the License for the specific language governing
//   rights and limitations under the License.
//
//***************************************************************************************************************

//var upload_range = 1;
var get_status_speed;
var get_status_url;
var get_data_loop = false;
var seconds = 0;
var minutes = 0;
var hours = 0;
var info_width = 0;
var info_bytes = 0;
var info_time_width = 500;
var info_time_bytes = 15;
var cedric_hold = true;
var total_upload_size = 0;
var total_Kbytes = 0;
var limite_vitesse=100;

function TJS_Remplacer(chaine) {
	chaine=chaine.replace(/[éèêë]/g,"e");
	chaine=chaine.replace(/[àâä]/g,"a");
	chaine=chaine.replace(/[ïî]/g,"i");
	chaine=chaine.replace(/[ùûü]/g,"u");
	chaine=chaine.replace(/[öô]/g,"o");
	return chaine;
}

// Check the file format before uploading
function checkFileNameFormat(){

	//if(!check_file_name_format){ return false; }

	for(var i = 0; i < upload_range; i++){
		if(document.form_upload.elements['upfile_' + i].value != ""){
			var string = document.form_upload.elements['upfile_' + i].value;
			var num_of_last_slash = string.lastIndexOf("\\");

			if(num_of_last_slash < 1){ num_of_last_slash = string.lastIndexOf("/"); }

			var file_name = string.slice(num_of_last_slash + 1, string.length);
			var re = /^[\w\.\-\°\s][\w\.\-\°\s]{1,128}$/i;

			var file_name = TJS_Remplacer(file_name);
						
			if(!re.test(file_name)){
				//alert("Sorry, uploading files in this format is not allowed. Please ensure your file names follow this format. \n\n1. Entire file cannot exceed 128 characters\n2. Format should be filename.extension or filename\n3. Legal characters are 1-9, a-z, A-Z, '_', '-'\n");
				return true;
			}
		}
	}
	return false;
}

// Check for illegal file extentions
function checkDisallowFileExtensions(){
	//if(!check_disallow_extensions){ return false; }

	for(var i = 0; i < upload_range; i++){
		if(document.form_upload.elements['upfile_' + i].value != ""){
					
			if(document.form_upload.elements['upfile_' + i].value.match(disallow_extensions)){
				var string = document.form_upload.elements['upfile_' + i].value;
				var num_of_last_slash = string.lastIndexOf("\\");

				if(num_of_last_slash < 1){ num_of_last_slash = string.lastIndexOf("/"); }

				var file_name = string.slice(num_of_last_slash + 1, string.length);
				var file_extension = file_name.slice(file_name.indexOf(".")).toLowerCase();
				
				//alert('Sorry, uploading a file with the extension "' + file_extension + '" is not allowed.');
				return true;
			}
		}
	}
	return false;
}

// Check for legal file extentions
function checkAllowFileExtensions(){
	if(!check_allow_extensions){ return false; }

	for(var i = 0; i < upload_range; i++){
		if(document.form_upload.elements['upfile_' + i].value != ""){
			if(!document.form_upload.elements['upfile_' + i].value.match(allow_extensions)){
				var string = document.form_upload.elements['upfile_' + i].value;
				var num_of_last_slash = string.lastIndexOf("\\");

				if(num_of_last_slash < 1){ num_of_last_slash = string.lastIndexOf("/"); }

				var file_name = string.slice(num_of_last_slash + 1, string.length);
				var file_extension = file_name.slice(file_name.indexOf(".")).toLowerCase();

				//alert('Sorry, uploading a file with the extension "' + file_extension + '" is not allowed.');
				return true;
			}
		}
	}
	return false;
}

// Make sure the user selected at least one file
function checkNullFileCount(){
	//if(!check_null_file_count){ return false; }

	var null_file_count = 0;
	//alert(upload_range);
	for(var i = 0; i < upload_range; i++){
		if(document.form_upload.elements['upfile_' + i].value == ""){ null_file_count++; }
	}

	if(null_file_count == upload_range){
		//alert("Please Choose A File To Upload.");
		return true;
	}
	else{ return false; }
}

// Make sure the user is not uploading duplicate files
function checkDuplicateFileCount(){
	//if(!check_duplicate_file_count){ return false; }

	var duplicate_flag = false;
	var file_count = 0;
	var duplicate_msg = "Duplicate Upload Files Detected.\n\n";
	var file_name_array = new Array();

	for(var i = 0; i < upload_range; i++){
		if(document.form_upload.elements['upfile_' + i].value != ""){
			var string = document.form_upload.elements['upfile_' + i].value;
			var num_of_last_slash = string.lastIndexOf("\\");

			if(num_of_last_slash < 1){ num_of_last_slash = string.lastIndexOf("/"); }

			var file_name = string.slice(num_of_last_slash + 1, string.length);

			file_name_array[i] = file_name;
		}
	}

	var num_files = file_name_array.length;

	for(var i = 0; i < num_files; i++){
		for(var j = 0; j < num_files; j++){
			if(file_name_array[i] == file_name_array[j] && file_name_array[i] != null){ file_count++; }
		}
		if(file_count > 1){
			duplicate_msg += 'Duplicate file "' + file_name_array[i] + '" detected in slot ' + (i + 1) + ".\n";
			duplicate_flag = true;
		}
		file_count = 0;
	}

	if(duplicate_flag){
		//alert(duplicate_msg);
		return true;
	}
	else{ return false; }
}

// Handle user pressing 'Enter' in the upload slots
function handleKey(event){
        if(document.all){ if(window.event.keyCode == 13){ return false; } }
        else{ if(event && event.which == 13){ return false; } }
}

// Submit the upload form
function uploadFiles(url,upload_range){
	//~ if(checkFileNameFormat()){ return false; }
	//~ if(checkDisallowFileExtensions()){ return false; }
	//~ if(checkAllowFileExtensions()){ return false; }
	//~ if(checkNullFileCount()){ return false; }
	//~ if(checkDuplicateFileCount()){ return false; }

	var total_uploads = 0;

	for(var i = 0; i < upload_range; i++){
		if(document.form_upload.elements['upfile_' + i].value != ""){ total_uploads++; }
	}

	document.getElementById('total_uploads').innerHTML = total_uploads;

	document.form_upload.submit();
	//document.getElementById('upload_button').disabled = true;
        hidePopup();
	//Effect.Fade('overlay', { duration: 0.3, from: 0.4, to: 0.0 });
	
	//closeBox();
	iniProgressRequest(url);

	for(var i = 0; i < upload_range; i++){ document.form_upload.elements['upfile_' + i].disabled = true; }
}

// Reset the file upload page
function resetForm(){ location.href = self.location; }

// Hide the progress bar
function hideProgressBar(){ document.getElementById('progress_bar').style.display = "none"; }

// Initialize the file upload page
function iniFilePage(){
	resetProgressBar();

	for(var i = 0; i < upload_range; i++){
		document.form_upload.elements['upfile_' + i].disabled = false;
		document.form_upload.elements['upfile_' + i].value = "";
	}

	document.getElementById('progress_info').innerHTML = "";
	document.getElementById('upload_button').disabled = false;
	document.getElementById('progress_bar').style.display = "none";
	document.form_upload.reset();
}

// Reset the progress bar
function resetProgressBar(){
	get_status_url = "";
	get_data_loop = false;
	seconds = 0;
	minutes = 0;
	hours = 0;
	info_width = 0;
	info_bytes = 0;
	cedric_hold = true;
	total_upload_size = 0;
	total_Kbytes = 0;
	
	document.getElementById('upload_status').style.width = '0px';
	document.getElementById('percent').innerHTML = '0%';
	document.getElementById('uploaded_files').innerHTML = 0;
	document.getElementById('total_uploads').innerHTML = '';
	document.getElementById('current').innerHTML = 0;
	document.getElementById('total_kbytes').innerHTML = '';
	//document.getElementById('time').innerHTML = 0;
	document.getElementById('remain').innerHTML = 0;
	//document.getElementById('speed').innerHTML = 0;
}

// Stop the upload
function stopUpload(){
	try{ window.stop(); }
	catch(e){
		try{ document.execCommand('Stop'); }
		catch(e){
		}
	}
	
	for (var i=0;i<top.frames.length;i++) {
		try{ top.frames[i].stop(); }
		catch(e){
			try{ top.frames[i].document.execCommand('Stop'); }
			catch(e){
			}
		}
	}
}

// Add one upload slot
function addUploadSlot(num){
	if(upload_range < max_upload_slots){
		if(num == upload_range){
			var up = document.getElementById('upload_slots');
			var dv = document.createElement("div");

			dv.innerHTML = '<input type="file" name="upfile_' + upload_range + '" ize="90" onChange="addUploadSlot('+(upload_range + 1)+')" onKeypress="return handleKey(event)">';
			up.appendChild(dv);
			upload_range++;
		}
	}
}

// Make the progress bar smooth
function smoothCedricStatus(){
	if(info_width < progress_bar_width && !cedric_hold){
		info_width++;
		document.getElementById('upload_status').style.width = info_width + 'px';
	}

	if(get_data_loop){ self.setTimeout("smoothCedricStatus()", info_time_width); }
}

// Make the bytes uploaded smooth
function smoothCedricBytes(){
	if(info_bytes < total_Kbytes && !cedric_hold){
		info_bytes++;
		document.getElementById('current').innerHTML = info_bytes;
	}

	if(get_data_loop){ self.setTimeout("smoothCedricBytes()", info_time_bytes); }
}

// Get the progress of the upload
function getProgressStatus(){
  var jsel = document.createElement('SCRIPT');

	jsel.type = 'text/javascript';
	jsel.src = get_status_url + "&rnd_id=" + Math.random();
	document.body.appendChild(jsel);

	if(get_data_loop){ self.setTimeout("getProgressStatus()", get_status_speed); }
}

// Calculate and display upload stats
function setProgressStatus(bytes_read, lapsed_time, uploaded_files){
	var byte_speed = 0;
	var time_remaining = 0;

	if(lapsed_time > 0){ byte_speed = bytes_read / lapsed_time; }
	if(byte_speed > 0){ time_remaining = Math.round((total_upload_size - bytes_read) / byte_speed); }

	if(cedric_progress_bar == 1){
		if(byte_speed != 0){
			info_time_width = Math.round(total_upload_size * 1000 / (byte_speed * progress_bar_width));
			info_time_bytes = Math.round(1024000 / byte_speed);
		}
		else{
			info_time_width = 200;
			info_time_bytes = 15;
		}
	}

	// Calculate percent finished
	var percent_float = bytes_read / total_upload_size;
	var percent = Math.round(percent_float * 100);
	var progress_bar_status = Math.round(percent_float * progress_bar_width);

	// Calculate time remaining
	var remaining_sec = (time_remaining % 60);
	var remaining_min = (((time_remaining - remaining_sec) % 3600) / 60);
	var remaining_hours = ((((time_remaining - remaining_sec) - (remaining_min * 60)) % 86400) / 3600);

	if(remaining_sec < 10){ remaining_sec = '0' + remaining_sec; }
	if(remaining_min < 10){ remaining_min = '0' + remaining_min; }
	if(remaining_hours < 10){ remaining_hours = '0' + remaining_hours; }

	var time_remaining_f = remaining_hours + ':' + remaining_min + ':' + remaining_sec;
	var Kbyte_speed = Math.round(byte_speed / 1024);
	var Kbytes_read = Math.round(bytes_read / 1024);

	if(cedric_progress_bar == 1){
		cedric_hold = false;

   		//if(progress_bar_status > info_width && Kbytes_read > info_bytes){
   		//	info_width = progress_bar_status;
   		//	info_bytes = Kbytes_read;
   		//}
   		//else{ cedric_hold = true; }

		info_width = progress_bar_status;
		info_bytes = Kbytes_read;
	}
	else{
		document.getElementById('upload_status').style.width = progress_bar_status + 'px';
		document.getElementById('current').innerHTML = Kbytes_read;
	}
	document.getElementById('percent').innerHTML = percent + '%';
	document.getElementById('uploaded_files').innerHTML = uploaded_files;
	if(Kbyte_speed >= limite_vitesse)
		var time_remain="<font color='green'>"+time_remaining_f+"</font>";
	else
		var time_remain="<font color='red'>"+time_remaining_f+"</font>";
	document.getElementById('remain').innerHTML = time_remain;
	//document.getElementById('speed').innerHTML = Kbyte_speed;
}


// Calculate the time spent uploading
function getElapsedTime(){
	seconds++;

	if(seconds == 60){
		seconds = 0;
		minutes++;
	}

	if(minutes == 60){
		minutes = 0;
		hours++;
	}

	var hr = "" + ((hours < 10) ? "0" : "") + hours;
	var min = "" + ((minutes < 10) ? "0" : "") + minutes;
	var sec = "" + ((seconds < 10) ? "0" : "") + seconds;

	//document.getElementById('time').innerHTML = hr + ":" + min + ":" + sec;

	if(get_data_loop){ self.setTimeout("getElapsedTime()", 1000); }
}

// Create the AJAX request
function createRequestObject(){
	var req = false;

	if(window.XMLHttpRequest){
		req = new XMLHttpRequest();

		if(req.overrideMimeType){ req.overrideMimeType('text/xml'); }
	}
	else if(window.ActiveXObject){
		try{ req = new ActiveXObject("Msxml2.XMLHTTP"); }
		catch(e){
			try{ req = new ActiveXObject("Microsoft.XMLHTTP"); }
			catch(e){}
		}
	}

	if(!req){
		document.getElementById('progress_info').innerHTML = "Error: Your browser does not support AJAX";
		return false;
	}
	else{ return req; }
}

// Initialize the progress bar
function iniProgressRequest(url){
	var req = false;
	req = createRequestObject();
	if(req){
		document.getElementById('progress_info').innerHTML = "Initialisation du téléchargement ...";
		
		if(LireCookie('dropBox') == '1')
			req.open("GET", "../../ajaxProxy.php?url=" + path_to_ini_status_script + "&rnd_id=" + Math.random(), true);
		else
			req.open("GET", "ajaxProxy.php?url=" + path_to_ini_status_script + "&rnd_id=" + Math.random(), true);
				
		req.onreadystatechange = function(){ iniProgressResponse(req, url); };
		req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		req.send(null);
		
	}
}

// Initialize the progress bar
function iniProgressResponse(req, url){
	if(req.readyState == 4){
		if(req.status == 200){
			var xml = req.responseXML;
						
			 if (navigator.appName == "Microsoft Internet Explorer") 
			 {
				try{xml = new ActiveXObject("msxml2.xmldom" )}catch(e){err=e.message} 
				try{xml = new ActiveXObject("Microsoft.xmldom")}catch(e){err=e.message} 
				try{xml = new ActiveXObject("MSXML.xmldom" )}catch(e){err=e.message} 
				try{xml = new ActiveXObject("MSXML3.xmldom" )}catch(e){err=e.message} 
				if(!xml){ alert("ERREUR : "+err); return } 
				xml.loadXML(req.responseText);
			}
			else
			{
				var xml = req.responseXML;
				//alert(req.responseXML);
			}
						
			if(xml.getElementsByTagName('error_status').item(0).firstChild.nodeValue == 1){
				document.getElementById('progress_info').innerHTML = xml.getElementsByTagName('error_msg').item(0).firstChild.nodeValue;
				
				if(xml.getElementsByTagName('stop_upload').item(0).firstChild.nodeValue == 1){ stopUpload(); }
			}
			else{
				get_status_speed = xml.getElementsByTagName('get_data_speed').item(0).firstChild.nodeValue;
				total_upload_size = xml.getElementsByTagName('total_bytes').item(0).firstChild.nodeValue;
				total_Kbytes = Math.round(total_upload_size / 1024);
				get_status_url = "https://" + url + "/uberUploader/uu_get_status.php?temp_dir_sid=" + xml.getElementsByTagName('temp_dir_sid').item(0).firstChild.nodeValue + "&start_time=" + xml.getElementsByTagName('start_time').item(0).firstChild.nodeValue + "&total_upload_size=" + xml.getElementsByTagName('total_bytes').item(0).firstChild.nodeValue;

				get_data_loop = true;

				if(document.form_upload.embedded_upload_results && document.form_upload.embedded_upload_results.value == 1){
					document.getElementById('upload_div').style.display = "none";
				}

				document.getElementById('progress_bar').style.display = "";
				document.getElementById('total_kbytes').innerHTML = total_Kbytes + " ";
				document.getElementById('progress_info').innerHTML = "Téléchargement en cours";

				getElapsedTime();
				getProgressStatus();

				if(cedric_progress_bar == 1){
					smoothCedricBytes();
					smoothCedricStatus();
				}
			}
			
			
		}
		else{
			document.getElementById('progress_info').innerHTML = "Error: " + req.status + " " + req.statusText;
			//stopUpload();
		}
	}
}

__POPUP_WIDTH__ = 390;
__POPUP_HEIGHT__ = 270;
__PROGRESS_DIV_WIDTH__ = 500;
__PROGRESS_DIV_HEIGHT__ = 350;
var upload_range=0;

function displayOpacifier()
{
  var div = document.createElement('div');

  if (/MSIE/.test(navigator.userAgent))
  {
    begin = 0;
    end = 50;
  }
  else
  {
    begin = 0.1;
    end = 0.5;
  }
  div.id = 'overlay';
  div.style.position = 'absolute';
  div.style.width = screen.availWidth + "px";
  div.style.height = screen.availHeight + "px";
  div.style.top = 0 + document.body.scrollTop;
  div.style.backgroundColor = '#000000';
  div.style.top = '0px';
  div.style.left = '0px';
  div.style.zIndex='3';
  div.style.opacity = 0.8;
  div.style.filter = 'alpha(opacity = 80)';
  div.style.KhtmlOpacity = 0.8;
  yScroll = document.body.scrollTop;
  document.body.appendChild(div);
  $("#overlay").fadeIn('slow');
}

function centerPopUp(div)
{
  div.style.left = (document.body.clientWidth - __POPUP_WIDTH__ ) / 2 + "px";
  div.style.top = (document.body.clientHeight - __POPUP_HEIGHT__ ) / 2 + "px";
}

function centerProgressBarDiv(div)
{
  div.style.left = (document.body.clientWidth - __PROGRESS_DIV_WIDTH__ ) / 2 + "px";
  div.style.top = (document.body.clientHeight - __PROGRESS_DIV_HEIGHT__ ) / 2 + "px";
}

function fixProgressBarDisplay()
{
  document.getElementById('progressBarDiv').style.display = 'block';
}

function displayProgressBarDiv()
{
	centerProgressBarDiv(document.getElementById('progressBarDiv'));
	document.getElementById('progressBarDiv').style.display = 'block';
	$("#progressBarDiv").show(3, function() { fixProgressBarDisplay(); });
}

function deletePopup()
{
	var div = document.getElementById('popUpBox');
  document.getElementById('popUpBox').parentNode.removeChild(div);
  displayProgressBarDiv();
}

function hidePopup()
{
  //Effect.Fade('popUpBox', {afterFinish: deletePopup, duration: 0.3});
  $("#popUpBox").fadeTo("fast",0,function() { deletePopup(); });
}

function popBox(url)
{
	var formulaire = document.getElementById('upload_slots');
	
	if(formulaire)
	{
		if (formulaire.hasChildNodes())
		{
			var collEnfants = formulaire.childNodes;
			for (var i = 0; i < collEnfants.length; i++)
			{
				if(collEnfants[i].tagName=="SPAN")
					upload_range++;
			}
		}
	}

  displayOpacifier();
  var div = document.createElement('div');
  div.style.zIndex='4';
  div.id = 'popUpBox';
  div.style.height = '200px';
  div.style.width = '400px';
  
  
  var reg = /popup_commande/;
  var reg2 = /valide_renouvellement_compte/;
  if(reg.exec(url) || reg2.exec(url))
  {
	div.style.left = (document.body.clientWidth - __POPUP_WIDTH__ ) / 2 + "px";
	div.style.top = "5px";
  }
  else
  {
	centerPopUp(div);
  }
  
  document.body.appendChild(div);
  //Remplit le innerHTML de la div avec le contenu de url

	var reg = /popup_upload_private/;
	var reg2 = /popup_renvoi.php/;
	var reg3 = /popup_renvoi2.php/;
		
	if(reg.exec(url))
	{
		$("#popUpBox").load(url,'',function() { autoCompletion2('1'); });
	}
	else if(reg2.exec(url))
	{
		$("#popUpBox").load(url,'',function() { autoCompletion() });
	}
	else if(reg3.exec(url))
	{
		$("#popUpBox").load(url,'',function() { autoCompletionRenvoi('1'); });
	}
	else
	{
		$("#popUpBox").load(url);
	}
	
}

function popBoxLight()
{
	var formulaire = document.getElementById('upload_slots');
	if (formulaire.hasChildNodes())
	{
		var collEnfants = formulaire.childNodes;
		for (var i = 0; i < collEnfants.length; i++)
		{
			if(collEnfants[i].tagName=="SPAN")
				upload_range++;
		}
	}

  displayOpacifier();
  var div = document.createElement('div');
  div.style.zIndex='4';
  div.id = 'popUpBox';
  div.style.height = '200px';
  div.style.width = '400px';
  
  centerPopUp(div);
  
  document.body.appendChild(div);
}

function autoCompletion()
{
	$("#destinatairePrivateRenvoi").autocomplete("search.php", {
		width: 165,
		selectFirst: false
	});
}

function autoCompletion2(i)
{
	$("#destinataireEnvoi_"+i).autocomplete("search.php", {
		width: 165,
		selectFirst: false
	});
}

function autoCompletionRenvoi(i)
{
	$("#destinatairePrivateRenvoi_"+1).autocomplete("search.php", {
		width: 165,
		selectFirst: false
	});
}

function supprOverlay()
{
	var compteur=0;
	var overlay=document.getElementsByTagName("DIV");
	
	for(i=0;i<overlay.length;i++)
	{
		if(overlay[i].id=="overlay")
		{
			document.body.removeChild(overlay[i]);
		}
	}
}

function closeBox()
{  
	afficheAnim();
	var div = document.getElementById('popUpBox');
	$("#popUpBox").fadeTo("fast",0,function () { supprOverlay(); });
	div.parentNode.removeChild(div);
}

function masqueAnim()
{
	var anim = document.getElementById('blocAnimation');
	if(anim!="" &&  anim)
		anim.style.display="none";
}

function afficheAnim()
{
	var anim = document.getElementById('blocAnimation');

	if(anim!="" && anim)
		anim.style.display="block";
}
var compteur=0;

function slide()
{
	var content = document.getElementById('blocHautPrivate');
	var menu = document.getElementById('blocMenu');
	var separation = document.getElementById('separationPrivate');
	var bas = document.getElementById('contenuBasPrivate');
	var containSlide = document.getElementById('containSlide');

	if(navigator.userAgent.indexOf("MSIE 7")!=-1 || navigator.userAgent.indexOf("MSIE 6")!=-1)
	{
		bas.style.display="none";
		content.style.height=content.offsetHeight+200+"px";
		//menu.style.height=menu.offsetHeight+220+"px";
	}
	else
	{
		bas.style.display="none";
		content.style.height=content.offsetHeight+220+"px";
		menu.style.height=menu.offsetHeight+220+"px";
	}
	
	containSlide.style.background="url('styles/default/graphs/bouton_slide_h.gif')";
	containSlide.innerHTML="<a href='javascript: slideH();' class='lien_12_gras_blanc'>R&eacute;duire</a>";
	
	
	var urlBase = document.location;
	urlBase = new String(urlBase);
	urlBase = urlBase.split('contain=');
	
	switch(urlBase[1])
	{
		case 'afficheHisto':
				var tab = document.getElementById('supportListeHisto');
				var ascenseur = document.getElementById('ascenseurListeHisto');
				var scrollBas = document.getElementById('scrollBasHisto');
				
				tab.style.height = '398px';
				ascenseur.style.height = '378px';
				scrollBas.style.marginTop = '368px';
				
				break;
				
		
		case 'afficheFichiers':
				var tab = document.getElementById('supportListeFichiers');
				var ascenseur = document.getElementById('ascenseurListeFichiers');
				var scrollBas = document.getElementById('scrollBasFichiers');
				
				tab.style.height = '448px';
				ascenseur.style.height = '418px';
				scrollBas.style.marginTop = '418px';
			
				break;
			
		/*case 'afficheContact':
				var tab = document.getElementById('supportListeContact');
				var ascenseur = document.getElementById('ascenseurListeContact');
				var scrollBas = document.getElementById('scrollBasContact');
				
				tab.style.height = '380px';
				ascenseur.style.height = '390px';
				scrollBas.style.marginTop = '351px';
			break;*/
	}
	
}

function slideH()
{
	var content = document.getElementById('blocHautPrivate');
	var menu = document.getElementById('blocMenu');
	var separation = document.getElementById('separationPrivate');
	var bas = document.getElementById('contenuBasPrivate');
	var containSlide = document.getElementById('containSlide');
	
	if(navigator.userAgent.indexOf("MSIE 7")!=-1 || navigator.userAgent.indexOf("MSIE 6")!=-1)
	{
		content.style.height=content.offsetHeight-220+"px";
		bas.style.display="block";
	}
	else
	{
		content.style.height=content.offsetHeight-220+"px";
		bas.style.display="block";
		menu.style.height=menu.offsetHeight-220+"px";
	}
	
	
	if(navigator.userAgent.indexOf("Safari") != -1)
		bas.style.display="inline";
	
	containSlide.style.background="url('styles/default/graphs/bouton_slide.gif')";
	containSlide.innerHTML="<a href='javascript: slide();' class='lien_12_gras_blanc'>Agrandir</a>";
	
	var urlBase = document.location;
	urlBase = new String(urlBase);
	urlBase = urlBase.split('contain=');
	
	switch(urlBase[1])
	{
		case 'afficheHisto':
				var tab = document.getElementById('supportListeHisto');
				var ascenseur = document.getElementById('ascenseurListeHisto');
				var scrollBas = document.getElementById('scrollBasHisto');
				
				tab.style.height = '210px';
				ascenseur.style.height = '190px';
				scrollBas.style.marginTop = '180px';
				
				break;
		
		case 'afficheFichiers':
				var tab = document.getElementById('supportListeFichiers');
				var ascenseur = document.getElementById('ascenseurListeFichiers');
				var scrollBas = document.getElementById('scrollBasFichiers');
				
				tab.style.height = '230px';
				ascenseur.style.height = '220px';
				scrollBas.style.marginTop = '200px';
				
				break;
			
		/*case 'afficheContact':
				var tab = document.getElementById('supportListeContact');
				var ascenseur = document.getElementById('ascenseurListeContact');
				var scrollBas = document.getElementById('scrollBasContact');
				
				tab.style.height = '190px';
				ascenseur.style.height = '190px';
				scrollBas.style.marginTop = '160px';

				break;*/
	}
}

// retourne un objet xmlHttpRequest.
// méthode compatible entre tous les navigateurs (IE/Firefox/Opera)
function getXMLHTTP(){
  var xhr=null;
  if(window.XMLHttpRequest) // Firefox et autres
  xhr = new XMLHttpRequest();
  else if(window.ActiveXObject){ // Internet Explorer
    try {
      xhr = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e1) {
        xhr = null;
      }
    }
  }
  else { // XMLHttpRequest non supporté par le navigateur
    alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
  }
  return xhr;
}

var _documentForm=null; // le formulaire contenant notre champ texte
var _inputField=null; // le champ texte lui-même
var _submitButton=null; // le bouton submit de notre formulaire

function initAutoComplete(field){
  _inputField=field;
  _inputField.autocomplete="off";
  creeAutocompletionDiv();
  _currentInputFieldValue=_inputField.value;
  _oldInputFieldValue=_currentInputFieldValue;
  cacheResults("",new Array())
  document.onkeydown=onKeyDownHandler;
  _inputField.onkeyup=onKeyUpHandler;
  _inputField.onblur=onBlurHandler;
  window.onresize=onResizeHandler;
  // Premier déclenchement de la fonction dans 200 millisecondes
  setTimeout("mainLoop()",200)
}

var _oldInputFieldValue=""; // valeur précédente du champ texte
var _currentInputFieldValue=""; // valeur actuelle du champ texte
var _resultCache=new Object(); // mécanisme de cache des requetes

// tourne en permanence pour suggerer suite à un changement du champ texte
function mainLoop(){
  if(_oldInputFieldValue!=_currentInputFieldValue){
    var valeur=escapeURI(_currentInputFieldValue);
    var suggestions=_resultCache[_currentInputFieldValue];
    if(suggestions){ // la réponse était encore dans le cache
      metsEnPlace(valeur,suggestions)
    }else{
      callSuggestions(valeur) // appel distant
    }
    _inputField.focus()
  }
  _oldInputFieldValue=_currentInputFieldValue;
  setTimeout("mainLoop()",200); // la fonction se redéclenchera dans 200 ms
  return true
}

// echappe les caractère spéciaux
function escapeURI(La){
  if(encodeURIComponent) {
    return encodeURIComponent(La);
  }
  if(escape) {
    return escape(La)
  }
}

var _xmlHttp = null; //l'objet xmlHttpRequest utilisé pour contacter le serveur
var _adresseRecherche = "autocomplete.php" //l'adresse à interroger pour trouver les suggestions

function callSuggestions(valeur){
  if(_xmlHttp&&_xmlHttp.readyState!=0){
    _xmlHttp.abort()
  }
  _xmlHttp=getXMLHTTP();
  if(_xmlHttp){
    //appel à l'url distante.
    _xmlHttp.open("GET",_adresseRecherche+"?recherche="+valeur,true);
    _xmlHttp.onreadystatechange=function() {
      if(_xmlHttp.readyState==4&&_xmlHttp.responseXML) {
        var liste = traiteXmlSuggestions(_xmlHttp.responseXML)
        cacheResults(valeur,liste)
        metsEnPlace(valeur,liste)
      }
    };
    // envoi de la requete
    _xmlHttp.send(null)
  }
}

// Mecanisme de caching des réponses
function cacheResults(debut,suggestions){
  _resultCache[debut]=suggestions
}

// Transformation XML en tableau
function traiteXmlSuggestions(xmlDoc) {
  var options = xmlDoc.getElementsByTagName('option');
  var optionsListe = new Array();
  for (var i=0; i < options.length; ++i) {
    optionsListe.push(options[i].firstChild.data);
  }
  return optionsListe;
}

//insère une règle avec son nom
function insereCSS(nom,regle){
  if (document.styleSheets) {
    var I=document.styleSheets[0];
    if(I.addRule){ // méthode IE
      I.addRule(nom,regle)
    }else if(I.insertRule){ // méthode DOM
      I.insertRule(nom+" { "+regle+" }",I.cssRules.length)
    }
  }
}

function initStyle(){
  var AutoCompleteDivListeStyle="font-size: 13px; font-family: arial,sans-serif; word-wrap:break-word; ";
  var AutoCompleteDivStyle="display: block; padding-left: 3; padding-right: 3; height: 16px; overflow: hidden; background-color: white;";
  var AutoCompleteDivActStyle="background-color: #3366cc; color: white ! important; ";
  insereCSS(".AutoCompleteDivListeStyle",AutoCompleteDivListeStyle);
  insereCSS(".AutoCompleteDiv",AutoCompleteDivStyle);
  insereCSS(".AutoCompleteDivAct",AutoCompleteDivActStyle);
}

function setStylePourElement(c,name){
  c.className=name;
}

// calcule le décalage à gauche
function calculateOffsetLeft(r){
  return calculateOffset(r,"offsetLeft")
}

// calcule le décalage vertical
function calculateOffsetTop(r){
  return calculateOffset(r,"offsetTop")
}

function calculateOffset(r,attr){
  var kb=0;
  while(r){
    kb+=r[attr];
    r=r.offsetParent
  }
  return kb
}

// calcule la largeur du champ
function calculateWidth(){
  return _inputField.offsetWidth-2*1
}

function setCompleteDivSize(){
  if(_completeDiv){
    _completeDiv.style.left=calculateOffsetLeft(_inputField)+"px";
    _completeDiv.style.top=calculateOffsetTop(_inputField)+_inputField.offsetHeight-1+"px";
    _completeDiv.style.width=calculateWidth()+"px"
  }
}

function creeAutocompletionDiv() {
  initStyle();
  _completeDiv=document.createElement("DIV");
  _completeDiv.id="completeDiv";
  var borderLeftRight=1;
  var borderTopBottom=1;
  _completeDiv.style.borderRight="black "+borderLeftRight+"px solid";
  _completeDiv.style.borderLeft="black "+borderLeftRight+"px solid";
  _completeDiv.style.borderTop="black "+borderTopBottom+"px solid";
  _completeDiv.style.borderBottom="black "+borderTopBottom+"px solid";
  _completeDiv.style.zIndex="1";
  _completeDiv.style.paddingRight="0";
  _completeDiv.style.paddingLeft="0";
  _completeDiv.style.paddingTop="0";
  _completeDiv.style.paddingBottom="0";
  setCompleteDivSize();
  _completeDiv.style.visibility="hidden";
  _completeDiv.style.position="absolute";
  _completeDiv.style.backgroundColor="white";
  document.body.appendChild(_completeDiv);
  setStylePourElement(_completeDiv,"AutoCompleteDivListeStyle");
}

function metsEnPlace(valeur, liste){
  while(_completeDiv.childNodes.length>0) {
    _completeDiv.removeChild(_completeDiv.childNodes[0]);
  }
  // mise en place des suggestions
  for(var f=0; f<liste.length; ++f){
    var nouveauDiv=document.createElement("DIV");
    nouveauDiv.onmousedown=divOnMouseDown;
    nouveauDiv.onmouseover=divOnMouseOver;
    nouveauDiv.onmouseout=divOnMouseOut;
    setStylePourElement(nouveauDiv,"AutoCompleteDiv");
    var nouveauSpan=document.createElement("SPAN");
    nouveauSpan.innerHTML=liste[f]; // le texte de la suggestion
    nouveauDiv.appendChild(nouveauSpan);
    _completeDiv.appendChild(nouveauDiv)
  }
  PressAction();
  if(_completeDivRows>0) {
    _completeDiv.height=16*_completeDivRows+4;
  } else {
    hideCompleteDiv();
  }

}

var _lastKeyCode=null;

// Handler pour le keydown du document
var onKeyDownHandler=function(event){
  // accès evenement compatible IE/Firefox
  if(!event&&window.event) {
    event=window.event;
  }
  // on enregistre la touche ayant déclenché l'evenement
  if(event) {
    _lastKeyCode=event.keyCode;
  }
}

var _eventKeycode = null;

// Handler pour le keyup de lu champ texte
var onKeyUpHandler=function(event){
  // accès evenement compatible IE/Firefox
  if(!event&&window.event) {
    event=window.event;
  }
  _eventKeycode=event.keyCode;
  // Dans les cas touches touche haute(38) ou touche basse (40)
  if(_eventKeycode==40||_eventKeycode==38) {
    // on autorise le blur du champ (traitement dans onblur)
    blurThenGetFocus();
  }
  // taille de la selection
  var N=rangeSize(_inputField);
  // taille du texte avant la selection (selection = suggestion d'autocomplétion)
  var v=beforeRangeSize(_inputField);
  // contenu du champ texte
  var V=_inputField.value;
  if(_eventKeycode!=0){
    if(N>0&&v!=-1) {
      // on recupere uniquement le champ texte tapé par l'utilisateur
      V=V.substring(0,v);
    }
    // 13 = touche entrée
    if(_eventKeycode==13||_eventKeycode==3){
      var d=_inputField;
      // on mets en place l'ensemble du champ texte en repoussant la selection
      if(_inputField.createTextRange){
        var t=_inputField.createTextRange();
        t.moveStart("character",_inputField.value.length);
        _inputField.select()
      } else if (d.setSelectionRange){
        _inputField.setSelectionRange(_inputField.value.length,_inputField.value.length)
      }
    } else {
      // si on a pas pu agrandir le champ non selectionné, on le mets en place violemment.
      if(_inputField.value!=V) {
        _inputField.value=V
      }
    }
  }
  // si la touche n'est ni haut, ni bas, on stocke la valeur utilisateur du champ
  if(_eventKeycode!=40&&_eventKeycode!=38) {
    // le champ courant n est pas change si key Up ou key Down
  	_currentInputFieldValue=V;
  }
  if(handleCursorUpDownEnter(_eventKeycode)&&_eventKeycode!=0) {
    // si on a préssé une touche autre que haut/bas/enter
    PressAction();
  }
}

// Change la suggestion selectionné.
// cette méthode traite les touches haut, bas et enter
function handleCursorUpDownEnter(eventCode){
  if(eventCode==40){
    highlightNewValue(_highlightedSuggestionIndex+1);
    return false
  }else if(eventCode==38){
    highlightNewValue(_highlightedSuggestionIndex-1);
    return false
  }else if(eventCode==13||eventCode==3){
    return false
  }
  return true
}

var _completeDivRows = 0;
var _completeDivDivList = null;
var _highlightedSuggestionIndex = -1;
var _highlightedSuggestionDiv = null;

// gère une touche pressée autre que haut/bas/enter
function PressAction(){
  _highlightedSuggestionIndex=-1;
  var suggestionList=_completeDiv.getElementsByTagName("div");
  var suggestionLongueur=suggestionList.length;
  // on stocke les valeurs précédentes
  // nombre de possibilités de complétion
  _completeDivRows=suggestionLongueur;
  // possiblités de complétion
  _completeDivDivList=suggestionList;
  // si le champ est vide, on cache les propositions de complétion
  if(_currentInputFieldValue==""||suggestionLongueur==0){
    hideCompleteDiv()
  }else{
    showCompleteDiv()
  }
  var trouve=false;
  // si on a du texte sur lequel travailler
  if(_currentInputFieldValue.length>0){
    var indice;
    // T vaut true si on a dans la liste de suggestions un mot commencant comme l'entrée utilisateur
    for(indice=0; indice<suggestionLongueur; indice++){
      if(getSuggestion(suggestionList.item(indice)).toUpperCase().indexOf(_currentInputFieldValue.toUpperCase())==0) {
        trouve=true;
        break
      }
    }
  }
  // on désélectionne toutes les suggestions
  for(var i=0; i<suggestionLongueur; i++) {
    setStylePourElement(suggestionList.item(i),"AutoCompleteDiv");
  }
  // si l'entrée utilisateur (n) est le début d'une suggestion (n-1) on sélectionne cette suggestion avant de continuer
  if(trouve){
    _highlightedSuggestionIndex=indice;
    _highlightedSuggestionDiv=suggestionList.item(_highlightedSuggestionIndex);
  }else{
    _highlightedSuggestionIndex=-1;
    _highlightedSuggestionDiv=null
  }
  var supprSelection=false;
  switch(_eventKeycode){
    // cursor left, cursor right, page up, page down, others??
    case 8:
    case 33:
    case 34:
    case 35:
    case 35:
    case 36:
    case 37:
    case 39:
    case 45:
    case 46:
      // on supprime la suggestion du texte utilisateur
      supprSelection=true;
      break;
    default:
      break
  }
  // si on a une suggestion (n-1) sélectionnée
  if(!supprSelection&&_highlightedSuggestionDiv){
    setStylePourElement(_highlightedSuggestionDiv,"AutoCompleteDivAct");
    var z;
    if(trouve) {
      z=getSuggestion(_highlightedSuggestionDiv).substr(0);
    } else {
      z=_currentInputFieldValue;
    }
    if(z!=_inputField.value){
      if(_inputField.value!=_currentInputFieldValue) {
        return;
      }
      // si on peut créer des range dans le document
      if(_inputField.createTextRange||_inputField.setSelectionRange) {
        _inputField.value=z;
      }
      // on sélectionne la fin de la suggestion
      if(_inputField.createTextRange){
        var t=_inputField.createTextRange();
        t.moveStart("character",_currentInputFieldValue.length);
        t.select()
      }else if(_inputField.setSelectionRange){
        _inputField.setSelectionRange(_currentInputFieldValue.length,_inputField.value.length)
      }
    }
  }else{
    // sinon, plus aucune suggestion de sélectionnée
    _highlightedSuggestionIndex=-1;
  }
}

var _cursorUpDownPressed = null;

// permet le blur du champ texte après que la touche haut/bas ai été pressé.
// le focus est récupéré après traitement (via le timeout).
function blurThenGetFocus(){
  _cursorUpDownPressed=true;
  _inputField.blur();
  setTimeout("_inputField.focus();",10);
  return
}

// taille de la selection dans le champ input
function rangeSize(n){
  var N=-1;
  if(n.createTextRange){
    var fa=document.selection.createRange().duplicate();
    N=fa.text.length
  }else if(n.setSelectionRange){
    N=n.selectionEnd-n.selectionStart
  }
  return N
}

// taille du champ input non selectionne
function beforeRangeSize(n){
  var v=0;
  if(n.createTextRange){
    var fa=document.selection.createRange().duplicate();
    fa.moveEnd("textedit",1);
    v=n.value.length-fa.text.length
  }else if(n.setSelectionRange){
    v=n.selectionStart
  }else{
    v=-1
  }
  return v
}

// Place le curseur à la fin du champ
function cursorAfterValue(n){
  if(n.createTextRange){
    var t=n.createTextRange();
    t.moveStart("character",n.value.length);
    t.select()
  } else if(n.setSelectionRange) {
    n.setSelectionRange(n.value.length,n.value.length)
  }
}


// Retourne la valeur de la possibilite (texte) contenu dans une div de possibilite
function getSuggestion(uneDiv){
  if(!uneDiv) {
    return null;
  }
  return trimCR(uneDiv.getElementsByTagName('span')[0].firstChild.data)
}

// supprime les caractères retour chariot et line feed d'une chaine de caractères
function trimCR(chaine){
  for(var f=0,nChaine="",zb="\n\r"; f<chaine.length; f++) {
    if (zb.indexOf(chaine.charAt(f))==-1) {
      nChaine+=chaine.charAt(f);
    }
  }
  return nChaine
}

// Cache completement les choix de completion
function hideCompleteDiv(){
  _completeDiv.style.visibility="hidden"
}

// Rends les choix de completion visibles
function showCompleteDiv(){
  _completeDiv.style.visibility="visible";
  setCompleteDivSize()
}

// Change la suggestion en surbrillance
function highlightNewValue(C){
  if(!_completeDivDivList||_completeDivRows<=0) {
    return;
  }
  showCompleteDiv();
  if(C>=_completeDivRows){
    C=_completeDivRows-1
  }
  if(_highlightedSuggestionIndex!=-1&&C!=_highlightedSuggestionIndex){
    setStylePourElement(_highlightedSuggestionDiv,"AutoCompleteDiv");
    _highlightedSuggestionIndex=-1
  }
  if(C<0){
    _highlightedSuggestionIndex=-1;
    _inputField.focus();
    return
  }
  _highlightedSuggestionIndex=C;
  _highlightedSuggestionDiv=_completeDivDivList.item(C);
  setStylePourElement(_highlightedSuggestionDiv,"AutoCompleteDivAct");
  _inputField.value=getSuggestion(_highlightedSuggestionDiv);
}

// Handler de resize de la fenetre
var onResizeHandler=function(event){
  // recalcule la taille des suggestions
  setCompleteDivSize();
}

// Handler de blur sur le champ texte
var onBlurHandler=function(event){
  if(!_cursorUpDownPressed){
    // si le blur n'est pas causé par la touche haut/bas
    hideCompleteDiv();
    // Si la dernière touche préssé est tab, on passe au bouton de validation
    if(_lastKeyCode==9){
     // _submitButton.focus();
      _lastKeyCode=-1
    }
  }
  _cursorUpDownPressed=false
};

// declenchee quand on clique sur une div contenant une possibilite
var divOnMouseDown=function(){
  _inputField.value=getSuggestion(this);
  //_documentForm.submit()
};

// declenchee quand on passe sur une div de possibilite. La div précédente est passee en style normal
var divOnMouseOver=function(){
  if(_highlightedSuggestionDiv) {
    setStylePourElement(_highlightedSuggestionDiv,"AutoCompleteDiv");
  }
  setStylePourElement(this,"AutoCompleteDivAct")
};

// declenchee quand la sourie quitte une div de possiblite. La div repasse a l'etat normal
var divOnMouseOut = function(){
  setStylePourElement(this,"AutoCompleteDiv");
};

//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}
