// ************************************
// Initialise Search fields
// ************************************
function initSearchFields(){
	if(self.document.forms[0].txtSQ){
		self.document.forms[0].txtSearchQuery.value = unescape(self.document.forms[0].txtSQ.value);
	}
	if(self.document.forms[0].txtDF){ 
		var strDF = self.document.forms[0].txtDF.value;
		if(strDF != ""){
			arrDF = new Array();
			arrDF = strDF.split('##');
			for(df = 0; df < arrDF.length; df++){
				strDFName = arrDF[df].substring(0, arrDF[df].indexOf('='));
				strDFValue = arrDF[df].substring(arrDF[df].indexOf('=')+1);
				eval('intDFExist = self.document.forms[0].' + strDFName + ';');
				if(intDFExist){
					eval('self.document.forms[0].' + strDFName + '.value = "' + strDFValue+ '";');
				}
			}
		}
	}
}
// ************************************
// Executes a Search URL given a query and arguments
// ************************************
function doSearch(type,query,starts,ends){
	var d = document.forms[0];
	if (query == null){
		var qry = escape(d.txtSearchQuery.value);
	} else { 
		var qry = escape(query);
	}
	if (d.txtSearchType) {
		if (d.txtSearchType.options) { 
			var typ = escape(d.txtSearchType.options[d.txtSearchType.selectedIndex].value); 
		} else {   
			var typ = escape(d.txtSearchType.value); 
		}  
	} else {   
		if(type == null){ 
			var typ = '';
		}else{ 
			var typ = type;
		}
	} 
	// Document Fields Boolean
	if (d.txtDFBoolean) {
		if (d.txtDFBoolean.options) { 
			var dfb = escape(d.txtDFBoolean.options[d.txtDFBoolean.selectedIndex].value); 
		} else {   
			var dfb = escape(d.txtDFBoolean.value); 
		}  
	}else{
		dfb = escape(' AND ');
	}
	// Document Fields
	if (d.txtDF1) {
		if (d.txtDF1.options) { 
			var df1 = escape(d.txtDF1.options[d.txtDF1.selectedIndex].value);  } else { var df1 = escape(d.txtDF1.value); 
		}  
	}
	if (d.txtDF2) {
		if (d.txtDF2.options) { 
			var df2 = escape(d.txtDF2.options[d.txtDF2.selectedIndex].value);  } else { var df2 = escape(d.txtDF2.value); 
		}  
	}
	if (d.txtDF3) {
		if (d.txtDF3.options) { 
			var df3 = escape(d.txtDF3.options[d.txtDF3.selectedIndex].value);  } else { var df3 = escape(d.txtDF3.value); 
		}  
	}
	if (d.txtDF4) {
		if (d.txtDF4.options) { 
			var df4 = escape(d.txtDF4.options[d.txtDF4.selectedIndex].value);  } else { var df4 = escape(d.txtDF4.value); 
		}  
	}
	if (d.txtDF5) {
		if (d.txtDF5.options) { 
			var df5 = escape(d.txtDF5.options[d.txtDF5.selectedIndex].value);  } else { var df5 = escape(d.txtDF5.value); 
		}  
	}
	if (d.txtDF6) {
		if (d.txtDF6.options) { 
			var df6 = escape(d.txtDF6.options[d.txtDF6.selectedIndex].value);  } else { var df6 = escape(d.txtDF6.value); 
		}  
	}
	if (d.txtDF7) {
		if (d.txtDF7.options) { 
			var df7 = escape(d.txtDF7.options[d.txtDF7.selectedIndex].value);  } else { var df7 = escape(d.txtDF7.value); 
		}  
	}
	if (d.txtDF8) {
		if (d.txtDF8.options) { 
			var df8 = escape(d.txtDF8.options[d.txtDF8.selectedIndex].value);  } else { var df8 = escape(d.txtDF8.value); 
		}  
	}
	if (d.txtDF9) {
		if (d.txtDF9.options) { 
			var df9 = escape(d.txtDF9.options[d.txtDF9.selectedIndex].value);  } else { var df9 = escape(d.txtDF9.value); 
		}  
	}
	if (d.txtDF10) {
		if (d.txtDF10.options) { 
			var df10 = escape(d.txtDF10.options[d.txtDF10.selectedIndex].value);  } else { var df10 = escape(d.txtDF10.value); 
		}  
	}
	if(starts == null){ starts = ''; } 
	if(ends == null){ ends = ''; }
	dfAll = "";
	if(dfb != null){ dfAll = dfAll + "&DFB=" + dfb; }
	if(df1 != null){ dfAll = dfAll + "&DF1=" + df1; }
	if(df2 != null){ dfAll = dfAll + "&DF2=" + df2; }
	if(df3 != null){ dfAll = dfAll + "&DF3=" + df3; }
	if(df4 != null){ dfAll = dfAll + "&DF4=" + df4; }
	if(df5 != null){ dfAll = dfAll + "&DF5=" + df5; }
	if(df6 != null){ dfAll = dfAll + "&DF6=" + df6; }
	if(df7 != null){ dfAll = dfAll + "&DF7=" + df7; }
	if(df8 != null){ dfAll = dfAll + "&DF8=" + df8; }
	if(df9 != null){ dfAll = dfAll + "&DF9=" + df9; }
	if(df10 != null){ dfAll = dfAll + "&DF10=" + df10; }
 	self.location = "/" + strCurrentDBPath + "/vwPagesWebLive/" + strSearchPage + "?opendocument&SID=" + strSessionID + "&DTC=" + strDateCode + "&SWHT=" + typ + "&SQRY=" + qry + "&SSTART=" + starts + "&SEND=" + ends + dfAll; 
}
