﻿var startAnimation = true;

var interval = 2.5; // delay between rotating images (in seconds)
var random_display = 0; // 0 = no, 1 = yes
interval *= 1000;

var image_index = 0;
image_list = new Array();

hover_image_list = new Array();
hover_image_list[0] = "images/flash-pics/flash-bench-on.jpg";
hover_image_list[1] = "images/flash-pics/flash-dates-on.jpg";
hover_image_list[2] = "images/flash-pics/flash-cases-on.jpg";

var image_bench_off = "images/flash-pics/flash-bench-off.jpg";
var image_dates_off = "images/flash-pics/flash-dates-off.jpg";
var image_cases_off = "images/flash-pics/flash-cases-off.jpg";

image_list[image_index++] = new imageItem("images/flash-pics/flash-bench-bar.jpg");
image_list[image_index++] = new imageItem("images/flash-pics/flash-dates-dockets.jpg");
image_list[image_index++] = new imageItem("images/flash-pics/flash-case-studies.jpg");

var number_of_image = image_list.length;
function imageItem(image_location) {
    this.image_item = new Image();
    this.image_item.src = image_location;
}
function get_ImageItemLocation(imageObj) {
    return (imageObj.image_item.src)
}
function generate(x, y) {
    var range = y - x + 1;
    return Math.floor(Math.random() * range) + x;
}
function getNextImage() {
    if (random_display) {
        image_index = generate(0, number_of_image - 1);
    }
    else {
        image_index = (image_index + 1) % number_of_image;
    }
    var new_image = get_ImageItemLocation(image_list[image_index]);
    return (new_image);
}


function rotateImage(place) {

    if (startAnimation == true) {
        var new_image = getNextImage();

        document["imgBench"].src = image_bench_off;
        document["imgDates"].src = image_dates_off;
        document["imgCases"].src = image_cases_off;

        if (image_index == 0) {
            document["imgBench"].src = hover_image_list[image_index];
        }
        else if (image_index == 1) {
            document["imgDates"].src = hover_image_list[image_index];
        }
        else if (image_index == 2) {
            document["imgCases"].src = hover_image_list[image_index];
        }

        document[place].src = new_image;
    }

    var recur_call = "rotateImage('" + place + "')";
    setTimeout(recur_call, interval);
}

function mouseOver(imageID) {
    startAnimation = false;

    document["imgBench"].src = image_bench_off;
    document["imgDates"].src = image_dates_off;
    //document["imgCases"].src = image_cases_off;

    if (imageID == 'imgBench') {
        document['imgBench'].src = 'images/flash-pics/flash-bench-on.jpg'
        document['imgElawServices'].src = 'images/flash-pics/flash-bench-bar.jpg'
        document.getElementById('imgElawServices').title = 'BenchBar';
    }
    else if (imageID == 'imgDates') {
        document['imgDates'].src = 'images/flash-pics/flash-dates-on.jpg'
        document['imgElawServices'].src = 'images/flash-pics/flash-dates-dockets.jpg'
        document.getElementById('imgElawServices').title = 'Docket';
    }
}

function mouseOut(imageID) {
    startAnimation = true;
}


///Method to validate login ,To check user name and password are mandatory
///Method will return true on login success and false on failure
function ValidateLogin(txtUserClientId,txtPasswordClientId,lblErrorMsgClientId) {
    var txtUserId = document.getElementById(txtUserClientId);
    var txtPassword = document.getElementById(txtPasswordClientId);
    var lblErrorMsg = document.getElementById(lblErrorMsgClientId);
    if (txtUserId != null && txtPassword != null && lblErrorMsg != null) {
        if (txtUserId.value.length == 0 && txtPassword.value.length == 0) {
            if (navigator.appCodeName !='Mozilla') {
                lblErrorMsg.innerText = "Please enter User ID and Password"
            }
            else {
                lblErrorMsg.innerHTML = "Please enter User ID and Password"
            }
            lblErrorMsg.style.display = "block"
            return false;
        }
        else if (txtUserId.value.length == 0) {
            lblErrorMsg.innerText = "Please enter User ID"
            lblErrorMsg.style.display = "block"
            return false;
        }
        else if ((txtUserId.value.indexOf(".") > 0) && (txtUserId.value.indexOf("@") > 0)) 
        {
            var emailExpression = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
            if (emailExpression.test(txtUserId.value)) {
                lblErrorMsg.innerText = "";
            }
            else {
                lblErrorMsg.innerText = "Invalid Email ID";
                return false;
            }
        }
                
        if (txtPassword.value.length == 0 ) {
            lblErrorMsg.innerText = "Please enter Password"
            lblErrorMsg.style.display = "block"
            return false;
        }
    }
    return true;
}

///Method to show the forgot password panel or login panel
function enableForGotPassword(status, setLoginUserIdText, txtUserIdOrEMailIdClientId, lblForgotPasswordErrMsgClientId, txtUserIdClientId, divLoginClientId, divForgotPasswordClientId) {
    var divLogin = document.getElementById(divLoginClientId);
    var divForGotPassword = document.getElementById(divForgotPasswordClientId);
    var txtUserIdOrEMailId = document.getElementById(txtUserIdOrEMailIdClientId);    
    var lblForgotPasswordErrMsg = document.getElementById(lblForgotPasswordErrMsgClientId);
    var txtUserId = document.getElementById(txtUserIdClientId);
    if (divLogin != null && divForGotPassword != null) {
        if (status) {//show forgot password is true
            divLogin.style.display = 'none';
            divForGotPassword.style.display = 'block';
            if (setLoginUserIdText == true) {
                txtUserIdOrEMailId.value = txtUserId.value;
                lblForgotPasswordErrMsg.innerText = "";
            }
            txtUserIdOrEMailId.focus();
        }
        else {
            divLogin.style.display = 'block';
            divForGotPassword.style.display = 'none';
            txtUserId.focus();
        }
    }
    return false;
}


///Method to validate forgot password fiealds
///will return true and do post back on successful validation
///will return false and show error message
function validateForgotPassword(lblForgotPasswordErrMsgClientId, txtUserIdOrEMailIdClientId) {
    var lblForgotpasswordErrMsg = document.getElementById(lblForgotPasswordErrMsgClientId);
    var txtUserIdOrEMailId = document.getElementById(txtUserIdOrEMailIdClientId);
    var userIDOrEmailId;
    if (lblForgotpasswordErrMsg != null && txtUserIdOrEMailId != null) {
        userIDOrEmailId = txtUserIdOrEMailId.value;
        if (userIDOrEmailId == "") {
            lblForgotpasswordErrMsg.innerText = "Please enter User ID or Email ID";
            return false;
        }
        if ((userIDOrEmailId.indexOf(".") > 0) && (userIDOrEmailId.indexOf("@") > 0)) {
            var emailExpression = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
            if (emailExpression.test(txtUserIdOrEMailId.value)) {
                lblForgotpasswordErrMsg.innerText = "";
                return true;
            }
            else {
                lblForgotpasswordErrMsg.innerText = "Invalid Email ID";
                return false;
            }
        }
    }
    return true;
}
// Subbs - Jun-22-2010 - Start - Show HelpTips callout
function showLayer(positionReference, id) {
    var globDHTMLLayer;
    var node = document.getElementById(id);
    globDHTMLLayer = node; 
    node.style.display = "block";
    return true;
}
// Subbs - Jun-22-2010 - End
function ShowFooterAtPageBottom(footerid) {
    document.getElementById(footerid).style.width = document.body.clientWidth - 35 + "px";
    if (document.body.scrollHeight > document.documentElement.clientHeight) {
        document.getElementById(footerid).className = 'tblfooterrel';
    }
    else {
        document.getElementById(footerid).className = 'tblfooterabs';
    }
}
function ShowFooterAtWelcomePageBottom(footerid) {
    if (document.body.scrollHeight > document.documentElement.clientHeight) {
        document.getElementById(footerid).className = 'tblfooterrel';
    }
    else {
        document.getElementById(footerid).className = 'tblfooterabs';
    }
}
