var curDiv = 'page0';var curPage = 0;var busy = false;var brandchoices;window.onload = function() {	setTimeout("showFirstPage()",50);}function swapPages(idOut, idIn){	curDiv = idIn;		new Effect.Fade(idOut, {		queue: 'end',		duration: 0.6	});		resizeSurvey();	resizeItemList();		new Effect.Appear(idIn, {		queue: 'end',		duration: 0.6,		afterFinish: finishSwapPages	});}function finishSwapPages(){	var inputs = $$('div#' + curDiv + ' input');	var selects = $$('div#' + curDiv + ' select');		if (inputs.length >= 1){		inputs[0].focus();		inputs[0].select();	}	else if (selects.length >= 1){		selects[0].focus();		selects[0].select();	}		if ($("page" + (curPage + 1))){		xajax.call('removePage', {				parameters: [(curPage + 1)],				mode:'synchronous'}			);	}		busy = false;}function showNextDiv(obj){	if (!busy){		busy = true;				if (obj.id)			var clickid = obj.id;		else			var clickid = obj;				var success = xajax.call('displayPage', {				parameters: [(curPage + 1), clickid, getFormValues()],				mode:'synchronous'}			);				if (success == 1){			curPage++;			swapPages(curDiv, 'page' + curPage);		}		else{			busy = false;			}	}		return;}function showFirstPage(){	busy = true;	curPage = 1;		xajax.call('displayPage', {		parameters: [1, "fp0", getFormValues()],		mode:'synchronous'}	);		swapPages(curDiv, 'page' + curPage);}function showLastDiv(){	if (!busy){		if ($("page" + (curPage - 1))){			busy = true;			curPage--;						swapPages(curDiv, 'page' + curPage);		}	}}function getFormValues(){	var fields = $$('div#' + curDiv + ' input, div#' + curDiv + ' select');	var values = new Array();	var j = 0;		for (i = 0; i<fields.length; i++){		values[j] = fields[i].value;		j++;	}		fields = $$('div#' + curDiv + ' .chkbuttonon');		for (i = 0; i<fields.length; i++){		values[j] = fields[i].id;		j++;	}		return values;}function hidePageFooter(pageNum){	var fields = $$('div#page' + pageNum + ' div.surveyfooter');		for (i=0; i<fields.length; i++){		fields[i].style.display = 'none';;	}}function initBrandAutocompleter(){	brandchoices = new Ajax.Autocompleter(		"brand", "brandchoices", "closet.brandlist.php", {		afterUpdateElement:window.selectBrand,		frequency:.001	});}function selectBrand(input, li){	//showNextDiv(li);}function initStyleAutocompleter(){	stylechoices = new Ajax.Autocompleter(		"stylename", "stylechoices", "closet.stylelist.php", {		frequency:.001	});}function initStyleNumAutocompleter(){	stylenumchoices = new Ajax.Autocompleter(		"stylenum", "stylenumchoices", "closet.stylenumlist.php", {		frequency:.001	});}function initRnAutocompleter(){	rnchoices = new Ajax.Autocompleter(		"rn", "rnchoices", "closet.rnlist.php", {		frequency:.001	});}function initSizeAutocompleter(){	sizechoices = new Ajax.Autocompleter(		"sizeinput", "sizechoices", "closet.sizelist.php", {		frequency:.001	});		lengthchoices = new Ajax.Autocompleter(		"lengthinput", "lengthchoices", "closet.lengthlist.php", {		frequency:.001	});}function resizeSurvey(){	var curHeight = $("surveybody").getHeight();	var endHeight = $(curDiv).getHeight() + 8;	var curWidth = $("surveybody").getWidth();	var endWidth = $(curDiv).getWidth() + 8;		if (curHeight != endHeight || curWidth != endWidth){		new Effect.Morph('surveybody',{		 	style: 'width:' + endWidth + 'px; height:' + endHeight + 'px;',						duration: 0.6		});	}	}function resizeItemList(){	var curHeight = $("itembox").getHeight();	var endHeight = $("itemlist").getHeight();	var curWidth = $("itembox").getWidth();	var endWidth = $("itemlist").getWidth();		if (curHeight != endHeight || curWidth != endWidth){		new Effect.Morph('itembox',{		 	style: 'width:' + endWidth + 'px; height:' + endHeight + 'px;',						duration: 0.6		});	}	}function doSizeSelection(input){	var value = input.options[input.selectedIndex].value;	if (value != "sz0") showNextDiv(value);}function toggleClass(obj, class1, class2){	if (obj.className == class1)		obj.className = class2;	else		obj.className = class1;}function shareOnFacebook(u){	t=document.title;	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');	return false;}function doStyleBoxFocus(obj){	$(obj.id + "box").className = "styleboxon clearfix"	$("styleimgbox").className = obj.id;			if (obj.id != "stylename")		$("stylenamebox").className = "styleboxoff clearfix"		if (obj.id != "stylenum")		$("stylenumbox").className = "styleboxoff clearfix"		if (obj.id != "rn")		$("rnbox").className = "styleboxoff clearfix"}