
var submittingForm=false;var editors=new Object();function FCKeditor_OnComplete(editorInstance)
{var opts={getCharactersLeft:function(){return this.maxLength-this.inputElement.find("body").text().length;}};var doc=editorInstance.EditorDocument;if(editorInstance.Name.match("detail"))
{editors["detail"]=editorInstance;jQuery(doc).countLength('#chars_remain2',2500,opts);}
if(editorInstance.Name.match("answer"))
{editors["answer"]=editorInstance;jQuery(doc).countLength('#chars_remain3',500,opts);}
editorInstance.Events.AttachEvent('OnFocus',FCKeditor_OnFocus);editorInstance.Events.AttachEvent('OnBlur',FCKeditor_OnBlur);}
function FCKeditor_OnFocus(editorInstance)
{if(editorInstance.Name.match("detail"))
{jQuery('#chars_remain2').show();}
if(editorInstance.Name.match("answer"))
{jQuery('#chars_remain3').show();}}
function FCKeditor_OnBlur(editorInstance)
{if(editorInstance.Name.match("detail"))
{jQuery('#chars_remain2').hide();}
if(editorInstance.Name.match("answer"))
{jQuery('#chars_remain3').hide();}}
jQuery(function(){jQuery('#story_subject').countLength('#chars_remain',125);jQuery('#story_form').ready(function(){jQuery.validator.addMethod("requiredFCK",function(value,element,param){var text=jQuery(editors[param].EditorDocument).find("body").text();return text!="";},"Please specify a value for this field.");jQuery.validator.addMethod("radioToggleRequired",function(value,element,param){if(value.length==0&&jQuery('#reset_avatar_1').attr('checked')){return false;}
return true},"Please select an image to upload.");jQuery("#story_form").validate({submitHandler:function(form){jQuery("#story_form").unbind("submit").submit(function(){return false;});form.submit();},errorPlacement:function(error,element){error.appendTo(element.siblings(".errorContainer"))},rules:{"story[subject]":{required:true,maxlength:125},"story[detail]":{requiredFCK:"detail"},"story[answer]":{requiredFCK:"answer"},"story[tac_contest_agree]":{required:true},"profile[line_of_business]":{required:true,digits:true},"profile[city]":{required:true,maxlength:255},"profile[state]":{required:true,maxlength:255},"avatar":{accept:"jpg|png|gif"}},messages:{"story[subject]":{required:"Please enter a title for your story."},"story[detail]":{requiredFCK:"Please enter more information about your story."},"story[answer]":{requiredFCK:"Please enter a tip for your story."},"story[tac_contest_agree]":{required:"Please accept the Terms and Conditions."},"avatar":{accept:"Please make sure your image has an extension. (.gif|.jpg|.png)"},"profile[line_of_business]":{required:"Please choose your Line of Business."},"profile[city]":{required:"Please enter your City."},"profile[state]":{required:"Please choose your State."}}});jQuery('#avatar').bind('change',function(e){if(jQuery('#avatar').val()!='')
jQuery('#reset_avatar_1').attr('checked',true);else
jQuery('#reset_avatar_0').attr('checked',true);});jQuery('#reset_avatar_0').bind("change",function(e){if(jQuery('#reset_avatar_0').attr('checked')){jQuery('#avatar').val('');}});submittingForm=true;return true;});});jQuery(document).ready(function(){jQuery('#profile_line_of_business').bind('change',ckLob);ckLob();});function ckLob(){if(jQuery('#profile_line_of_business option:selected').text()=='Other')
jQuery('#profile_line_of_business_other').show('fast').prev().show('fast');else
jQuery('#profile_line_of_business_other').val('').hide().prev().hide();}
function HasText(input,hintLabel){return Trim(input.attr("value"))!=''&&(!hintLabel||input.attr("value")!=hintLabel.attr("innerHTML"))}
window.onbeforeunload=function(){if(!promptBeforeLosingContent)
return;if(submittingForm){return;}
if(HasText(jQuery('#story_subject'),jQuery('#subject_label'))||HasText(jQuery('#story_detail'),jQuery('#detail_label'))||HasText(jQuery('#story_answer'),jQuery('#answer_label')))
{return'There are unsaved changes on the page. These changes will be lost.';}}