//Grid
$.fn.grid = function(count) {
	this.children().addClass("grid-item");
    this.children(':nth-child(' + count + 'n)').addClass('end-row-grid-item');
    this.children(':nth-child(' + count + 'n+1)').addClass('new-row-grid-item');
	this.children(':first-child').removeClass('new-row-grid-item');
	this.addClass('ofclear');
};


// Turns label text into placeholder text
this.label2value = function(){	

	// CSS class names
	// put any class name you want
	// define this in external css (example provided)
	var inactive = "inactive";
	var active = "active";
	var focused = "focused";
	
	// function
	$("label.placeholder-text").each(function(){		
		obj = document.getElementById($(this).attr("for"));
		if(($(obj).attr("type") == "text") || (obj.tagName.toLowerCase() == "textarea")){			
			$(obj).addClass(inactive);			
			var text = $(this).text();
			$(this).css("display","none");			
			$(obj).val(text);
			$(obj).focus(function(){	
				$(this).addClass(focused);
				$(this).removeClass(inactive);
				$(this).removeClass(active);								  
				if($(this).val() == text) $(this).val("");
			});	
			$(obj).blur(function(){	
				$(this).removeClass(focused);													 
				if($(this).val() == "") {
					$(this).val(text);
					$(this).addClass(inactive);
				} else {
					$(this).addClass(active);		
				};				
			});				
		};	
	});		
};

// Disables Right-Mouse Click					   
/*$(this).bind("contextmenu", function(e) {
	e.preventDefault();
});*/

$(document).ready(function(){
	
	//Turns label text to placeholder text
	label2value();	
	
	
	$('.video-js-box').hover(function(){
			$(this).children(".vjs-controls").fadeIn(300);
		},
		
		function(){
			$(this).children(".vjs-controls").delay(500).fadeOut(300);
		}); 
	
	//Grids
	$('#tshirt-grid').grid(5);
	$('#subscription-grid').grid(5);


	$('.subscription-tooltip').each(function () {
	   $(this).qtip({
		  content: {
			text: $(this).nextAll('.tip').find('.tip-body'),
		title: {
			text: $(this).nextAll('.tip').find('.tip-title'),
			   }
		},
		style: 'ui-tooltip-form-info', // Give it some style
		position: {
			my: 'bottom center',
			at: 'top center' // at the bottom right of...
		}
	   });
	});

}); // Closes documnent.ready
