
/**
 *	Show the company asddress information or hide it depending on
 *  this setting.
 */
function toggleCompanyInfo()
{
	if (document.getElementById("infoEqual").checked)
		$("#companyInfo").fadeOut();
	else
		$("#companyInfo").fadeIn()
		
	$("#usePayInfo").val(document.getElementById("infoEqual").checked ?  "no" : "yes");
}


function showInfo(id)
{
	texts.show(id, "#infoContent");
}


function registerClick(aff)
{
	$.getJSON(config.urlBase + "service/registerClick.php?affiliate=" + escape(aff),
			function(data)
			{
			}
		);
}

function initialize()
{
	// initialize texts
	product.preloadTexts(); 
	product.preloadProducts();
	form.preloadTexts();
	texts.defaultLocation("#infoContent");
	
	// assign affiliation
	var affiliate = $.query.get("affiliate");
	if (typeof(affiliate) != "undefined")
	{
		config.affiliate = affiliate;
		registerClick(affiliate);
	}
	
	// setup form elements
	form.progress("completeCart", INCOMPLETE);
	form.progress("completePersonalInfo", INCOMPLETE);
	form.progress("completePaymentInfo", INCOMPLETE);
	form.progress("completeBankInfo", INCOMPLETE);
	
	// attach click handler for every element
	$("input[@type='text']", $(".element")).focus(function()
		{
			form.validate(false);
			
			// add to list
			if (!form.touched(this))
				form.touchedElements.push(this);
		}
	);
	
	setInterval("validateTimer()", 1000);
}

function validateTimer()
{
	form.validate(false);
}
