/*
 * Components Script
 */

$(document).ready(function(){ 
	
	/* Remove nojs Class of html */
	
	$('html').removeClass('nojs');
	
	/* Cancel natural link of .button a and popup close*/
	
	$('form .button a, #widget_close, .delete>a, .cancelLink').click(function(e){
		e.preventDefault();
	});
		
	/* Dropdown User */
	
	var stateDropdownUser = false;

	// On click if the .drop is hidden, display it
	$('.dropdown.user>a').click(function(e){
		e.preventDefault();
		if(stateDropdownUser == false){
			e.stopPropagation();
			$(this).next('.drop').addClass('active');
			stateDropdownUser = true;
		}
	});	
		
	// Cancel hide .drop if click on .drop items
	$('.drop a').click(function(e){
		e.stopPropagation();
	});
	
	$('.nav.main a').focus(function(){
		if(stateDropdownUser == true){
			$('.dropdown.user>a').next('.drop').removeClass('active');
			stateDropdownUser = false;
		}
	});	
	
	// On click anywhere on the screen if the .drop is display, hide it
	$('html').click(function(){
		if(stateDropdownUser == true){
			$('.dropdown.user>a').next('.drop').removeClass('active');
			stateDropdownUser = false;
		}
	});
	
});
