$(document).ready(function(){
			
			
						   
    /*$("#search").hover(
        function(){
            $("#search_about-effect").stop();
            $("#search_about-effect").animate({height:"31px"},'fast');
            $("#search").css("color","#ffffff");
            $("#search").css("font-weight","bold");
            $("#about").css("color","#231F20");
        }, function()
        {
            $("#search_about-effect").stop();
            $("#search_about-effect").animate({height:"0px"},'fast');
            $("#search").css("color","#666666");
            $("#search").css("font-weight","normal");
            $("#about").css("color","#231F20");    
        }
    );*/
   
    $(".btAboutPreta").click(function(){
        $("#about_info").slideDown('fast');
	
		if($('#slid').is(":visible")) 
		{
		}
		else
		{
			$('#slid').toggle('slow'); $('#falseSlid').toggle('slow');
		}
	});
    $(".closeAbout").click(function(){
         $("#about_info").slideUp('fast');
		 
         
    });

    $("#info_banner").hover(
        function(){
            $("#bannerDescription").fadeIn();
        }, function()
        {
            $("#bannerDescription").fadeOut();
        }
    );
    $('#clientsShow').cycle({
        fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
    });

    $(".show").hover(
        function(){
            $(this).find('.description').fadeIn('normal');
        },function(){
            $(this).find('.description').fadeOut('normal');
        }
    );
    $(".case_left").hover(
        function(){
            $(this).find('.description').fadeIn('normal');
        },function(){
            $(this).find('.description').fadeOut('normal');
        }
    );
    $(".case_right").hover(
        function(){
            $(this).find('.description').fadeIn('normal');
        },function(){
            $(this).find('.description').fadeOut('normal');
        }
    );

    $("#coupon_show").hover(
        function()
		{
		$('#coupon').fadeIn();
		}
        ,function(){
            $('#coupon').fadeOut();
        }
    );
	
	
	$("#coupon_show").mousemove(function(e)
	{
		$('#coupon').css('top', findYCoord(e)+20).css('left', findXCoord(e)+20);
	});
	$("#pointPurchase_show").mousemove(function(e)
	{
		$('#pointPurchase').css('top', findYCoord(e)+20).css('left', findXCoord(e)+20);
	});
	$("#couponOk_show").mousemove(function(e)
	{
		$('#couponOk').css('top', findYCoord(e)+20).css('left', findXCoord(e)+20);
	});
	
    $("#pointPurchase_show").hover(
        function(){
            $('#pointPurchase').css("display","block");
        },function(){
            $('#pointPurchase').css("display","none");
        }
    );
    $("#couponOk_show").hover(
        function(){
            $("#couponOk").css("display","block");
        },function(){
            $("#couponOk").css("display","none");
        }
    );
    $(".input").hover(
        function(){
            $(this).css("color","#FFF");
            $(this).css("backgroundPosition","0px -48px");
        },function(){
            $(this).css("color","#000");
            $(this).css("backgroundPosition","0px 0px");
        }
    );
    
    $("#btBuscaPreta").click(function(){
    
		$("#searchOpen").slideDown("fast");
		$("#buscaPreta").slideUp("fast");
    });
	
    $("#close_search").click(function(){
        $("#searchOpen").slideUp("fast");
    });
	
	$("#search").hover( function()
	{
		$("#buscaPreta").slideDown("fast");
	});
	
	$("#buscaPreta").mouseout(function()
	{
		$("#buscaPreta").slideUp("fast");
	});
	
	$("#aboutPreta").mouseout(function()
	{
		$("#aboutPreta").slideUp("fast");
	});
	
	
	 $("#about_link").hover(
        function()
		{
			$("#aboutPreta").slideDown('fast');
		}
    );
});

function submitGetInTouch(){
	
	var callmes;
	
	if($('#name').val() != "" && $('#tel').val() != "" && $('#email').val() != "" && $('#name').val() != "Name" && $('#tel').val() != "Telephone Number" && $('#email').val() != "Email")
	{
		
		if(echeck($("#email").val()))
		{
			
			if ($('#callMe').is(':checked')) callmes = 'yes';
			else callmes = 'no';
			
			$('#unsubmitted').fadeOut('slow', function() { $.post("../ajax/touch.php", { name: $('#name').val(), tel: $('#tel').val(), callMe: callmes, email: $('#email').val()  },
																																									
			   function(data){
					$('#unsubmitted').html(data);
					$('#unsubmitted').fadeIn('slow'); 
					
			   });  } );
		}
		else
		{
			alert('Please type a valid email');	
		}
	}
	else
	{
		alert('Please type all fields.');	
	}
}
function submitGetInTouchPeriod(period)
{
	
		$('#unsubmitted').fadeOut('slow', function() { $.post("../ajax/touch2.php", { periodo: period,  name: $('#nameX').val(), tel: $('#telX').val(), callMe: $('#callMeX').val(), email: $('#emailX').val() },
																																								
		   function(data){
				$('#unsubmitted').html(data);
				$('#unsubmitted').fadeIn('slow'); 
				
		   });  } );
	
}
function submitOk(){

$('#unsubmitted').fadeOut('slow', function() { $.post("../ajax/touchBack.php",
																																								
   function(data){
		$('#unsubmitted').html(data);
		$('#unsubmitted').fadeIn('slow'); 
		
   }
   );
   } );

}

function cases(categoria,bg)
{
	$('#cases').fadeOut('slow', function() { $.post("../ajax/cases.php", { category: categoria },
   
   function(data){
   		$('#cases').html(data);
		$('#cases').fadeIn('slow'); 
	 	
   });  } );
}

function bgFilter(bg)
{
	$("#clicado").css('background-image','url(../image/'+bg+')');	
}



function findXCoord(evt) {
	if (evt.x) 	return evt.x; 
	if (evt.pageX) return evt.pageX; 
}

function findYCoord(evt) {
	if (evt.y) return evt.y; 
	if (evt.pageY) return evt.pageY; 
}

function echeck(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	    return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		return false
	 }
	
	 if (str.indexOf(" ")!=-1){
		return false
	 }
	 return true					
}
