jQuery(function() {
	
	
	///// Intro para a pagina
	jQuery('#main h1, #main h3').each(function(tituloAnima) {
		jQuery(this).delay( tituloAnima * 600 ).animate({ opacity:1, 'margin-left':'0' }, 'slow', function() {
			jQuery('#galeriaSites li').each(function(idx) {
				jQuery(this).delay( idx * 600 ).animate({ opacity:1, 'margin-top':'0' }, 1127);
			});
		});
	});
	
	
	///// Show/Hide formulario para login
	jQuery('.links li a').click(function(e) {
		var idMenuClicado = jQuery(this).attr('rel');
		
		if(jQuery('.links li a').hasClass('onView')){
			
			if(jQuery(this).attr('class') == 'onView'){
				jQuery('.links li a').removeAttr('class');
				
				jQuery('.loginForm').fadeOut();
				jQuery('#formularios').fadeOut();
				
				
			} else {
				jQuery('.links li a').removeAttr('class');
				jQuery(this).addClass('onView');
				
				jQuery('#formularios').fadeIn();
				
				if(idMenuClicado == 'form_ftp'){
					jQuery('#form_webmail').hide();
					jQuery('#form_personalizze').hide();
					jQuery('#form_ftp').fadeIn();
					
				} else if(idMenuClicado == 'form_webmail'){
					jQuery('#form_ftp').hide();
					jQuery('#form_personalizze').hide();
					jQuery('#form_webmail').fadeIn();
					
				} else if(idMenuClicado == 'form_personalizze'){
					jQuery('#form_ftp').hide();
					jQuery('#form_webmail').hide();
					jQuery('#form_personalizze').fadeIn();
				}
			}
			
			
		} else {
			jQuery(this).addClass('onView');
			jQuery(this).addClass('onView');
			jQuery('#formularios').fadeIn();
			
			if(idMenuClicado == 'form_ftp'){
				jQuery('#form_webmail').hide();
				jQuery('#form_personalizze').hide();
				jQuery('#form_ftp').fadeIn();
				
			} else if(idMenuClicado == 'form_webmail'){
				jQuery('#form_ftp').hide();
				jQuery('#form_personalizze').hide();
				jQuery('#form_webmail').fadeIn();
				
			} else if(idMenuClicado == 'form_personalizze'){
				jQuery('#form_ftp').hide();
				jQuery('#form_webmail').hide();
				jQuery('#form_personalizze').fadeIn();
			}
		}
		
	});
	
	
	///// hover link para os sites
	jQuery('.linkSite a').mouseenter(function() {
		jQuery('.links li a').removeAttr('class');
		jQuery('.loginForm, #formularios').fadeOut();
		
		var idSideHover = jQuery(this).attr('rel');
		jQuery('.linkSite a').children('span').stop().animate({ backgroundPosition:'0 -49px' }, 'fast');
		jQuery(this).children('span').stop().animate({ backgroundPosition:'0 0' }, 'fast');
		
		jQuery('#imagemDestaque').css({ opacity:0 });
		switch(idSideHover) {
			case 'tecnovidro':
				jQuery('#imagemDestaque')
					.css({ opacity:0, background:'#2596D4 url(landingIMG/destaque_tecnovidro.jpg) no-repeat center 0' })
					.stop()
					.animate({ opacity:1 }, 'slow');
			break;
			
			case 'saintcalre':
				jQuery('#imagemDestaque')
					.css({ opacity:0, background:'#cccccc url(landingIMG/destaque_saintcalre.jpg) no-repeat center 0' })
					.stop()
					.animate({ opacity:1 }, 'slow');
			break;
			
			case 'casavitra':
				jQuery('#imagemDestaque')
					.css({ opacity:0, background:'#070907 url(landingIMG/destaque_casavitra.jpg) no-repeat center 0' })
					.stop()
					.animate({ opacity:1 }, 'slow');
			break;
			
			case 'casavitraloja':
				jQuery('#imagemDestaque')
					.css({ opacity:0, background:'#183B26 url(landingIMG/destaque_casavitraloja.jpg) no-repeat center 0' })
					.stop()
					.animate({ opacity:1 }, 'slow');
			break;
		}
		
	}).mouseleave(function() {
		jQuery('#imagemDestaque')
			.css({ opacity:0, background:'#2596D4 url(landingIMG/destaque_tecnovidro.jpg) no-repeat center top' })
			.stop()
			.animate({ opacity:1 }, 'slow');
		
		jQuery('.linkSite a').children('span').stop().animate({ backgroundPosition:'0 0' }, 'fast');
		jQuery(this).children('span').stop().animate({ backgroundPosition:'0 0' }, 'fast');
	});
	
	jQuery('.form').each(function(){
		var default_first = jQuery(this).children('input:first').val();
		var default_last = jQuery(this).children('input:last').val();
		
		jQuery(this).children('input:first').focus(function(){
			if (this.value == default_first) this.value = '';
		}).blur(function(){
			if (this.value == '') this.value = default_first;
		});

		jQuery(this).children('input:last').focus(function(){
			if (this.value == default_last) this.value = '';
		}).blur(function(){
			if (this.value == '') this.value = default_last;
		});
	});
	
});
