
/*
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


/*
color Picker 
------------------------*/

$('#colorSelector').ColorPicker({
		color: '#0000ff',
		onShow: function (colpkr) {
			$(colpkr).fadeIn(500);
			return false;
		},
		onHide: function (colpkr) {
			$(colpkr).fadeOut(500);
			return false;
		},
		onChange: function (hsb, hex, rgb) {
			$('body').css('backgroundColor', '#' + hex);
		$('style#pattern').text('body {background-image:url(images/pattern/1.png;}');
		}
	});
	


$('#colorSelector_inner').ColorPicker({
		color: '#0000ff',
		onShow: function (colpkr) {
			$(colpkr).fadeIn(500);
			return false;
		},
		onHide: function (colpkr) {
			$(colpkr).fadeOut(500);
			return false;
		},
		onChange: function (hsb, hex, rgb) {
			$('.tweet_roll a,.sidebar_tabs ul li a,.toggles a,.sorting a.current_link').css('color','#' +hex);
		}
	});


$('.pattern li').click(function() {
		var pat = $(this).css('background-image');
		$('style#pattern').text('body {background-image:' + pat + ';}');
		$('body').css({'background-color' : ''});

	});

$("div.panel_button").click(function(){
		$("div#panel").animate({
			left: "0px"
		}, "fast");
		$(".panel_button").animate({
			left: "150px"
		}, "fast");
		$("div.panel_button").toggle();
});	
	
$("div.hide_button").click(function(){
	$("div#panel").animate({
		left: "-150px"
	}, "fast");
	$(".panel_button").animate({
		left: "0px"
	}, "fast");
});



$('.color li.c1').click(function() {
	$('head').append('<link rel="stylesheet" href="css/c1.css" />');
})
	
$('.color li.c2').click(function() {
		$('head').append('<link rel="stylesheet" href="css/c2.css" />');
})

$('.color li.c3').click(function() {
		$('head').append('<link rel="stylesheet" href="css/c3.css" />');
})


$('.shadows li.one').click(function() {
$('.slideshadow').addClass('slideshadow1');
$('.slideshadow').removeClass('slideshadow2');
})
			
$('.shadows li.two').click(function() {
$('.slideshadow').removeClass('slideshadow1');
$('.slideshadow').addClass('slideshadow2');
})
	
$('.shadows li.default').click(function() {
$('.slideshadow').addClass('slideshadow');
$('.slideshadow').removeClass('slideshadow2 slideshadow1');
})
		

/*
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 = {
				chair:		 'Just chillin&rsquo;, chair-style so do not dos all mice: you&rsquo;ve.',
				wise: 		 'He has the look of a wise, fierce warrior sss all mice: you&rsquo;ve.',
				mousepatrol: 'Attention all mice: you&rsquo;ve been warnedd. all mice: you&rsquo;ve ',
				sleepy: 	'Stop taking pictures of me&hellip;  trying to sleep her doing .',
				acrocat:    'Introducing: the INCREDIBLE ACROCAT all mice: you&rsquo;veall mice: '
			};
			
$('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 subject = $('#subject').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(subject.length == 0){
			error = true;
            $('#subject_error').fadeIn(500);
        }else{
			$('#subject_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






