function showhideForm(formulaire,statut){if(statut=="show"){$("div#"+formulaire).fadeIn(1000);}
else if(statut=="hide"){$("div#"+formulaire).hide();}}
var ddaccordion={contentclassname:{},expandone:function(headerclass,selected){this.toggleone(headerclass,selected,"expand")},collapseone:function(headerclass,selected){this.toggleone(headerclass,selected,"collapse")},expandall:function(headerclass){var $=jQuery
var $headers=$('.'+headerclass)
$('.'+this.contentclassname[headerclass]+':hidden').each(function(){$headers.eq(parseInt($(this).attr('contentindex'))).trigger("evt_accordion")})},collapseall:function(headerclass){var $=jQuery
var $headers=$('.'+headerclass)
$('.'+this.contentclassname[headerclass]+':visible').each(function(){$headers.eq(parseInt($(this).attr('contentindex'))).trigger("evt_accordion")})},toggleone:function(headerclass,selected,optstate){var $=jQuery
var $targetHeader=$('.'+headerclass).eq(selected)
var $subcontent=$('.'+this.contentclassname[headerclass]).eq(selected)
if(typeof optstate=="undefined"||optstate=="expand"&&$subcontent.is(":hidden")||optstate=="collapse"&&$subcontent.is(":visible"))
$targetHeader.trigger("evt_accordion")},expandit:function($targetHeader,$targetContent,config,useractivated,directclick){this.transformHeader($targetHeader,config,"expand")
$targetContent.slideDown(config.animatespeed,function(){config.onopenclose($targetHeader.get(0),parseInt($targetHeader.attr('headerindex')),$targetContent.css('display'),useractivated)
if(config.postreveal=="gotourl"&&directclick){var targetLink=($targetHeader.is("a"))?$targetHeader.get(0):$targetHeader.find('a:eq(0)').get(0)
if(targetLink)
setTimeout(function(){location=targetLink.href},200)}})},collapseit:function($targetHeader,$targetContent,config,isuseractivated){this.transformHeader($targetHeader,config,"collapse")
$targetContent.slideUp(config.animatespeed,function(){config.onopenclose($targetHeader.get(0),parseInt($targetHeader.attr('headerindex')),$targetContent.css('display'),isuseractivated)})},transformHeader:function($targetHeader,config,state){$targetHeader.addClass((state=="expand")?config.cssclass.expand:config.cssclass.collapse).removeClass((state=="expand")?config.cssclass.collapse:config.cssclass.expand)
if(config.htmlsetting.location=='src'){$targetHeader=($targetHeader.is("img"))?$targetHeader:$targetHeader.find('img').eq(0)
$targetHeader.attr('src',(state=="expand")?config.htmlsetting.expand:config.htmlsetting.collapse)}
else if(config.htmlsetting.location=="prefix")
$targetHeader.find('.accordprefix').html((state=="expand")?config.htmlsetting.expand:config.htmlsetting.collapse)
else if(config.htmlsetting.location=="suffix")
$targetHeader.find('.accordsuffix').html((state=="expand")?config.htmlsetting.expand:config.htmlsetting.collapse)},urlparamselect:function(headerclass){var result=window.location.search.match(new RegExp(headerclass+"=((\\d+)(,(\\d+))*)","i"))
if(result!=null)
result=RegExp.$1.split(',')
return result},getCookie:function(Name){var re=new RegExp(Name+"=[^;]+","i")
if(document.cookie.match(re))
return document.cookie.match(re)[0].split("=")[1]
return null},setCookie:function(name,value){document.cookie=name+"="+value+"; path=/"},init:function(config){document.write('<style type="text/css">\n')
document.write('.'+config.contentclass+'{display: none}\n')
document.write('<\/style>')
jQuery(document).ready(function($){ddaccordion.urlparamselect(config.headerclass)
var persistedheaders=ddaccordion.getCookie(config.headerclass)
ddaccordion.contentclassname[config.headerclass]=config.contentclass
config.cssclass={collapse:config.toggleclass[0],expand:config.toggleclass[1]}
config.revealtype=config.revealtype||"click"
config.revealtype=config.revealtype.replace(/mouseover/i,"mouseenter")
if(config.revealtype=="clickgo"){config.postreveal="gotourl"
config.revealtype="click"}
if(typeof config.togglehtml=="undefined")
config.htmlsetting={location:"none"}
else
config.htmlsetting={location:config.togglehtml[0],collapse:config.togglehtml[1],expand:config.togglehtml[2]}
config.oninit=(typeof config.oninit=="undefined")?function(){}:config.oninit
config.onopenclose=(typeof config.onopenclose=="undefined")?function(){}:config.onopenclose
var lastexpanded={}
var expandedindices=ddaccordion.urlparamselect(config.headerclass)||((config.persiststate&&persistedheaders!=null)?persistedheaders:config.defaultexpanded)
if(typeof expandedindices=='string')
expandedindices=expandedindices.replace(/c/ig,'').split(',')
var $subcontents=$('.'+config["contentclass"])
if(expandedindices.length==1&&expandedindices[0]=="-1")
expandedindices=[]
if(config["collapseprev"]&&expandedindices.length>1)
expandedindices=[expandedindices.pop()]
if(config["onemustopen"]&&expandedindices.length==0)
expandedindices=[0]
$('.'+config["headerclass"]).each(function(index){if(/(prefix)|(suffix)/i.test(config.htmlsetting.location)&&$(this).html()!=""){$('<span class="accordprefix"></span>').prependTo(this)
$('<span class="accordsuffix"></span>').appendTo(this)}
$(this).attr('headerindex',index+'h')
$subcontents.eq(index).attr('contentindex',index+'c')
var $subcontent=$subcontents.eq(index)
var needle=(typeof expandedindices[0]=="number")?index:index+''
if(jQuery.inArray(needle,expandedindices)!=-1){if(config.animatedefault==false)
$subcontent.show()
ddaccordion.expandit($(this),$subcontent,config,false)
lastexpanded={$header:$(this),$content:$subcontent}}
else{$subcontent.hide()
config.onopenclose($(this).get(0),parseInt($(this).attr('headerindex')),$subcontent.css('display'),false)
ddaccordion.transformHeader($(this),config,"collapse")}})
$('.'+config["headerclass"]).bind("evt_accordion",function(e,isdirectclick){var $subcontent=$subcontents.eq(parseInt($(this).attr('headerindex')))
if($subcontent.css('display')=="none"){ddaccordion.expandit($(this),$subcontent,config,true,isdirectclick)
if(config["collapseprev"]&&lastexpanded.$header&&$(this).get(0)!=lastexpanded.$header.get(0)){ddaccordion.collapseit(lastexpanded.$header,lastexpanded.$content,config,true)}
lastexpanded={$header:$(this),$content:$subcontent}}
else if(!config["onemustopen"]||config["onemustopen"]&&lastexpanded.$header&&$(this).get(0)!=lastexpanded.$header.get(0)){ddaccordion.collapseit($(this),$subcontent,config,true)}})
$('.'+config["headerclass"]).bind(config.revealtype,function(){if(config.revealtype=="mouseenter"){clearTimeout(config.revealdelay)
var headerindex=parseInt($(this).attr("headerindex"))
config.revealdelay=setTimeout(function(){ddaccordion.expandone(config["headerclass"],headerindex)},config.mouseoverdelay||0)}
else{$(this).trigger("evt_accordion",[true])
return false}})
$('.'+config["headerclass"]).bind("mouseleave",function(){clearTimeout(config.revealdelay)})
config.oninit($('.'+config["headerclass"]).get(),expandedindices)
$(window).bind('unload',function(){$('.'+config["headerclass"]).unbind()
var expandedindices=[]
$('.'+config["contentclass"]+":visible").each(function(index){expandedindices.push($(this).attr('contentindex'))})
if(config.persiststate==true&&$('.'+config["headerclass"]).length>0){expandedindices=(expandedindices.length==0)?'-1c':expandedindices
ddaccordion.setCookie(config.headerclass,expandedindices)}})})}}
function CheckForm(fid){this.fid=fid;this.setFormulaire(fid);this.formulaire=document;this.messageError=[];this.value=[];this.c=[];this.t=[];this.r=[];this.m=[];this.p=[];this.l=[];this.ol=[];this.e=[];this.tab_comp=[];this.type_comp=[];this.custom_cond=[];}
CheckForm.prototype={debug:false,authorizeKeyControl:true,formLock:true,idMsg:null,defaultLinkOperator:'==',regSeparator:':',msgElement:'p',validateColor:'#e5ff80',errorColor:'#ff5555',msgAttributes:{'style':'color=#000;padding:2px;font-size:0.9em;','class':'checkform-error'},isImgDisplay:false,validateImg:'./Img/checkform-validate.png',errorImg:'./Img/checkform-error.png',casseSensitive:true,formulaire:document,messageError:[],value:[],c:[],t:[],r:[],m:[],p:[],l:[],ol:[],e:[],tab_comp:[],type_comp:[],custom_cond:[],authorized:{alpha:/^[a-z ._\-]$/i,alphanum:/^[a-z0-9 ._\-]$/i,digitSign:/^[\-+0-9]$/,digit:/^[0-9]$/,nodigit:/^[^0-9]$/,number:/^[\d\.]$/,email:/^[a-zA-Z0-9\._%@\-]$/i,phone:/^[\d\s\+\.\-]$/,url:/^[a-z0-9\-\.\/_]$/i,date:/^[0-9\s\. ]$/,hexaColor:/#[0-9a-fA-F]$/},reg:{required:/[^.*]/,alpha:/^[a-z ._\-]+$/i,alphanum:/^[a-z0-9 ._\-]+$/i,digitSign:/^[\-+]?[0-9]+$/,digit:/^[0-9]+$/i,nodigit:/^[^0-9]+$/,number:/^[\-+]?\d*\.?\d+$/,email:/^[a-z0-9._%\-]+@[a-z0-9.\-]+\.[a-z]{2,4}$/i,phone:/^[0-9]{2}[\s]{0,1}[0-9]{2}[\s]{0,1}[0-9]{2}[\s]{0,1}[0-9]{2}[\s]{0,1}[0-9]{2}$/,url:/^(http|https):\/\/[a-z0-9\-\.\/_]+\.[a-z]{2,3}$/i,date:/^[0-9]{1,2}.[0-9]{1,2}.[0-9]{2,4}$/,hexaColor:/#[0-9a-fA-F]{6}/,notEmpty:/^(.*[^0\s].*)$/},prevKeyCode:'',keyCodeValues:{32:' ',9:'\t',13:'\n',48:'Ã ',49:'&',50:'Ã©',51:'"',52:"'",53:'(',54:'-',5:'Ã¨',56:'_',57:'Ã§',96:'0',97:'1',98:'2',99:'3',100:'4',101:'5',102:'6',103:'7',104:'8',105:'9',65:'a',66:'b',67:'c',68:'d',69:'e',70:'f',71:'g',72:'h',73:'i',74:'j',75:'k',76:'l',77:'m',78:'n',79:'o',80:'p',81:'q',82:'r',83:'s',84:'t',85:'u',86:'v',87:'w',88:'x',89:'y',90:'z',91:'.',111:'/',109:'-',107:'+',106:'*',186:';',187:'=',188:',',189:'-',191:'/',220:'\\',219:')',222:'\'',221:'^',192:'`',190:';'},fieldModif:{'field_id':'c','field_type':'t','field_reg':'r','field_msg':'m','field_event':'e','field_tab_comp':'tab_comp','field_type_comp':'type_comp','field_custom_cond':'custom_cond'},setValue:function(elem,n){if(elem.value!==''){this.value[n]=elem.value;}
else{this.value[n]='';}},setFormulaire:function(fid){this.formulaire=document.getElementById(fid);if(this.formulaire.nodeName=='FORM'){this.addEventListener(this.formulaire,"submit",this.bind(this,this.traiteSubmit),false);}
else if(this.formulaire.nodeName=='INPUT'){this.addEventListener(this.formulaire,"click",this.bind(this,this.traiteSubmit),false);}},setDebug:function(bool){this.debug=bool;},setAuthorizeKeyControl:function(bool){this.authorizeKeyControl=bool;},setFormLock:function(value){this.formLock=value;},setIsImgDisplay:function(value){this.isImgDisplay=value;},setIdMsg:function(value){this.idMsg=value;},setDefaultLinkOperator:function(value){this.defaultLinkOperator=value;},setRegSeparator:function(value){this.regSeparator=value;},setMsgElement:function(value){this.msgElement=value;},setValidateColor:function(color){this.validateColor=color;},setErrorColor:function(color){this.errorColor=color;},setMsgAttributes:function(array){this.msgAttributes=array;},setCasseSensitive:function(value){this.casseSensitive=value;},setElement:function(chp,element,value){var num_reg=this.getNumReg(chp);if(num_reg!==false){this[this.fieldModif[element]][num_reg]=value;}},getMessageError:function(){return this.messageError;},traiteKeyCode:function(keyCode,loc_e){var return_value=null;if(typeof(this.keyCodeValues[keyCode])!=='undefined'&&!loc_e.shiftKey&&!loc_e.altKey){return_value=this.keyCodeValues[keyCode];}
else if(typeof(this.keyCodeValues[keyCode])!=='undefined'&&(this.prevKeyCode==16||loc_e.shiftKey)){switch(keyCode){case 48:return_value='0';break;case 219:return_value='Â°';break;case 107:return_value='+';break;case 190:return_value='.';break;default:return_value=(keyCode%48);}}
else if(typeof(this.keyCodeValues[keyCode])!=='undefined'&&(this.prevKeyCode==18||loc_e.altKey)){switch(keyCode){case 48:return_value='@';break;case 49:return_value='^';break;case 50:return_value='~';break;case 55:return_value='`';break;case 52:return_value='|';break;case 53:return_value='[';break;case 54:return_value='{';break;case 51:return_value='#';break;case 56:return_value='\\';break;case 219:return_value=']';break;case 107:return_value='}';break;default:return_value=this.keyCodeValues[keyCode];}}
else if(typeof(this.keyCodeValues[keyCode])!=='undefined'){return_value=this.keyCodeValues[keyCode];}
this.prevKeyCode=keyCode;return return_value;},traitePress:function(n,e){var loc_e=e||window.event;if(loc_e.keyCode==9||loc_e.keyCode==8||loc_e.keyCode==37||loc_e.keyCode==38||loc_e.keyCode==39||loc_e.keyCode==40){return;}
var loc_reg=this.parseReg(this.r[n]);for(i in loc_reg){if(typeof(this.authorized[loc_reg[i]])!=='undefined')
{var keyValue=this.traiteKeyCode(loc_e.keyCode,loc_e);if(this.authorized[loc_reg[i]].test(keyValue)===false&&(loc_reg[i]!='required'||keyValue!='')){this.messageError[n]=this.m[n];break;}
else{delete this.messageError[n];}}}
if(typeof(this.messageError[n])!=='undefined'){if(loc_e.preventDefault){loc_e.preventDefault();}
loc_e.returnValue=false;return false;}
this.validateReg(n);},traiteSubmit:function(e){this.validateReg();if(this.messageError!==''&&(this.messageError.join('')).length!==0&&this.formLock===true){var loc_e=e||window.event;if(loc_e.preventDefault){loc_e.preventDefault();}
loc_e.returnValue=false;return false;}},delReg:function(chp){var num_reg=this.getNumReg(chp);this.removeEventListener(this.$(chp),this.e[num_reg],this.bind(this,this.validateReg,[num_reg]),false);this.value[num_reg]="";this.c[num_reg]="";this.t[num_reg]="";this.r[num_reg]="";this.m[num_reg]="";this.p[num_reg]="";this.l[num_reg]="";this.ol[num_reg]="";this.e[num_reg]="";this.tab_comp[num_reg]="";this.type_comp[num_reg]="";this.custom_cond[num_reg]="";delete this.messageError[num_reg];if(this.isImgDisplay===true){this.afficheMsg(num_reg);}else{this.hiddeMsg(num_reg);}},addReg:function(chp,typ,reg,event,mes,par,custom_reg,liens,operateur_liens,tab_comp,type_comp,custom_cond){var num_reg=this.getNumReg(chp);if(num_reg!==false){return false;}
if(this.$(chp)!==null)
{this.initialise(arguments);var att=this.c.length-1;if(typeof(typ)!='undefined')
{if(typ=='radio'||typ=='checkbox'){var tab_element=document.getElementsByName(chp);for(var i=0,sz=tab_element.length;i<sz;i++){this.addEventListener(tab_element[i],event,this.bind(this,this.validateReg,[att]),false);}}
else
this.addEventListener(this.$(chp),event,this.bind(this,this.validateReg,[att]),false);}
if(this.authorizeKeyControl===true&&this.existAuthorizedReg(att))
{this.addEventListener(this.$(chp),'keydown',this.bind(this,this.traitePress,[att]),false);}}
else{this.showError('DÃ©veloppeur : Attention l\'Ã©lÃ©ment id = "'+chp+'" n\'existe pas.\n'
+'l\'Ã©lÃ©ment name = "'+chp+'" n\'existe pas non plus.');}},initialise:function(){this.c.push(arguments['0']['0']);this.t.push(arguments['0']['1']);this.r.push(arguments['0']['2']);this.e.push(arguments['0']['3']);this.m.push(arguments['0']['4']);this.p.push(arguments['0']['5']);var custom=arguments['0']['6'];if(custom!==''&&custom!='undefined'&&typeof(custom)!='undefined'){this.reg.custom=custom;}
this.l.push((arguments['0']['7']!='undefined')?arguments['0']['7']:'');this.ol.push((arguments['0']['8']!='undefined')?arguments['0']['8']:'');this.tab_comp.push((arguments['0']['9']!='undefined')?arguments['0']['9']:'');this.type_comp.push((arguments['0']['10']!='undefined')?arguments['0']['10']:'');this.custom_cond.push((arguments['0']['11']!='undefined')?arguments['0']['11']:'');},validateReg:function(){if(arguments.length!==0)
{for(var i=0,sz=arguments.length;i<sz;++i){this.execute(arguments[i]);}}
else
{for(var n in this.t){if(n!='undefined'){this.execute(n);}}}},execute:function(n){if(isNaN(n)||this.c[n]==''){return;}
this.setValue(this.$(this.c[n]),n);var loc_reg=this.parseReg(this.r[n]);var isError=false;if(loc_reg.length!==0)
{for(i in loc_reg){if(typeof(loc_reg[i])=='string'){if(!this.reg[loc_reg[i]].test(this.value[n])&&(this.isRequired(n)||this.value[n]!='')){isError=true;break;}}}}
if(typeof(this.p[n])!='undefined')
{var length=(typeof(this.value[n])=='undefined')?0:this.value[n].length;if(length<this.p[n]['0']||length>this.p[n]['1']){isError=true;}}
if(typeof(this.t[n])!='undefined')
{var tab_element=document.getElementsByName(this.c[n]);var nb_checked=0;for(var i=0,sz=tab_element.length;i<sz;i++){if(typeof(tab_element[i])!=='object'){continue;}
if(tab_element[i].checked===true){++nb_checked;}}
if(this.t[n]=='radio'){if(this.r[n]=='required'){if(nb_checked<1){isError=true;}}
if(nb_checked>1){isError=true;}}
else if(this.t[n]=='checkbox')
{if(typeof(this.p[n])!='undefined')
{if(nb_checked<this.p[n]['0']||nb_checked>this.p[n]['1'])
isError=true;}}}
if(typeof(this.l[n])!='undefined')
{for(var i in this.l[n])
{var operator=(typeof(this.ol[n])!=='undefined')?this.ol[n]:this.defaultLinkOperator;if(!eval("'"+this.value[n]+"' "+operator+" '"+this.$(this.l[n][i]).value+"'")){isError=true;}}}
if(typeof(this.tab_comp[n])!='undefined')
{var tab_words=this.value[n].split(' ');var nb_found=0;for(var i=0,sz=this.tab_comp[n].length;i<sz;++i)
{for(var j=0,sz2=tab_words.length;j<sz2;++j)
{if(this.casseSensitive===false){if(this.tab_comp[n][i].toLowerCase()==tab_words[j].toLowerCase()){++nb_found;}}else{if(this.tab_comp[n][i]==tab_words[j]){++nb_found;}}}}
var nb_nf=this.tab_comp[n].length-nb_found;if(this.type_comp[n]=='texte_rand'){if(nb_found!=this.tab_comp[n].length){isError=true;}}else{if(this.type_comp[n]>=0){if(nb_found!=this.type_comp[n]){isError=true;}}else if(nb_found==0){isError=true;}}}
if(typeof(this.custom_cond[n])!='undefined')
{if(!eval("'"+this.value[n]+"' "+this.custom_cond[n])){isError=true;}}
if(isError)
{this.messageError[n]=this.m[n];this.afficheMsg(n);}
else{delete this.messageError[n];if(this.isImgDisplay===true){this.afficheMsg(n);}else{this.hiddeMsg(n);}}},hiddeMsg:function(n){if(document.getElementById(this.fid+'-msg-error-'+n)===null){return false;}
var node=document.getElementById(this.fid+'-msg-error-'+n);node.parentNode.removeChild(node);this.colorize(n,false);},afficheMsg:function(n){this.hiddeMsg(n);var new_node=document.createElement(this.msgElement);new_node.id=this.fid+'-msg-error-'+n;var txt=this.messageError[n];if(this.isImgDisplay===true){new_node.className='checkform-img-error';var image=document.createElement('img');image.id=this.fid+'-checkform-image-'+n;if(typeof(txt)=='undefined'){image.src=this.validateImg;}
else if(this.errorImg!=''){image.src=this.errorImg;}
new_node.appendChild(image);}else{new_node.className='checkform-msg-error';var new_txt=document.createTextNode(txt);new_node.appendChild(new_txt);}
for(var i in this.msgAttributes){if(i!='undefined'){new_node.setAttribute(i,this.msgAttributes[i]);}}
if(this.idMsg!==null&&this.isImgDisplay===false){var cur_node=this.$(this.idMsg);cur_node.appendChild(new_node,cur_node);}else{var cur_node=this.$(this.c[n]);this.insertAfter(new_node,cur_node);}
this.colorize(n,true);},colorize:function(n,state){if(typeof(this.$(this.c[n]))==='undefined'){return false;}
if(state){this.$(this.c[n]).style.backgroundColor=this.errorColor;}
else{this.$(this.c[n]).style.backgroundColor=this.validateColor;}},showError:function(msg){if(this.debug){alert(msg);}},isRequired:function(n){var loc_reg=this.parseReg(this.r[n]);if(loc_reg.length!==0)
{for(i in loc_reg){if(typeof(loc_reg[i])=='string'){if(loc_reg[i]=='required'){return true;}}}}
return false;},getNumReg:function(chp){for(var i=0,sz=this.c.length;i<sz;++i){if(this.c[i]==chp){return i;}}
return false;},existAuthorizedReg:function(n){var loc_reg=this.parseReg(this.r[n]);if(loc_reg.length!==0)
{for(i in loc_reg){if(typeof(this.authorized[loc_reg[i]])!=='undefined'){return true;}}}
return false;},parseReg:function(reg){return reg.split(this.regSeparator);},$:function(elem){if(document.getElementById(elem)!==null){return document.getElementById(elem);}
else if(typeof(document.getElementsByName(elem))!='undefined'){return document.getElementsByName(elem)['0'];}
else{return null;}},insertAfter:function(new_node,node){var parent_node=node.parentNode.parentNode;var next_node=node.parentNode.nextSibling;try
{if(next_node===null){parent_node.appendChild(new_node,parent_node);}
else{parent_node.insertBefore(new_node,next_node);}}
catch(e)
{showError(e);}},addEventListener:function(element,event_name,observer,capturing){if(element.addEventListener){element.addEventListener(event_name,observer,capturing);}
else if(element.attachEvent){element.attachEvent("on"+event_name,observer);}},removeEventListener:function(element,event_name,observer,capturing){if(element.removeEventListener){element.removeEventListener(event_name,observer,capturing);}
else if(element.detachEvent){element.detachEvent("on"+event_name,observer);}},bind:function(obj,fun,args){return function(){if(obj===true){obj=this;}
var f=typeof fun==="string"?obj[fun]:fun;return f.apply(obj,Array.prototype.slice.call(args||[]).concat(Array.prototype.slice.call(arguments)));};}};(function($){$.fn.NiceIt=function(settings){settings=jQuery.extend({Version:'1.0'},settings);var jQueryMatchedObj=this;Run(this,jQueryMatchedObj);function Run(objForm,jQueryMatchedObj){for(var idx=0;idx<jQueryMatchedObj.length;idx++){var form=$(jQueryMatchedObj[idx]);if(!$(form).attr('id')){$(form).attr('id','fm-'+idx);}
$(form).setTabIndexes();$(form).fnReplaceCheckBoxes();$(form).fnReplaceRadioButtons();$(form).fnReplaceInputBoxes();$(form).fnReplaceSelectBoxes();$(form).fnReplaceSelectboxesM();$(form).fnReplaceTextareas();$(form).fnReplaceButtons();$(form).fnReplaceFiles();}}
return;};$.fn.setTabIndexes=function(){$(this).find('select, input:not(:hidden), textarea, button').each(function(i,ctrl){$(ctrl).attr('tabindex',(i+1));});}
$.fn.fnReplaceCheckBoxes=function(){var objForm=this;$(objForm).find('input[type="checkbox"]').each(function(i,ctrl){$(ctrl).hide();var id='fmCbx-'+$(objForm).attr('id')+'-'+(i+1);if($(ctrl).attr('id')){id='fmChbx-'+$(ctrl).attr('id');}
$(ctrl).after('<b class="fmCheckbox'+($(ctrl).attr('checked')?' checked':'')+'" id="'+id+'">&nbsp;</b>');var nCtrl=$('#'+id);if($(ctrl).attr('disabled')){$(nCtrl).addClass('chbx-disabled');return;}
$(ctrl).bind('click',function(){if(!$(ctrl).attr('checked')){$(nCtrl).removeClass('checked');}else{$(nCtrl).addClass('checked');}});$(nCtrl).bind('click',function(){if($(ctrl).attr('checked')){$(ctrl).attr('checked',false);$(nCtrl).removeClass('checked');}else{$(ctrl).attr('checked',true);$(nCtrl).addClass('checked');}});$('label[for="'+$(ctrl).attr('id')+'"]').bind('click',function(){if($(ctrl).attr('checked')){$(ctrl).attr('checked',false);$(nCtrl).removeClass('checked');}else{$(ctrl).attr('checked',true);$(nCtrl).addClass('checked');}});});}
$.fn.fnReplaceRadioButtons=function(){var objForm=this;$(objForm).find('input[type="radio"]').each(function(i,ctrl){$(ctrl).hide();var id='fmRbtn-'+$(objForm).attr('id')+'-'+(i+1);if($(ctrl).attr('id')){id='fmRbtn-'+$(ctrl).attr('id');}
$(ctrl).after('<a rel="'+$(ctrl).attr('name')+'" class="fmRadio'+($(ctrl).attr('checked')?' checked':'')+'" id="'+id+'">&nbsp;</a>');var nCtrl=$('#'+id);if($(ctrl).attr('disabled')){$(nCtrl).addClass('rbtn-disabled');return;}
$(ctrl).bind('click',function(){$('.fmRadio[rel="'+$(ctrl).attr('name')+'"]').removeClass('checked');$(nCtrl).addClass('checked');});$(nCtrl).bind('click',function(){$('.fmRadio[rel="'+$(nCtrl).attr('rel')+'"]').removeClass('checked');$('input[name="'+$(nCtrl).attr('rel')+'"]').attr('checked',false);$(this).addClass('checked');$(ctrl).attr('checked',true);return false;});});}
$.fn.fnReplaceInputBoxes=function(){var objForm=this;$(objForm).find('input[type="text"],input[type="password"]').each(function(i,ctrl){var width='50%';if($(ctrl).css('width')!='auto'&&$(ctrl).parent().css('width')!='auto'){width=Math.ceil(100*parseFloat($(ctrl).css('width'))/parseFloat($(ctrl).parent().css('width')))+'%';}
var id='fmInp-'+$(objForm).attr('id')+'-'+(i+1);if($(ctrl).attr('id')){id='fmInp-'+$(ctrl).attr('id');}
$(ctrl).width('100%');$(ctrl).wrap('<span class="fmInput" id="'+id+'"><span></span></span>');var nCtrl=$('#'+id);$(nCtrl).width(width);if($(ctrl).attr('disabled')){$(nCtrl).addClass('disabled');}
$(nCtrl).swapStyles($(ctrl));$(ctrl).bind('focus',function(){if($(ctrl).val()==$(ctrl).attr('title')){$(ctrl).val('');}
$(nCtrl).CtrlInFocus();});$(ctrl).bind('blur',function(){if($(ctrl).val()==''){$(ctrl).val($(ctrl).attr('title'));}
$(nCtrl).CtrlOutFocus();});});}
$.fn.fnReplaceSelectBoxes=function(){var objForm=this;var cite='strong span cite';$(objForm).find('select').each(function(i,ctrl){if($(ctrl).attr('multiple')){return;}
var width='50%';if($(ctrl).css('width')!='auto'&&$(ctrl).parent().css('width')!='auto'){width=Math.ceil(100*parseFloat($(ctrl).css('width'))/parseFloat($(ctrl).parent().css('width')))+'%';}
var id='fmCbox-'+$(objForm).attr('id')+'-'+(i+1);if($(ctrl).attr('id')){id=$(ctrl).attr('id');$(ctrl).attr('id','');}
$(ctrl).width('100%');var selectedTxt=($(ctrl).find('option:selected').text()!=''?$(ctrl).find('option:selected').text():'&nbsp;');$(ctrl).before('<div class="fmSelect" tabindex="'+$(ctrl).attr('tabindex')+'" id="'+id+'"><strong><span><cite>'+selectedTxt+'</cite></span></strong><ul></ul></div>');$(ctrl).attr('tabindex','');$(ctrl).hide();var nCtrl=$('#'+id);$(nCtrl).width(width);$(nCtrl).swapStyles($(ctrl));$(nCtrl).bind('click',function(){$(this).find('ul').show();});$(nCtrl).bind('mouseleave',function(){$(this).find('ul').hide();});$(nCtrl).bind('focus',function(){$('body').focus();$('.fmSelect').css('z-index','100');$(nCtrl).css('z-index','1500');$(this).CtrlInFocus();});$(nCtrl).bind('blur',function(){$(this).CtrlOutFocus();});$(ctrl).find('option').each(function(idx,item){nCtrl.find('ul').append('<li option="'+$(item).attr('value')+'">'+$(item).text()+'</li>');});nCtrl.find('li').each(function(num,elem){$(elem).bind('mouseenter',function(){$(this).addClass('active');});$(elem).bind('mouseout',function(){$(this).removeClass('active');});$(elem).bind('click',function(){nCtrl.find(cite).text($(this).text());$(ctrl).val($(this).attr('option'));nCtrl.find('ul').fadeOut();});});nCtrl.bind('keydown',function(event){var selected=$(ctrl).find('option:selected');$(nCtrl).find('ul').hide();if(event.keyCode==38){if(selected.val()!=$(ctrl).find('option:first').val()){selected.prev().attr('selected',true);$(nCtrl).find(cite).text(selected.prev().text());}
return false;}
if(event.keyCode==40){if(selected.val()!=$(ctrl).find('option:last').val()){selected.next().attr('selected',true);$(nCtrl).find(cite).text(selected.next().text());}
return false;}
if(event.keyCode==33){$(ctrl).find('option:first').attr('selected',true);$(nCtrl).find(cite).text($(ctrl).find('option:first').text());return false;}
if(event.keyCode==34){$(ctrl).find('option:last').attr('selected',true);$(nCtrl).find(cite).text($(ctrl).find('option:last').text());return false;}});$(ctrl).bind('change',function(){nCtrl.find(cite).text($(this).find('option:selected').text());});});}
$.fn.fnReplaceSelectboxesM=function(){var objForm=this;$(objForm).find('select[multiple]').each(function(i,ctrl){var width='100%';var height=$(ctrl).height();if($(ctrl).css('width')!='auto'&&$(ctrl).parent().css('width')!='auto'){width=Math.ceil(100*parseFloat($(ctrl).css('width'))/parseFloat($(ctrl).parent().css('width')))+'%';}
var id='fmMsel-'+$(objForm).attr('id')+'-'+(i+1);if($(ctrl).attr('id')){id=$(ctrl).attr('id');$(ctrl).attr('id','');}
$(ctrl).wrap('<span class="fmMultipleSelect" id="'+id+'"><span><span><span></span></span></span></span>');var nCtrl=$('#'+id);$(nCtrl).width(width);$(ctrl).width('96%');$(ctrl).height(height);$(ctrl).bind('focus',function(){$(nCtrl).CtrlInFocus();});$(ctrl).bind('blur',function(){$(nCtrl).CtrlOutFocus();});});}
$.fn.fnReplaceTextareas=function(){var objForm=this;$(objForm).find('textarea').each(function(i,ctrl){var width='50%';var height=$(ctrl).height();if($(ctrl).css('width')!='auto'&&$(ctrl).parent().css('width')!='auto'){width=Math.ceil(100*parseFloat($(ctrl).css('width'))/parseFloat($(ctrl).parent().css('width')))+'%';}
var id='fmTarea-'+$(objForm).attr('id')+'-'+(i+1);if($(ctrl).attr('id')){id='fmTarea-'+$(ctrl).attr('id');}
$(ctrl).wrap('<span class="fmTextarea" id="'+id+'"><span><span><span></span></span></span></span>');var nCtrl=$('#'+id);$(nCtrl).width(width);$(ctrl).height(height);if($(ctrl).attr('disabled')){$(nCtrl).addClass('tx-disabled');}
$(ctrl).bind('focus',function(){$(nCtrl).CtrlInFocus();});$(ctrl).bind('blur',function(){$(nCtrl).CtrlOutFocus();});});}
$.fn.fnReplaceButtons=function(){var objForm=this;$(objForm).find('button:not(.fmButton)').each(function(i,ctrl){$(ctrl).addClass('fmButton');if($(ctrl).attr('type').toLowerCase()=='submit'){$(ctrl).wrapInner('<strong><span></span></strong>');}else{$(ctrl).wrapInner('<span><span></span></span>');}
$(ctrl).bind('focus',function(){$(ctrl).CtrlInFocus();});$(ctrl).bind('blur',function(){$(ctrl).CtrlOutFocus();});});}
$.fn.fnReplaceFiles=function(){var objForm=this;$(objForm).find('input[type="file"]').each(function(i,ctrl){var width='50%';if($(ctrl).css('width')!='auto'&&$(ctrl).parent().css('width')!='auto'){width=Math.ceil(100*parseFloat($(ctrl).css('width'))/parseFloat($(ctrl).parent().css('width')))+'%';}
var id='fmFinp-'+$(objForm).attr('id')+'-'+(i+1);if($(ctrl).attr('id')){id='fmFinp-'+$(ctrl).attr('id');}
$(ctrl).before('<a tabindex="'+$(ctrl).attr('tabindex')+'" class="fnFileInput" id="'+id+'"><span><cite>Not Selected ...</cite><strong>'+($(ctrl).attr('title')!=''?$(ctrl).attr('title'):'Browse ...')+'</strong></span></a>');$(ctrl).attr('tabindex',0);$(ctrl).addClass('fnFileHidden');var nCtrl=$('#'+id);$(ctrl).appendTo('#'+id+' span strong');$(nCtrl).width(width);if($(ctrl).attr('disabled')){$(nCtrl).addClass('disabled');}
$(ctrl).bind('change',function(){$(nCtrl).find('cite').text($(this).attr('value'));});$(nCtrl).bind('focus',function(){$(nCtrl).CtrlInFocus();});$(nCtrl).bind('blur',function(){$(nCtrl).CtrlOutFocus();});});}
$.fn.swapStyles=function(objSrc){var styles=new Array('margin-left','margin-right','margin-top','margin-bottom');$(styles).each(function(idx,property){$(this).css(property,$(objSrc).css(property));});$(objSrc).addClass('fmZero');}
$.fn.CtrlInFocus=function(){$(this).addClass('fmInFocus');}
$.fn.CtrlOutFocus=function(){$(this).removeClass('fmInFocus');}})(jQuery);
