﻿function showpanel(id) {
    $('.ctPanel').hide();
    $('#' + id).show();
}


function Login() {
    if ($('#loginUsername').val() == "" || $('#loginPassword').val() == "") {
        alert('Please Input Username and Password');
    }
    else {
        $.ajax({
            type: "POST",
            url: "default.aspx/LoginVerify",
            data: "{username: '" + $('#loginUsername').val() + "', password: '" + $('#loginPassword').val() + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(response) {
                //$("#DemoResulting").html('Checking');

                if (response.d == "1") {

                    $(location).attr('href', 'portal/default.aspx');
                }
                else {
                    alert('Invalid Username and Password');
                }
            }
        });

    }

}

function FreeDown() {
    alert('test');
    window.open('http://software.3wifi.com/wifi3k/createli.php?action=freedemolink');
}
function Contact() {
    $('.msg').html('');

    var verify = 0;

    if ($('#contactName').val() == "") {
        $("#msgContactName").html('Required');
        verify = 1;
    }
    if ($('#contactEmail').val() == "") {
        $("#msgContactEmail").html('Required');
        verify = 1;
    }
    if ($('#contactQuestion').val() == "") {
        $("#msgContactQuestion").html('Required');
        verify = 1;
    }

    if (verify == 1)
        return;
    else {
        $.ajax({
            type: "POST",
            url: "default.aspx/Contact",
            data: "{name: '" + $('#contactName').val() + "', email: '" + $('#contactEmail').val() + "', phone: '" + $('#contactPhone').val() + "', question: '" + $('#contactQuestion').val() + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(response) {
                //$("#DemoResulting").html('Checking');

                if (response.d == "1") {
                    alert('Your Question Already Sent To Us');
                }
                else {
                    alert('Sent Failed');
                }
            }
        });
    }
}
function SignupM() {
    $('.msg').html('');
    
    var verify = 0;
    
    if ($('#signupEmail').val() == "") {
        $("#msgEmail").html('Required');
        verify = 1;
    }
    if ($('#signupPassword').val() == "") {
        $("#msgPassword").html('Required');
        verify = 1;
    }
    if ($('#signupConfirm').val() != $('#signupPassword').val()) {
        $("#msgConfirm").html('Password not match');
        verify = 1;
    }
    if ($('#signupFullName').val() == "") {
        $("#msgFullName").html('Required');
        verify = 1;
    }
    if ($('#signupPhone').val() == "") {
        $("#msgPhone").html('Required');
        verify = 1;
    }

    if (verify == 1)
{
alert('test');
     return;
}
    else {
        $.ajax({
            type: "POST",
            url: "default.aspx/Signup",
            data: "{username: '" + $('#signupEmail').val() + "', password: '" + $('#signupPassword').val() + "', fullname: '" + $('#signupFullName').val() + "', phone: '" + $('#signupPhone').val() + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(response) {
                //$("#DemoResulting").html('Checking');

                if (response.d == "1") {
			$("#Msg").html('Signup Successfully');
                }
                else {
                    if (response.d == "2") {
                        $("#msgEmail").html('User Exist');
			$("#Msg").html('User Exist');
                    }
                    else {
			$("#Msg").html('Failed');
                    }
                }
            }
        });
    }
}

function Signup() {
    $('.msg').html('');
    
    var verify = 0;
    
    if ($('#signupEmail').val() == "") {
        $("#msgEmail").html('Required');
        verify = 1;
    }
    if ($('#signupPassword').val() == "") {
        $("#msgPassword").html('Required');
        verify = 1;
    }
    if ($('#signupConfirm').val() != $('#signupPassword').val()) {
        $("#msgConfirm").html('Password not match');
        verify = 1;
    }
    if ($('#signupFullName').val() == "") {
        $("#msgFullName").html('Required');
        verify = 1;
    }
    if ($('#signupPhone').val() == "") {
        $("#msgPhone").html('Required');
        verify = 1;
    }

    if ($('#cbAgree:checked').val() == null) {
        $("#msgAgree").css('color', 'Red');
        verify = 1;
    }

    if (verify == 1)
{
     return;
}
    else {
        $.ajax({
            type: "POST",
            url: "default.aspx/Signup",
            data: "{username: '" + $('#signupEmail').val() + "', password: '" + $('#signupPassword').val() + "', fullname: '" + $('#signupFullName').val() + "', phone: '" + $('#signupPhone').val() + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(response) {
                //$("#DemoResulting").html('Checking');

                if (response.d == "1") {
                    alert('Signup Successfully');
			$("#lbMsg").html('Signup Successfully');
                }
                else {
                    if (response.d == "2") {
                        $("#msgEmail").html('User Exist');
			$("#lbMsg").html('User Exist');
                    }
                    else {
                        alert('Signup Failed');
			$("#lbMsg").html('Failed');
                    }
                }
            }
        });
    }
}
function get_param(name) {
    if (location.href.indexOf("?") >= 0) {
        var query = location.href.split("?")[1];
        var params = query.split("&");
        for (var i = 0; i < params.length; i++) {
            value_pair = params[i].split("=");
            if (value_pair[0] == name)
                return unescape(value_pair[1]);
        }
    }
    return "";
}

function test() { alert('test') }
