function fixQueryTerm (qstr) {
	if (qstr == null) return null;
	qstr = qstr.replace(/[\@\&\|\;\>\<\[\]\(\)\{\}]+/g, "");
	qstr = qstr.replace(/\*\*+/g, "*");
	qstr = qstr.replace(/ \*$/g, "");
	qstr = qstr.replace(/ \* /g, "");
	qstr = qstr.replace(/^\* /g, "");
	qstr = qstr.replace(/\s+$/, "");
	qstr = qstr.replace(/^\s+/, "");
	qstr = qstr.replace(/\s+/g, " ");
	return qstr;
}

function makeSRSString(qstr, seperator){
	singleTerms = qstr.split(" ");
	queryFixed="";
	for (i=0; i<singleTerms.length; i++) {
		if (singleTerms[i].length > 1){
			queryFixed += escape(singleTerms[i]);
			queryFixed += "*";
			queryFixed += seperator;
		}
	}
	queryFixed = queryFixed.substr(0, queryFixed.length-1);
	return queryFixed;
}

function MM_swapImgRestore() {
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() {
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_jumpMenu(targ,selObj,restore){ 
//alert(selObj.options[selObj.selectedIndex].value);
  if(selObj.options[selObj.selectedIndex].value != "")
  {
  	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  	if (restore) selObj.selectedIndex=0;
  }
}

///////////////////////////////////////////////// OVERRIDE SEARCH GIZMO METHODS /////////////////////////////////////////////////

var gizmoSelectArray=new Array(1);

function confirmSubmit(){
	var agree=confirm("Are you sure you wish to continue?");
	if (agree){
		return true ;
	}
	else{
		return false ;
	}
}

///////////////////////////////////////////////// OPEN WINDOW METHODS /////////////////////////////////////////////////

var qstr = "empty";
var newWin;

function openWindow(address)
{ 
	newWin = window.open(address,'_help','personalbar=0, toolbar=0,location=0,directories=0,menuBar=0,status=0,resizable=yes,scrollBars=0, resizable=1, width=800, height = 500,top=0,left=0'); 
    newWin.resizeTo(800, 500);
    newWin.focus();
}

function openHelpWindow(){ 
	newWin = window.open('','help','width=160,height=500','toolbar=no', 'location=no','directories=no','status=no','menubar=no','scrollbars=no','resizable=no'); 
    newWin.resizeTo(800, 500);	
    newWin.focus();
}

function openPopupWindow(){ 
	newWin = window.open('','popup','width=600,height=500','toolbar=no', 'location=no','directories=no','status=no','menubar=no','scrollbars=no','resizable=no'); 
    newWin.focus();
}

function openWindow2(address)
{ 
	newWin = window.open(address,'_pic','personalbar=0, toolbar=0,location=0,directories=0,menuBar=0,status=0,scrollBars=0, resizable=1, width=587, height = 445,top=0,left=0'); 
	newWin.focus();
}

function openWindow2can(address)
{ 
	newWin = window.open(address,'_help','personalbar=0, toolbar=0,location=0,directories=0,menuBar=0,status=0,resizable=yes,scrollBars=1, resizable=1, width=450, height = 125,top=0,left=0'); 
    newWin.resizeTo(450, 125);
    newWin.focus();
}

function openWindowScroll(address)
{ 
	newWin = window.open(address,'_help','personalbar=0, toolbar=0,location=0,directories=0,menuBar=0,status=0,resizable=yes,scrollBars=1, resizable=1, width=800, height = 500,top=0,left=0'); 
    newWin.resizeTo(800, 500);
    newWin.focus();
}

function openWindowMenus(address)
{
	newWin = window.open(address,'_link','personalbar=1, toolbar=1,location=1,directories=1,menuBar=1,status=1,resizable=yes,scrollBars=1, resizable=1, width=800, height = 500,top=0,left=0');
    newWin.resizeTo(800, 500);
    newWin.focus();
}
// BookmARK this page //
function bookmark(url,title){
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
}
