// Code starts AFTER these functions c line 60

var finalCount=0;
window.finalCount=0;
self.finalCount=0;


//var searchScript = ( document.location.host.match(/firstclassplants\.com/) ) ? "search_fcp_db.cgi" : "search_db_07.cgi";
var searchScript ="search_db_07.cgi";
var thisAction="http://"+document.location.host+"/cgi-bin/FirstClassDB/"+searchScript;
//alert("thisAction:"+thisAction)
document.MAINFORM.setAttribute("action",thisAction)

//alert(thisAction)

var mouseButPressed=0;

function adjustForSmallerBrowserWindows(){
if(document.body.offsetHeight<455){
	//alert(document.body.offsetHeight)
	var lPos='520px';
	document.getElementById('SEARCHHINT').style.left=lPos;
	document.getElementById('SEARCHGROUP').style.left=lPos;
	document.getElementById('BASEGREENLINERIGHT').style.left=lPos;
	document.body.style.overflowY='auto'
	document.body.scroll='auto'
	}
}

function showDeptPicAndDescr(dTx){
	//alert(dTx)
	//document.MAINFORM.seekme.style.visibility="visible"
	var baseName=document.MAINFORM.seekme.value;
	document.getElementById('DEPTPIC').alt=baseName;
	if(dTx){dTx=dTx.replace(/<.+?>/g," ")}

	document.getElementById('SEARCHPREVIEW').innerHTML="<br>"+dTx;

	if(dTx.length>200){
	document.getElementById('SEARCHPREVIEW').innerHTML=dTx;
	//document.getElementById('SEARCHPREVIEW').style.height='70px'
	}

	else{document.getElementById('SEARCHPREVIEW').innerHTML="<br>"+dTx;}

	baseName=baseName.toLowerCase();
	baseName=baseName.replace(/\s+/g,"_");
	baseName = "pix/dept_search_pix/"+baseName+"_drp.jpg"
	//alert("2: "+baseName)
	document.getElementById('DEPTPIC').src=baseName;

	document.getElementById('DEPTPIC').style.visibility='visible';
	document.getElementById('SEARCHPREVIEW').style.visibility='visible'
	//alert(53+":"+dTx)
	styleScrollers()

}

// CODE STARTS HERE: adjustForSmallerBrowserWindows has been set above so it may be called from here:

var departmentalQuery=0;
var modus = document.location.search;
var resultsHeader =  "<img  ID=YOURRESULTSPIC src='pix/search_results_for_small.gif' width=187 height=21  border=0 alt=''>";

if(modus.match(/search_mode/)){
//alert("You are in "+modus)

	window.onload=function(){
	//alert("120 Loading in search mode...")
	toDoOnLoad()

		if(parent.deptSearchTerm){
			departmentalQuery=1;
			//alert("Hiding VIEWOPTIONSDIV and SPAN")
			document.getElementById('VIEWOPTIONSSPAN').style.display="none";
			document.getElementById('VIEWOPTIONSDIV').style.display="none";


			//alert("originalDeptTerm:"+parent.originalDeptTerm)
			//alert(parent.originalDeptTerm+"\n"+parent.originalDeptTerm.length)
			var tradelessOriginalDeptTerm=parent.originalDeptTerm;
			tradelessOriginalDeptTerm=tradelessOriginalDeptTerm.replace(/TRADEMARK/,"");

			with(document.getElementById('YOURRESULTS') ){

				// here we replace letterspacing for very long dept names
				if(tradelessOriginalDeptTerm.length>24){style.letterSpacing="0px"}
				else if(tradelessOriginalDeptTerm.length>18){style.letterSpacing="1px"}
				else{style.letterSpacing="2px"}

				parent.originalDeptTerm=parent.originalDeptTerm.replace(/\™/,"<sup style=font-size:14px>&trade;</sup>")

				// shorten long names:
				parent.originalDeptTerm=parent.originalDeptTerm.replace(/Varieties/,"Plants")

				innerHTML=parent.originalDeptTerm;

				}
				parent.originalDeptTerm=""

			}

		else{
			departmentalQuery=0;
			document.getElementById('VIEWOPTIONSSPAN').style.display="inline";
			document.getElementById('VIEWOPTIONSDIV').style.display="block";
		}


//alert("departmentalQuery:"+departmentalQuery)

		if(departmentalQuery==1){
				//alert("departmentalQuery:"+departmentalQuery)

				var tempdS=parent.currentDept;
				//alert(tempdS)
				document.getElementById('dept_search').value=tempdS;
				tempdS=tempdS.replace(/cultivars/i,"");
				tempdS=tempdS.replace(/Eklonis/i,"")
				document.getElementById('CURDEP').innerHTML=tempdS+" "; //Monday, January 07, 2008.  The title lacks a space
				//parent.currentDept=""; done from search_db_07.cgi

				document.MAINFORM.seekme.value = parent.frames[1].document.getElementById('CONTROLSEEKME').value; // boot & braces

				//alert("116 Hiding SEEKME so it don't show thru the drp_ dept pic")
				document.getElementById('SEEKME').style.visibility='hidden';

				document.getElementById('SEARCHPREVIEW').style.visibility='visible';
				//document.getElementById('YOURRESULTS').innerHTML=parent.deptSearchTerm;

				document.getElementById('YOURRESULTS').style.visibility='visible';


				document.getElementById('SEARCHHINT').style.visibility='hidden';
				document.getElementById('SEARCHGROUP').style.visibility='hidden';
				document.getElementById('GOBUT').style.visibility='hidden';
				document.getElementById('CLEARSELBUT').style.visibility='hidden';

				showDeptPicAndDescr(parent.deptDescr)


				parent.deptDescr="";
				parent.deptSearchTerm="";

				document.getElementById('BACTOPRODUCTSPAGEMESSAGE').style.visibility='visible';
				//alert("109 - Loading in search mode...")
		}
		else{
		//alert(modus +"\n NOT departmentalQuery")

				document.getElementById('SEARCHPREVIEW').innerHTML= document.MAINFORM.seekme.value=
				parent.frames[1].document.getElementById('CONTROLSEEKME').value;
				//alert("103: Submitting...")
				document.forms[0].submit()

				// The search term has already been put here

				document.getElementById('SEARCHPREVIEW').style.visibility='visible';

				document.getElementById('YOURRESULTS').innerHTML=resultsHeader;


				document.getElementById('YOURRESULTS').style.visibility='visible'
				document.getElementById('SEARCHHINT').style.visibility='visible';
				document.getElementById('SEARCHGROUP').style.visibility='visible';
				document.getElementById('GOBUT').style.visibility='visible';
				document.getElementById('CLEARSELBUT').style.visibility='visible';

//alert("About to click SEEKEME")
				document.MAINFORM.seekme.click()
//alert("Just clicked SEEKEME")
		}

		// this is the name of a particular plant subgroup

		adjustPullDowns()

		//alert(171)

		document.getElementById('TOPPANELBG').style.visibility='visible';
	}

}
else{window.onload=showStandardStart;}

//alert(177)

parent.colorNaviButs();

function showStandardStart(){
	toDoOnLoad()
	//alert("showStandardStart runs onload")
	adjustPullDowns()
	//alert("SSS")
	//adjustForSmallerBrowserWindows()
	document.getElementById('SEARCHYOURWAY').style.visibility='visible';

	document.getElementById('TOPGREENLINERIGHT').style.visibility='visible';
	document.getElementById('BASEGREENLINERIGHT').style.visibility='visible';
	document.getElementById('SEARCHGROUP').style.visibility='visible';
	document.getElementById('SEARCHHINT').style.visibility='visible';


		document.getElementById('TOPPANELBG').style.visibility='visible';
	showBlanksInFrame(173)
//alert("Would showStandardStart")

}

function adjustPullDowns(){
if(!document.all){
	var pulldowns=document.getElementsByTagName("span")
	for (h=0;h<pulldowns.length;h++){
			if(pulldowns[h].id && pulldowns[h].id.match(/PULLER/) ) {
			//alert(pulldowns[h].id)
				pulldowns[h].className="PULLDOWNMOZ";
			}
		}
	}
}


function rubric(passed){
	//alert(passed)
	var moiree = passed.split(/\s/)
	if(moiree.length > 1){
		document.getElementById("SEARCHOPTIONS").style.visibility="visible"
	}
}

function cancelAllField(){
document.MAINFORM.All.checked=false;
with(document.MAINFORM.seekme){if(value=="Search here"){value=""}}
}

function cancelIndividualFields(){
with(document.MAINFORM.seekme){if(value=="Search here"){value=""}}
	for(i=3;i<document.MAINFORM.elements.length-5;i++){ // 5th from the last is seekme - the search box
		//alert(i+" :"+document.MAINFORM.elements[i].name)
		if(document.MAINFORM.elements[i]){document.MAINFORM.elements[i].checked=false}
	}
}


var plantTypesTop,plantTypesBottom,plantTypesLeft,plantTypesRight;
var flowerColorTop,flowerColorBottom,flowerColorLeft,flowerColorRight;
var growthHabitTop,growthHabitBottom,growthHabitLeft,growthHabitRight;
var heatToleranceTop,heatToleranceBottom,heatToleranceLeft,heatToleranceRight;
var floweringTimeTop,floweringTimeBottom,floweringTimeLeft,floweringTimeRight;

function fixBBs(){

var toffset=document.getElementById('SEARCHGROUP').offsetTop-(document.body.scrollTop)-20;
//alert("d-b-scrollTop:"+document.body.scrollTop+"\ndocument.getElementById('SEARCHGROUP').offsetTop:"+document.getElementById('SEARCHGROUP').offsetTop+"\ntoffset:"+toffset)

// Get mouse state

 plantTypesTop =  eval(document.getElementById('PLANTTYPES').offsetTop+toffset);
 plantTypesBottom = eval( plantTypesTop+document.getElementById('PLANTTYPES').clientHeight+30)
 plantTypesLeft = document.getElementById('PLANTTYPES').offsetLeft+ document.getElementById('SEARCHGROUP').offsetLeft -10;
 plantTypesRight = eval(plantTypesLeft+document.getElementById('PLANTTYPES').clientWidth+34)
//alert(document.getElementById('PLANTTYPES').id+"\nT: "+plantTypesTop+"\nB: "+plantTypesBottom+"\nL: "+plantTypesLeft+"\nR: "+plantTypesRight)

 flowerColorTop = eval(document.getElementById('FLOWERCOLOR').offsetTop+toffset);
 flowerColorBottom = eval( flowerColorTop+document.getElementById('FLOWERCOLOR').clientHeight+30)
 flowerColorLeft = document.getElementById('FLOWERCOLOR').offsetLeft+document.getElementById('SEARCHGROUP').offsetLeft -10;
 flowerColorRight = eval(flowerColorLeft+document.getElementById('FLOWERCOLOR').clientWidth+34)
//alert(document.getElementById('FLOWERCOLOR').id+"\nT: "+flowerColorTop+"\nB: "+flowerColorBottom+"\nL: "+flowerColorLeft+"\nR: "+flowerColorRight)

 growthHabitTop = document.getElementById('GROWTHHABIT').offsetTop+toffset;
 growthHabitBottom = eval( growthHabitTop+document.getElementById('GROWTHHABIT').clientHeight+30)
 growthHabitLeft = document.getElementById('GROWTHHABIT').offsetLeft+document.getElementById('SEARCHGROUP').offsetLeft -10;
 growthHabitRight = eval(growthHabitLeft+document.getElementById('GROWTHHABIT').clientWidth)
//alert(document.getElementById('GROWTHHABIT').id+"\nT: "+growthHabitTop+"\nB: "+growthHabitBottom+"\nL: "+growthHabitLeft+"\nR: "+growthHabitRight)

 heatToleranceTop = document.getElementById('HEATTOLERANCE').offsetTop+toffset;
 heatToleranceBottom = eval( heatToleranceTop+document.getElementById('HEATTOLERANCE').clientHeight+30)
 heatToleranceLeft = document.getElementById('HEATTOLERANCE').offsetLeft+document.getElementById('SEARCHGROUP').offsetLeft -10;
 heatToleranceRight = eval(heatToleranceLeft+document.getElementById('HEATTOLERANCE').clientWidth)
//alert(document.getElementById('HEATTOLERANCE').id+"\nT: "+heatToleranceTop+"\nB: "+heatToleranceBottom+"\nL: "+heatToleranceLeft+"\nR: "+heatToleranceRight)

 floweringTimeTop = document.getElementById('FLOWERINGTIME').offsetTop+toffset;
 floweringTimeBottom = eval( floweringTimeTop+document.getElementById('FLOWERINGTIME').clientHeight+30)
 floweringTimeLeft = document.getElementById('FLOWERINGTIME').offsetLeft+document.getElementById('SEARCHGROUP').offsetLeft -10;
 floweringTimeRight = eval(heatToleranceLeft+document.getElementById('FLOWERINGTIME').clientWidth)
//alert(document.getElementById('HEATTOLERANCE').id+"\nT: "+heatToleranceTop+"\nB: "+heatToleranceBottom+"\nL: "+heatToleranceLeft+"\nR: "+heatToleranceRight)



}


//var xx,yy;

function ratCheck(xx,yy) {

//window.status="X:"+xx+" Y "+yy+" Mousepressed: "+mouseButPressed;
//alert("X:"+xx+" Y "+yy)


if(document.getElementById('PLANTTYPES').style.visibility=='visible' ){
	if(xx<plantTypesLeft || xx>plantTypesRight || yy<plantTypesTop || yy>plantTypesBottom){
		//alert("PT is out of range:\nL:"+plantTypesLeft+"\nR:"+plantTypesRight+"\nT:"+plantTypesTop+"\nB:"+plantTypesBottom)
		document.getElementById('PLANTTYPES').style.visibility='hidden';
	}
}

if(document.getElementById('FLOWERCOLOR').style.visibility=='visible' ){
	if(xx<flowerColorLeft || xx>flowerColorRight || yy<flowerColorTop || yy>flowerColorBottom){
		//alert("PT is Outa range:\nL:"+flowerColorLeft+"\nR:"+flowerColorRight+"\nT:"+flowerColorTop+"\nB:"+flowerColorBottom)
		document.getElementById('FLOWERCOLOR').style.visibility='hidden';
	}
}

if(document.getElementById('GROWTHHABIT').style.visibility=='visible' ){
	if(xx<growthHabitLeft || xx>growthHabitRight || yy<growthHabitTop || yy>growthHabitBottom){
		//alert("PT is Outa range:\nL:"+growthHabitLeft+"\nR:"+growthHabitRight+"\nT:"+growthHabitTop+"\nB:"+growthHabitBottom)
		document.getElementById('GROWTHHABIT').style.visibility='hidden';
	}
}


if(document.getElementById('HEATTOLERANCE').style.visibility=='visible' ){
	if(xx<heatToleranceLeft || xx>heatToleranceRight || yy<heatToleranceTop || yy>heatToleranceBottom){
		//alert("PT is Outa range:\nL:"+heatToleranceLeft+"\nR:"+heatToleranceRight+"\nT:"+heatToleranceTop+"\nB:"+heatToleranceBottom)
		document.getElementById('HEATTOLERANCE').style.visibility='hidden';
	}
}

if(document.getElementById('FLOWERINGTIME').style.visibility=='visible' ){
	if(xx< floweringTimeLeft || xx> floweringTimeRight || yy< floweringTimeTop || yy> floweringTimeBottom){
		//alert("PT is Outa range:\nL:"+ floweringTimeLeft+"\nR:"+ floweringTimeRight+"\nT:"+ floweringTimeTop+"\nB:"+ floweringTimeBottom)
		document.getElementById('FLOWERINGTIME').style.visibility='hidden';
	}
}
return true

}

var doTheScroll;

function showScrollers(doTheScroll){ // doScroll is reserved word
//alert("doTheScroll: "+doTheScroll)

self.doTheScroll=doTheScroll

if(parent.finalCount>8){alert(315);
document.getElementById('MOREBUT').style.visibility='visible'}

if(document.all){
	self.frames[0].document.body.style.overflowY='scroll' ;
	self.frames[0].document.body.style.overflowX='hidden'
	self.frames[0].document.body.setAttribute('scroll','auto');
	self.frames[0].frameElement.style.overflowY='scroll' ;
}
else{
	self.frames[0].frameElement.style.overflowY='scroll' ;
	self.frames[0].frameElement.style.overflowX='hidden'
}

if(doTheScroll){
//alert(self.frames[0].document.body.scrollHeight+"\n"+self.frames[0].document.body.scrollTop);
setTimeout("blubber()",50)
}

else{
self.frames[0].scrollBy(0,0) // KICKSTARTS SCROLLBARS AFTER RETURN TO RESULTS FROM DETAILED VIEW
}

}


function blubber(){
var scrH=parseInt(self.frames[0].document.body.scrollHeight);
var scrTop = parseInt(self.frames[0].document.body.scrollTop);

//alert(scrH+"\n"+scrTop);

var diff=scrH-scrTop;

//alert( scrH+ " minus " +scrTop+ " = "+diff);

if(diff<439){//alert(350);
document.getElementById('MOREBUT').style.visibility='hidden'}
// NOTHING MORE TO SCROLL FOR
if(diff<293){
	//alert("The difference is too small to scroll: "+diff)
	if(parent.finalCount>8){
		//alert(354)
		document.getElementById('MOREBUT').style.visibility='visible'
		}
	self.frames[0].document.body.style.overflowY='scroll' ;
	//self.frames[0].document.body.scroll='yes'
	self.frames[0].scrollBy(0,0)
}

else if(doTheScroll){self.frames[0].scrollBy(0,146)}  // one row


}

function doSearch(){
// alert(document.getElementById('SEARCHPREVIEW').childNodes[0].nodeValue)
// DOM here is far too complex - one would have to cover all cases of <B> and <SPAN> etc
// so I get innerHTML and strip the tags, since Moz knows no innerText

document.getElementById('ALTICONS').style.display="none"// get rid of alts before search

var reportText =document.getElementById('SEARCHPREVIEW').innerHTML + document.getElementById('SPECIALSEARCHES').innerHTML
reportText = reportText.replace(/<.+?>/g,"");
//alert("reportText.length:"+reportText.length+"\n"+reportText)
if(reportText.length==0 || reportText.match(/have been cleared$/)){alert("Please select something to search for \nfrom the left of this page")}
else{
	document.getElementById('BOTTOMPANELBG').style.visibility='hidden';

	//alert("353: Submitting...")
	document.forms[0].submit()
	document.getElementById('YOURRESULTS').style.visibility='visible';
	finalCount=0;
	}
}


var compositeTerm = "";
var termsToGo = new Array(); // just for the report at present

var botNamesTermsToGo = new Array();
var colorTermsToGo = new Array();
var growthHabitTermsToGo = new Array();
var heatToleranceTermsToGo = new Array();
var floweringTimeTermsToGo = new Array();

/*
SEEKBOTANICAL
SEEKCOLOR
SEEKGROWTHHABIT
SEEKHEATTOLERANCE
SEEKFLOWERINGTIME
*/


function searchInBotNames(obj){
var nom=obj.name

hideButtonsTitlesAndTexts("searchInBotNames")

showSearchPreview()

if(obj.checked==false){
	for(c=0;c<botNamesTermsToGo.length;c++){
		if(botNamesTermsToGo[c]==nom){
			//alert("Cancelling "+nom);
			botNamesTermsToGo.splice(c,1)
			botNamesTermsToGo=botNamesTermsToGo.sort()
			}
		}
	removeFromTermsToGo(nom)
	document.forms[0].SEEKBOTANICAL.value=botNamesTermsToGo; // comma-separated
	showMenuReport()
	return
}

cancelAllField()

document.forms[0].any_word.checked=true
document.forms[0].botanical_name.checked=true

document.MAINFORM.seekme.value=""
parent.frames[1].document.getElementById('CONTROLSEEKME').value=""

botNamesTermsToGo.push(nom);
document.forms[0].SEEKBOTANICAL.value=botNamesTermsToGo; // comma-separated

termsToGo.push(nom);
//document.MAINFORM.seekme.value = termsToGo

compositeTerm = "";
		for(i=0;i<termsToGo.length;i++){
			compositeTerm += termsToGo[i]+"<br>"
		}

//alert("About to show menu report")

showMenuReport()
} // end funct searchInBotNames



function searchInColors(obj){
var nom=obj.name

if(obj.checked==false){
	for(c=0;c<colorTermsToGo.length;c++){
		if(colorTermsToGo[c]==nom){
			//alert("Cancelling "+nom);
			colorTermsToGo.splice(c,1)
			colorTermsToGo=colorTermsToGo.sort()
			}
		}
	removeFromTermsToGo(nom)
	document.forms[0].SEEKCOLOR.value=colorTermsToGo; // comma-separated
	showMenuReport()
	return
}

cancelAllField()
document.forms[0].any_word.checked=true
document.forms[0].flower_color.checked=true

document.MAINFORM.seekme.value="";
parent.frames[1].document.getElementById('CONTROLSEEKME').value="";

colorTermsToGo.push(nom);
document.forms[0].SEEKCOLOR.value=colorTermsToGo; // comma-separated

termsToGo.push(nom);
//document.MAINFORM.seekme.value = termsToGo
//alert(nom)

compositeTerm = "";
		for(i=0;i<termsToGo.length;i++){
			compositeTerm += termsToGo[i]+"<br>"
		}

showMenuReport()
} // end funct searchInColors




function searchInGrowthHabit(obj){
var nom=obj.name

if(obj.checked==false){
	for(c=0;c<growthHabitTermsToGo.length;c++){
		if(growthHabitTermsToGo[c]==nom){
			//alert("Cancelling "+nom);
			growthHabitTermsToGo.splice(c,1)
			growthHabitTermsToGo =growthHabitTermsToGo.sort()
			}
		}
	removeFromTermsToGo(nom)
	document.forms[0].SEEKGROWTHHABIT.value = growthHabitTermsToGo; // comma-separated
	showMenuReport()
	return
}

cancelAllField()
document.forms[0].any_word.checked=true
document.forms[0].growth_habit.checked=true

document.MAINFORM.seekme.value="";
parent.frames[1].document.getElementById('CONTROLSEEKME').value="";

growthHabitTermsToGo.push(nom);
document.forms[0].SEEKGROWTHHABIT.value = growthHabitTermsToGo; // comma-separated

termsToGo.push("Growth habit: "+nom);

compositeTerm = "";
		for(i=0;i<termsToGo.length;i++){
			compositeTerm += termsToGo[i]+"<br>"
		}

showMenuReport()
} // end funct searchInGrowthHabit



function searchInHeatTolerance(obj){
var nom=obj.name

if(obj.checked==false){
	for(c=0;c<heatToleranceTermsToGo.length;c++){
		if(heatToleranceTermsToGo[c]==nom){
			//alert("Cancelling "+nom);
			heatToleranceTermsToGo.splice(c,1)
			heatToleranceTermsToGo =heatToleranceTermsToGo.sort()
			}
		}
	removeFromTermsToGo(nom)
	document.forms[0].SEEKHEATTOLERANCE.value = heatToleranceTermsToGo; // comma-separated
	showMenuReport()
	return
}

cancelAllField()
document.forms[0].any_word.checked=true
document.forms[0].heat_tolerance.checked=true

document.MAINFORM.seekme.value="";
parent.frames[1].document.getElementById('CONTROLSEEKME').value="";

heatToleranceTermsToGo.push(nom);
document.forms[0].SEEKHEATTOLERANCE.value = heatToleranceTermsToGo; // comma-separated

termsToGo.push("Heat Tolerance: "+nom);

compositeTerm = "";
		for(i=0;i<termsToGo.length;i++){
			compositeTerm += termsToGo[i]+"<br>"
		}

showMenuReport()
} // end funct searchInHeatTolerance




function searchInFloweringTime(obj){
var nom=obj.name

if(obj.checked==false){
	for(c=0;c<floweringTimeTermsToGo.length;c++){
		if(floweringTimeTermsToGo[c]==nom){
			//alert("Cancelling "+nom);
			floweringTimeTermsToGo.splice(c,1)
			floweringTimeTermsToGo =floweringTimeTermsToGo.sort()
			}
		}
	removeFromTermsToGo(nom)
	document.forms[0].SEEKFLOWERINGTIME.value = floweringTimeTermsToGo; // comma-separated
	showMenuReport()
	return
}

cancelAllField()
document.forms[0].any_word.checked=true
document.forms[0].flowering_time.checked=true

document.MAINFORM.seekme.value="";
parent.frames[1].document.getElementById('CONTROLSEEKME').value="";

floweringTimeTermsToGo.push(nom);
document.forms[0].SEEKFLOWERINGTIME.value = floweringTimeTermsToGo; // comma-separated

termsToGo.push("Flowering Time: "+nom);

compositeTerm = "";
		for(i=0;i<termsToGo.length;i++){
			compositeTerm += termsToGo[i]+"<br>"
		}

showMenuReport()
} // end funct searchInFloweringTime


function removeFromTermsToGo(nom){

for(c=0;c<termsToGo.length;c++){
		if(termsToGo[c].match(nom)){
			//alert("Cancelling from main: "+nom);
			termsToGo.splice(c,1)
			//alert("termsToGo after splice: "+termsToGo)
			termsToGo=termsToGo.sort()
			}
		}
showMenuReport()
}// end funct removeFromTermsToGo

function showMenuReport(){

compositeTerm="";
//alert(1)

for(i=0;i<termsToGo.length;i++){
			compositeTerm += "<li>"+termsToGo[i]
		}


// Here, we establish to search term report. We look in arrays for each of the menu terms and consolidate them, then report them under their indiviidual category headings

var preview = "";

if(document.forms[0].SEEKBOTANICAL.value){preview += " <b>Plant type</b>: "+document.forms[0].SEEKBOTANICAL.value+". "}
if(document.forms[0].SEEKCOLOR.value){preview += " <b>Flower color</b>: "+document.forms[0].SEEKCOLOR.value+". "}
if(document.forms[0].SEEKGROWTHHABIT.value){preview += " <b>Growth habit</b>: "+document.forms[0].SEEKGROWTHHABIT.value+". "}
if(document.forms[0].SEEKHEATTOLERANCE.value){preview += " <b>Heat tolerance</b>: "+document.forms[0].SEEKHEATTOLERANCE.value+". "}
if(document.forms[0].SEEKFLOWERINGTIME.value){preview += " <b>Flowering time</b>: "+document.forms[0].SEEKFLOWERINGTIME.value+". "}

preview=preview.replace(/\,/g,", ");

if(preview.length<1){
//alert(document.MAINFORM.seekme.value)
preview=document.MAINFORM.seekme.value}

if(!departmentalQuery){
//alert(616)
document.getElementById('SEARCHPREVIEW').innerHTML=preview;}

hideButtonsTitlesAndTexts("showMenuReport")

showBlanksInFrame(631)
showSearchPreview()

}


function searchBoxClickHandler(passed){
parent.frames[1].document.getElementById('CONTROLSEEKME').value=document.MAINFORM.seekme.value;
if(passed=='Search here'){
	document.MAINFORM.seekme.value=''
	}
if( termsToGo.length>0){
	if(confirm('Searching form this search box \nwill remove your menu searches. \n\nDo you want to go ahead?') ){
			document.MAINFORM.seekme.value='';
			clearMenus()
		}
		else{
			//alert("Your preselections remain intact")

		}
	}

	else{
	//hideButtonsAndMenus()
	document.getElementById('SPECIALSEARCHES').innerHTML=document.MAINFORM.seekme.value;  // ???
	showSearchPreview()
	}
} //end funct searchBoxClickHandler


function clearMenus(){

termsToGo.length=0;

document.MENUCHOICES.reset()
document.MAINFORM.reset()


//here we clear the SPECIALS field
document.getElementById('SPECIALSEARCHES').innerHTML="";
searchReport="";


// Clear the menu arrays...
botNamesTermsToGo.length=0;
colorTermsToGo.length=0;
growthHabitTermsToGo.length=0;
heatToleranceTermsToGo.length=0;
floweringTimeTermsToGo.length=0;

document.getElementById('SEARCHPREVIEW').innerHTML="&nbsp;<br >Your selections have been cleared";
document.getElementById('CLEARSELBUT').style.visibility='hidden';

showBlanksInFrame(684)

}

function addToSpecials(passedName){
with(document.MAINFORM.seekme){if(value=="Search here"){value=""}}
showSearchPreview()
}

function goBackToProductPage(){

//alert("Going back to "+parent.cameFromHere)
var rogering;

if(!parent.cameFromHere || parent.cameFromHere=="undefined"){
	parent.cameFromHere="http://firstclassplants.com/FCP/home_firstclassplants.htm"
	}
var rogering = parent.cameFromHere

self.location=rogering

//if (navigator.appName.match(/Microsoft/)){
//	if(document.title=="Search the First Class Plants database"){setTimeout("goBackToProductPage()",200)}
	 //alert('Nochmal !');
	// return
//}

}

var store

function toDoOnLoad(){
	fixBBs()
	hideButtonsTitlesAndTexts("anfang")
	//store=document.getElementById('HIRESINNERDIV').innerHTML;
	if(parent.writeMenus){
		setTimeout("parent.writeMenus()",500) ;
	}
	parent.currentPage=self.location.href
	adjustForSmallerBrowserWindows();
}


////////////////////////////////////////////// end of part one   ////////////////////////////////////////


var searchTermReport=  "XXX";

function rearrangeFurniture(type){

//alert("As rearrangeFurniture runs, type is: "+type)

hideButtonsTitlesAndTexts("rearrangeFurniture")

if(type=="BACKTORESULTS"){
//alert("At this point, finalCount is: "+finalCount+"\nand type is: "+type)
	self.history.go(-1);

	if(!document.getElementById('BACKTORESULTSTEXTLINK').innerHTML.match(/search results/) ){
		document.getElementById('BACKTORESULTSTEXTLINK').innerHTML=" &laquo; Back to search results"
		}

	document.getElementById('SEEKME').style.visibility='visible';
	document.getElementById('ALTICONS').style.display="none"
	collectSpecialsForReport()

	document.getElementById('SEARCHPREVIEW').style.visibility='visible'
	document.getElementById('LUPE').style.visibility='visible'

	if(departmentalQuery==1){
		//alert("754 - going back to thumbs");
		document.getElementById('DEPTPIC').style.visibility='visible';
		document.getElementById('SEARCHPREVIEW').style.visibility='hidden'
		document.getElementById('YOURRESULTS').style.visibility='visible';
		document.getElementById('BACTOPRODUCTSPAGEMESSAGE').style.visibility='visible';
	}
	else{
		//alert(760);
		document.getElementById('DEPTPIC').style.visibility='hidden';
		document.getElementById('YOURRESULTS').innerHTML=document.MAINFORM.seekme.value;
		document.getElementById('YOURRESULTS').style.visibility='visible';
		document.getElementById('CLEARSELBUT').style.visibility='visible';
	}

	//alert("798 Showing CLEARSELBUT...")

	//document.getElementById('SPECIALSEARCHES').innerHTML=searchTermReport;

	if(finalCount>8){showScrollers()}

	setTimeout("document.getElementById('MAINFRAME').style.visibility='visible'",500)

	}

else if(type=="MAINRESULTS"){

	document.getElementById('MAINFRAME').style.visibility='visible'
	document.getElementById('TOPGREENLINE').style.visibility='visible';
	document.getElementById('BOTTOMGREENLINE').style.visibility='visible';

	if(departmentalQuery==1){
		//alert(925 +": "+resultsHeader)
		with(document.getElementById('YOURRESULTS')){
			if(innerHTML.match(/stars dark foliage/i)){innerHTML="New Stars &ndash; Dark Foliage"}
		}

		document.getElementById('YOURRESULTS').style.visibility='visible';
		//alert(927 +": "+document.getElementById('YOURRESULTS').innerHTML)
		document.getElementById('CLEARSELBUT').style.visibility='hidden';
		}
	else{
		//alert("772 Showing CLEARSELBUT... since departmentalQuery is "+departmentalQuery)
		document.getElementById('CLEARSELBUT').style.visibility='visible';
	}
//return


	document.getElementById('SEARCHPREVIEW').style.visibility='visible';

	if(!window.finalCount || window.finalCount<1){
		//alert("Display Page:\nfinalCount: "+finalCount);

		document.getElementById('NOBANANAS').style.visibility='visible';
		document.getElementById('YOURRESULTS').style.visibility='hidden';
		collectSpecialsForReport()
		//alert(2 +": "+searchTermReport)
		showBlanksInFrame(881)
		}

	else{
		collectSpecialsForReport()

		if(departmentalQuery!=1){document.getElementById('YOURRESULTS').innerHTML=resultsHeader}
		document.getElementById('YOURRESULTS').style.visibility='visible';
		//alert("departmentalQuery is: "+departmentalQuery)
		document.getElementById('LUPE').style.visibility='visible'
		if(finalCount>8)	{//alert(840)
			document.getElementById('MOREBUT').style.visibility='visible'
		}
		document.getElementById('YOURRESULTS').style.visibility='visible';
		}

	}

else if(type=="DETAILEDVIEW"){
	document.images['BIGPIC'].style.visibility='visible';
	document.getElementById('MAINFRAME').style.visibility='hidden'
	document.getElementById('OTHERNAMES').style.visibility='visible';

	document.getElementById('INDIVIDUALPLANTNAME').style.visibility='visible';
	document.getElementById('TOPGREENLINE').style.visibility='visible';
	document.getElementById('BOTTOMGREENLINE').style.visibility='visible';

//alert(document.getElementById('DAUMEN').innerHTML)

	if(document.getElementById('DAUMEN').innerHTML.length>1){
		document.getElementById('PRODUCTTHUMBDIV').style.visibility='visible';
		document.getElementById('DEPTPIC').style.visibility='hidden';
		}


	document.getElementById('BACKTORESULTSTEXTLINK').style.visibility='visible';

	document.getElementById('BACTOPRODUCTSPAGEMESSAGE').style.visibility='hidden'
	document.getElementById('SEARCHPREVIEW').style.visibility='hidden';
	document.getElementById('INDIVIDUALPLANTDETAILS').style.visibility='visible';

	//document.getElementById('INDIVIDUALPLANTNAME').innerHTML=reportTable;


	}

} // end funct rearrangeFurniture

var isNew,is241,isHD,isSE,isEE,isSunLover,isNoPinch,reportTable;


function showRelevantIcons(){

var iconReport="";

			if(self.isNew.match(/Yes|1/i))  {iconReport += "<img src='pix/new.gif' width=38 height=20  border=0  style=margin-right:2px alt='New variety!'>"}
			if(is241.match(/Yes/i))           {iconReport += "<img src=pix/2for1_logo.gif width=22 height=20 border=0 style=margin-right:2px alt='Two plants for the price of one!'>"}
			if(isSunLover.match(/Yes/i))    {iconReport += "<img src=pix/sunlover_logo.gif width=24 height=20 border=0 style=margin-right:2px alt='Sun Lover'>"}
			if(isHD.match(/Yes/i))            {iconReport += "<img src=pix/hd_logo.gif width=20 height=20 border=0  style=margin-right:2px alt='High Density'>"}
			if(isNoPinch.match(/Yes/i))     {iconReport += "<img src=pix/no_pinch_logo.gif width=20 height=20 border=0 style=margin-right:2px alt='No Pinch'>"}
			if(isSE && isSE.match(/Yes/i))            {iconReport += "<img src=pix/tinies/space_efficient_logo_tiny.gif width=12 height=12 border=0  style=margin-right:2px alt='Space Efficient' onclick='alert(\"This variety is Space Efficient\")'>"}
			if(isEE && isEE.match(/Yes/i))			 {iconReport += "<img src=pix/tinies/energy_efficient_logo_tiny.gif width=12 height=12 border=0 style=margin-right:2px alt='Energy Efficient' onclick='alert(\"This variety is Energy Efficient\")'>"}

			document.getElementById('SPECIALSEARCHICONS').innerHTML=iconReport;
			document.getElementById('SPECIALSEARCHICONS').style.visibility='visible';
			document.getElementById('SPECIALSEARCHICONS').style.textAlign='right';

 isNew=is241=isHD=isSunLover=isNoPinch="";

 			if(isSE)  {isSE=""}
			if(isEE)  {isEE=""}

 //alert(944+": iconReport:\n"+iconReport)

}



function collectSpecialsForReport(){

	searchTermReport = ""; //"&nbsp;<BR>";

	var numberOfExtras=0;
	with (document.forms[0]){

		if(twofor1.checked==true || HD.checked==true || EE.checked==true || SE.checked==true || sunlover.checked==true || newt.checked==true || nopinch.checked==true){

			//alert("SE.checked: "+SE.checked)

			specialChecked=1
			searchTermReport +="<div align=right style=padding-right:10px;color:#FF5C0F><!-- [ -->";

			if(newt.checked==true)       {searchTermReport += " New, ";numberOfExtras++}
			if(twofor1.checked==true)  {searchTermReport += " 2 for 1, ";numberOfExtras++}
			if(HD.checked==true)         {searchTermReport += " High Density, ";numberOfExtras++}
			if(EE.checked==true)       {searchTermReport += " Energy Efficient, ";numberOfExtras++}
			if(SE.checked==true)       {searchTermReport += " Space Efficient, ";numberOfExtras++}
			if(sunlover.checked==true)  {searchTermReport += " Sun lover, ";numberOfExtras++}
			if(nopinch.checked==true)  {searchTermReport += " No Pinch, ";numberOfExtras++}

			//if(numberOfExtras>3){searchTermReport = searchTermReport.replace(/\&nbsp\;<BR>/,"")}
		//	alert("948 Showing CLEARSELBUT...")
			document.getElementById('CLEARSELBUT').style.visibility='visible';
		}

		searchTermReport=searchTermReport.substring(0,searchTermReport.length-2); // kill final comma

	}

	//alert("searchTermReport.length: "+searchTermReport.length)

	document.getElementById('SPECIALSEARCHES').innerHTML=searchTermReport;
	document.getElementById('SPECIALSEARCHES').style.visibility='visible';

}


function hideButtonsTitlesAndTexts(caller){
//alert("hideButtonsTitlesAndTexts runs\ncalled from "+caller)

document.getElementById('ANOTHERVIEW').style.visibility='hidden'

	document.images['BIGPIC'].src="pix/t.gif";
	document.images['BIGPIC'].style.visibility='hidden';

	var thingsToHide=new Array('SEARCHYOURWAY','INDIVIDUALPLANTNAME','SPECIALSEARCHES','NOBANANAS','MOREBUT','BACKTORESULTSTEXTLINK','INDETAIL','TOPGREENLINE','BOTTOMGREENLINE','YOURRESULTS','OTHERNAMES','LUPE','BOTTOMPANELBG','SEARCHFOR','INDIVIDUALPLANTDETAILS','SPECIALSEARCHICONS','CLEARSELBUT','PRODUCTTHUMBDIV');
	for (v=0;v<thingsToHide.length;v++ ){document.getElementById(thingsToHide[v]).style.visibility='hidden'}
}

function showSearchPreview(){
//alert("showSearchPreview runs!")

	if(document.getElementById('SEARCHFOR').style.visibility=='hidden'){
	hideButtonsTitlesAndTexts("showSearchPreview")



		//alert("departmentalQuery: "+departmentalQuery)

		if(departmentalQuery == 1){
				//alert("910 Hiding CLEARSELBUT since departmentalQuery is: "+departmentalQuery)
				document.getElementById('CLEARSELBUT').style.visibility='hidden';
				document.getElementById('YOURRESULTS').style.visibility='visible'
				//document.getElementById('SEARCHPREVIEW').style.visibility='hidden'

		}
		else {
				//showBlanksInFrame(1004)
				//alert("942 Showing CLEARSELBUT since departmentalQuery is: "+departmentalQuery)
				document.getElementById('CLEARSELBUT').style.visibility='visible';
				document.getElementById('SEARCHPREVIEW').style.visibility='visible'
				document.getElementById('SEARCHFOR').style.visibility='visible'

				document.getElementById('TOPPANELBG').style.visibility='visible';
				document.getElementById('TOPGREENLINE').style.visibility='visible';
				document.getElementById('BOTTOMGREENLINE').style.visibility='visible';
			}
	}

	collectSpecialsForReport()
}


function styleScrollers(){
 if(document.all){

	with(document.getElementById('SEARCHPREVIEW').style){
		scrollbarFaceColor="#FFEBC2";
		scrollbarHighlightColor="#EBFEDE";
		scrollbarArrowColor="#FF9900";
		scrollbarShadowColor="#CCB0BD";
		scrollbarDarkShadowColor="#ffffff";
		scrollbarBaseColor="#FEEED6";
		scrollbarLightShadowColor="#FF99FF";
		scrollbarTrackColor="#E6F3E0";
		width="505px"
	}

	//alert("scrollbars styled!")
 }

}

function showBlanksInFrame(caller){
	document.images['BIGPIC'].style.visibility='hidden';
	document.getElementById('MAINFRAME').style.visibility='visible';
	self.frames[0].location="http://"+self.location.host+"/FCP/blank_results.htm";
	document.getElementById('BOTTOMPANELBG').style.visibility='visible';
//alert("Showed Blanx from: "+caller)
}



// transferred from main page Tuesday, December 18, 2007...

function checkAndSendHiResPswd(){
var v=document.HIRESPSWDCHECKER.HIRESPSWD.value;
alert(v)
}



function registerForHiRes(){
document.getElementById('HIRESINNERDIV').innerHTML="";
document.getElementById('HIRESINNERDIV').innerHTML=document.getElementById('REGISTERFORMDIV').innerHTML
}

function checkAndSendHiResRegistration(){
document.REGISTERFORM.submit()
document.getElementById('HIRESINNERDIV').innerHTML=store;
alert("Your registration has been sent to Selecta First Class.\n\nPlease check your email for your password\nand enter it in the password box on this page.\nYou can then start downloading Hi-Res images.");

document.getElementById('HIRESPSWD').style.backgroundColor='#FC9E1C';
document.getElementById('HIRESPSWD').value='PASSWORD HERE';
setTimeout("document.getElementById('HIRESPSWD').style.backgroundColor='#ffffff';document.getElementById('HIRESPSWD').value='';",2000)

}

function reactToHiResIconClick(){
if(parent.hirescollection.length>0){
var hiResImageReport='Your collection of hi-res images contains:<br>';


	for (var i in parent.hirescollection){
	var hiray=parent.hirescollection[i].split(/~/,100);

	hiResImageReport+="<img src='"+hiray[1]+"' width=45px height=45px> <a href='#' onclick=downloadSingleHiResImage('"+hiray[1]+"',this.innerHTML)>"+hiray[0]+"</a><br>"
//downloadSingleHiResImage
	}

	var downloadAllBut=document.getElementById('DAB').innerHTML;

	document.getElementById('HIRESINNERDIV').innerHTML=hiResImageReport+downloadAllBut
	document.getElementById('HIRESINNERDIV').style.display='block';
	}
document.getElementById('HIRESINTRO').style.display='block'
}

function downloadSingleHiResImage(im,imname){
//alert(im+"\n"+imname)
im=im.replace(/\/thumbs/,"");
im=im.replace(/_t\.gif/,".jpg");
//alert(im)
singleDownloadPage="singledownloadpage.htm?"+im+"~"+imname
var noo = window.open(singleDownloadPage, '', 'width=483,height=400,top=10,left=10, scrollbars=no,resizable=yes,menubar=no,location=no,toolbar=no,status=0')
}

function downloadAll(){
alert("Would download all pix")
}


function showProdPic(obj){
	// reset text to green
	var viewtableTDColl=document.getElementById('PRODTHUMBTABLE').rows;
	for(var i=0;i<viewtableTDColl.length;i++){viewtableTDColl[i].childNodes[1].style.color='#006600'}
	//alert(obj.childNodes[0].childNodes[0].tagName)
	var basepic=obj.childNodes[0].childNodes[0].src;
	//alert(basepic)
	basepic=basepic.replace(/prod_thumbs\//,"")
	// standard view
	if(basepic.match(/_s_/)){ basepic=basepic.replace(/production_pix\//,""); basepic=basepic.replace(/_s_pt/,"")}
	// closeup view
	else if(basepic.match(/_c_/)){basepic=basepic.replace(/_c_pt/,"_c_p")}
	// production view
	else{basepic=basepic.replace(/_(.)_pt/,"_$1_p")}
	//alert(basepic)
	document.images['BIGPIC'].src=basepic
	obj.childNodes[1].style.color='#FFB703'
}

var indivTitle="";

function showAlt(imsrc){

//alert("imsrc:"+imsrc)

imsrc=imsrc.replace(/.+\/thumbs\/(\d+.+)_t\.gif/,"$1~");
var bigPicName=window.indivTitle;
bigPicName=bigPicName.replace(/<.+?>/g,"");
bigPicName=bigPicName.replace(/\™/g,"TRADEMARK");

//bigPicName=unescape(bigPicName);
//alert("bigPicName: "+bigPicName)


imsrc+=bigPicName;

//alert("Showing " +imsrc+ " as big pic")

self.frames[0].location="http://"+self.location.host+"/cgi-bin/FirstClassDB/show_one_item_07.cgi?line="+imsrc;
}

var tempAltname="&nbsp; &laquo; Click for alternative";

function showAltAlt(im){

with(document.getElementById('CLICKFORALTS')){
	//tempAltname=innerHTML;

	innerHTML="&nbsp; "+im.alt;
	//style.backgroundColor="gold";
	if(parent.is_gecko){style.paddingTop="5px"}
	style.display="block";
	}
}

function hideAltAlt(im){
	with(document.getElementById('CLICKFORALTS')){
	//style.display="none";
	innerHTML=tempAltname
	}
}


if(document.all){document.getElementById('VIEWOPTIONSDIV').style.height="44px"}

var currentBigPic="";

function checkForAnotherView(){

if(currentBigPic.match(/trixi/i) ){

 if(currentBigPic.match(/_1\.jpg/)){
	//alert(currentBigPic)
	currentBigPic=currentBigPic.replace(/_1\.jpg/,"_2.jpg");
	//alert(currentBigPic)
 }

else  if(currentBigPic.match(/_2\.jpg/)){
	//alert(currentBigPic)
	currentBigPic=currentBigPic.replace(/_2\.jpg/,"_1.jpg");
	//alert(currentBigPic)
 }

document.getElementById('BIGPIC').src=currentBigPic


}
}

var scriptLoaded=1;
var pageLoaded=0;

//alert("ss Loadad")


