function checkLogin(){
	var vChk;
	var user = $('#f_username').val();
	var pwd = $('#f_pwd').val();
	if(user =='' || pwd =='' ){
		alert('Please input username and password.');
		document.getElementById('f_username').focus();
		return;
	}else{
		var baseUrl = '/'+projectName+'/authen/index/login';
		$.ajax({
			type: "POST",
			url: baseUrl,
			data: {username:user,password:pwd,remember:vChk},
			success: function(msg){
			  eval(msg);
			}
		});
	}
	return false;
}
function CancelReset(){
	$('#f_username').val('');
	$('#f_pwd').val('');
}
function selectChkAll(elm) {
	 var parents = $(elm).parents("table").get(0);
    if(elm.checked) {
        $(':checkbox:not(#'+elm.id+')',parents).each(function(){
            $(this).check();
         });
    }
    else{
    	$(':checkbox:not(#'+elm.id+')',parents).each(function(){
            $(this).uncheck();
           });
      }
}
function checkOut(){
	var vChk = '1';
	_confirm('Do you want to logout?',function(){
		var baseUrl = '/'+projectName+'/authen/index/logout';
		$.ajax({
			type: "POST",
			url: baseUrl,
			data: {remember:vChk},
			success: function(msg){
			  eval(msg);
			  window.location.href = '/'+projectName+'/account/account/index/';
			}
		});
	},{icon:'question'});
}
function checkEvent(objEvent){
	if($('#f_email').val() && $('#f_pwd').val()){
		if(objEvent.keyCode == '13' || objEvent.keyCode =='9'){
			checkLogin();
		}
	}
}
function openLinkMenu(url){
	window.location.href = '/'+projectName+'/'+url;
}
function selectChkAll(elm){
	var parents = $(elm).parents("table").get(0);
    if(elm.checked) {
        $(':checkbox:not(#'+elm.id+')',parents).each(function(){
            $(this).check();
        });
    }
    else{
    	$(':checkbox:not(#'+elm.id+')',parents).each(function(){
            $(this).uncheck();
        });
    }
}

$(document).ready(function() {
    $("a[@id=Admin]").click(function(){
       window.location.href = '/'+projectName+'/master/admin/index/';
    });
    $("a[@id=Profile]").click(function(){
       window.location.href = '/'+projectName+'/master/profile/index/';
    });
    $("a[@id=Sms]").click(function(){
       window.location.href = '/'+projectName+'/master/sms/index/';
    });
});
