/* Last published on : 26-May-11 16:00:38 */
var COM_KLM_REBRAND_FORMS={form:'klm-form',formContainer:'klm-form-container',formConfirmationField:'klm-form-confirmation',formSubmitField:'klm-form-submit',formErrorBoxId:'form-error-box',formMsgBoxClassName:'form-message-box',submitButtonId:'submitButton',formFieldInformationId:'form-field-information',repeatButtonClass:'repeat-button',deleteButtonClass:'delete-button',infoIconClassName:"field-info-link",messageBox:null,messageBoxHeader:null,messageBoxList:null,messageBoxAnchorErrorClass:'link-more',fieldToolTips:{},init:function(){var to,tar,i,inputs,t,box,showMessage,hideMessage,formChildren,s,input,el,tagName,DOMFormElement,num;num=0;DOMFormElement=YAHOO.util.Dom.get('klm-form');if(!DOMFormElement&&document.forms['klm-form']){DOMFormElement=document.forms['klm-form'];}
if(DOMFormElement){inputs=[];t=YAHOO.util.Dom.getElementsByClassName(COM_KLM_REBRAND_FORMS.formFieldInformationId,'div');repeatButtons=YAHOO.util.Dom.getElementsByClassName(COM_KLM_REBRAND_FORMS.repeatButtonClass,'a');deleteButtons=YAHOO.util.Dom.getElementsByClassName(COM_KLM_REBRAND_FORMS.deleteButtonClass,'a');for(i=0;i<t.length;i=i+1){s=t[i].getElementsByTagName('span');input=YAHOO.util.Dom.get(s[0].innerHTML);inputs[i]=new COM_KLM_REBRAND_FORMS.formMessage(s);}
for(i=0;i<repeatButtons.length;i++){b=repeatButtons[i];data=b.id.split('-button-');blockID=data[0];if(data.length>1){if(data[1].length==0){num=1;}else{num=parseInt(data[1])+1;}}else{num=1;}
YAHOO.util.Event.addListener(b,'click',COM_KLM_REBRAND_FORMS.duplicateBlock,{id:blockID,num:num});}
for(i=0;i<deleteButtons.length;i++){b=deleteButtons[i];data=b.id.split('-deletebutton-');blockID=data[0];num=data[1];YAHOO.util.Event.addListener(b,'click',COM_KLM_REBRAND_FORMS.deleteBlock,{id:blockID,num:num});}
COM_KLM_REBRAND_FORMS.addFormValidationEvent(DOMFormElement);COM_KLM_REBRAND_FORMS.addTooltips(DOMFormElement);COM_KLM_REBRAND_FORMS.selectFirstFormField();setTimeout(function(){COM_KLM_REBRAND_FORMS.removeTREvents();},1000);}},duplicateBlock:function(e,args){YAHOO.util.Event.preventDefault(e);var container=YAHOO.util.Dom.get(COM_KLM_REBRAND_FORMS.formContainer);var validationField=document.createElement('input');validationField.type='hidden';validationField.name='validateFormField';validationField.value='false';var duplicationField=document.createElement('input');duplicationField.type='hidden';duplicationField.name='sfx'+args.id;duplicationField.value=args.num;var confirmationField=YAHOO.util.Dom.get(COM_KLM_REBRAND_FORMS.formConfirmationField);if(confirmationField){container.removeChild(confirmationField);}
var submitField=YAHOO.util.Dom.get(COM_KLM_REBRAND_FORMS.formSubmitField);if(submitField){submitField.value='false';}
YAHOO.util.Dom.insertAfter(validationField,YAHOO.util.Dom.getLastChild(container));YAHOO.util.Dom.insertAfter(duplicationField,YAHOO.util.Dom.getLastChild(container));var form=YAHOO.util.Dom.get(COM_KLM_REBRAND_FORMS.form);if(!form){form=document.forms[COM_KLM_REBRAND_FORMS.form];}
form.submit();},deleteBlock:function(e,args){YAHOO.util.Event.preventDefault(e);var container=YAHOO.util.Dom.get(COM_KLM_REBRAND_FORMS.formContainer);var validationField=document.createElement('input');validationField.type='hidden';validationField.name='validateFormField';validationField.value='false';var block=YAHOO.util.Dom.get(args.id+'_'+args.num);block.parentNode.removeChild(block);var confirmationField=YAHOO.util.Dom.get(COM_KLM_REBRAND_FORMS.formConfirmationField);if(confirmationField){container.removeChild(confirmationField);}
var submitField=YAHOO.util.Dom.get(COM_KLM_REBRAND_FORMS.formSubmitField);if(submitField){submitField.value='false';}
YAHOO.util.Dom.insertAfter(validationField,YAHOO.util.Dom.getLastChild(container));var form=YAHOO.util.Dom.get(COM_KLM_REBRAND_FORMS.form);if(!form){form=document.forms[COM_KLM_REBRAND_FORMS.form];}
form.submit();},removeTREvents:function(){var DOMFormElement,tableRows;DOMFormElement=YAHOO.util.Dom.get('klm-form');if(!DOMFormElement&&document.forms['klm-form']){DOMFormElement=document.forms['klm-form'];}
if(DOMFormElement){tableRows=DOMFormElement.getElementsByTagName('tr');for(i=0;i<tableRows.length;i=i+1){YAHOO.util.Event.purgeElement(tableRows[i])}}},selectFirstFormField:function(){var DOMFormElement,formChildren,firstField,interval;DOMFormElement=YAHOO.util.Dom.get('klm-form');if(!DOMFormElement&&document.forms['klm-form']){DOMFormElement=document.forms['klm-form'];}
if(DOMFormElement){formChildren=DOMFormElement.getElementsByTagName('*');for(i=0;i<formChildren.length;i=i+1){firstField=formChildren[i];tagName=firstField.tagName.toLowerCase();className=firstField.className.toLowerCase();if(((tagName==='input'&&firstField.type!='hidden')||tagName==='select'||tagName==='textarea')&&!className.match('readonly')){if(firstField.attributes["labelshowinmail"]==null||firstField.attributes["labelshowinmail"].nodeValue!='labelshowinmail'){if(COM_KLM_REBRAND_FORMS.getFormBlock(firstField).style.display!='none'){firstField.blur();break;}}}}
interval=window.setInterval(function(){firstFieldFocus=YAHOO.util.Dom.hasClass(firstField,"isSelected");if(firstFieldFocus){window.clearInterval(interval);}else{firstField.focus();YAHOO.util.Dom.addClass(firstField,"isSelected");}},100);}},getFormBlock:function(el){if(YAHOO.util.Dom.hasClass(el,'form-block')){return el;}else{if(el.tagName!='body'){return COM_KLM_REBRAND_FORMS.getFormBlock(el.parentNode);}else{return false;}}},formMessage:function(data){var mBox,mBoxContent,mBoxArrow,tableRow,y,x,myAnim,elem,lastTd,helpText,elements;helpText=data[1].innerHTML;mBox=document.createElement('div');mBox.className=COM_KLM_REBRAND_FORMS.formMsgBoxClassName;mBox.style.display='none';if(helpText!==""){mBoxContent=document.createElement('div');mBoxContent.appendChild(document.createTextNode(helpText));mBoxContent.className="mBoxContent";mBoxArrow=document.createElement('div');mBoxArrow.appendChild(document.createTextNode(""));mBoxArrow.className="mBoxArrow";mBox.appendChild(mBoxContent);mBox.appendChild(mBoxArrow);YAHOO.util.Dom.setStyle(mBox,'opacity',0);tableRow=YAHOO.util.Dom.get(data[0]).parentNode.parentNode.parentNode;lastTd=YAHOO.util.Dom.getLastChild(tableRow);lastTd.appendChild(mBox);}
if(data[0].innerHTML.length>0){elements=data[0].innerHTML.split(',');for(var e=0;e<elements.length;e++){currElem=YAHOO.util.Dom.get(YAHOO.lang.trim(elements[e]));boolTagName=currElem.tagName.toLowerCase()==='input';currAttr=currElem.getAttribute('type');boolHasType=currAttr!==null;if(boolTagName&&boolHasType&&(currAttr.toLowerCase()==='radio'||currAttr.toLowerCase()==='checkbox')){inputElemParent=currElem.parentNode;siblings=YAHOO.util.Dom.getChildren(inputElemParent);for(i=siblings.length-1;i>=0;i--){COM_KLM_REBRAND_FORMS.addFieldEvents(siblings[i],mBox);};}else{COM_KLM_REBRAND_FORMS.addFieldEvents(currElem,mBox);}}}},addFieldEvents:function(elem,mBox){YAHOO.util.Event.addListener(elem,'click',function(e){COM_KLM_REBRAND_FORMS.addHasFocusClass(this);mBox.style.display='block';myAnim=new YAHOO.util.Anim(mBox,{opacity:{to:1}},0.1);myAnim.onComplete.subscribe(function(){mBox.style.display='block';});myAnim.animate();});YAHOO.util.Event.addListener(elem,'blur',function(e){COM_KLM_REBRAND_FORMS.removeHasFocusClass(this);myAnim=new YAHOO.util.Anim(mBox,{opacity:{to:0}},0.1);myAnim.onComplete.subscribe(function(){mBox.style.display='none';});myAnim.animate();});},addTooltips:function(form){var infoIconBox,infoIconToolTip,infoIcon,infoIcons,i;infoIcons=YAHOO.util.Dom.getElementsByClassName(COM_KLM_REBRAND_FORMS.infoIconClassName,'div',form);for(i=0;i<infoIcons.length;i=i+1){infoIcon=YAHOO.util.Dom.get(infoIcons[i]);infoIconBox=infoIcon.id.replace('-link','-box');COM_KLM_REBRAND_FORMS.fieldToolTips[infoIconBox]=new ToolTip(infoIconBox);YAHOO.util.Event.addListener(infoIcon,"mouseover",COM_KLM_REBRAND_FORMS.showToolTip,infoIconBox);YAHOO.util.Event.addListener(infoIcon,"mouseout",COM_KLM_REBRAND_FORMS.hideToolTip,infoIconBox);}},showToolTip:function(){COM_KLM_REBRAND_FORMS.fieldToolTips[this.id.replace('-link','-box')].show();},hideToolTip:function(){COM_KLM_REBRAND_FORMS.fieldToolTips[this.id.replace('-link','-box')].hide();},addFormValidationEvent:function(form){var submitButton,backButton,prevButton,nextButton,eventAddingResult,confField,oNextStep,oDisplayedStep;submitButton=YAHOO.util.Dom.get('submitButton');nextButton=YAHOO.util.Dom.get('nextButton');prevButton=YAHOO.util.Dom.get('prevButton');confField=YAHOO.util.Dom.get('klm-form-confirmation');oNextStep=YAHOO.util.Dom.get('nextStep');oSubmitField=YAHOO.util.Dom.get('klm-form-submit');oDisplayedStep=YAHOO.util.Dom.get('displayedStep');if(submitButton){eventAddingResult=YAHOO.util.Event.addListener(submitButton,'click',function(e){YAHOO.util.Event.preventDefault(e);if(COM_KLM_REBRAND_FORMS.validateForm(form)){if(oSubmitField){oSubmitField.value='true';}
if(confField){confField.value='true';}
if(confField&&oSubmitField){oSubmitField.value='false';}
if(oNextStep){oNextStep.value=parseInt(oDisplayedStep.value);}
if(form.CallerCountryCode){if(form.CallerCountryCode.value.length>2){form.action=form.CallerCountryCode.value;}else
{COM_KLM_REBRAND_FORMS.setFormAction(form);}}else{COM_KLM_REBRAND_FORMS.setFormAction(form);}
form.submit();}});}
if(nextButton){eventAddingResult=YAHOO.util.Event.addListener(nextButton,'click',function(e){YAHOO.util.Event.preventDefault(e);if(COM_KLM_REBRAND_FORMS.validateForm(form)){oNextStep.value=parseInt(oDisplayedStep.value)+1;if(confField){confField.value='false';}
form.submit();}});}
if(prevButton){eventAddingResult=YAHOO.util.Event.addListener(prevButton,'click',function(e){YAHOO.util.Event.preventDefault(e);oNextStep.value=parseInt(oDisplayedStep.value)-1;if(confField){confField.value='false';}
form.submit();});}},replaceVars:function(s){s=unescape(s);var pattern="\[[a-zA-Z0-9_]*\]";var reg=new RegExp(pattern);var matches=reg.exec(s);var match;var fieldID;var field;var value='';if(matches){for(i=0;i<matches.length;i++){match=matches[i];fieldID=match.substr(1,match.length-2);field=YAHOO.util.Dom.get(fieldID);if(field){if(field.tagName.toLowerCase()==='input'){value=field.value;}else if(field.tagName.toLowerCase()==='select'){value=field.options[field.selectedIndex].value;}
s=s.replace(match,value);}}}
return s;},setFormAction:function(form){},validateForm:function(form){var field,fieldMsg,fieldName,fieldLabel,errorCounter,mandatoryFieldDivs,parentTr,i,fieldIsInvalid,formIsInvalid;this.messageBox=YAHOO.util.Dom.get(COM_KLM_REBRAND_FORMS.formErrorBoxId);this.messageBoxHeader=YAHOO.util.Dom.getFirstChild(this.messageBox);this.messageBoxHeader.innerHTML=formLongErrorMsgs.errorBoxHeader;this.messageBoxList=YAHOO.util.Dom.getLastChild(this.messageBox);this.messageBoxList.innerHTML="";mandatoryFieldDivs=YAHOO.util.Dom.getElementsByClassName('mandatoryField','div',form);formIsInvalid=false;for(i=0;i<mandatoryFieldDivs.length;i=i+1){field=YAHOO.util.Dom.getFirstChild(YAHOO.util.Dom.getFirstChild(mandatoryFieldDivs[i]));fieldIsInvalid=this.validateField(field);if(fieldIsInvalid){formIsInvalid=true;}}
if(!formIsInvalid){COM_KLM_REBRAND_FORMS.messageBox.style.display='none';return true;}else{COM_KLM_REBRAND_FORMS.messageBox.style.display='block';return false;}},validateField:function(field){var fieldIsInvalid,parentTr,shortMessage,maxlength,fieldType;parentTr=this.getParentTr(field);maxlength=YAHOO.util.Dom.getElementsByClassName('format-maxlength','p',parentTr)[0].innerHTML;fieldType=YAHOO.util.Dom.getElementsByClassName('fieldtype','p',parentTr)[0].innerHTML;if(maxlength!="")
maxlength=parseInt(maxlength);else
maxlength=0;YAHOO.util.Dom.setStyle(YAHOO.util.Dom.getElementsByClassName('error-message','p',parentTr),'display','none');if(this.isEmpty(field)){fieldIsInvalid=true;YAHOO.util.Dom.addClass(parentTr,'error');this.addVerboseErrMsg(field,'mandatory');}else if(fieldType==='File reference'&&(field.value.length>0&&!field.value.match('^[a-zA-z]{2,5}[0-9]{5}$'))){fieldIsInvalid=true;YAHOO.util.Dom.addClass(parentTr,'error');this.addVerboseErrMsg(field,'format');}else if(field.value&&(maxlength>0&&field.value.length>maxlength)){fieldIsInvalid=true;YAHOO.util.Dom.addClass(parentTr,'error');this.addVerboseErrMsg(field,'format');}else{fieldIsInvalid=false;YAHOO.util.Dom.removeClass(parentTr,'error');}
return fieldIsInvalid;},addVerboseErrMsg:function(field,type){var liTag,aTag,aTagHTML,liContents,liContentsLeft,liContentsRight,parentTr,message,errorField,shortMessage;parentTr=this.getParentTr(field);message=YAHOO.util.Dom.getElementsByClassName(type+'-error','p',parentTr)[0].innerHTML;maxlength=YAHOO.util.Dom.getElementsByClassName('format-maxlength','p',parentTr)[0].innerHTML;message=message.replace('%maxlength%',maxlength);YAHOO.util.Dom.setStyle(YAHOO.util.Dom.getElementsByClassName(type+'-short-error','p',parentTr),'display','block');aTag=document.createElement('a');aTag.href='#'+field.id;aTag.innerHTML=this.getLabel(field);aTag.className=this.messageBoxAnchorErrorClass;liTag=document.createElement('li');liContentsLeft=message.split("'%@'")[0];liContentsRight=message.split("'%@'")[1];liTag.appendChild(document.createTextNode(liContentsLeft));liTag.appendChild(aTag);liTag.appendChild(document.createTextNode(liContentsRight));this.messageBoxList.appendChild(liTag);},isEmpty:function(field){var returnValue,parentElem,radioButton,radioButtons,i;if((field.tagName.toLowerCase()==='input')&&(field.type.toLowerCase()==='radio')){radioButtons=field.parentNode.getElementsByTagName('input');returnValue=true;for(i=0;i<radioButtons.length;i=i+1){radioButton=radioButtons[i];if(radioButton.checked){returnValue=false;}}}else if((field.tagName.toLowerCase()==='input')||(field.tagName.toLowerCase()==='textarea')){returnValue=(""===field.value);}else if((field.tagName.toLowerCase()==='select')&&(field.selectedIndex===-1)){returnValue=true;}else if((field.tagName.toLowerCase()==='select')&&(field.selectedIndex>-1)){returnValue=(""===field.options[field.selectedIndex].value);}else if((field.tagName.toLowerCase()==='input')&&(field.type.toLowerCase()==='radio')){parentElem=field.parentNode;radioButtons=parentElem.getElementsByTagName('input');}
return returnValue;},getLabel:function(field){var fieldId,firstTd,secondTd,labelElem,parentTr,parentElem,returnValue;if(field.tagName.toLowerCase()!=='textarea'){fieldId=field.id;parentTr=this.getParentTr(field);firstTd=YAHOO.util.Dom.getFirstChild(parentTr);secondTd=YAHOO.util.Dom.getNextSibling(firstTd);labelElem=YAHOO.util.Dom.getFirstChild(secondTd);returnValue=labelElem.innerHTML;}else{returnValue=YAHOO.util.Dom.get(field.id+'-label').innerHTML;}
return returnValue;},getParentTr:function(field){var parentElem;parentElem=field.parentNode;while(parentElem.tagName.toLowerCase()!=="tr"){parentElem=parentElem.parentNode;}
return parentElem;},getTextAreaLabel:function(field){},fillConfirmationFields:function(){var form,optionalFields,mandatoryFields,fieldsToProcess,currentField,i,confirmationParagraph,elements,info,ids;fieldsToProcess=YAHOO.util.Dom.getElementsByClassName('form-field-information');for(i=0;i<fieldsToProcess.length;i=i+1){info=fieldsToProcess[i];ids=YAHOO.util.Dom.getFirstChild(info).innerHTML;elements=ids.split(',');for(var e=0;e<elements.length;e++){currentField=YAHOO.util.Dom.get(YAHOO.lang.trim(elements[e]));confirmationParagraph=YAHOO.util.Dom.getLastChild(currentField.parentNode.parentNode);COM_KLM_REBRAND_FORMS.copyValue(currentField,confirmationParagraph);}}
form=YAHOO.util.Dom.get('klm-form');if(!form&&document.forms['klm-form']){form=document.forms['klm-form'];}
var backButton=YAHOO.util.Dom.get('backButton');if(backButton){eventAddingResult=YAHOO.util.Event.addListener(backButton,'click',function(e){YAHOO.util.Event.preventDefault(e);YAHOO.util.Dom.get('klm-form-confirmation').value='false';YAHOO.util.Dom.get('klm-form-submit').value='false';form.submit();});}
var submitButton=YAHOO.util.Dom.get('submitButton');if(submitButton){eventAddingResult=YAHOO.util.Event.addListener(submitButton,'click',function(e){YAHOO.util.Event.preventDefault(e);COM_KLM_REBRAND_FORMS.setFormAction(form);form.submit();});}},copyValue:function(field,elem){var value,relatedRadioButtons,relatedCheckBoxes,i,currentElem,valueArray,selectOptions,regex,replacementElem,parentTr,fieldType;parentTr=this.getParentTr(field);fieldType=YAHOO.util.Dom.getElementsByClassName('fieldtype','p',parentTr)[0].innerHTML;switch(field.tagName.toLowerCase()){case"input":switch(field.type.toLowerCase()){case"text":value=field.value;break;case"hidden":value=field.value;break;case"radio":relatedRadioButtons=document.getElementsByName(field.name);for(i=0;i<relatedRadioButtons.length;i=i+1){currentElem=relatedRadioButtons[i];if(currentElem.checked){value=YAHOO.util.Dom.getNextSibling(currentElem).innerHTML;break;}}
break;case"checkbox":relatedCheckBoxes=document.getElementsByName(field.name);valueArray=[];for(i=0;i<relatedCheckBoxes.length;i=i+1){currentElem=relatedCheckBoxes[i];if(currentElem.checked){valueArray.push(YAHOO.util.Dom.getNextSibling(currentElem).innerHTML);}}
value=valueArray.join(", ");break;}
break;case"select":if(fieldType.toLowerCase()!='date'){if(field.multiple){selectOptions=field.options;valueArray=[];for(i=0;i<selectOptions.length;i=i+1){currentElem=selectOptions[i];if(currentElem.selected){valueArray.push(currentElem.text);}}
value=valueArray.join(", ");}else{value=field.options[field.selectedIndex].text;}}
break;case"textarea":value=field.value;break;}
if(value&&value.length>0){elem.innerHTML=elem.innerHTML+' '+value;}},addHasFocusClass:function(elem){if(elem){if(elem.tagName.toLowerCase()!=='select'&&elem.tagName.toLowerCase()!=='option'){YAHOO.util.Dom.addClass(elem,"hasFocus");YAHOO.util.Dom.addClass(elem,"isSelected");}}},removeHasFocusClass:function(elem){if(elem){if(elem.tagName.toLowerCase()!=='select'&&elem.tagName.toLowerCase()!=='option'){YAHOO.util.Dom.removeClass(elem,"hasFocus");YAHOO.util.Dom.removeClass(elem,"isSelected");}}}};YAHOO.util.Event.addListener(window,'load',function(){if(YAHOO.util.Dom.get('klm-form-container')){COM_KLM_REBRAND_FORMS.init();}
YAHOO.util.Event.onContentReady('klm-conf-form-container',COM_KLM_REBRAND_FORMS.fillConfirmationFields);});function onClickCheckBox(element,thisElement,j){var str=thisElement;var myTextField;var arrTest=str.split("_");if(parseInt(arrTest[arrTest.length-1])>=0){arrTest.splice(arrTest.length-1,0,"selected");myTextField=document.getElementById(arrTest.join("_"));}else{arrTest.push("selected");myTextField=document.getElementById(arrTest.join("_"));}
var docElement=document.getElementsByName(thisElement);var total=0;if(element.checked){if(!myTextField.value.indexOf(element.value)>-1){myTextField.value=myTextField.value+element.value;}}else{if(myTextField.value.indexOf(element.value)>-1){myTextField.value=myTextField.value.replace(element.value,"");}}
for(var i=0;i<docElement.length;i++){if(docElement[i].checked){total=total+1;}
if(total>3){alert("Please Select only three")
docElement[j].checked=false;myTextField.value=myTextField.value.replace(element.value,"");return false;}}}
COM_KLM_REBRAND_FORMS_CALENDAR={calendars:{},datePickerTrigger:'datePickerTrigger',genericCalendar:'generic-calendar',locale:{},init:function(){var datePickers,datePicker,i,calendars,calendar,calElem,calId,inputId,inputElem,triggerId,attributes,minDay,minMonth,minYear,pagedate,indate;datePickers=YAHOO.util.Dom.getElementsByClassName(COM_KLM_REBRAND_FORMS_CALENDAR.datePickerTrigger,'a');COM_KLM_REBRAND_FORMS_CALENDAR.locale=COM_KLM_REBRAND_FORMS_CALENDAR.extractLocale();for(i=datePickers.length-1;i>=0;i--){datePicker=datePickers[i];inputId=datePicker.id.replace('_picker','');inputElem=YAHOO.util.Dom.get(inputId);calId=inputId+"_cal";calElem=YAHOO.util.Dom.get(calId);if(inputElem.value!=''){if(inputElem.value.indexOf('-')>2){inputElem.value=COM_KLM_REBRAND_FORMS_CALENDAR.getPrefillDate(inputElem.value);}}
attributes={navigator:true,START_WEEKDAY:1,DATE_FIELD_DELIMITER:COM_KLM_REBRAND_FORMS_CALENDAR.locale.DATE_FIELD_DELIMITER,MDY_DAY_POSITION:COM_KLM_REBRAND_FORMS_CALENDAR.locale.MDY_DAY_POSITION,MDY_MONTH_POSITION:COM_KLM_REBRAND_FORMS_CALENDAR.locale.MDY_MONTH_POSITION,MDY_YEAR_POSITION:COM_KLM_REBRAND_FORMS_CALENDAR.locale.MDY_YEAR_POSITION,MD_DAY_POSITION:COM_KLM_REBRAND_FORMS_CALENDAR.locale.MD_DAY_POSITION,MD_MONTH_POSITION:COM_KLM_REBRAND_FORMS_CALENDAR.locale.MD_MONTH_POSITION,MONTHS_SHORT:COM_KLM_REBRAND_FORMS_CALENDAR.locale.MONTHS_SHORT,MONTHS_LONG:COM_KLM_REBRAND_FORMS_CALENDAR.locale.MONTHS_LONG,WEEKDAYS_SHORT:COM_KLM_REBRAND_FORMS_CALENDAR.locale.WEEKDAYS_SHORT,title:"Choose a date:",close:true};calendar=COM_KLM_REBRAND_FORMS_CALENDAR.calendars[calId]=new YAHOO.widget.Calendar(calId,attributes);calendar.render();calendar.hide();calElem.style.position='absolute';YAHOO.util.Event.addListener([datePicker,inputElem],"click",COM_KLM_REBRAND_FORMS_CALENDAR.handleTrigger,calendar,true);COM_KLM_REBRAND_FORMS_CALENDAR.calendars[calId].selectEvent.subscribe(COM_KLM_REBRAND_FORMS_CALENDAR.handleSelect,calendar,true);YAHOO.util.Event.addListener([datePicker,inputElem],"blur",COM_KLM_REBRAND_FORMS_CALENDAR.handleBlur,calendar,true);};},extractLocale:function(){var locale,dateFormat,explodedDateFormat,delimiter,MDY_DAY,MDY_MONTH,MDY_YEAR,MD_DAY,MD_MONTH;dateFormat=window.formDateFormat.toLowerCase();delimiter=dateFormat.charAt(2)
explodedDateFormat=dateFormat.split(delimiter);for(i=0;i<explodedDateFormat.length;i=i+1){if(explodedDateFormat[i]==='dd'){MDY_DAY=i+1;MD_DAY=i+1;};if(explodedDateFormat[i]==='mm'){MDY_MONTH=i+1;MD_MONTH=i+1;};if(explodedDateFormat[i]==='yyyy'){MDY_YEAR=i+1;};};locale={DATE_FIELD_DELIMITER:delimiter,MDY_DAY_POSITION:MDY_DAY,MDY_MONTH_POSITION:MDY_MONTH,MDY_YEAR_POSITION:MDY_YEAR,MD_DAY_POSITION:MD_DAY,MD_MONTH_POSITION:MD_MONTH,MONTHS_SHORT:window.monthNamesShort,MONTHS_LONG:window.monthNamesLong,WEEKDAYS_SHORT:window.dayNamesShort};return locale;},handleTrigger:function(){var calElem,inputElem,calId,selectedDates,firstDate,calendar,prefilledDate;COM_KLM_REBRAND_FORMS_CALENDAR.hideAllCalendars();calElem=this.oDomContainer;inputElem=YAHOO.util.Dom.getFirstChild(YAHOO.util.Dom.getFirstChild(calElem.parentNode));calId=YAHOO.util.Dom.getNextSibling(inputElem).id.replace('_picker','_cal');calendar=COM_KLM_REBRAND_FORMS_CALENDAR.calendars[calId];if(inputElem.value!==""){prefilledDate=COM_KLM_REBRAND_FORMS_CALENDAR.getDate(inputElem.value);calendar.select(prefilledDate);selectedDates=calendar.getSelectedDates();if(selectedDates.length>0){firstDate=selectedDates[0];calendar.cfg.setProperty("pagedate",(prefilledDate.getMonth()+1)+
COM_KLM_REBRAND_FORMS_CALENDAR.locale.DATE_FIELD_DELIMITER+
prefilledDate.getFullYear());}}
calendar.render();calendar.show();},hideAllCalendars:function(){var calendars,x;calendars=COM_KLM_REBRAND_FORMS_CALENDAR.calendars;for(x in calendars){calendars[x].hide();}},getDate:function(dateString){var dateFormat,delimiter,explodedDateFormat,explodedDate,returnDate;dateFormat=window.formDateFormat.toLowerCase();delimiter=dateFormat.charAt(2)
explodedDateFormat=dateFormat.split(delimiter);explodedDate=dateString.split(delimiter);returnDate=new Date();for(i=0;i<explodedDateFormat.length;i=i+1){if(explodedDateFormat[i]==='dd'){returnDate.setDate(explodedDate[i]);};if(explodedDateFormat[i]==='mm'){returnDate.setMonth(explodedDate[i]-1);};if(explodedDateFormat[i]==='yyyy'){returnDate.setYear(explodedDate[i]);};};return returnDate;},getPrefillDate:function(dateString){var dateFormat,delimiter,explodedDateFormat,explodedDate,returnDate;dateFormat=window.formDateFormat.toLowerCase();delimiter=dateFormat.charAt(2)
explodedDateFormat=dateFormat.split(delimiter);explodedDate=dateString.split('-');returnDate='';for(i=0;i<explodedDateFormat.length;i=i+1){if(explodedDateFormat[i]==='dd'){returnDate=returnDate+explodedDate[2];};if(explodedDateFormat[i]==='mm'){returnDate=returnDate+explodedDate[1];};if(explodedDateFormat[i]==='yyyy'){returnDate=returnDate+explodedDate[0];};if((i+1)<explodedDateFormat.length){returnDate=returnDate+delimiter;}};return returnDate;},handleSelect:function(type,args,obj){var that,dates,date,day,month,year,dateField,delimiter,ddPos,mmPos,yyyyPos,newValue;that=COM_KLM_REBRAND_FORMS_CALENDAR;ddPos=that.locale.MD_DAY_POSITION;mmPos=that.locale.MD_MONTH_POSITION;yyyyPos=that.locale.MD_YEAR_POSITION;newValue='';delimiter=that.locale.DATE_FIELD_DELIMITER;dates=args[0];date=dates[0];year=date[0];month=date[1];day=date[2];day=day+'';month=month+'';if(day.length===1){day="0"+day;}
if(month.length===1){month="0"+month;}
dateField=YAHOO.util.Dom.getFirstChild(YAHOO.util.Dom.getFirstChild(obj.oDomContainer.parentNode));if(ddPos===1){newValue=newValue+day+delimiter;}else if(mmPos===1){newValue=newValue+month+delimiter;}
if(ddPos===2){newValue=newValue+day+delimiter;}else if(mmPos===2){newValue=newValue+month+delimiter;}
newValue=newValue+year;var dateFieldB=YAHOO.util.Dom.get(dateField.id.substr(0,dateField.id.length-2));if(dateFieldB){dateFieldB.value=year+'-'+month+'-'+day;}
dateField.value=newValue;obj.hide();},handleBlur:function(e,obj){var dateField=YAHOO.util.Event.getTarget(e);var oDate=COM_KLM_REBRAND_FORMS_CALENDAR.getDate(dateField.value);var dateFieldB=YAHOO.util.Dom.get(dateField.id.substr(0,dateField.id.length-2));if(dateFieldB&&oDate){var monthValue=(oDate.getMonth()+1)+'';var dayValue=oDate.getDate()+'';if(dayValue.length===1){dayValue="0"+dayValue;}
if(monthValue.length===1){monthValue="0"+monthValue;}
dateFieldB.value=oDate.getFullYear()+'-'+monthValue+'-'+dayValue;}}}
YAHOO.util.Event.onDOMReady(COM_KLM_REBRAND_FORMS_CALENDAR.init);
YAHOO.namespace('klm.dateselect');var DateSelect=function(){var Dom=YAHOO.util.Dom;var Event=YAHOO.util.Event;var date_select=YAHOO.klm.dateselect;var future_years=0;var past_years=120;var current_date=new Date();var fields=Dom.getElementsByClassName('date_select');var confContainer=Dom.get('klm-conf-form-container');date_select.init=function(){var field=null;var dayField=null;var monthField=null;var yearField=null;var set_date=current_date;var fieldCollection;var confField=null;for(i=0;i<fields.length;i++){field=fields[i];confField=Dom.getElementsByClassName('confirmation','p',field.parentNode.parentNode)[0];set_date=current_date;if(field.value!=''){set_date=date_select.parseDate(field.value);}
dayField=Dom.get(field.id+'d');date_select.fillDays(dayField,set_date);monthField=Dom.get(field.id+'m');date_select.fillMonths(monthField,set_date);yearField=Dom.get(field.id+'y');date_select.fillYears(yearField,set_date);fieldCollection={field:field,day:dayField,month:monthField,year:yearField};if(field.value==''){date_select.setValue(fieldCollection);}
if(confContainer){if(confField){confField.innerHTML=formDateFormat.toLowerCase().replace('dd',dayField.options[dayField.selectedIndex].value);confField.innerHTML=confField.innerHTML.replace('mm',monthField.options[monthField.selectedIndex].value);confField.innerHTML=confField.innerHTML.replace('yyyy',yearField.options[yearField.selectedIndex].value);}}else{Event.addListener([dayField,monthField,yearField],'change',date_select.onChange,{obj:this,fields:fieldCollection});}}}
date_select.parseDate=function(value){var values=value.split('-');var returnDate=new Date();if(values.length==3){if(values[1].indexOf('0')==0){values[1]=values[1].charAt(1);}
if(values[2].indexOf('0')==0){values[2]=values[2].charAt(1);}
returnDate.setFullYear(parseInt(values[0]));returnDate.setMonth((parseInt(values[1])-1));returnDate.setDate(parseInt(values[2]));}
return returnDate;}
date_select.fillDays=function(field,set_date){var day=set_date.getDate();var option=null;var value=null;for(d=1;d<=31;d++){value=date_select.parseValue(d);option=document.createElement('option');option.value=value;option.innerHTML=value;if(d==day){option.selected='selected';}
field.appendChild(option);}}
date_select.fillMonths=function(field,set_date){var month=set_date.getMonth()+1;var option=null;var value=null;for(m=1;m<=12;m++){value=date_select.parseValue(m);option=document.createElement('option');option.value=value;option.innerHTML=value;if(m==month){option.selected='selected';}
field.appendChild(option);}}
date_select.resetValue=function(selectField){for(r=0;r<selectField.options.length;r++){selectField.options[r].selected=false;}
var option=document.createElement('option');option.selected='selected';selectField.appendChild(option);}
date_select.parseValue=function(num){var value=num+'';if(value.length==1){value='0'+value;}
return value;}
date_select.fillYears=function(field,set_date){var year=set_date.getFullYear();var option=null;for(y=(year+future_years);y>(year-past_years);y--){option=document.createElement('option');option.value=y;option.innerHTML=y;if(y==year){option.selected='selected';}
field.appendChild(option);}}
date_select.onChange=function(e,args){args.obj.setValue(args.fields);}
date_select.setValue=function(fields){fields.field.value=fields.year.options[fields.year.selectedIndex].value+'-'+fields.month.options[fields.month.selectedIndex].value+'-'+fields.day.options[fields.day.selectedIndex].value;}
date_select.init();}
YAHOO.util.Event.onContentReady(['klm-form-container','klm-conf-form-container'],function(){new DateSelect();});
