$(document).ready(function() {

	/*----------------------------
	
	Add Last Class 
	
	----------------------------*/
	$("#otherposts div:last-child, ul#menu-main-menu li:last-child, .page-template-viral-archives-php #content .video-item:nth-child(3n+4), .clientcat .client-item:nth-child(3n+3), ul#menu-agency-menu li:last-child ").addClass("last");
	
	/*----------------------------
	
	Fitvid 
	
	----------------------------*/
	$("#content").fitVids();
	
	/*----------------------------
	
	Input Placeholder Hide
	
	----------------------------*/
	$('form input:text, form textarea').each(function(){
        $.data(this, 'default', this.value);
    }).focus(function(){
        if ($.data(this, 'default') == this.value) {
            this.value = '';
        }
    }).blur(function(){
        if (this.value == '') {
            this.value = $.data(this, 'default');
        }
    });

	/*----------------------------
	
	Mobile Menu Switcher 
	
	----------------------------*/
	$('#mainmenu ul').mobileMenu({
	  switchWidth: 768,                  
	  topOptionText: 'Select a category',    
	});

	/*----------------------------
	
	Sidebar Tabs
	
	----------------------------*/
	$('#tabnav li a').on('click', function(){
		$('#tabnav li').removeClass("active");
		$(this).parent().addClass("active");
		$("#tabcontent ul").hide();
		$($(this).attr("rel")).show();	
		return false;
	});
	
	/*----------------------------
	
	Share Links
	
	----------------------------*/
	var links = $('.sharelinks').find('a');
	
	links.on('click', function(e){
		$this = $(this);
		
		if(popupUrl($this.attr('href'), 420)) {
		
		e.preventDefault();
		
		}
	})
	
	function popupUrl(url, height) {
		var width = 800;
		var popupName = 'popup_' + width + 'x' + height;
		
		var left = (screen.width-width)/2;
		var top = ((screen.height-height)/2)+25;
		var params = 'width=' + width + ',height=' + height + ',location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,left=' + left + ',top=' + top;
		
		window[popupName] = window.open(url, popupName, params);
		
		if(window.focus)
		{
			window[popupName].focus();
		}
		
		return true;
	}
	
	
});

