// JavaScript Document

function createSly()
{
	try {
	var windowRef = window.open("<%= FLASH_PATH %>/master.html", "master", "width=308,height=605,scroll=yes,resizable=yes,status=no,location=no")	
	}
	catch(e){}
	if (windowRef == null){
	alert("Wablet: You have a pop-up blocker active.  Please add wablet.com to your Allowed list.");
	}
}

function encrypt_login()
{
	if (document.getElementById( "sendpassword" ) && document.getElementById( "sendpassword" ).getAttribute("fc") == "false")
	{
	    document.getElementById( "sendpassword" ).value = document.getElementById( "password" ).value
	    encrypt_password( "sendpassword" )
   	}
}

function changePwd()
{
	if (fromCookie().getAttribute("fc") == "true")
	{
		document.getElementById("sendpassword").setAttribute("fc", "false");
		document.getElementById("sendpassword").setAttribute("value", "");
	}
}

function validate_encrypt_password()
{

    var password = document.getElementById( "member_account_password" ).value;
    var confirm_password = document.getElementById( "member_account_password_confirmation" ).value;


    if( password.length == 0 || confirm_password.length == 0 ) {
        document.getElementById( "signuperror" ).innerHTML = "Blank passwords are not allowed."
        document.getElementById( "signuperror" ).style.display = 'block'
        return false;
    }

    if( password.length > 32 || confirm_password.length > 32 ) {
        document.getElementById( "signuperror" ).innerHTML = "Passwords must not exceed 32 characters."
        document.getElementById( "signuperror" ).style.display = 'block'
        return false;
    }

    if( password != confirm_password ) {
        document.getElementById( "signuperror" ).innerHTML = "The passwords do not match."
                document.getElementById( "signuperror" ).style.display = 'block'
        return false;
    }
    
    encrypt_password( "member_account_password" )
    document.getElementById( "member_account_password_confirmation" ).value = document.getElementById( "member_account_password" ).value
    return true;
}

function encrypt_password( id )
{
    var password = document.getElementById( id ).value;
	var e = "10001";
	var m = "c8c7748de6b3c5994223f19e2d7129fca1e97c6d2572b6c35d7ed4f9efea207d9b32c51231adfae99a02d1e2a76a9f1b6fd6a197714f1b4aeeaabaf40fcd68cff8e3d7d38dca19bed5b09967a5fa62ca08b42f92ec0e49343a85d223de50a9acf8017d221aae9c24ce5fde8d589ccd881cda8c3bba7046da3c0ea31fb796b1e5";

    var rsa = new RSAKey();
    rsa.setPublic(m, e);
    var res = rsa.encrypt(password);
    document.getElementById( id ).value = res;
    return true
}

function eps( v )
{
	var e = "10001";
	var m = "c8c7748de6b3c5994223f19e2d7129fca1e97c6d2572b6c35d7ed4f9efea207d9b32c51231adfae99a02d1e2a76a9f1b6fd6a197714f1b4aeeaabaf40fcd68cff8e3d7d38dca19bed5b09967a5fa62ca08b42f92ec0e49343a85d223de50a9acf8017d221aae9c24ce5fde8d589ccd881cda8c3bba7046da3c0ea31fb796b1e5";

    var rsa = new RSAKey();
    rsa.setPublic(m, e);
    var res = rsa.encrypt(v);
    v = res;
    return v;
}

function removeTag( id ) {
    try {
		document.getElementById( id ).firstChild.nodeValue = "";
	}
	catch(e){}

}