function MemberScriptHelper() {
    //var uri = "http://qa.api.huggies.com.sg/huggies/Service.svc/";
    var detail = "This is script on production";
    var MemberUser = "";
    var MemberPassword = "";
    var MemberEmail = "";
    
    this.SetMemberID = function(memberUser) {
        MemberUser = memberUser;
    }
    this.AddCounter = function(func)
{   
    this.AysPost("AsyHelper","UpdateViews",{},func);
}
    this.SetMemberPassword = function(memberPassword) {
        MemberPassword = memberPassword;
    }
    this.SetMemberEmail = function(memberEmail) {
        MemberEmail = memberEmail;
    }
    
    this.Login = function(UserName,Paswword,func) {
        this.AysPost("AsyHelper",
        "Login",
        { username: UserName,password: Paswword},
        func);
    }
      this.LoginMGM = function(UserName,Paswword,ismgm,func) {
        this.AysPost("AsyHelper",
        "Login",
        { username: UserName,password: Paswword,ismgm: ismgm},
        func);
    }
    this.Logout = function(func) {
        this.AysPost("AsyHelper",
        "Logout",
        { },
        func);
    }
    this.IsAuthentication = function(func)
        {
            this.AysPost("AsyHelper",
            "IsAuthentication",
            {},
            func,
            false);
        }
    this.GetCurrentUser = function(func)
        {
        this.AysPost("AsyHelper",
            "GetCurrentUser",
            {},
            func);
        }
    this.GetCurrentPageHtml = function(CurrentPage,CurrentNode, func)
        {
        this.AysPost("AsyHelper",
            "getArticleOveriviewHtml",
            {currentPage: CurrentPage, currentNode: CurrentNode},
            func);
        }
    this.GetCurrentEbookPageHtml = function(CurrentPage, func)
        {
        this.AysPost("AsyHelper",
            "getEbookHtml",
            {currentPage: CurrentPage},
            func);
        }    
    this.RemvoeEbook = function(AllItem, func)
        {
        this.AysPost("AsyHelper",
            "removeEbook",
            {allItem: AllItem},
            func);
        }   
    this.AddEbook = function(articleID, func)
        {
        this.AysPost("AsyHelper",
            "AddEbookToMember",
            {articleID: articleID},
            func);
        }        
          this.loadData = function(loginName,func)
 {
 this.AysPost("AsyHelper","GetCurrentUser",{loginname:loginName},func);
 }

this.makeNew = function(name,nickName,email,country,address,username,password,answer,gender,dob,isMgm,imageid,mgmusername,func)
{
 this.AysPost("AsyHelper","makeNew",{name:name,nickName:nickName ,email:email,country:country,address:address,username:username,password:password,answer:answer,gender:gender,dob:dob,isMgm:isMgm,imageid:imageid,mgmusername:mgmusername},func);
 
}
  this.checkPassword = function(loginName,oldPassword,func)
{

this.AysPost("AsyHelper","checkOldPasswwordForUpdateMember",{loginname:loginName,password:oldPassword},func);

}
this.checkEmail = function(Email,func)
{
     this.AysPost("AsyHelper","checkEmail",{Email:Email},func);
}

this.updateProfile =function(name,nickName,email,country,address,username,password,answer,gender,dob,func)
{
this.AysPost("AsyHelper","updateMember",{name:name,nickName:nickName ,email:email,country:country,address:address,username:username,password:password,answer:answer,gender:gender,dob:dob},func);
}

this.checkLogin = function(loginName,func)
{
this.AysPost("AsyHelper","checkLoginName",{loginname:loginName},func);
}
this.checkEmailForUpdate= function(Email,login,func)
{   
this.AysPost("AsyHelper","checkEmailForUpdate",{email:Email,loginname:login },func);
}
this.clear_form_elements=  function(ele)  {

    $(ele).find(':input').each(function() {
        switch(this.type) {
            case 'password':
            case 'select-multiple':
            case 'select-one':
            case 'text':
            case 'textarea':
                $(this).val('');
                break;
            case 'checkbox':
            case 'radio':
                this.checked = true;
        }
    });

}



this.checkEmailAndUsername = function(email,login,answer,func)
{this.AysPost("AsyHelper","checkForgotPassword",{email:email ,loginname:login,answer:answer },func);
//alert(email +" +  " + login + " " + answer);
}
    this.AysPost = function(extensionAlias,methodName,postData,func,async){
            var domain=window.location.href.match(/:\/\/(.[^/]+)/)[1];
            var Async = true;
            if (async == false){
                Async = false;
            }            
            var uriPost = "http://" + domain + "/Handler/Handler.ashx?extensionAlias=" + extensionAlias + "&methodName=" + methodName;
            $.ajax({
               type: "POST",
               url: uriPost,
               async:Async,
               data: postData,
               dataType:"json",
               success: function(data) {
                    if (func) {
                        func(data);
                    }
                    }
             });
            
        }
    
}


