$(document).ready(function(){
    initRollovers();
});

function initRollovers()
{    
    
    // setup hover events to show roll image.
    $(":image.roll,img.roll").hover(
        function(){
            var osrc = $(this).attr("src");
            var ftype = osrc.substring(osrc.lastIndexOf('.'), osrc.length);
            var hsrc = osrc.replace(ftype,"_o"+ftype);
            $(this).attr("osrc", osrc);
            $(this).attr("src",hsrc);
        },
        function(){
            $(this).attr("src",$(this).attr("osrc"));
        }        
    );
    
//    // setup click events.
//    $(":image.roll").click(
//        function(event){
//            $(this).css("visibility","hidden");
//        }
//    );
    
    //var preLoad = new Array();
    // preload images.
    $(":image.roll,img.roll").each(function(){
        var osrc = $(this).attr("src");
        var ftype = osrc.substring(osrc.lastIndexOf('.'), osrc.length);
        var hsrc = osrc.replace(ftype,"_o"+ftype);
        /// preload over image.
        var himg = new Image()
        himg.src = hsrc;
        //$(this).attr("hsrc",hsrc);
    });
    
    /// show focused field.
    var focusCss = {
        backgroundColor:"#E1E1E3",
        color:"#800000"}
    var inputFlds = $("form :text, form :password, form select");
//    inputFlds.hover(
//        function(){
//            var origStyle = $(this).attr("style");
//            $(this).attr("ostyle",origStyle);
//            $(this).css(focusCss);
//        },
//        function(){
//            $(this).attr("style",$(this).attr("ostyle"));
//        }        
//    );
    inputFlds.focus(function(){
        $(this).prev("label").css({backgroundColor:"yellow"});
        //var origStyle = $(this).parent("td").prev("td").attr("style");
        //$(this).parent("td").prev("td").attr("ostyle",origStyle);
        //$(this).parent("td").prev("td").css(focusCss);
    });
    inputFlds.blur(function(){
        $(this).prev("label").css({backgroundColor:""});
        //$(this).parent("td").prev("td").attr("style",$(this).attr("ostyle"));
    });
    
}

function blockpage()
{
    var coverStyle = {
        backgroundColor:"#000000",
        left:"0pt",
        opacity:"0.2", 
        position:"fixed",
        display:"block",
        top:"0pt",
        height:"100%", 
        width:"100%", 
        zIndex:"1002"}
    var coverBox = $("#divCover");
    coverBox.css(coverStyle);
}

