﻿function init()
{
    //document.onmousemove = update; // update(event) implied on NS, update(null) implied on IE
    //update();
    setInputsForAutoClear();
    
}

/*
setInputsForAutoClear, clearDefaultText, replaceDefaultText, and addEvent
are courtesy of Scott Andrew and/or Ross Shannon, (c) 2000–2007 Ross Shannon, 
Used by permission. http://www.yourhtmlsource.com/about/
http://www.yourhtmlsource.com/forms/clearingdefaulttext.html
*/
function setInputsForAutoClear() 
{
    var formInputs = document.getElementsByTagName('input');
    for (var i = 0; i < formInputs.length; i++) 
        {
            var theInput = formInputs[i];
   
            if (theInput.type == 'text' && theInput.className.match(/\bcleardefault\b/)) 
            {  
           
                /* Add event handlers */          
                addEvent(theInput, 'focus', clearDefaultText, false);
                addEvent(theInput, 'blur', replaceDefaultText, false);
         
                /* Save the current value */
                if (theInput.value != '') 
                {
                    theInput.defaultText = theInput.value;
                }
            }
        }
}

function clearDefaultText(e) 
{
    var target = window.event ? window.event.srcElement : e ? e.target : null;

    if (!target) return;

    if (target.value == target.defaultText) 
    {
        target.value = '';
    }
}

function replaceDefaultText(e) 
{
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    
    if (!target) return;
    
    if (target.value == '' && target.defaultText) 
    {
        target.value = target.defaultText;
    }
}

/* 
* Cross-browser event handling, by Scott Andrew
*/
function addEvent(element, eventType, lamdaFunction, useCapture) 
{
    if (element.addEventListener) 
    {
        element.addEventListener(eventType, lamdaFunction, useCapture);
        return true;
    } 
    else if (element.attachEvent) 
    {
        var r = element.attachEvent('on' + eventType, lamdaFunction);
        return r;
    } 
    else 
    {
        return false;
    }
}

function submit()
{
    document.searchform.submit();
}

function doPulldownSearch(value)
{
    if ('' != value)
    {
        document.location.href = value;
    }
}

function popupContent(url,width,height){
	var popUp = window.open(url, "win", "scrollbars=auto,width=" + width + ",height=" + height);
	var halfAvailWidth = Math.round(screen.availWidth / 2);
	var halfAvailHeight = Math.round(screen.availHeight / 2);
	var x = halfAvailWidth - (width / 2);
	var y = halfAvailHeight - (height / 2);
	
	popUp.focus();
	
	if(navigator.appName == "Netscape"){

		popUp.screenX = x;
		popUp.screenY = y;
	} else {
		popUp.moveTo(x,y);
	}
}

function processKey(e,formName,URL)
{    

	if (null == e)        
	e = window.event ;    
	if (e.keyCode == 13)  
			{
						document.getElementById('formName').onSubmit = '';
						 document.getElementById('formName').action = URL;
			       document.getElementById('formName').submit();
			       
			       return false;
			        
		}
}
function processClick(formName,URL)
{    

	
						document.getElementById('formName').onSubmit = '';
						 document.getElementById('formName').action = URL;
			       document.getElementById('formName').submit();
			       
				        
		
}
