jQuery(document).ready(function() {
								
	///// TRANSFORM CHECKBOX /////							
	jQuery('input:checkbox').uniform();
	
	///// LOGIN FORM SUBMIT /////
	jQuery('#login').submit(function() {
		if(jQuery('#username').val() == '' && jQuery('#password').val() == '') {
			jQuery('.nousername').fadeIn();
			jQuery('.nopassword').hide();
			return false;	
		}
		if(jQuery('#username').val() != '' && jQuery('#password').val() == '') {
			jQuery('.nopassword').fadeIn().find('.userlogged h4, .userlogged a span').text(jQuery('#username').val());
			jQuery('.nousername,.username').hide();
			return false;
		}
		jQuery('#submit_btn').css({"background-color":"#c0c0c0","border":"0px"}).attr("disabled",true).text("正在登录...");
		jQuery.ajax({
            type: "POST",
            url: "user/login",
            data: { username: jQuery("#username").val(), password: jQuery.md5(jQuery("#password").val()), platform:1},
            dataType: "json",
            success: function (data) {
                if(data.code != 0) {
                	jQuery("#submit_btn").css({"background":"#f0801d url(../images/btngrad.png) repeat-x top left"}).attr("disabled",false).text("登录");
                	jQuery('.nopassword').fadeIn().find('.userlogged h4, .userlogged a span').text(data.message);
                	jQuery('.nopassword').fadeIn().find('.loginmsg').text(data.message);
                } else {
                	if(data.data.sysUser.hotelId) {
                		location.href = 'resources/hotelIndex.html?v=1.1.3#/hotelIndex';
                	} else {
                		location.href = 'resources/dashboard.html?v=1.2.2#/main';
                	}
                }
            }
        });
	});
	
	///// ADD PLACEHOLDER /////
	jQuery('#username').attr('placeholder','手机号');
	jQuery('#password').attr('placeholder','密码');
});