function highLightImage(img,overOut)
{
//    //IF IE
//    document.getElementById("tempImageOpacity").value = img.style.filter;
//    //IF mozilla
//    document.getElementById("tempImageOpacity").value = img.style.mozOpacity;
//    img.style.filter='alpha(opacity=100)';
    if(overOut == 1) {
        img.style.width = "98px";
        img.style.height = "98px";
        img.style.margin = "1px";
    } else {
        img.style.width = "100px";
        img.style.height = "100px";
        img.style.margin = "0px";
    }
}    

function focPwd()
{
    document.getElementById("loginPasswordLabel").style.display = "none";   
    document.getElementById("loginPassword").style.display = "block";
    document.getElementById("loginPassword").focus();
}    

function focUserName()
{
    if(document.getElementById("userNameFocCheck").value == "1") {
        if(document.getElementById("loginUserName").value == document.getElementById("resetUserName").value) {
            document.getElementById("loginUserName").value = "";
        }
    } else {
        document.getElementById("userNameFocCheck").value = "1";
    }
}

function blurUserName()
{
    if(document.getElementById("loginUserName").value == "") {
        document.getElementById("loginUserName").value = document.getElementById("resetUserName").value;
    }
}

//SIGN UP

function signUpGender(gender)
{
    gender0 = document.getElementById("gender0");
    gender1 = document.getElementById("gender1");
    
    if(gender == 1) { //IF boy
        gender0.src = gender0.src.replace("1.png","0.png");
        gender1.src = gender1.src.replace("0.png","1.png");
    } else { //IF girl
        gender0.src = gender0.src.replace("0.png","1.png");
        gender1.src = gender1.src.replace("1.png","0.png");
    }
    
    document.getElementById("Male").value = gender;
}

function isDate(dateStr) {

//var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
var datePat = /^(\d{4})(\/|-)(\d{1,2})(\/|-)(\d{1,2})$/;
var matchArray = dateStr.match(datePat); // is the format ok?

if (matchArray == null) {
//alert("Please enter date as either mm/dd/yyyy or mm-dd-yyyy.");
return false;
}

//month = matchArray[1]; // p@rse date into variables
//day = matchArray[3];
//year = matchArray[5];

year = matchArray[1];
month = matchArray[3]; // p@rse date into variables
day = matchArray[5];

if (month < 1 || month > 12) { // check month range
//alert("Month must be between 1 and 12.");
return false;
}

if (day < 1 || day > 31) {
//alert("Day must be between 1 and 31.");
return false;
}

if ((month==4 || month==6 || month==9 || month==11) && day==31) {
//alert("Month "+month+" doesn`t have 31 days!")
return false;
}

if (month == 2) { // check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day > 29 || (day==29 && !isleap)) {
//alert("February " + year + " doesn`t have " + day + " days!");
return false;
}
}
return true; // date is valid
}


//CHECK PASSWORD --------- START --------------------------------------

var commonPasswords = new Array('password', 'pass', '1234', '1246'); 
 
var numbers = "0123456789"; 
var lowercase = "abcdefghijklmnopqrstuvwxyz"; 
var uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
var punctuation = "!.@$£#*()%~<>{}[]"; 
 
function checkPassword(password, stableName) { 
 
    var combinations = 0; 
 
    if (contains(password, numbers) > 0) { 
        combinations += 10; 
    } 
 
    if (contains(password, lowercase) > 0) { 
        combinations += 26; 
    } 
 
    if (contains(password, uppercase) > 0) { 
        combinations += 26; 
    } 
 
    if (contains(password, punctuation) > 0) { 
        combinations += punctuation.length; 
    } 
 
    // work out the total combinations 
    var totalCombinations = Math.pow(combinations, password.length); 
 
    // if the password is a common password, then everthing changes... 
    if (isCommonPassword(password)) { 
        totalCombinations = 75000 // about the size of the dictionary 
    } 
    
    // if password and username are the same
    if (password == stableName) {
        totalCombinations = 1;
    }
 
    // work out how long it would take to crack this (@ 200 attempts per second) 
    var timeInSeconds = (totalCombinations / 200) / 2; 
 
    // this is how many days? (there are 86,400 seconds in a day. 
    var timeInDays = timeInSeconds / 86400 
 
    // how long we want it to last 
    var lifetime = 365; 
 
    // how close is the time to the projected time? 
    var percentage = timeInDays / lifetime; 
 
    var friendlyPercentage = cap(Math.round(percentage * 100), 100); 
    if (totalCombinations != 75000 && friendlyPercentage < (password.length * 5)) { 
        friendlyPercentage += password.length * 5; 
    } 
 
    var progressBar = document.getElementById("progressBar"); 
    progressBar.style.width = friendlyPercentage + "%"; 
 
    var passwordValid = document.getElementById("passwordValid"); 
    passwordValid.value = "0";
 
    if (percentage > 1) { 
        // strong password 
        progressBar.style.backgroundColor = "#73ac1a"; 
        passwordValid.value = "1";
        return; 
    } 
 
    if (percentage > 0.5) { 
        // reasonable password 
        progressBar.style.backgroundColor = "#ffd700"; 
        return; 
    } 
 
    if (percentage > 0.10) { 
        // weak password 
        progressBar.style.backgroundColor = "#ff7200"; 
        return; 
    } 
 
    // useless password! 
    if (percentage <= 0.10) { 
        // weak password 
        progressBar.style.backgroundColor = "#ff0086"; 
        return; 
    } 
 
 
} 
 
function cap(number, max) { 
    if (number > max) { 
        return max; 
    } else { 
        return number; 
    } 
} 
 
function isCommonPassword(password) { 
 
    for (i = 0; i < commonPasswords.length; i++) { 
        var commonPassword = commonPasswords[i]; 
        if (password == commonPassword) { 
            return true; 
        } 
    } 
 
    return false; 
 
} 
 
function contains(password, validChars) { 
 
    count = 0; 
 
    for (i = 0; i < password.length; i++) { 
        var char = password.charAt(i); 
        if (validChars.indexOf(char) > -1) { 
            count++; 
        } 
    } 
 
    return count; 
} 

//CHECK PASSWORD --------- END --------------------------------------
