var browserVersion = parseInt(navigator.appVersion);
var isNetscape = navigator.appName.indexOf("Netscape") != -1;
var isIE = navigator.appName.indexOf("Microsoft") != -1;
var agent = navigator.userAgent.toLowerCase();
var isWindows = agent.indexOf("win") != -1;
var isMac = agent.indexOf("mac") != -1;
var isNix = agent.indexOf("X11") != -1;

/**
* clear a form default value
*/

function clearText(thefield){
	if (thefield.defaultValue==thefield.value) {
	 thefield.value = "";
	} else if (thefield.value=='') {
	 thefield.value = thefield.defaultValue;
	} 
}

/**
 * open a js window
 */
function openWindow(url, width, height, left, top, name, scroll, resize, menu) {
        if (width==null) width = 500;
        if (height==null) height = 500;
        if (left == null) left = 10;
        if (top == null) top = 10;
        if (name == null) name = 'usweb_popup';
        if (scroll == null) scroll = 'no';
        if (resize == null) resize = 'no';
		if (menu == null) menu = 'no';

        window.open(url, name, 'toolbar=no,location=no,status=no,directories=no,menubar='+menu+',scrollbars='+scroll+',resizable='+resize+',width='+width+',height='+height+',left='+left+',top='+top, 'replace=false');
}

function addLoadEvent(func)
{
  var oldonload = window.onload;
  if (typeof window.onload != 'function')
  {
    window.onload = func;
  }
  else
  {
    window.onload = function()
    {
      oldonload();
      func();
    }
  }
}


function toggle_hidden ( targetId ) {
    target      = document.getElementById( targetId );
    new_value   = (target.value == 0) ? 1 : 0;
    target.value = new_value;
}

function change_inner_text ( targetId, text1, text2 ) {
	if (document.getElementById) {
		innerTxt = document.getElementById( targetId );
		if ( innerTxt ) {
			if (innerTxt.innerHTML == text1) { 
			    innerTxt.innerHTML = text2;
			} else {
				innerTxt.innerHTML = text1;
			} 	
		}
	}	
}


function pageNav(increment)
{
    if (increment == "next") {
        document.pageNavForm.page_num.value++;
    } else {
        document.pageNavForm.page_num.value--;
    }
    document.pageNavForm.submit();
    return false;
}

function gotoPage(pageNo) {
  f=document.pageNavForm;
  f.page_num.value=pageNo;
  f.submit();
  return false;
}

function changeClass(obj, newClass)
{   
    obj.className = newClass;
}   

function menu_over (obj) {
        if (isIE) {
                obj.className += ' over';
        }
}

function menu_out (obj) {
        if (isIE) {
                obj.className = obj.className.replace(' over', '');
        }
}

function changePointer (obj, pointer)
{
    pointer = (pointer != '') ? pointer : 'pointer';
    if (isIE && browserVersion < 6 && pointer == 'pointer') {
        pointer = 'hand';
    }
    if (pointer == 'normal') {
        pointer = 'default';
    }

    obj.style.cursor = pointer;
}

