0)
thiswizard.createfieldsets($theform, setting.manualfieldsets)
var $stepsguide=$('') //create Steps Container to house the "steps" text
var $sections=$theform.find('fieldset.sectionwrap').hide() //find all fieldset elements within form and hide them initially
if (setting.revealfx[0]=="slide"){ //create outer DIV that will house all the fieldset.sectionwrap elements
$sectionswrapper=$('').insertBefore($sections.eq(0)) //add DIV above the first fieldset.sectionwrap element
$sectionswrapper_inner=$('') //create inner DIV of $sectionswrapper that will scroll to reveal a fieldset element
}
var maxfieldsetwidth=$sections.eq(0).outerWidth() //variable to get width of widest fieldset.sectionwrap
$sections.slice(1).each(function(i){ //loop through $sections (starting from 2nd one)
maxfieldsetwidth=Math.max($(this).outerWidth(), maxfieldsetwidth)
})
maxfieldsetwidth+=2 //add 2px to final width to reveal fieldset border (if not removed via CSS)
thiswizard.maxfieldsetwidth=maxfieldsetwidth
$sections.each(function(i){ //loop through $sections again
var $section=$(this)
if (setting.revealfx[0]=="slide"){
$section.data('page', i).css({position:'absolute', top:0, left:maxfieldsetwidth*i}).appendTo($sectionswrapper_inner) //set fieldset position to "absolute" and move it to inside sectionswrapper_inner DIV
}
$section.data('elements', []) //empty array to contain elements within this section that should be validated for data (applicable only if validate option is defined)
//create each "step" DIV and add it to main Steps Container:
var $thestep=$('').data('section', i).html('Step '+(i+1)+''+$section.find('legend:eq(0)').text()+'
').appendTo($stepsguide)
$thestep.click(function(){ //assign behavior to each step div
thiswizard.loadsection($(this).data('section'))
})
})
if (setting.revealfx[0]=="slide"){
$sectionswrapper.width(maxfieldsetwidth) //set fieldset wrapper to width of widest fieldset
$sectionswrapper.append($sectionswrapper_inner) //add $sectionswrapper_inner as a child of $sectionswrapper
}
$theform.prepend($stepsguide) //add $thesteps div to the beginning of the form
//$stepsguide.insertBefore($sectionswrapper) //add Steps Container before sectionswrapper container
var $thesteps=$stepsguide.find('div.step')
//create pagination DIV and add it to end of form:
var $paginatediv=$('Back Step 1 of Next
')
$theform.append($paginatediv)
thiswizard.$theform=$theform
if (setting.revealfx[0]=="slide"){
thiswizard.sections={$outerwrapper:$sectionswrapper, $innerwrapper:$sectionswrapper_inner, $sections:$sections, count:$sections.length} //remember various parts of section container
thiswizard.sections.$sections.show()
}
else{
thiswizard.sections={$sections:$sections, count:$sections.length} //remember various parts of section container
}
thiswizard.$thesteps=$thesteps //remember this ref
thiswizard.paginatediv={$main:$paginatediv, $navlinks:$paginatediv.find('span.prev, span.next'), $status:$paginatediv.find('span.status')} //remember various parts of pagination DIV
thiswizard.paginatediv.$main.click(function(e){ //assign behavior to pagination buttons
if (/(prev)|(next)/.test(e.target.className))
thiswizard.loadsection(e.target.className)
})
var i=(setting.persistsection)? formtowizard.routines.getCookie(setting.formid+"_persist") : 0
thiswizard.loadsection(i||0, true) //show the first section
thiswizard.setting.oninit($, i, $sections.eq(i)) //call oninit event handler
if (setting.validate){ //if validate array defined
thiswizard.addvalidatefields() //seek out and cache form elements that should be validated
thiswizard.$theform.submit(function(){
var returnval=true
for (var i=0; i