jQuery.NiceJForms={options:{selectRightSideWidth:27,selectLeftSideWidth:1,selectAreaHeight:21,selectAreaOptionsOverlap:2,imagesPath:(typeof (root_path)!="undefined"?root_path:"/")+"imgs/formElements/",afterSelect:null},selectText:"please select",preloads:new Array(),inputs:new Array(),labels:new Array(),textareas:new Array(),selects:new Array(),radios:new Array(),checkboxes:new Array(),texts:new Array(),buttons:new Array(),radioLabels:new Array(),checkboxLabels:new Array(),hasImages:true,keyPressed:function(E){var H=E.charCode||E.keyCode||-1;if(E.type=="keyup"){return false}switch(H){case 40:var D=jQuery.NiceJForms.selects;var A=$(this).parent().parent().attr("id").replace(/sarea/g,"");var G=0;for(var F=0;F<D[A].options.length;F++){if(D[A].options[F].selected){G=F}}++G;if(G>=D[A].options.length){G=0}jQuery.NiceJForms.selectMe(D[A].id,G,A);return false;break;case 38:var D=jQuery.NiceJForms.selects;var A=$(this).parent().parent().attr("id").replace(/sarea/g,"");var G=0;for(var F=0;F<D[A].options.length;F++){if(D[A].options[F].selected){G=F}}--G;if(G<0){G=D[A].options.length-1}jQuery.NiceJForms.selectMe(D[A].id,G,A);return false;break;default:var B=String.fromCharCode(H).toLowerCase();var C=/^[0-9A-Za-z]+$/;if(!C.test(B)){return true}var D=jQuery.NiceJForms.selects;var A=$(this).parent().parent().attr("id").replace(/sarea/g,"");var G=0;for(var F=0;F<D[A].options.length;F++){if(D[A].options[F].innerHTML.substring(0,1).toLowerCase()==B){G=F;break}}jQuery.NiceJForms.selectMe(D[A].id,G,A);return false;break}},build:function(A){if(A){jQuery.extend(jQuery.NiceJForms.options,A)}if(window.event){jQuery("body",document).bind("keyup",jQuery.NiceJForms.keyPressed);jQuery("body",document).bind("click",jQuery.NiceJForms.hideAllOptions)}else{jQuery(document).bind("keyup",jQuery.NiceJForms.keyPressed);jQuery(document).bind("click",jQuery.NiceJForms.hideAllOptions)}var B=document.createElement("img");$(B).attr("src",jQuery.NiceJForms.options.imagesPath+"blank.gif").attr("id","imagineTest");jQuery("body").append(B);if(B.complete){if(B.offsetWidth=="1"){jQuery.NiceJForms.hasImages=true}else{jQuery.NiceJForms.hasImages=false}}$(B).remove();if(jQuery.NiceJForms.hasImages){$("form.niceform").add("form.tldform").each(function(){el=jQuery(this);jQuery.NiceJForms.preloadImages();jQuery.NiceJForms.getElements(el)});jQuery.NiceJForms.replaceSelects();if(!$.browser.safari){}}},preloadImages:function(){jQuery.NiceJForms.preloads=$.preloadImages(jQuery.NiceJForms.options.imagesPath+"button_left_xon.gif",jQuery.NiceJForms.options.imagesPath+"button_right_xon.gif",jQuery.NiceJForms.options.imagesPath+"input_left_xon.gif",jQuery.NiceJForms.options.imagesPath+"input_right_xon.gif",jQuery.NiceJForms.options.imagesPath+"txtarea_bl_xon.gif",jQuery.NiceJForms.options.imagesPath+"txtarea_br_xon.gif",jQuery.NiceJForms.options.imagesPath+"txtarea_cntr_xon.gif",jQuery.NiceJForms.options.imagesPath+"txtarea_l_xon.gif",jQuery.NiceJForms.options.imagesPath+"txtarea_tl_xon.gif",jQuery.NiceJForms.options.imagesPath+"txtarea_tr_xon.gif")},getElements:function(H){el=H?jQuery(H):jQuery(this);var E=0;var G=0;var D=0;var F=0;var B=0;var C=0;var A=0;jQuery.NiceJForms.inputs=$("input",el);jQuery.NiceJForms.labels=$("label",el);jQuery.NiceJForms.textareas=$("textarea",el);jQuery.NiceJForms.radios=$("input[type=radio]",el);jQuery.NiceJForms.checkboxes=$("input[type=checkbox]",el);jQuery.NiceJForms.texts=$("input[type=text]",el).add($("input[type=password]",el));jQuery.NiceJForms.buttons=$("input[type=submit]",el).add($("input[type=button]",el));$("select",el).each(function(){jQuery.NiceJForms.selects.push(this)});jQuery.NiceJForms.labels.each(function(I){labelFor=$(jQuery.NiceJForms.labels[I]).attr("for");jQuery.NiceJForms.radios.each(function(J){if(labelFor==$(jQuery.NiceJForms.radios[J]).attr("id")){if(jQuery.NiceJForms.radios[J].checked){$(jQuery.NiceJForms.labels[I]).removeClass().addClass("chosen")}jQuery.NiceJForms.radioLabels[F]=jQuery.NiceJForms.labels[I];++F}});jQuery.NiceJForms.checkboxes.each(function(J){if(labelFor==$(this).attr("id")){if(this.checked){$(jQuery.NiceJForms.labels[I]).removeClass().addClass("chosen")}jQuery.NiceJForms.checkboxLabels[B]=jQuery.NiceJForms.labels[I];++B}})})},replaceSelects:function(){var A=this;jQuery.NiceJForms.selects=$(jQuery.NiceJForms.selects);jQuery.NiceJForms.selects.each(function(C){var D=document.createElement("div");var E=document.createElement("div");var I=document.createElement("div");var B=document.createElement("div");var G=document.createElement("a");var J=document.createTextNode(jQuery.NiceJForms.selectText);var F=parseInt(this.className.replace(/width_/g,""));if(!F){F=300}jQuery(B).attr({id:"mySelectText"+C}).css({width:F-10+"px"});jQuery(D).attr({id:"sarea"+C}).css({width:F+jQuery.NiceJForms.options.selectRightSideWidth+jQuery.NiceJForms.options.selectLeftSideWidth+"px"}).addClass("selectArea");jQuery(G).css({width:F+jQuery.NiceJForms.options.selectRightSideWidth+jQuery.NiceJForms.options.selectLeftSideWidth+"px",marginLeft:-F-jQuery.NiceJForms.options.selectLeftSideWidth+"px",cursor:"pointer"}).addClass("selectButton").bind("click",{who:C},function(K){A.showOptions(K)}).keydown(jQuery.NiceJForms.keyPressed).attr("href","javascript:void(0)");jQuery(E).addClass("left");jQuery(I).addClass("right").append(G);jQuery(B).addClass("center").append(J);jQuery(D).append(E).append(I).append(B).insertBefore(this);$(this).hide();var H=document.createElement("div");selectAreaPos=$(D).offset();jQuery(H).attr({id:"optionsDiv"+C}).css({width:F+1+"px",left:selectAreaPos.left+"px",top:selectAreaPos.top+jQuery(B).height()+7-jQuery.NiceJForms.options.selectAreaOptionsOverlap+"px"}).addClass("optionsDivInvisible");$(jQuery.NiceJForms.selects[C]).children().each(function(K){var L=document.createElement("p");var M=document.createElement("a");var N=document.createTextNode(jQuery.NiceJForms.selects[C].options[K].text);jQuery(M).attr({href:"#"}).css({cursor:"pointer"}).append(N).bind("click",{who:C,id:jQuery.NiceJForms.selects[C].id,option:K,select:C},function(O){A.showOptions(O);A.selectMe(jQuery.NiceJForms.selects[C].id,K,C);return false});jQuery(L).append(M);jQuery(H).append(L);if(jQuery.NiceJForms.selects[C].options[K].selected){A.selectMe($(jQuery.NiceJForms.selects[C]).attr("id"),K,C)}});jQuery("body").append(H)})},selectMe:function(A,D,B){selectField=$("#"+A);sFoptions=selectField.children();selectField.children().each(function(E){if(E==D){sFoptions[E].selected="selected";if(jQuery.NiceJForms.options.afterSelect){jQuery.NiceJForms.options.afterSelect(jQuery.NiceJForms.selects[B].id)}}else{sFoptions[E].selected=""}});textVar=$("#mySelectText"+B);var C=document.createTextNode($(sFoptions[D]).text());textVar.empty().append(C)},showOptions:function(B){var A=this;selectAreaTop=$("#sarea"+B.data.who).offset().top+$("#sarea"+B.data.who).height()-2;selectAreaLeft=$("#sarea"+B.data.who).offset().left;if($("#optionsDiv"+B.data.who).height()>308){$("#optionsDiv"+B.data.who).height(308)}$("#optionsDiv"+B.data.who).css({top:selectAreaTop,left:selectAreaLeft}).toggleClass("optionsDivVisible").toggleClass("optionsDivInvisible")},hideOptions:function(B){if(!B){var B=window.event}var A=(B.relatedTarget)?B.relatedTarget:B.toElement;if(((A.nodeName!="A")&&(A.nodeName!="DIV"))||((A.nodeName=="A")&&(A.className=="selectButton")&&(A.nodeName!="DIV"))){}B.cancelBubble=true;if(B.stopPropagation){B.stopPropagation()}},hideAllOptions:function(B){var A="";if($(B.target).attr("class")=="selectButton"){A=$(B.target).parent().parent()[0].id.replace(/sarea/g,"")}$(".optionsDivVisible").not("#optionsDiv"+A).removeClass("optionsDivVisible").addClass("optionsDivInvisible")}};jQuery.preloadImages=function(){var B=new Array();for(var A=0;A<arguments.length;A++){B[A]=jQuery("<img>").attr("src",arguments[A])}return B};
