/*
Image zoom
--------------------------------*/
function imghover(){
$("a.zoom img,a.video img").mouseover(function(){
	$(this).stop(true,true);
	$(this).fadeTo(300, 0.6);
});

$("a.zoom img,a.video img").mouseout(function(){
	$(this).fadeTo(400, 1.0);
});

}

/*
facny box function
------------------------*/
function fancy(){
$("a.zoom,a.video").fancybox({
'titleShow'     : false,
'showCloseButton': true,
'transitionIn'	: 'elastic',
'transitionOut'	: 'elastic',
'easingIn'      : 'easeOutBack',
'easingOut'     : 'easeInBack'
}); 
}




$(function(){ // load after window


/*
Toggles
-------------------------------*/

$(".toggle_container").hide(); 

$(".toggle_trigger").click(function(){
	$(this).toggleClass("toggle_active").next().slideToggle("fast");
	return false;
});



/*###################
Auto clear for input
#####################*/

$('.autoclear').click(
function() {
if ( this.value == this.defaultValue ) {
this.value = '';
} 
});

$('.autoclear').blur(
function() {
if (this.value == '') {
this.value = this.defaultValue;
}
}
);


/*
Button hover effect 
------------------------------------*/


$(".tab_content").hide(); //Hide all content
$("ul.tabs li:first").addClass("active").show(); //Activate first tab

$(".tab_content").filter(':first').show(); //Show first tab content


$("ul.tabs li").click(function() {

	$("ul.tabs li").removeClass("active"); //Remove any "active" class
	$(this).addClass("active"); //Add "active" class to selected tab
	$(".tab_content").hide(); //Hide all tab content

	var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
	$(activeTab).fadeIn(); //Fade in the active ID content
	return false;
});



	
/*
roundabout 
----------------------------------------*/

var descs = {
				pfs:		 '<a href="http://www.professionalflooring.com/" title="Visit PFS Website" target="_blank">Click here</a> to visit PFS.',
				rozlaw: 		 '<a href="http://www.rozlawllc.com/" title="Visit Rozlaw" target="_blank">Click here</a> to visit Rozlaw, LLC.',
				shafer: '<a href="http://www.shaferservices.com/" title="Visit Shafer" target="_blank">Click here</a> to visit Shafer Services.',
				stoneoak: 	'<a href="http://www.stoneoakinfo.com/" title="Visit Stone Oak" target="_blank">Click here</a> to visit Stone Oak.',
				steambrite:    '<a href="http://www.steam-brite.com" title="Visit Steam Brite">Click here</a> to visit Steam Brite.'
			};
			
$('li').focus(function() {
	var useText = (typeof descs[$(this).attr('id')] != 'undefined') ? descs[$(this).attr('id')] : '';
	$('#description').html(useText).hide(200).toggle(200);
});

/*
cufon
---------------------------------
	*/
Cufon.replace('h1,h2,h3,h4,h6,.bigbutton span'); 

/*
share button on blog 
-------------------------------------------*/	
$('.social').hide();

	$('.post ul li').eq(0).find('.social_tips').click(function(){
		$('.post ul li').eq(0).find('.social').slideToggle(600);
	});		
	
	$('.post ul li').eq(5).find('.social_tips').click(function(){
	$('.post ul li').eq(5).find('.social').slideToggle(600);
	});

	$('.social').find('img').stop().animate({opacity:0.7});
	$('.social').find('img').hover(function(){
	$(this).stop().animate({width:'24px',
	height: '24px',
	opacity:1
	});
	},function(){
	$(this).stop().animate({width:'18px',
			height: '18px',
			opacity:0.8
			
			});
		
	});
	
/*
Disable all the A links
---------------------------------------*/

$('a').click(function(){
	var h = $(this).attr('href');
	if (h=='#')
	{
		return false;
	}

});
			
	
/*
Social tips and hover 
-----------------------------------*/

	$('#social img,.toll').tipsy({
			delayIn :200,
			delayOut :200,
			fade : false,
			gravity: 's',
			title : 'alt'
	
	});
		
		
	$('#social img').css({opacity : 0.6});
	$('#social img').hover(function(){
		$(this).stop().animate({
		opacity : 1
		},400);
	
	},function(){
	$(this).stop().animate({
		opacity : 0.5
		},300);
	
	});
	
/*
Wslider :Why transforms 
-------------------------------------------*/

$('#navigation ul li a,#tab-menu li a').hover(function(){
	$(this).animate({
		paddingLeft : '17px'
	},200);
		
},function(){
	$(this).animate({
		paddingLeft : '12px'
	},200);
	
},200);


/*
Contact Page
----------------------------------------*/

// Contact Form
	$('#send_message').click(function(e){
        e.preventDefault();
        var error = false;
        var name = $('#name').val();
        var email = $('#email').val();
        var homeph = $('#homeph').val();
        var message = $('#message').val();

        if(name.length == 0){
			error = true;
            $('#name_error').fadeIn(500);
        }else{
			$('#name_error').fadeOut(500);
        }
        if(email.length == 0 || email.indexOf('@') == '-1'){
			error = true;
            $('#email_error').fadeIn(500);
        }else{
			$('#email_error').fadeOut(500);
        }
/*
        if(homeph.length == 0){
			error = true;
            $('#homeph_error').fadeIn(500);
        }else{
			$('#homeph_error').fadeOut(500);
        }

        if(message.length == 0){
			error = true;
            $('#message_error').fadeIn(500);
        }else{
			$('#message_error').fadeOut(500);
        }
*/

        if(error == false){
			$('#send_message').attr({'disabled' : 'true', 'value' : 'Sending...' });

            /* using the jquery's post(ajax) function and a lifesaver
            function serialize() which gets all the data from the form
            we submit it to send_email.php */
            $.post("js/send_email.php", $("#contact_form").serialize(),function(result){
				if(result == 'sent'){
					$('#cf_submit_p').remove();
                    $('#mail_success').fadeIn(500);
                }else{
					$('#mail_fail').fadeIn(500);
                    $('#send_message').removeAttr('disabled').attr('value', 'Send Message');
                }
            });
        }
    });


	
/*
quick sand jquery 
-----------------------------------*/

// Custom sorting plugin
	// bind radiobuttons in the form
	var $filterType = jQuery('#filter a');
	// get the first collection
	var $list = jQuery('#portfolio-sorting');
	// clone applications to get a second collection
	var $data = $list.clone();

	$filterType.click(function(event) {

		if (jQuery(this).attr('rel') == 'everyone') {
		  var $sortedData = $data.find('li');
		} else {
			var $sortedData = $data.find('.'+ jQuery(this).attr('rel'));
		}

		jQuery('#filter a').removeClass('current_link');
		jQuery(this).addClass('current_link');
			
		$list.quicksand($sortedData, {
		  attribute: 'id',
		  duration: 800,
		  easing: 'easeInOutQuad',
		  useScaling: 'false',
		   adjustHeight: 'auto'
		   },function(){
		   
		   fancy(),
		   imghover()

		   });

		   return false;

		});
		
		

});//end of document .ready






