// JavaScript Calls

$(document).ready(function() {

// window.onload = function(){ alert("onload test"); }


/* 	REMOVE FORM TEXT ON FOCUS
/* ----------------------------------------- */			

	 $('.search-text').focus(function(){
     	if($(this).val() == 'Search blog'){
     		$(this).val('');
     	}
     });
      
	 $('.search-text').blur(function(){
      	if($(this).val() == ''){
      		$(this).val('Search blog');
      	}
     });

	$('.pagename-contact input, .pagename-contact textarea').each(function() {

			var default_value = $(this).attr("title");
			$(this).val(default_value);
			$(this).focus(function() {
				if(this.value == default_value) {
					this.value = '';
				}
			});
			$(this).blur(function() {
				if(this.value === '') {
					this.value = default_value;
				}
			});
		});


/* 	FONT PAGE SLIDER
/* ----------------------------------------- */	

	$('#hero').slides({
		preload: true,
		generateNextPrev: true,
		play: 5000,
		slideSpeed: 1100
	});

	// Highlight links on hover
	
	$("#hero").mouseover(function(){
		$("a.prev", this).css( {backgroundPosition: "-507px -64px"} );
	});

	$("#hero").mouseout(function(){
		$("a.prev", this).css( {backgroundPosition: "-507px -7px"} );
	});
	
	$("#hero").mouseover(function(){
		$("a.next", this).css( {backgroundPosition: "-459px -64px"} );
	});

	$("#hero").mouseout(function(){
		$("a.next", this).css( {backgroundPosition: "-459px -7px"} );
	});

/* 	SERVICES
/* ----------------------------------------- */
	
	$('.pagename-services .three-col article:last').addClass('last');
	$('.pagename-portfolio ul.three-col li:nth-child(3n)').addClass('last');
	$('.pagename-press ul.press-items li:nth-child(4n)').addClass('last');
	$('.single-portfolio ul#gallery li:nth-child(3n)').addClass('last');
	$('.single-inspiration ul#gallery li:nth-child(3n)').addClass('last');
	
	
/* 	TESTIMONIALS
/* ----------------------------------------- */
	
	$(".home .testimonials").cycle({
			fx: 	'fade', 
		    speed:   1800, 
		    timeout: 5000
	});
     

/* 	ADD / REMOVE / CHANGE CLASS
/* ----------------------------------------- */
	
	$(".comment_content").addClass('new_class');
	

/* 	FANCYBOX
/* ----------------------------------------- */
	
	$("a.grouped_elements").fancybox({
		padding: 5,
		overlayColor: '#e4e4e4',
		overlayOpacity: 0.7
	});


/* 	FANCYBOX VIDEO IFRAME FIX
/* ----------------------------------------- */
	
    $(function(){
        var fancybox_iframe = $('.fb-vid');
        if (fancybox_iframe.length > 0){
            fancybox_iframe.each(function(index){
                // Inline frame width param
                if( $(this).attr('href').match(/width=[0-9]+/i) ){
                    var fWidth = parseInt($(this).attr('href').match(/width=[0-9]+/i)[0].replace('width=',''));
                } else {
                    var fWidth = '70%';
                }
                // Inline frame height param
                if( $(this).attr('href').match(/height=[0-9]+/i) ){
                    var fHeight = parseInt($(this).attr('href').match(/height=[0-9]+/i)[0].replace('height=',''));
                } else {
                    var fHeight = '70%';
                }
                if(window.console&&window.console.log) { 
                    console.log('fWidth #'+index+': '+fWidth); 
                    console.log('fHeight #'+index+': '+fHeight); 
                }
                $(this).fancybox({
                    'titlePosition' : 'inside',
                    'type'          : 'iframe',
                    'autoScale'     : true,
                    'padding'       : '0',
                    'width'         : 800,
                    'height'        : 450,
                    'centerOnScroll': true,
					'overlayOpacity': 0.85,
					'overlayColor'	: '#fff'
                });
            });
        }
    });
 
 
 
 
}); /* end of as page load scripts */


