﻿function ShowError(title, message)
{
    Ext.MessageBox.show({
           title:title,
           msg: message,
           buttons: Ext.MessageBox.OK,
           icon: Ext.MessageBox.ERROR
       });
}
function ShowWarn(title, message)
{
    Ext.MessageBox.show({
           title:title,
           msg: message,
           buttons: Ext.MessageBox.OK,
           icon: Ext.MessageBox.WARNING
       });
}
function ShowInfo(title, message) {
    Ext.MessageBox.show({
        title: title,
        msg: message,
        buttons: Ext.MessageBox.OK,
        icon: Ext.MessageBox.INFORMATION
    });
}

function ToggleCountry() {
    if (document.getElementById("countrybox").style.display == 'none') document.getElementById("countrybox").style.display = 'block';
    else document.getElementById("countrybox").style.display = 'none';
}
function CountrySelect(name) {
    document.getElementById("currentCountry").src = "../Images/country_" + name + ".png";
    document.getElementById("countrybox").style.display = 'none';

    switch (name) {
        case 'can':
            document.getElementById("ctl00_ContentPlaceHolder1_tbCountryCode").value = '+1';
            document.getElementById("ctl00_ContentPlaceHolder1_tbCountryID").value = '38';
            break;
        case 'usa':
            document.getElementById("ctl00_ContentPlaceHolder1_tbCountryCode").value = '+1';
            document.getElementById("ctl00_ContentPlaceHolder1_tbCountryID").value = '223';
            break;
        case 'chn':
            document.getElementById("ctl00_ContentPlaceHolder1_tbCountryCode").value = '+86';
            document.getElementById("ctl00_ContentPlaceHolder1_tbCountryID").value = '44';
            break;
        case 'hk':
            document.getElementById("ctl00_ContentPlaceHolder1_tbCountryCode").value = '+852';
            document.getElementById("ctl00_ContentPlaceHolder1_tbCountryID").value = '95';
            break;
        case 'snp':
            document.getElementById("ctl00_ContentPlaceHolder1_tbCountryCode").value = '+65';
            document.getElementById("ctl00_ContentPlaceHolder1_tbCountryID").value = '191';
            break;
    }
}
function ToggleCountry2() {
    if (document.getElementById("countrybox2").style.display == 'none') document.getElementById("countrybox2").style.display = 'block';
    else document.getElementById("countrybox2").style.display = 'none';
}
function Country2Select(name) {
    document.getElementById("currentCountry2").src = "../Images/country_" + name + ".png";
    document.getElementById("countrybox2").style.display = 'none';

    switch (name) {
        case 'can':
            document.getElementById("ctl00_ContentPlaceHolder1_tbCountryCode2").value = '+1';
            document.getElementById("ctl00_ContentPlaceHolder1_tbCountryID2").value = '38';
            break;
        case 'usa':
            document.getElementById("ctl00_ContentPlaceHolder1_tbCountryCode2").value = '+1';
            document.getElementById("ctl00_ContentPlaceHolder1_tbCountryID2").value = '223';
            break;
        case 'chn':
            document.getElementById("ctl00_ContentPlaceHolder1_tbCountryCode2").value = '+86';
            document.getElementById("ctl00_ContentPlaceHolder1_tbCountryID2").value = '44';
            break;
        case 'hk':
            document.getElementById("ctl00_ContentPlaceHolder1_tbCountryCode2").value = '+852';
            document.getElementById("ctl00_ContentPlaceHolder1_tbCountryID2").value = '95';
            break;
        case 'snp':
            document.getElementById("ctl00_ContentPlaceHolder1_tbCountryCode2").value = '+65';
            document.getElementById("ctl00_ContentPlaceHolder1_tbCountryID2").value = '191';
            break;
    }
}

function ToggleSelect() {
    if (document.getElementById("selectbox").style.display == 'none') document.getElementById("selectbox").style.display = 'block';
    else document.getElementById("selectbox").style.display = 'none';
}
function ShowSelect() {
    document.getElementById("selectbox").style.display = 'block';
}
function HideSelect() {
    document.getElementById("selectbox").style.display = 'none';
}

function checkUser() {
    $.ajax({
        type: "POST",
        url: "signup.aspx/CheckUser",
        data: "{username: '" + $('#ctl00_ContentPlaceHolder1_tbEmail').val() + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(response) {
            $("#ctl00_ContentPlaceHolder1_lbUserCheck").html('Checking');

            if (response.d == "True") {
                $("#ctl00_ContentPlaceHolder1_lbUserCheck").html('&nbsp;&nbsp;<span style="color: Red;">User Exist</span>');
            }
            else {
                $("#ctl00_ContentPlaceHolder1_lbUserCheck").html('');
            }
        }
    });
}

function checkNumber() {
    $.ajax({
        type: "POST",
        url: "signup.aspx/CheckPhoneNumber",
        data: "{number: '" + $('#ctl00_ContentPlaceHolder1_tbNumber').val() + "', id:'" + $('#ctl00_ContentPlaceHolder1_tbCountryID').val() + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(response) {
            $("#ctl00_ContentPlaceHolder1_lbNumberCheck").html('Checking');

            if (response.d == "True") {
                $("#ctl00_ContentPlaceHolder1_lbNumberCheck").html('&nbsp;&nbsp;<span style="color: Red;">Phone Number already exist in our system</span>');
            }
            else {
                $("#ctl00_ContentPlaceHolder1_lbNumberCheck").html('');
            }
        }
    });
}
function checkValid() {
    if (document.getElementById("ctl00_ContentPlaceHolder1_lbUserCheck").innerHTML == '' && document.getElementById("ctl00_ContentPlaceHolder1_lbNumberCheck").innerHTML == '' && document.getElementById("ctl00_ContentPlaceHolder1_lbPassCheck").innerHTML == '')
        return true;
    else
        return false;
}
function checkPass() {
    if (document.getElementById("ctl00_ContentPlaceHolder1_tbPass").value == document.getElementById("ctl00_ContentPlaceHolder1_tbConfirm").value) 
    {
        $("#ctl00_ContentPlaceHolder1_lbPassCheck").html('');
    }
    else {
        $("#ctl00_ContentPlaceHolder1_lbPassCheck").html('&nbsp;&nbsp;<span style="color: Red;">Passwords Not Same</span>');
    }
}

function clipper(value) {
    clipboardData.setData("Text", value.toString());
    }
function ChangePage(id) {
    document.getElementById(id).className = "itemon";
}

function MakeDemoCall() {
    $.ajax({
        type: "POST",
        url: "default.aspx/MakeDemoCall",
        data: "{hostnumber: '" + $('#hostnumber').val() + "', callnumber: '" + $('#callnumber').val() +  "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(response) {
            //$("#DemoResulting").html('Checking');

            if (response.d == "True") {
                alert("success");
            }
            else {
                alert("fail");
            }
        }
    });
}

function Signup() {
    alert('test');
    $.ajax({
        type: "POST",
        url: "default.aspx/QuickSignup",
        data: "{email: '" + $('#sgEmail').val() + "', password: '" + $('#sgPass').val() + "', firstname:'" + $('#sgFirstName').val() + "' , lastname:'" + $('#sgLastName').val() + "', phone:'" + $('#sgPhone').val() + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(response) {
            //$("#DemoResulting").html('Checking');

            if (response.d == "True") {
                alert("success");
            }
            else {
                alert("fail");
            }
        }
    });
}

function CallGirl() {
    $.ajax({
        type: "POST",
        url: "default2.aspx/MakeDemoCall",
        data: "{number: '" + $('#ctl00_ContentPlaceHolder1_tbCallGirlNumber').val() + "', email: '" + $('#ctl00_ContentPlaceHolder1_tbCallGirlEmail').val() + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(response) {
            //$("#DemoResulting").html('Checking');

            if (response.d == "True") {
                $('#ctl00_ContentPlaceHolder1_lbCallGirl').text('Your phone will be ring in seconds');
            }
            else {
                alert("fail");
            }
        }
    });
}


function copyToClipboard() {
//    var content = document.getElementById("ctl00_tbCode");
//    content.focus()
//    content.select()
//    range = content.createTextRange()
//    range.execCommand("Copy")
//    window.status = "Contents copied to clipboard"
//    setTimeout("window.status=''", 1800)

    var text = document.getElementById("ctl00_tbCopycode").value;
    
    if(window.clipboardData)  
  {  
     window.clipboardData.setData('text',text);  
     }  
     else  
     {  
         var clipboarddiv=document.getElementById('divclipboardswf');  
     if(clipboarddiv==null)  
     {  
        clipboarddiv=document.createElement('div');  
            clipboarddiv.setAttribute("name", "divclipboardswf");  
        clipboarddiv.setAttribute("id", "divclipboardswf");  
        document.body.appendChild(clipboarddiv);  
     }  
         clipboarddiv.innerHTML='<embed src="../Flash/clipboard.swf" FlashVars="clipboard='+ encodeURIComponent(text)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';  
     }  
     alert('The text is copied to your clipboard...');  
     return false;  
}

function InitTab(id) {
    $('#' + id).addClass("here");
}
