// JavaScript Document
$(document).ready(function(){
						   
	// Help window
	$("#help").corner({antiAlias: true});	
	$(".question").addClass('closed');
	
	$(".question").click(function(){
		$(".answer").hide("slow");
		$(".question").removeClass('open').addClass('closed');
		$(this).removeClass('closed').addClass('open');
		$(this).find(".answer").slideDown("slow");
	});
	
	
	// show help	
	$(".question").hide(); // hide all questions
	var helpsection = $(".stepForm > li:nth-child(1)").attr('class');
	if(typeof(helpsection) != 'undefined' && helpsection.length){
		$(".question."+helpsection).show(); // show questions with matching class
	}
	$(".question").addClass('closed'); // add the closed class
	$(".question:visible").eq(0).removeClass('closed').addClass('open'); // open the first visible question
	$(".question:visible").eq(0).find(".answer").slideDown("slow"); // open the first visible question
	
	// form tips
	$("input").focus(function() {
		if(!$(this).parent().find(".invalid").is(":visible")){
			$(this).parent().find(".formhint").show();
		}
	}).blur(function(){
		$(this).parent().find(".formhint").hide();
	});

	$("select").focus(function() {
		if(!$(this).parent().parent().parent().find(".invalid").is(":visible")){
			$(this).parent().parent().parent().find(".formhint").show();
		}
	}).blur(function(){
		$(this).parent().parent().parent().find(".formhint").hide();
	});
	
	$(".showInvoice").click(function(){
		$("#invoiceImage").show();
	});
	
	$(".clickhide").click(function(){
		$(this).hide();
	});
	
	// formtat select box

	$("ol.formElements li SELECT").not('.noround').wrap('<div class="select_border"/>');
	$("ol.formElements li SELECT").not('.noround').wrap('<div class="select_mask"/>');
		
	$(".stepForm > li").hide();
	$(".stepForm > li:nth-child(1)").show();
	$(".stepForm > li:nth-child(1)").addClass("activeForm");
	
});

function showFormStep(stepNo){
	
	// show breadcrumb
	$(".bc").hide();
	for(var s = 1; s <= stepNo; s++){
		$("#bc"+s).show();
	}
	$("ul.breadcrumb").attr("class",function(){
		return $(this).attr('class').replace(/breadcrumb-\S+/g, '');
	});
	$("ul.breadcrumb").addClass("breadcrumb-step"+stepNo);
	
	$(".stepForm > li").hide();
	$(".stepForm > li").removeClass("activeForm");
	$(".stepForm > li:nth-child("+stepNo+")").show();
	var helpsection = $(".stepForm > li:nth-child("+stepNo+")").attr('class');
	$(".stepForm > li:nth-child("+stepNo+")").addClass("activeForm");
	
	// show help
	$(".question").hide(); // hide all questions
	if(typeof(helpsection) != 'undefined' && helpsection.length){
		$(".question."+helpsection).show(); // show questions with matching class
	}
	$(".question").addClass('closed'); // add the closed class
	$(".question:visible").eq(0).removeClass('closed').addClass('open'); // open the first visible question
	$(".question:visible").eq(0).find(".answer").slideDown("slow"); // open the first visible question

	
}
