﻿// JScript File
//Add watermark effect to a text box
function LoginBox_WatermarkFocus(txtElem, strWatermark, cssActive) {
    if (txtElem.value == strWatermark)
    {
        txtElem.value = '';
        txtElem.className = cssActive;
    }
}

function LoginBox_WatermarkBlur(txtElem, strWatermark, cssWaterMark) {
    if (txtElem.value == '')
    { 
        txtElem.value = strWatermark;
        txtElem.className = cssWaterMark;
    }
}

function LoginBox_login(txtUN, txtPW, txtUNW, txtPWW)
{
    if (txtUN.value == '' || txtPW.value == '' || txtUN.value ==  txtUNW|| txtPW.value == txtPWW)
    {
        alert("please enter valid username and/or password");
    } else {
        window.location = "?fun=login&arg=" +  LoginBox_Encrypt(txtPW.value) + LoginBox_Encrypt("@") + LoginBox_Encrypt(txtUN.value);
    }   
}

function LoginBox_Encrypt(txt)
{
    var tResult=''; 

    for(var a=0; a < txt.length; a++) {
        tResult += LoginBox_Hex(txt.charCodeAt(a)); 
    }
    return tResult; 
}

function LoginBox_Hex(num)
{
    var tResult = num.toString(16);
    if (tResult.length < 2) tResult = "0" + tResult;
    return tResult;
}

