

function checkProducts()
{
	if (  $('#product-checkbox').attr('checked'))
	{
		$('#tabs').tabs( 'enable' , 1 )
	
	}
	else
	{
		$('#tabs').tabs( 'disable' , 1 )
	}
}

function checkServices()
{
	if ($('#service-checkbox').attr('checked') )
	{
		$('#tabs').tabs( 'enable' , 2 )
	}
	else
	{
		$('#tabs').tabs( 'disable' , 2 )

	}	
}



function nextPos(curPos)
{
	if ( curPos+1 == 3)
	{
		
		displayConfirmation() 
	}
	var disabledTabs = $('#tabs').tabs('option', 'disabled');
	var isDisabled = false
	
	for ( var i=0; i<disabledTabs.length; i++)
	{
		if  ( (curPos+1) == disabledTabs[i])
		{
			isDisabled = true
		}
	}
		
	if ( isDisabled)
	{
		nextPos(curPos+1)
	}
	else
	{
		$('#tabs').tabs( 'select' , curPos+1 )	
		
	}

}



function displayConfirmation()
{
	

	
	$('#confirmation').html ( "Nom: " + $('#name').val() + "<br/>")
	
	if ( $('#compname').val() != "")
	{
		$('#confirmation').append ( "Nom de Compagnie: " + $('#compname').val() + "<br/>")
	}
		
	if ( $('#email').val() != "")
	{
		$('#confirmation').append ( "Courriel: " + $('#email').val()+ "<br/>")
	}
				
	if ( $('#telephone').val() != "")
	{
		$('#confirmation').append ( "Telephone: " + $('#telephone').val()+ "<br/>")
	}
				
				
				
	$('#confirmation').append ( "<br/>Profil: "+ $("input[name='custType']").val()+ "<br/>");


	// address
	var inputs = $("input.addressInput[value!='']");

	if (inputs.length > 0)
	{
		$('#confirmation').append ("<br/><br/>\n ----    Adresse  ----- <br/>\n");
	}
	for ( var i=0; i<inputs.length; i++)
	{
				
		$('#confirmation').append(   inputs[i].value + " "  );
	}


	$('#confirmation').append( "<br/>" + $('#province').val() + " " + $('#postal').val()  )

	// prod
	var inputs = $("input.productInputClass[value!=0][value!='']");

	if (inputs.length > 0 &&  $('#product-checkbox').attr('checked'))
	{
		$('#confirmation').append ("<br/><br/>\n ----   Produit(s)   ----- <br/>\n");
	}
	for ( var i=0; i<inputs.length; i++)
	{
		
		$('#confirmation').append( "["+inputs[i].getAttribute("productDesc")  + "] x "  + inputs[i].value  + " "+  jQuery(inputs[i]).parents().find('select.qt').val() + "\n<br/>" );
	}
	
	var inputs = $("input.serviceInputClass[value!=0][value!='']");

	if (inputs.length > 0 &&  $('#service-checkbox').attr('checked'))
	{
		$('#confirmation').append ( "<br/><br/>\n ----   Service(s)   ----- <br/>\n");
	}
	for ( var i=0; i<inputs.length; i++)
	{
		
		$('#confirmation').append( "[" + inputs[i].getAttribute("productDesc")  + "] x "  + inputs[i].value  + " "+  jQuery(inputs[i]).parents().find('select.qt').val() + "\n<br/>" );
	}	
	
	if ( $('#consultation').attr('checked') )
	{
		$('#confirmation').append( "Consultation " + "\n<br/>" );
			
	}
}


function sendQuote()
{	
	var message = "message=" +$('#confirmation').html() 
	message += "\n<br/>---- Commentaires ----\n<br/>" + $('#commentaire').val()
	message += "&sender=" +  $('#name').val()
	message += "&sender_email="+  $('#email').val() 
	send(	message)
}



function send(message){
	$.ajax({	
		type: "POST",
		url: "quote_send.php",
		data: message,
		cache: false,
		success: function(html){
			$("#response").fadeIn("slow");
			$("#response").html(html);
			setTimeout('$("#response").fadeOut("slow")',2000);
			$('#tabs').html("Votre demande a &eacute;t&eacute; soumise. Un de nos conseillers vous contactera sous peu. Merci de choisir Gazon Bastien.");
		}
		
	});
}

