function popWindow(wURL, wName, wHeight, wWidth, wAddress) {
	sHeight = (screen.height-wHeight) / 2;
    sWidth = (screen.width-wWidth) / 2;
	if ( wAddress == true ) {
		sAddress = "yes";
	} else {
		sAddress = "no";
	}
    pWin = window.open( wURL, wName, "scrollbars=yes,height="+wHeight+",width="+wWidth+",status=no,location="+sAddress+",resizable=no,top="+sHeight+",left="+sWidth );
    pWin.focus();
}
function swapToRedImage(img_obj_name) {	
	if ( document.images[img_obj_name] ) {
		c_img_path = document.images[img_obj_name].src;
		document.images[img_obj_name].src = c_img_path.slice(0,c_img_path.indexOf("_blue.gif")) + "_red.gif";					
	}
}
function swapToBlueImage(img_obj_name) {	
	if ( document.images[img_obj_name] ) {
		c_img_path = document.images[img_obj_name].src;
		document.images[img_obj_name].src = c_img_path.slice(0,c_img_path.indexOf("_red.gif")) + "_blue.gif";					
	}
}
var isDHTML = 0;
var isID = 0;
var isAll = 0;
var isLayers = 0;
if ( document.getElementById ) {
	isID = 1;
	isDHTML = 1;
} else {
	if ( document.all ) {
		isAll = 1;
		isDHTML = 1;
	} else {
		if ( (navigator.appName.indexOf('Netscape') != -1) && (parseInt(navigator.appVersion) == 4) ) {
			isLayers = 1;
			isDHTML = 1;
		}
	}
}
/* returns DOM object or null if not available */
function retrieveDOM( objectID, withStyle ) {
	if (withStyle == 1) {
		if (isID) {
				return (document.getElementById(objectID).style);
		} else {
			if (isAll) {
					return (document.all[objectID].style);
			} else {
				if (isLayers) {
						return (window.document.layers[objectID]);
				}
			}
		}
	} else {
		if (isID) { 
				return (document.getElementById(objectID));
		} else {
			if (isAll) {
					return (document.all[objectID]);
			} else {
				if (isLayers) {
						return (window.document.layers[objectID]);
				}
			}			
		}
	}
}
/* DHTML Menu functions and variables */
var netscapeTopVar = 0;
var netscapeLeftVar = 0;
var menuHorizontal = false;
var menuOffsetLeft = 0;
var menuOffsetTop = 2;
var domDBMenu = null;
var oldDomDBMenu = null;
var previousMenuID = null;
var t = 0;
var lDelay = 15;
var lCount = 0;
var pause = 50;
function delayHide() {
 		 if ( (oldDomDBMenu) && (t  == 0) ) {
				selectVisibility(false);
  		 		 oldDomDBMenu.visibility = 'hidden';
  		 		 oldDomDBMenu.zIndex = '0';
  		 		 oldDomDBMenu = null;
  		 		 lCount = 0;
  		 		 return false;
 		 }
 		 if ( t == 2 ) {
  		 		 lCount = 0;
  		 		 return false;
 		 }
 		 if ( t == 1 ) {
  		 		 lCount = lCount + 1;
  		 		 if ( lDelay <= lCount ) {
   		 		 		 t = 0;
  		 		 }
  		 		 if ( lDelay >= lCount ) {
   		 		 		 setTimeout( "delayHide('+t+')", pause );
 		 		 }
 		 }
}
function closeMenu() {
	if ( oldDomDBMenu ) {
		selectVisibility(false);
		 oldDomDBMenu.visibility = 'hidden';
		 oldDomDBMenu.zIndex = '0';
   		 t = 2;
		 lCount = 0;
		 oldDomDBMenu = null;
	}
}
function popMenu(menuName,menuNum) {
	if(isDHTML) {
		selectVisibility(true);
 		 t = 2;
	 	 if (oldDomDBMenu) {
			if ( previousMenuID != null ) {
				if ( previousMenuID != menuName + 'Menu' + menuNum ) {
	 		 	 	oldDomDBMenu.visibility = 'hidden';
		 	 		oldDomDBMenu.zIndex = '0';
		    	 		lCount = 0;
				} else {
					return;
				}
			} else {
 		 		 oldDomDBMenu.visibility = 'hidden';
	 		 	 oldDomDBMenu.zIndex = '0';
	    			 lCount = 0;
			}
 		 }
	 	var idMenuOpt = menuName + 'MenuHead' + menuNum; 
	 	var domMenuOpt = retrieveDOM(idMenuOpt, 0); 
	 	var idDBMenu = menuName + 'Menu' + menuNum;
	 	var domDBMenu = retrieveDOM(idDBMenu, 1); 	
		var t_val_tmp = getElementPosition(idMenuOpt);
		t_val_left = t_val_tmp.left;
		t_val_top = t_val_tmp.top;	
		menuLeft = /*domMenuOpt.offsetLeft +*/ menuOffsetLeft + t_val_left;		
		menuTop = domMenuOpt.offsetHeight + menuOffsetTop + t_val_top;
	 	 if (oldDomDBMenu != domDBMenu) {
 	 		 domDBMenu.left = menuLeft;
 	 		 domDBMenu.top = menuTop;
	 		 domDBMenu.visibility = 'visible';
 	 		 domDBMenu.zIndex = '100';
 		 	 oldDomDBMenu = domDBMenu;
			 previousMenuID = idDBMenu;
 		 } else {
 			 oldDomDBMenu = null;
 		 }		
	} else {
 		  return null;
	}
}
function selectVisibility(hide) {
	var f_item; var f_obj;
	for( f=0; f<document.forms.length; f++ ) {
		for( i=0; i<document.forms[f].length; i++ ) {	
			f_item = document.forms[f].elements[i];
			if ( f_item.type.indexOf("select") > -1 ) {
				if ( f_item.title == "menu_hide" ) {
					f_obj = retrieveDOM( f_item.id, 1 );
					//if ( !f_obj ) { return; }
					if ( hide ) {						
						f_item.style.visibility = "hidden";
						//f_obj.visibility = "hidden";
					} else {
						f_item.style.visibility = "visible";
						//f_obj.visibility = "visible";
					}
				}
			}
		}
	}
}
function getElementPosition(elemID) {
    var offsetTrail = document.getElementById(elemID);
    var offsetLeft = 0;
    var offsetTop = 0;
    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTop += offsetTrail.offsetTop;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
        offsetTop += document.body.topMargin;
    }
    return {left:offsetLeft, top:offsetTop};
}
/* show/hide a by ID */
function abstractVisibility(id, show) {
    var d_obj = retrieveDOM(id,1);
    if ( d_obj ) {
        if ( show ) {
            d_obj.visibility = "visible";
        } else  {
            d_obj.visibility = "hidden";
        }
    }
}
/* 
* Set a Cookie.
* cName = name of cookie
* cVal = value of cookie (will be escaped)
* cRetain = boolean true|false to allow the cookie to be saved after browser close
*/
function setCookie( cName, cVal, cRetain ) {
    cExpire = "";
    if ( cRetain == true ) {
        cDate = new Date();
        cDate.setFullYear( cDate.getFullYear() + 1 );  
        cExpire = "; expires=" + cDate.toGMTString();
    }    
    document.cookie = cName + "=" + escape(cVal) + cExpire + "; path=/";
}
/* 
* Gets a Cookie, if one exists, by specified name.
*/
function getCookie( CookieName ) {
    var search = CookieName + "=";
    if (document.cookie.length > 0) {          
        offset = document.cookie.indexOf(search);
        if (offset != -1) {              
            offset += search.length; 
            end = document.cookie.indexOf(";", offset);
            if (end == -1)
                end = document.cookie.length;
            return ( unescape(document.cookie.substring(offset, end)) );
        } 
    }
}
/*  (returns null if no key/value is in the Query_String) */
function getQueryParameter( key ) {
	 q_string_path = location.search;
     if ( q_string_path.indexOf(key) != -1 ) {
		if ( q_string_path.indexOf("?")==0 ) {
			q_string_path = q_string_path.slice(1);
		}
		tKeys = q_string_path.split( "&" );
		fVal = null;
	
		for( i=0; i<tKeys.length; i++ ) {
			if ( tKeys[i] != "" ) {
				if ( tKeys[i].indexOf( "=" ) != -1 ) {
					if ( tKeys[i].indexOf( key ) != -1 ) {
						tVals = tKeys[i].split( "=" );
						if ( tVals[0] == key ) {
							fVal = tVals[1];	
							i = tKeys.length + 1;	
							return fVal;					
					    }
					}
				}
			}
		}	
		//return fVal;
	} else {
		return null;
	}
}

function replaceCharacters( text, charToRemove, charToAdd ) {

	if ( text.indexOf(charToRemove) != -1 ) {
		tmp = text.split(charToRemove);
		tmptext="";
		for(i=0;i<tmp.length;i++) {
		 	if (i==0) {
				tmptext = tmp[i];
			} else {				
				tmptext += charToAdd+tmp[i];
			}
		}
		text = tmptext;
	}	
	return text
	
}