/* NuYoung - Roneri 2009 | JQUERY ADDRESS |*/// navegation
/*<![CDATA[*/
	
	$(document).ready(function () {

		loadcontent();
		
	});

	$(function () {
		$('a.intwo').address(function() {
			
			$.address.value( $(this).attr('href').replace(/\/^#/, '') );
//			$.address.title( $(this).attr('title') );
			loadcontent();
			return $(this).attr('href').replace(/\/^#/, '');
//			return $(this).attr('href');
			
		});
	});
	
	function loadcontent(){

		var pagina = $.address.pathNames().toString();
		
		switch (pagina) {
			case "" :
			case "/" :
				$("div.sessiones").hide();$("#home").hide().html( $.ajax({  url: '_ajax.asp?pagina=home' ,  async: false }).responseText ).fadeIn(500);
//				$('.slideshow').cycle({fx: 'fade', speed:   1000, timeout: 5000, next:   '.slideshow', pause:   1 });
			break
			case "A_marca" :
				$("div.sessiones").hide();$("#A_marca").hide().html( $.ajax({  url: '_ajax.asp?pagina=A_marca' ,  async: false }).responseText ).fadeIn(500);
			break
			case "Colecao" :
				$("div.sessiones").hide();$("#colecao").hide().html( $.ajax({  url: '_ajax.asp?pagina=colecao' ,  async: false }).responseText ).fadeIn(500);
				$("#slider").easySlider({controlsBefore:	'<div id="controls">', controlsAfter:	'</div>', continuous: false });
				$(document).ready(function(){
					$("a[rel^='prettyPhoto']").prettyPhoto({
						animationSpeed: 'slow', /* fast/slow/normal */
						padding: 40, /* padding for each side of the picture */
						opacity: 0.85, /* Value betwee 0 and 1 */
						showTitle: true, /* true/false */
						allowresize: true, /* true/false */
						counter_separator_label: ' / ', /* The separator for the gallery counter 1 "of" 2 */
						theme: 'dark_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
						callback: function(){}
					});
				});

			break
			case "Revenda" :
				$("div.sessiones").hide();$("#revendas").hide().html( $.ajax({  url: '_ajax.asp?pagina=revendas' ,  async: false }).responseText ).fadeIn(500);
			break
			case "Contato" :
				$("div.sessiones").hide();$("#contato").hide().html( $.ajax({  url: '_ajax.asp?pagina=contato' ,  async: false }).responseText ).fadeIn(500);
				$(document).ready(function(){
					$('#form').bind('submit', function() { 
						$.get("_ajax.asp", $("#form").serialize(), function(data){ 
								$('#result').html(data);
								if (data == 'Sua Mensagem foi enviada com sucesso!'){
									$("#form")[0].reset();
								}
						}); 
						return false; 
					}); 
				});
			break
			case "Cadastro" :
				$("div.sessiones").hide();$("#cadastro").hide().html( $.ajax({  url: '_ajax.asp?pagina=cadastro' ,  async: false }).responseText ).fadeIn(500);
				jQuery(function() {
								
					$('input[name="Data"]').mask("99/99/9999");
					$('input[name="Cep"]').mask("99999-999");
					$('input[name="Celular"]').mask("(99) 9999-9999");
					
					var v = jQuery("#form_cadastro").validate({
						errorLabelContainer: $("#validacadastro"),
						rules: {
							Nome: { required: true }
							,Data: { required: true, dateBR: true }
							,Endereco: { required: true}
							,Cep: { required: true}
							,Cidade: { required: true}
							,Estado: { required: true}
							,Celular: { required: true}
							,Email: { required: true, email: true }
							
						},
						messages: {
							Nome: "Informe seu Nome"
							,Data: {required:"Informe a data de seu nascimento", dateBR: "Formato de data inválido"	}
							,Endereco : "Informe seu Endereço "
							,Cep : "Informe seu Cep "
							,Cidade : "Informe sua Cidade "
							,Estado : "Informe sua Estado "
							,Celular : "Informe seu Celular "
							,Email: {required:"Informe seu Email", email: "Formato de e-mail inválido"	}

						},
						submitHandler: function(form) {
							$.post("_ajax.asp", $("#form_cadastro").serialize(), function(data){ 
								$('#resultcadastro').html(data);
								if (data.indexOf('sucesso') >= 0){
									$("#form_cadastro").slideUp(1400);
									$("#form_cadastro")[0].reset();
									$('#resultcadastro').animate( { marginTop:"20%", fontSize: "14px"}, 1600 )
								}
							});
							return false;
						}
					});
					
				});
			break
			default:
				$("div.sessiones").hide();$("#home").hide().html( $.ajax({  url: '_ajax.asp?pagina=home' ,  async: false }).responseText ).fadeIn(500);
//				$('.slideshow').cycle({fx: 'fade', speed:   1000, timeout: 5000, next:   '.slideshow', pause:   1 });
			break
		}
	}
	
			
	/*]]>*/