// JavaScript Document

// Cufon replace

Cufon.replace('.button-white,.offers h2,.grid_13 h3,.heading h4,.description,.wraporder h4,.discount', {
            fontFamily:'PT Sans Caption',
			textShadow:'1px 1px 1px #ffffff'
			});
Cufon.replace('.slider-text h3,.slider-text h1', {
            fontFamily:'PT Sans Caption',
			textShadow:'1px 1px 3px #6a6a6a'
			});
Cufon.replace('.button-black', {
            fontFamily:'PT Sans',
			textShadow:'1px 1px 3px #6a6a6a'
			});
Cufon.replace('.button', {
            fontFamily:'PT Sans Caption',
			textShadow:'1px 1px 3px #6a6a6a'
			});

$(document).ready(function(){						
	
	// Slider effect / setting 
						   
    $('#sliders').cycle({			
	    fx:'fade', 
    	speed:500, 
    	timeout:5000,  
    	pause:1,
		cleartypeNoBg: true,
		next:'#slider-show-next', 
	    prev:'#slider-show-prev',
		pager:'#slider-show-pager',
		activePagerClass:'active-page',
		pagerAnchorBuilder:function(pages, slider) {
		        return '<a><span>'+(pages+1)+'</span></a>';
		    },
		
		after: function(){
		
		$(this).parent().find('.slider-text').animate({right: '0px',opacity: 1},
											  {easing: 'easeOutExpo',
											  duration: 1000}
											  );
		
		$(this).find('.slider-img').animate({left: '0px',opacity: 1},
										{easing: 'easeOutExpo',
									     duration: 1000,
										 complete: function (){
											 
											 $(this).parent().find('.slider-img-bg').animate({top: '0px',opacity: 1},
									                                    {duration: 1000,
									                                     easing: 'easeOutExpo',
									                                     complete: function (){
																			
																			$(this).parent().find('.discount').animate({left: '90px',opacity: 1},
											                                                         {easing: 'easeOutExpo',
											                                                           duration: 1000});
																			}
																		});
											 }
										});
			 
			 },
			 
	    before: function(){
	
        $(this).parents("#slider-show").removeClass();
	    $(this).parents("#slider-show").addClass( $(this).attr("id") );
		$('.offers').find("h2 span").removeClass();
	    $('.offers').find("h2 span").addClass( $(this).attr("id") );
		$('.discount').find("h1").removeClass();
	    $('.discount').find("h1").addClass( $(this).attr("id") );
		//$('.offers').find("a").removeAttr("id");
	    $('.offers').find("a").attr("id", $(this).attr("id") );
		$(this).find('.slider-img').css({opacity: '0',left: '-465px' });
		$(this).find('.slider-img-bg').css({opacity: '0',top: '-450px' });
		$(this).find('.slider-text').css({opacity: '0',right: '-465px' });
		$(this).find('.discount').css({opacity: '0',left: '0' });
		Cufon.refresh();
	
	    }

	});
	
	
	// Slider arrow hide / show

	$('#slider-show-next,#slider-show-prev').hide();
	
	$('#slider-show').hover(
		function() {
		  $('#slider-show-next,#slider-show-prev').stop().fadeTo(500, 1);
		},
		function() {
		  $('#slider-show-next,#slider-show-prev').stop().fadeTo(500, 0);
	   });
	
	$(".block1 .services li").hover(function(){
		$(this).animate({marginTop: 40},150);
		$(this).find('a').stop().fadeTo(100, 0.5);
		},
		function(){
		$(this).animate({marginTop: 50},150);
		$(this).find('a').stop().fadeTo(100, 1);
		return false;
	});
	
	// Gallery
	
	$("a[rel^='prettyPhoto']").prettyPhoto();
	$('.gallery a').hover(
		function() {
		  $(this).find('img').fadeTo(300, 0.5);
		  $(this).children('.zoom').fadeIn(300).animate({bottom:"+=30px"},500);
		},
		function() {
		  $(this).find('img').fadeTo(300, 1);
		  $(this).children('.zoom').fadeOut(300).animate({bottom:"0px"},500);
	   });
	
	
   // Newsletter Form Validate / Submit
   
   
   $('.newsletter a').click(function(){
		 $(".newsletter a").toggleClass("close");	
		 $(".news-block").toggle(150);							 
       });
 


   $('#submit').formValidator({scope: '#newssend',errorDiv: '#errormess'});
	
	var option = {
	 beforeSubmit: function() {
		    $('#newssend').hide();
		    $('.sendnews').show();
		},
		success: function() {
			$('.sendnews').hide();
			$("#mess").show().html('<p>Thank for subscription !</p>');
			$("#mess").delay(1500).fadeOut(500);
			$('#newssend').delay(2000).fadeIn(500);
			$('#newssend').clearForm();		
		  },
		url: './php/newssend.php'
	   };
	   
	   
	
	  $('#newssend').submit(function() {
	  $(this).ajaxSubmit(option);
		return false;
	   });
   
   // Twetter plugin
   
   $.fn.twitterSearch.defaults.css.a.color = '#646464';
   $('#twitter').twitterSearch({ 
    term:   'envato',
	title: false,
    // no fade 
    animOut: { opacity: 1 }, 
    avatar:  true, 
    anchors: true, 
    bird:    true, 
    colorExterior: '#f6f6f6', 
    colorInterior: '#f6f6f6', 
    pause:   true, 
    time:    false, 
    timeout: 2000 
    });
   
   // Feedback
   
   $('.feedback').cycle({ 			
	    fx:'fade', 
    	speed:500, 
    	timeout:3000,  
    	pause:1
	});
    
	

	  
	// Follow Effect
	
	$('#socicon li a img').fadeTo(100, 0.7);
	$('#socicon li').hover(function(){
		$(this).find('a img').animate({width: 30},150);
		},
		function(){
		$(this).find('a img').animate({width: 32},150);
		
	});



});
