/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
var timer;

function scrollTop(){
    window.scrollTo(0, 0);
}

function showWaitCursor(){
    document.getElementById('body').style.cursor='wait';   
    
}
function hideWaitCursor(){
    document.getElementById('body').style.cursor='default';
}

function getOfferViewer(){
    window.open( "ho_event_response_offer_viewer.xhtml", 
    "_blank", 
    "toolbar=0,titlebar=0,menubar=0,scrollbars=0,status=0,width=657px,height=475px,top=150px,left=210px");
}
                                        
function doTimeout () {
    window.location="/faces/SessionExpired.xhtml";
}
function registerTimeout() {
    timer = setTimeout("doTimeout()",1805000);
    /* short frame for testing */
    //timer = setTimeout("doTimeout()",5000);
}
function resetTimeout(){
     clearTimeout(timer);
     timer = setTimeout("doTimeout()",1805000);
}

function registerBlinkTimeout(){
    setTimeout("location.reload(true)", 1000000);
}

function killEnter(evt)
{
    if(evt.keyCode == 13 || evt.which == 13)
    {
        return false;
    }
    return true;
}

function stopRKey(evt) {
    var evt = (evt) ? evt : ((event) ? event : null);
    var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
    if ((evt.keyCode == 13) && (node.type=="text"))  {return false;}
}


function toggle(box,id) {
      
    var v=document.getElementById(id);
    if(box.checked==true) {
        document.getElementById(id).value='testing';
    }
    else {
        v.value='12345';
    }
   
}

function SaveScrollXY() {
    var scrOfX = 0, scrOfY = 0;     
    if( typeof( window.pageYOffset ) == 'number' ) {
        //Netscape compliant
        scrOfY = window.pageYOffset;
        scrOfX = window.pageXOffset;
    } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
        //DOM compliant
        scrOfY = document.body.scrollTop;
        scrOfX = document.body.scrollLeft;
    } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
        //IE6 standards compliant mode
        scrOfY = document.documentElement.scrollTop;
        scrOfX = document.documentElement.scrollLeft;
    }

    document.getElementById('form-event:ScrollX').value = scrOfX
    document.getElementById('form-event:ScrollY').value = scrOfY+200;
                
    // alert(scrOfY);
                 
}
 
function ResetScrollPosition() { 
    var hidx, hidy;
    hidx = document.getElementById('form-event:ScrollX');
    hidy = document.getElementById('form-event:ScrollY');
    if (typeof hidx != 'undefined' && typeof hidy != 'undefined' ) {
        window.scrollTo(hidx.value, hidy.value);
    }
               
}
         
 
function closeMe()
{
    top.window.opener = top;
    top.window.open(",'_parent',");
    top.window.close();
}
 
        

function focusOnFirstInput() {

    var forms = document.forms;
    var len = forms.length;

    for (var i = 0; i < len; i++) {
        var form = forms[i];
        for (var j = 0; j < form.length; j++) {
            var input = form[j];
            if (input.type != "hidden"
                && input.type != "button"
                && input.type != "submit") {

                if (!input.disabled && input.style.display != "none") {
                    input.focus();
                    return;
                }
            }
        }
    }
}
     
     
function f_setfocus( aForm )
{
    if( aForm.elements[0]!=null) {
        var i;
        var max = aForm.length;
        for( i = 0; i < max; i++ ) {
            if( aForm.elements[ i ].type != "hidden" &&
                !aForm.elements[ i ].disabled &&
                !aForm.elements[ i ].readOnly ) {
                aForm.elements[ i ].focus();
                break;
            }
        }
    }
}


            