jQuery.inputHighlight = function(color){  
    $("input,textarea").each(function(){  
        $(this).focus(function(){  
            $(this).css({"background" : color});  
        });  
        $(this).blur(function(){  
            $(this).css({"background" : "white"});  
        });  
    });  
}


/* ============================================================== */

jQuery.navMouse= function(){
	$('li.hideSNav').each(function(){
		$(this).mouseover(function(){
			$(this).attr('class','showSNav');
			var idHide = $(this).attr('name');
			$(idHide).css('background','none');		
		});  
		$(this).mouseout(function(){
			var type = $(this).attr('lang');
			var idHide = $(this).attr('name');
			
			$(this).attr('class','hideSNav');
			
			if( type == 'active'){
				$(idHide).css('background','none');
			}else{			
				$(idHide).css('background','url('+server+'images/navItems.png) no-repeat left top');
			}
		});
	});
}

/* ============================================================== */


function resetForm(id) {
	$('#'+id).each(function(){
	       this.reset();
	});
}

$(document).ready(function(){
	$.inputHighlight("#f1fbff");
	$.navMouse();
	//======================================== login 
	/*$("#login_form").validate({
		messages: {
			log_username:{
				required: 	"Xin hãy nhập vào Tên đăng nhập",
				minlength:	"Tên đăng nhập tối thiểu {0} ký tự"
			},
			log_password:{
				required: 	"Xin hãy nhập vào Mật khẩu",
				minlength:	"Mật khẩu tối thiểu {0} ký tự"
			}
		}
	});*/
	$('a#login').click( function(){
		$("#login_form").submit();
	});
	//========================================
	$('a#show_reg_form').click( function(){
		$('form#register_form').slideDown();
	});
	
	//========================================
	$("a[rel='utilBox']").colorbox({
		current:'',opacity:.2
	});
	//========================================
	$('#reg_reset').click( function(){
		resetForm('register_form');
	});
	//========================================
	$('#reg_close').click( function(){
		$('#register_form').slideUp();
	});
	//========================================
	/*$("#register_form").validate({
		messages: {
			x_name:{
				required: 	"Xin hãy nhập vào Họ và Tên",
				minlength: 	"Họ và Tên tối thiểu là {0} ký tự"
			},
			x_address:{
				required:	"Xin hãy nhập vào Địa chỉ",
				minlength:	"Địa chỉ tối thiểu là {0} ký tự"
			},
			x_phone:{
				required: 	"Xin hãy nhập vào Điện thoại",
				minlength:	"Điện thoại tối thiểu là {0} ký tự"
			},
			x_email:{
				required: 	"Xin hãy nhập vào Địa chỉ Email",
				email:		"Địa chỉ Email phỉ có dạng hoten@domain.com"
			},
			x_username:{
				required: 	"Xin hãy nhập vào Tên đăng nhập",
				minlength:	"Tên đăng nhập tối thiểu {0} ký tự"
			},
			x_password:{
				required: 	"Xin hãy nhập vào Mật khẩu",
				minlength:	"Mật khẩu tối thiểu {0} ký tự"
			}
		}
	});*/
	
	$('#reg_submit').click( function(){		
		$("#register_form").submit();
	});
	
});


