$(document).ready(function() {
	
	// Expand Panel
	$("#open").click(function(){
		$("div#panel").slideDown("slow");
	
	});	
	
	$(".contacttrigger").click(function(){
		$("div#panel").slideDown("slow");
		$("#toggle a").toggle();
	
	});	
	
	// Collapse Panel
	$("#close").click(function(){
		$("div#panel").slideUp("slow");	
	});		
	
	// Switch buttons on click
	$("#toggle a").click(function () {
		$("#toggle a").toggle();
	});		

});

$(document).ready(function() {
	<!-- Gallery -->

	$('.control-panel').append('<ul class="nav"></ul>');

	$('.stage-slider').cycle({ 
		fx:     'fade', 
		timeout: 10000,
		speed: 750,
		pager:  '.control-panel .nav',
		pause:  1,
		cleartype:  true,
    	cleartypeNoBg:  true,
		
		pagerAnchorBuilder: function(idx, slide) { 
        return '<li><a href="#"><img src="/wp-content/themes/DynamiX/images/blank.gif" width="16" height="16" alt="slide" /></a></li>'; 
    } 
		
	});


	$('#pause').click(function() { 
		$('.stage-slider').cycle('pause'); 
	});
	
	$('#resume').click(function() { 
		$('.stage-slider').cycle('resume'); 
	});
	
	
	$("#toggle_slide_nav a").click(function () {
			$("#toggle_slide_nav a").toggle();
	});	

});


$(document).ready(function() {
	
	// Show Social Icons
	$(".socialinit").click(function(){
		$("div.socialicons").animate({width: 'show'});
	
	});	
	
	// Hide Social Icons
	$(".socialhide").click(function(){
		$("div.socialicons").animate({width: 'hide'});
	
	});		

	// Switch buttons on click
	$("#togglesocial li").click(function () {
		$("#togglesocial li").toggle();
	});	

});



$(document).ready(function() {

	<!-- Group Slider -->

	$('.group-slider').cycle({ 
		fx:     'scrollHorz', 
		timeout: 0,
		speed: 750,
		easing: 'easeInOutExpo',
		prev: '#leftnav',
		next: '#rightnav'
	});

});



/******************************************************************/
/*	Sidebar Mini Gallery									      */
/******************************************************************/

$(document).ready(function() {


	$('.mini-slider').cycle({ 
		fx:     'scrollHorz', 
		timeout: 5000,
		speed: 750,
		easing: 'easeInOutExpo',		
		prev: '#leftnav',
		next: '#rightnav',
		cleartype:  true,
    	cleartypeNoBg:  true
	});


	$('#pause').click(function() { 
		$('.stage-slider').cycle('pause'); 
	});
	
	$('#resume').click(function() { 
		$('.stage-slider').cycle('resume'); 
	});
	
	
	$("#toggle_slide_nav a").click(function () {
			$("#toggle_slide_nav a").toggle();
	});	

});

/******************************************************************/
/*	Sidebar Mini Gallery *END*								      */
/******************************************************************/

$(document).ready(function() {

  // Reset Font Size
  var originalFontSize = $('html').css('font-size');
    $(".resetFont").click(function(){
    $('html').css('font-size', originalFontSize);
  });
  // Increase Font Size
  $(".increaseFont").click(function(){
    var currentFontSize = $('.content-wrapper-inner').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum*1.1;
    $('.content-wrapper-inner').css('font-size', newFontSize);	
    return false;
  });
  // Decrease Font Size
  $(".decreaseFont").click(function(){
    var currentFontSize = $('.content-wrapper-inner').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum*0.9;
    $('.content-wrapper-inner').css('font-size', newFontSize);
    return false;
  });

});




/******************************************************************/
/*	Gallery Thumbnail Hover Function						      */
/******************************************************************/

$(document).ready(function () {

	
$('.galleryimg,.shortcodeimg,.galleryvid').hover(
		
		//Mouseover, fadeIn the hidden hover class	
		function() {
		$(this).children('div').css('display', 'block'); // FIX IE BUG	
		$(this).children('div').fadeTo("fast",0.6);
				
		}, 
	
		//Mouseout, fadeOut the hover class
		function() {
		$(this).children('div').fadeTo("fast",0, function() {
		});
		
		
	});


});




/******************************************************************/
/*	Stage Gallery Hover Function						      	  */
/******************************************************************/
/*
$(document).ready(function () {

	
$('.gallerywrap,.post-gallery-wrap').hover(
		
		//Mouseover, fadeIn the hidden hover class	
		function() {
		$(this).children('.control-wrap').fadeIn("fast");
		}, 
	
		//Mouseout, fadeOut the hover class
		function() {
		$(this).children('.control-wrap').fadeOut("fast");
		
		
	});


}); */

/******************************************************************/
/*	Stage Gallery Hover Function *END*					      	  */
/******************************************************************/

/******************************************************************/
/*	Contact Form										      	  */
/******************************************************************/

$(document).ready(function() {
	$('form#contactForm').submit(function() {
		$('form#contactForm .error').remove();
		var hasError = false;
		$('.requiredField').each(function() {
			if(jQuery.trim($(this).val()) == '') {
				var labelText = $(this).prev('label').text();
				$(this).parent().append('<span class="error">You forgot to enter your '+labelText+'.</span>');
				hasError = true;
			} else if($(this).hasClass('email')) {
				var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
				if(!emailReg.test(jQuery.trim($(this).val()))) {
					var labelText = $(this).prev('label').text();
					$(this).parent().append('<span class="error">You entered an invalid '+labelText+'.</span>');
					hasError = true;
				}
			}
		});
		if(!hasError) {
			$('form#contactForm li.buttons button').fadeOut('normal', function() {
				$(this).parent().append('<img src="/wp-content/themes/td-v3/images/template/loading.gif" alt="Loading&hellip;" height="31" width="31" />');
			});
			var formInput = $(this).serialize();
			$.post($(this).attr('action'),formInput, function(data){
				$('form#contactForm').slideUp("fast", function() {				   
					$(this).before('<p class="thanks"><strong>Thanks!</strong> Your email was successfully sent. I check my email all the time, so I should be in touch soon.</p>');
				});
			});
		}
		
		return false;
		
	});
});

/******************************************************************/
/*	Contact Form *END*									      	  */
/******************************************************************/

