/******************************************************************/
/*	Navigation												      */
/******************************************************************/

$(document).ready(function() {
$("#dropmenu ul").css({display: "none"}); // Opera Fix
$("#dropmenu li").hover(function(){
		$(this).find('ul:first').animate({height: "show"}, 150, "easeInOutCubic");
		},function(){
		$(this).find('ul:first').animate({height: "hide"}, 250, "easeInBack");
		});
		
});


/******************************************************************/
/*	Navigation *END*										      */
/******************************************************************/

/******************************************************************/
/*	Back to top Animation	by ronluna working      		      */
/******************************************************************/
function dynamix_do_backtotop(){
	$(document).ready(function() {
		$('.hozbreak-top a').click(function(){
		     $('html, body').animate({scrollTop: '0px'}, 300);
		     return false;
		});
	});
}
$(document).ready(function() {
	dynamix_do_backtotop();
});
/******************************************************************/
/*	Back to top Animation *END*								      */
/******************************************************************/


/******************************************************************/
/*	Drop Panel		by ron luna working!					      */
/******************************************************************/
function dynamix_do_droppanel(){
	//$(document).ready(function() {
		
		// Expand Panel
		$("#open").click(function(){
			$("div#panel").animate({height: "show"}, 900, "easeInOutCubic");
		
		});	
		
		$(".contacttrigger").click(function(){
			$("div#panel").animate({height: "show"}, 900, "easeInOutCubic");
			$("#toggle a").toggle();
		
		});	
	
		$(".droppaneltrigger").click(function(){
			$("div#panel").animate({height: "show"}, 900, "easeInOutCubic");
			$("#toggle a").toggle();
		
		});	
		
		// Collapse Panel
		$("#close").click(function(){
			$("div#panel").animate({height: "hide"}, 600, "easeInBack");	
		});		
		
		// Switch buttons on click
		$("#toggle a").click(function () {
			$("#toggle a").toggle();
		});		
	
	//});

}

$(document).ready(function() {
	dynamix_do_droppanel();
});
/******************************************************************/
/*	Drop Panel *END*										      */
/******************************************************************/



/******************************************************************/
/*	Stage Gallery Navigation								      */
/******************************************************************/

function dynamix_do_stage_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="http://losperros.com/site/wp-content/themes/DynamiX/images/blank.gif" width="16" height="16" alt="slide" /></a></li>'; 
    }});
	
}
$(document).ready(function() {

	dynamix_do_stage_gallery();

	$('#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();
	});	

});

/******************************************************************/
/*	Stage Gallery Navigation *END*							      */
/******************************************************************/



/******************************************************************/
/*	Social Icons Animate									      */
/******************************************************************/

function dynamix_do_social_icons(){
	
	// 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() {
	dynamix_do_social_icons();
});
/******************************************************************/
/*	Social Icons Animate *END*								      */
/******************************************************************/



/******************************************************************/
/*	Group Slider Gallery 									      */
/******************************************************************/

function dynamix_do_slider_gallery(){
	$('.group-slider').cycle({ 
		fx:     'scrollHorz', 
		timeout: 0,
		speed: 750,
		easing: 'easeInOutExpo',
		prev: '#leftnav',
		next: '#rightnav'
	});
}

$(document).ready(function() {

	dynamix_do_slider_gallery();

});
/******************************************************************/
/*	Group Slider Gallery *END*								      */
/******************************************************************/



/******************************************************************/
/*	Sidebar Mini Gallery									      */
/******************************************************************/

function dynamix_do_mini_gallery(){
	$('.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();
	});	

}

$(document).ready(function() {

	dynamix_do_mini_gallery();


});

/******************************************************************/
/*	Sidebar Mini Gallery *END*								      */
/******************************************************************/


/******************************************************************/
/*	Text Resizer by ronluna working!    					      */
/******************************************************************/
function dynamix_do_text_resizer(){
	$(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;
	  });
	
	});
}

$(document).ready(function() {
	dynamix_do_text_resizer();
});
/******************************************************************/
/*	Text Resizer *END*	 									      */
/******************************************************************/


/******************************************************************/
/*	prettyPhotojs by ronluna not working					      */
/******************************************************************/
function dynamix_do_prettyphotojs(){
		$(".gridimg-wrap a[rel^='prettyPhoto']").prettyPhoto({theme:'light_rounded'}); 
}

//$(document).ready(function() {
//	dynamix_do_prettyphotojs();
//});
/******************************************************************/
/*	prettyPhotojs *END*	 									      */
/******************************************************************/


/******************************************************************/
/*	Gallery Image Hover 									      */
/******************************************************************/

function dynamix_do_image_hover(){

$('.galleryimg,.shortcodeimg,.shortcodevid,.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() {
		});
		
		
	});
}
$(document).ready(function () {

	dynamix_do_image_hover();


});
/******************************************************************/
/*	Gallery Image Hover *END*								      */
/******************************************************************/


/******************************************************************/
/*	Contact Form										      	  */
/******************************************************************/

function dynamix_do_contact_form(){
	$('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;
		
	});

}

$(document).ready(function() {
	dynamix_do_contact_form();
});

/******************************************************************/
/*	Contact Form *END*									      	  */
/******************************************************************/

/******************************************************************/
/*	Twitter Feed Cycle									      	  */
/******************************************************************/
/* Combining Tweets with JQuery Cycle ALL - CreativeWorkz.  */

function gettweets( name,tweetsnum ) {

//Your twitter name
var twitter_name = name;

//Number of tweets you want to get back
var twitter_count = tweetsnum;
//Callback function name
var callback_name = "tweet_callback";
//Twitter search url
var twitter_search = "http://twitter.com/statuses/user_timeline";
//Return type (json or xml)
var return_type = "json";
//Adds script tags to the head/body tag

( function() {
var ts = document.createElement('script');
ts.type = 'text/javascript';
ts.async = true;
ts.src = twitter_search + "." + return_type + "?screen_name=" + twitter_name + "&count=" + twitter_count + "&callback=" + callback_name;
( document.getElementsByTagName( 'head' )[ 0 ] || document.getElementsByTagName( 'body' )[ 0 ] ).appendChild( ts );
} )();

}

//Call back function
function tweet_callback( data ) {
//Loop through the data from twitter
$.each( data, function( i, tweet ) {
//Make sure the text isn't undefined
if( tweet.text != undefined ) {
//Lets do some regex magic to replace urls, hashtags, and usernames
var text = tweet.text.toString().replace( /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig, '<a href="$1">$1</a>' ).replace( /(^|\s)@(\w+)/, '<a href="http://www.twitter.com/$2">@$2</a>' ).replace( /[#]+[A-Za-z0-9-_]+/ig, function(t) { var tag = t.replace("#","%23"); return t.link("http://search.twitter.com/search?q="+tag); } );
//Lets append each tweet to a ul with the id of tweet_container
$( "#tweet_container" ).append( "<span>" + text + "</span>");
			$('#tweet_container').cycle({ // Cycle through tweets
				fx: 'fade',
				speed: 1000,
				timeout: 10000,
				cleartype:  1 // enable cleartype corrections 
			});
}
});
}
/******************************************************************/
/*	Twitter Feed Cycle *END*							      	  */
/******************************************************************/

/******************************************************************/
/*	Accordion											      	  */
/******************************************************************/
$(document).ready(function() {

	// Accordion
	$(".accordion").accordion({ header: "h3" });
	
	
});

/******************************************************************/
/*	Accordion *END*										      	  */
/******************************************************************/

/******************************************************************/
/*	Tabs												      	  */
/******************************************************************/
$(document).ready(function() {
	// Tabs
	$(".dyntabs").tabs({ fx: { height:'toggle', duration:'fast' }  });	
});

/******************************************************************/
/*	Tabs *END*											      	  */
/******************************************************************/	

function dynamix_do_jquery_jplayer(){
//$(document).ready(function(){

	var playItem = 0;

	var myPlayList = [
		{name:"SHM - Save the World",mp3:"http://losperros.com/site/wp-content/uploads/02-Save-the-World-Style-of-Eye-Carli-Remix.mp3"},
		{name:"Autoerotique - Turn Up The Volume",mp3:"http://losperros.com/site/wp-content/uploads/03-Turn-Up-the-Volume.mp3"},
		{name:"Chris Brown - Beautiful People",mp3:"http://losperros.com/site/wp-content/uploads/01-Beautiful-People-Felix-Cartal-Club-Remix.mp3"},
		{name:"Murphy Jax - Time to Bump",mp3:"http://losperros.com/site/wp-content/uploads/03-Time-to-Bump.mp3"}

	];

	// Local copy of jQuery selectors, for performance.
	var jpPlayTime = $("#jplayer_play_time");
	var jpTotalTime = $("#jplayer_total_time");


	$("#jquery_jplayer").jPlayer({
		ready: function() {
			displayPlayList();
			playListInit(false); // Parameter is a boolean for autoplay.
		}
	})
	.jPlayer("onProgressChange", function(loadPercent, playedPercentRelative, playedPercentAbsolute, playedTime, totalTime) {
		jpPlayTime.text($.jPlayer.convertTime(playedTime));
		jpTotalTime.text($.jPlayer.convertTime(totalTime));
	})
	.jPlayer("onSoundComplete", function() {
		playListNext();
	});

	$("#jplayer_previous").click( function() {
		playListPrev();
		$(this).blur();
		return false;
	});

	$("#jplayer_next").click( function() {
		playListNext();
		$(this).blur();
		return false;
	});

	function displayPlayList() {
		$("#jplayer_playlist ul").empty();
		for (i=0; i < myPlayList.length; i++) {
			var listItem = (i == myPlayList.length-1) ? "<li class='jplayer_playlist_item_last'>" : "<li>";
			listItem += "<a href='#' id='jplayer_playlist_item_"+i+"' tabindex='1'>"+ myPlayList[i].name +"</a></li>";
			$("#jplayer_playlist ul").append(listItem);
			$("#jplayer_playlist_item_"+i).data( "index", i ).click( function() {
				var index = $(this).data("index");
				if (playItem != index) {
					playListChange( index );
				} else {
					$("#jquery_jplayer").jPlayer("play");
				}
				$(this).blur();
				return false;
			});
		}
	}

	function playListInit(autoplay) {
		if(autoplay) {
			playListChange( playItem );
		} else {
			playListConfig( playItem );
		}
	}

	function playListConfig( index ) {
		$("#jplayer_playlist_item_"+playItem).removeClass("jplayer_playlist_current").parent().removeClass("jplayer_playlist_current");
		$("#jplayer_playlist_item_"+index).addClass("jplayer_playlist_current").parent().addClass("jplayer_playlist_current");
		playItem = index;
		$("#jquery_jplayer").jPlayer("setFile", myPlayList[playItem].mp3);
	}

	function playListChange( index ) {
		playListConfig( index );
		$("#jquery_jplayer").jPlayer("play");
	}

	function playListNext() {
		var index = (playItem+1 < myPlayList.length) ? playItem+1 : 0;
		playListChange( index );
	}

	function playListPrev() {
		var index = (playItem-1 >= 0) ? playItem-1 : myPlayList.length-1;
		playListChange( index );
	}
//});
}
$(document).ready(function(){
	dynamix_do_jquery_jplayer();
});

function dynamix_do_quickmenu(){

}



$(document).ready(function(){
	dynamix_do_quickmenu();
});

