﻿
$(document).ready(function() {     

       
    
   $("#search-region input").val('Αναζήτηση...');
    
    
    
   

      
    $.ajax({
          type: "POST",
          url: base+"/products/getWithAjax",
          data: {which: 'lastProducts'},
          success: function(msg)
          {
	           $("#lastProducts").fadeOut("slow",
		       	function()
		        {
		        			$('#loader_for_lastProducts').fadeOut('slow');
    	           	$("#lastProducts").html(msg).fadeIn("slow");	           
	            }
	           );
          }
     });


    $(".tab").click(function(){            
            var which = $(this).attr('alt');                                    
            $("#lastProducts").fadeOut('slow');
            var t = $("<img />").attr('src',pb+'/images/c-loader.gif').appendTo($(this));
            $.ajax({
                type: "POST",
                url: base+"/products/getWithAjax/",
                data: {which : which},
                success: function(msg){                	  	                	
	                	$("#lastProducts").html(msg).fadeIn('fast');            	                	
	                	$(t).fadeOut('fast');
                }
            });
        
    });

 
 // carousel
    $('#mycarousel').jcarousel({
        scroll: 1,
        auto:1,
        wrap:'both',
        animation:'slow'
    });


//effects
    $(".menu li").hover(function(){
        $(this).animate({     
//           backgroundColor: "#A0000f"
                backgroundColor:"#FC9DB9"
        }, 700);
        $(this).animate({
            backgroundColor: "#fff"
        }, 500);
    });
    
   


    $(".box").hover(function(){
        $(this).animate({
            backgroundColor: "#a5d8f6"
	    
        }, 900);
        $(this).animate({
            backgroundColor: "#fff"
        }, 900);
    });




//fancy boxes
    $('#product a[rel="group"]').fancybox({
        'zoomSpeedIn': 300,
        'zoomSpeedOut': 300,
        'overlayShow': true
    });



// contact form

$("#contactFormSubmit").click(
	function()
	{
		
		var name = $('#name').val();
		var email = $('#email').val();
		var body = $('#body').val();		
		$.ajax({		
			type: "POST",
			url: base + "/modules/contact/sendEmail",
			data: {name: name, email: email, body: body},
			beforeSend:function()
			{
				 var t = $("<img />").attr('src',pb+'/images/loader.gif');
				 $('contactForm').animate({opacity:'0.45'},700);
				 
				$("#contactFormSubmit").after($(t));
			},
			success: function(msg)
			{

				var tmp = 'Το μήνυμα αποστάλθηκε, σας ευχαριστούμε, σύντομα θα επικοινωνίσουμε μαζί σας!';
				$("#contactForm").fadeOut(function(){
					$("#bform").append($('<span class=\'info\'></span>').html(tmp));
				});
			}			
		});
		
		
	}
);
	


//search 


$("#search-region input").click(function(){
            $(this).val("");
//alert('Υπο κατασκευή');

});


$("#search_form").submit(function(){
    
    var q = $("#search-region input").val();

    var ar = q.split(" ");
    q = ar.join("+");
    window.location="/index.php/search/"+q;
    return false;
});






});


