$(document).ready(function(){
		
	// INPUT CLASS CHANGE
	$('input.text_input').focus(function(){
		
		$(this).addClass('input_focus');
	});
	
	$('input').blur(function(){
		
		$(this).removeClass('input_focus');
	}); 
	
	
	// ADD REVIEW FORM
	$('#review_form').submit(function(){
		  
		if ($('#review_light').val() == '' || $('#review_first').val() == '' || $('#review_second').val() == '' || $('#review_final').val() == '' || $('#wrapper').val() == '' || $('#size_l').val() == '' || $('#size_rg').val() == '' || $('#price_text').val() == '00.00' || $('#comments').val() == '') {  
		
			$("#messages").fadeIn("slow").addClass('error-box').html("Please enter all required fields!");
			return false;
		}else{
			
			return true;
		}
	});
	
	// FORGOT PASSWORD FORM
	$('#forgot_form').submit(function(){
		  
		if ($('#email_address').val() == '') {  
		
			$("#messages").fadeIn("slow").addClass('error-box').html("Please enter all required fields!");
			return false;
		}else{
			
			return true;
		}
	});	
	
	// LOGIN FORM
	$('#login_form').submit(function(){
		  
		if ($('#email').val() == '' || $('#password').val() == '') {  
		
			$("#messages").fadeIn("slow").addClass('error-box').html("All fields are required!");
			return false;
		}else{
			
			return true;
		}
	});
	
	// CREATE ACCOUNT FORM
	$('#create_form').submit(function(){
		  
		if ($('#username').val() == '' || $('#username').val() == '' || $('#lastname').val() == '' || $('#email').val() == '' || $('#password').val() == '' || $('#years').val() == '') {  
		
			$("#messages").fadeIn("slow").addClass('error-box').html("Please enter all required fields!");
			return false;
		}else{
			
			return true;
		}
	});
	
	
	
	
	// BRAND TEXT CHANGING
	$("#brand_text, #product_text, #vitola_text, #price_text, #header-search").blur(function(){
		if(!$(this).val()) $(this).val($(this).attr("title"));
		
	});
	$("#brand_text, #product_text, #vitola_text, #price_text, #header-search").focus(function(){
		if($(this).val() == $(this).attr("title")) $(this).val("");
	});
	
	// BRAND
	$('#product').hide();
	$('#brand_other').hide();
	$('#product_other').hide();
	$("#brand").change(function () {
		
		$('#brand_text').val() == '';
		$('#product_text').val() == '';
		
		if($('#brand  option:selected').val() == 'add'){
			
			//$('#brand_other').html('<br /><input class="text_input" type="text" id="brand_text" name="brand_other" size="45" title="Enter brand name" value="Enter brand name" />');
			$('#brand_other').show();
			$('#product').hide();
			//$('#product_other').html('<input class="text_input" type="text" id="product_text" name="product_other" size="35" title="Enter cigar name" value="Enter cigar name" />');
			$('#product_other').show();
		}else{
			
			
			//$('#brand_other').html('');
			$('#brand_other').hide();
			//$('#product_other').html('');
			$('#product_other').hide();
			$('#product').show();
			$.post('process.php', {brand_id : $('#brand  option:selected').val(), product_id : $('#product  option:selected').val()}, function(data){
																									 
				if(data.length >0) {
					
					$('#product').html(data);
				}
			
			}); 
		}
		
		if($('#brand  option:selected').val() == 10000000000000000000000){
			
			$('#product').hide();
		}
		
	}).change();
	
	// PRODUCT
	$("#product").change(function () {			
		
		$('#product_other').val() == '';
		
		if($('#product  option:selected').val() == 'add'){
			
			$('#product_other').show();
			//$('#product_other').html('<br><input class="text_input" type="text" id="product_text" name="product_other" size="45" title="Enter cigar name" value="Enter cigar name" />');
			$('#break').html('<br />');
		}else{
			
			$('#break').html('');
		}
		if($('#product  option:selected').val() == 10000000000000000000000){
			
			$('#product_other').hide();
		}
			
	}).change();
	
	
	// VITOLA
	$('#vitola_other').hide();
	$("#vitola").change(function () {
		
		if($('#vitola  option:selected').val() == 'add'){
			
			$('#vitola_other').show();
			//$('#vitola_other').html('<br><input class="text_input" type="text" id="vitola_text" name="vitola_other" size="45" title="Enter vitola name" value="Enter vitola name" />');
			$('#vitola_other').val() == '';
		}else{
			
			$('#vitola_other').hide();
		}
		
		if($('#vitola  option:selected').val() == 10000000000000000000000){
			
			$('#vitola_other').hide();
		}
			
	}).change();
});