<?php 
//Make it a JavaScript file
header("Content-type: text/javascript");
if(file_exists('../../../../wp-load.php')) {
	include '../../../../wp-load.php';
}
else {
	include '../../../../../wp-load.php';
}
?>


// hover fade
jQuery(document).ready(function() {
	//prevent to load the fade effect on IE8 (poor quality)
	//add the class "fade-hover" to any element you want to add the Fade effect
	if (!($.browser.msie  && parseInt($.browser.version) < 9)) {
		jQuery(".ml_fade-hover, .featured-image.ml_icon_picture img, .featured-image.ml_icon_video img, .featured-image.ml_icon_html img, .ml_social a").hover(
			function() {
				jQuery(this).fadeTo(300, 0.5, 'easeOutQuad');
			},
			function() {
				jQuery(this).fadeTo(400, 1, 'easeInQuad');
			}
		);
	}
	jQuery(".ml_grayscale_thumb img").hover(
		function() {
			jQuery(this).fadeTo(400, 0, 'easeOutQuad');
		},
		function() {
			jQuery(this).fadeTo(500, 1, 'easeInQuad');
		}
	);	
});


/*--- Portfolio Filter ---*/
jQuery(document).ready(function() {
	//start when the link is clicked
	jQuery(".ul-portfolio-categories a").click(function() {
		jQuery(this).css("outline","none");
		jQuery(".ul-portfolio-categories .selected").removeClass("selected");
		jQuery(this).parent().addClass("selected");
		
		//get the link value
		var preFilterVal = jQuery(this).text();
		//set the path to the AJAX sanitizer
		var sanitizeUrl = '<?php echo get_template_directory_uri().'/includes/sanitize.php'; ?>';		
		//get the sanitized link via AJAX (with sanitize_title() wordpress function) and starts the magic
		jQuery.get(sanitizeUrl, {slug: preFilterVal}, function (data) {
			var filterVal = data;
			//no conflict
			var filterVal = '.skill_' + filterVal;
			
			//when click All, show all
			if(filterVal == ".skill_<?php echo sanitize_title(__('All', 'meydjer')) ?>") {
				jQuery('.ml_portfolio_masonry').isotope({ filter: '*' });
			} 
			
			//show portfolio items by skill
			else {
				jQuery('.ml_portfolio_masonry').isotope({ filter: filterVal });
			}
		});
		return false;
	});
});


/*-------------------------------------------------*/
/*	Custom Javascripts
/*-------------------------------------------------*/
<?php echo of_get_option('ml_custom_js'); ?>