//alert("menudriver popper loading...")

//------------Tuesday, May 30, 2006---------------------------------------
// revised Saturday, Wednesday, May 30, 2007

if(document.location.href.match(/selecta|www\./i)){
	self.location="http://firstclassplants.com/FCP/first_class_plants.html"
	}


//var currentnewsflash="http://firstclassplants.com/m/SFC_NewsFlash_May2009.pdf";
var currentnewsflash="http://firstclassplants.com/m/SFC_NewsFlash_Feb2010.pdf";

var hirescollection=new Array();
var cameFromHere;

var agent = navigator.userAgent.toLowerCase();
var os = navigator.platform.toLowerCase();

var is_windows = (os.indexOf("win") != -1);
var is_mac = (os.indexOf("mac") != -1);
var is_netscape = (navigator.appName == "Netscape");
var is_ie = (agent.indexOf("msie") !=-1);

var major = is_ie? parseInt(agent.substring(agent.indexOf('msie')+5)):parseInt(navigator.appVersion);
var minor = is_ie? parseFloat(agent.substring(agent.indexOf('msie')+5)):parseFloat(navigator.appVersion);
var is_modern_mac =(is_ie && is_mac && minor >= 4)
var is_mac_ie45 = (is_ie && is_mac && minor == 4.5);
var is_mac_ie5 =  (is_ie && is_mac && minor == 5 );
var is_mac_ie52 =  (is_ie && is_mac && major == 5 && minor > 5.1);
var is_modern_win = (is_ie && is_windows && major >= 4);
var is_ie5min_win = (is_ie && is_windows && major >= 5);
var is_ns_4min = (is_netscape && major >= 4);
var is_gecko = (agent.match(/gecko/));
var is_firefox = (agent.match(/firefox/));
var ns_version;

if(is_netscape){
ns_version = agent.toString();
ns_version = ns_version.replace(/.+netscape\//,"");
ns_version = parseInt(ns_version)
//alert(ns_version)
}

var is_ns_8plus = (is_netscape &&  ns_version>7)

var ff_version;
if(is_firefox){ff_version = agent.toString();
ff_version = ff_version.replace(/.+firefox\//,"");
ff_version = parseInt(ff_version)
//alert(ff_version)
}
var is_ff_104plus = (is_firefox &&  ff_version>1)
//alert(major)

var lang = is_ie? navigator.userLanguage.substring(0,2):navigator.language;

var finger = (document.all) ? "hand" : "pointer";

historyList = new Array();

var tup;

var messages=new Array(agent, os, is_windows, is_mac, is_netscape, is_ie, is_modern_mac, is_mac_ie45, is_mac_ie5, is_modern_win, is_ie5min_win, is_ns_4min, is_ns_8plus,is_gecko,is_firefox);

message_names=new Array("agent","os","is_windows","is_mac","is_netscape","is_ie","is_modern_mac","is_mac_ie45","is_mac_ie5","is_modern_win","is_ie5min_win","is_ns_4min","is_ns_8plus","is_gecko","is_firefox");

var frameDoc;

function showBrowser(){
var report="";
for (var i in messages){report+=message_names[i]+": "+messages[i]+"\n";}
//alert(report)
if(is_mac_ie5){alert("This is IE5 on a Mac")}
}

showBrowser()
var modern=0;

modern=(document.getElementById)? 1:0;

//alert(modern)


var toplevel=1;
var basedir="";
var toploaded=0;
var menu="x";
var finishedKlapping=0;
 if (modern) standab=15;


var o="";var type="" // intranet web file
var p="page index not yet set";
var chP="page forename not yet set";
var urlements=self.location.toString().split("/",10);
for (el=0;el<urlements.length-1;el++) {
	//alert("Element "+el+": "+urlements[el])
	basedir += urlements[el]+"/";
}



/*

HOME
ABOUT US
NEWS
PRODUCTS
CARE LIBRARY Monday, November 19, 2007 removed!
SALES
PEST CONTROL
CONTACT

*/


var about_bb,news_bb,products_bb,sales_bb,online_availability_bb,justCalledFromALink=0;

//care_bb,

function choosePage(passedFromMenuLink,type) {

linkArgs=passedFromMenuLink.split("Z");
var mN=linkArgs[0];
var chP=linkArgs[1];
//alert(mN+"\n"+chP)

//alert("CP runs, called from a "+type+"\nas justCalledFromALink is: "+justCalledFromALink+"\nand the product name is: "+products_menu_items[chP])
// perhaps this is causing Stefan's problem?
// comment: products_menu_items is the same as care_menu_items so counts for both
// the line serves to prevent a second click after a click on a TD
//if(justCalledFromALink == products_menu_items[chP]){alert(999);justCalledFromALink=0;return false}
//if(mN=="products"){alert("Looking for: "+products_menu_items[chP]+" in: "+mN)}
//else if(mN=="care"){alert("Looking for: "+care_menu_items[chP]+" in: "+mN)}
//alert("Looking for: "+products_menu_items[chP]+" in: "+mN)

var menu_wanted=eval(mN+"_menu_items");
var pageWanted=menu_wanted[chP]

pageWanted=pageWanted.toLowerCase();
pageWanted=pageWanted.replace(/\s+/g,"_");
pageWanted=pageWanted.replace(/\&trade;/g,"");

//alert(""+pageWanted+"")

//|care
if( mN.match(/products/i) ){
	//alert("Products: "+pageWanted)
	if(pageWanted=="program_information"){pageWanted = "http://"+self.location.host+"/FCP/program_information.htm"}
else{
	pageWanted = "http://"+self.location.host+"/FCP/"+mN + "_dept/" + pageWanted +"_"+mN+"_intro.htm"
}
	}


	else if(mN.match(/online/i) ){
		if(pageWanted=="registered_user"){window.open('http://12.69.83.218/WEB_OBJSELH/LOGONX.MBR','CustomerData', 'width=650,height=400,top=10,left=10,screenX=10,screenY=10,scrollbars=yes,resizable=yes,status=yes');
		return
	}

	else if(pageWanted=="availability"){

		var tempZiel="http://12.69.83.218/WEB_OBJSELP/INOC01.pgm?CGIINP01=AccessFree&CGI103=%20%20%20%20SNN01N2N')";

		window.open(tempZiel,'CustomerData', 'width=660, height=590,top=10,left=10,screenX=10,screenY=10,scrollbars=yes,resizable=yes,status=yes');
		return
	}

	else if(pageWanted=="download_availability"){

		var tempZiel="http://12.69.83.218/WEB_OBJSELP/WSE002.pgm?CGIINP01=AccessFree&CGI103=N')";

		window.open(tempZiel,'CustomerData', 'width=660, height=760,top=10,left=10,screenX=10,screenY=10,scrollbars=yes,resizable=yes,status=yes');
		return
	}


	}

else{
	//alert("NOT Products: "+pageWanted)
	//if(pageWanted.match(/recip/)){
	//	pageWanted="recipies/"+pageWanted;
		//alert("Recipies: "+pageWanted)
	//}

	pageWanted = "http://"+self.location.host+"/FCP/"+pageWanted+".htm"
	//alert(pageWanted)
}

//alert("pageWanted: "+pageWanted)

//if(pageWanted.match(/authorized/) ){
//	window.open("http://217.59.50.194/WEB_OBJSELH/LOGONX.MBR","CustomerData","width=650,height=400,top=10,left=10,screenX=10,screenY=10,scrollbars=yes,resizable=yes,status=yes")
//	return false
//	}
//else
	if(pageWanted.match(/current/) ){	window.open(currentnewsflash,"CurrentNewsFlash","width=800,height=500,top=10,left=10,screenX=10,screenY=10,scrollbars=yes,resizable=yes,status=yes")
	return false
	}

	else if(pageWanted.match(/minifamous/) ){
		pageWanted = "mf_club_news.htm"
	}


// alert(pageWanted)

self.frames[2].document.location=pageWanted;

//alert('menu hidden as choosePage ends')

if(type && type=="link"){justCalledFromALink=products_menu_items[chP]}
// to avoid repeat call from stubborn bubble
//alert("justCalledFromALink: "+justCalledFromALink)

return 0
}


var about_menu_items
var news_menu_items
//var care_menu_items;
var products_menu_items;
var sales_menu_items;
//var online_availability_menu_items;

about_menu_items= new Array(
"About Selecta First Class",
"Targeted Breeding & Production",
"A Winning Range",
"Our Award Winners"
);

news_menu_items = new Array(
"News from Selecta First Class",
"News of the MiniFamous Club",
"Current News Flash",
"News Flash Archive",
"Sign-Up for our Email Newsletter",
"Job Opportunities"
);


//products_menu_items=care_menu_items = new Array(
products_menu_items = new Array(
"Program Information",
//"Angelonia",
"Argyranthemum",
"Begonia",
"Bracteantha",
"Calibrachoa",
"Dianthus",
"Diascia",
//"Heliotropium arborescens",
//"Gaura",
"Impatiens New Guinea",
"Lobelia",
"Nemesia",
"Osteospermum",
"Pelargonium",
"Petunia",
"Poinsettia",
"Other companion plants",
"Specialty garden plants",
"Verbena"
);


sales_menu_items=new Array(
"Distribution",
"Standard Liner Program",
"TrixiLinerTM Program",
"Marketing Tools",
"Recipes with Plants",
"Trial Presentations",
"Self Propagation & Licensing"
);

//online_availability_menu_items=new Array(
//"Registered User",
//"Availability",
//"Download Availability"
//);


var menuContents=new Array();
//registers above arrays of menu items
var menuNames=new Array("about","news","products","sales"); // ORDER MATTERS!, "care",		 ,"online_availability"
for (i=0;i<menuNames.length;i++) {
	menuContents[i]=eval(menuNames[i]+"_menu_items");
}

var menusHaveBeenWrittenForThisPage;

function writeMenus(tup) {
var thisMenuId;
menuString="";
//alert("I would write the menus")

frameDoc=self.frames[2].document;
//if(tup=="BALKAN"){//alert('B');
//	frameDoc=self.frames[2].frames[0].document;
//}
self.frameDoc=frameDoc;
top.tup=tup;
//alert("top.tup: "+top.tup)


//if(menusHaveBeenWrittenForThisPage==self.frames[2].location.href){
//better test for the existence of a menu
//if(frameDoc.getElementById('care')){
//	alert("Doppelgemoppelt!\n"+menusHaveBeenWrittenForThisPage)
	//return
	//}
//already written


for (m=0;m<=menuContents.length-1;m++) {

	var menuString="";

	thisMenuId=menuNames[m];

//alert("writing Menu "+menuNames[m]);

	var currentMenuDiv=frameDoc.createElement("DIV");
		//currentMenuDiv.setAttribute("className", "barstyle");
		currentMenuDiv.setAttribute("id", thisMenuId);
		frameDoc.body.appendChild(currentMenuDiv);
		currentMenuDiv.className="barstyle"; // NB this usage

	var currentMenuTable=frameDoc.createElement("TABLE");
		currentMenuTable.setAttribute("width", "100%");
		currentMenuTable.setAttribute("cellSpacing", "0");
		currentMenuTable.setAttribute("cellPadding", "0");
		currentMenuTable.setAttribute("border", "0");
	currentMenuDiv.appendChild(currentMenuTable)

	var currentTableBody=frameDoc.createElement("TBODY");
	currentMenuTable.appendChild(currentTableBody);


for (var i in menuContents[m]){
	//	alert(menuNames[m]+": "+menuContents[m]);

		var currentTableRow=frameDoc.createElement("TR");
			currentTableBody.appendChild(currentTableRow)

		var currentTableCell=frameDoc.createElement("TD");
			currentTableCell.className="menustyle";  // NB this usage
			currentTableCell.setAttribute("height", "22");
			currentTableCell.setAttribute("bgColor", "#CDE8C1"); //light  green //#FFF2C1 light beige-yellow

		currentTableRow.appendChild(currentTableCell);
				currentTableCell.style.paddingLeft="4px";
				currentTableCell.style.paddingTop="4px";
				currentTableCell.style.paddingRight="4px";
				currentTableCell.style.height="22px";

		//var linkElement=frameDoc.createElement("A");
		var linkElement=frameDoc.createTextNode(menuContents[m][i]);

				currentTableCell.appendChild(linkElement);

			//	if(menuContents[m][i].match(/TM/)){
							//alert("Just created "+menuContents[m][i])
			//				}

				currentTableCell.onmouseover=function(){
					if(document.all){this.style.cursor='hand'}else{this.style.cursor='pointer'}
					this.style.backgroundColor='#FFCE4F' // navileiste menu bg  orange color
					//this.style.color='#D65023' // red #CC0000   orange #E16411
					};
		currentTableCell.onmouseout=function(){
			this.style.backgroundColor='#CDE8C1';
			//this.style.color='#298C19' //
		};

		// for functions see below

		var linkLiteral = menuNames[m]+"Z"+i;
		//alert(linkLiteral)

		// these have been moved here to use the passable variables
				currentTableCell.setAttribute("id", linkLiteral);
				currentTableCell.onclick=function(){choosePage(this.id,"TD");cancelBubble=true}
				// Ff won't accept a name attribute for a TD cell
				currentTableCell.style.borderWidth="0px";
				currentTableCell.style.borderBottomWidth="1px";
				currentTableCell.style.borderStyle="solid";
				currentTableCell.style.borderColor="#ffffff";

				currentTableCell.innerHTML=currentTableCell.innerHTML.replace(/TM/,"&trade;")

				//linkElement.setAttribute("name", linkLiteral);
				//linkElement.onclick=function(e){choosePage(this.name,"link");cancelBubble=true;return false}
				//linkElement.onmouseover=function(){if(document.all){this.style.cursor='hand'}else{this.style.cursor='pointer'}window.status=""; return true}
				//linkElement.innerHTML=menuContents[m][i] // TextNode won't show HTM special chars
				//linkElement.className="menulinker"; // NB this usage

		} //end individual link items


	} // end menu group



// adjust menu lengths if necessary:
frameDoc.getElementById('news').style.width='200px';
//frameDoc.getElementById('online_availability').style.width='140px';

// boundingboxes

//alert("is_ns_8plus:"+is_ns_8plus); alert("is_firefox:"+is_firefox)

	about_bb=new Array(77,280,0,100)
	news_bb=new Array(160,380,0,135)
	products_bb=new Array(238,440,0,380)
	//care_bb=new Array(336,535,0,406)
	sales_bb=new Array(390,600,0,160)
	//online_availability_bb=new Array(560,700,0,70)

finishedKlapping=1;
//alert("zte!")

//if(   !self.frames[2].location.href.match(/willkommen|blank|sent/)   )   {addBack()}

//if(gridsOn==1){showGrids()}

menusHaveBeenWrittenForThisPage=frameDoc.location.href;
if(!top.dontAddMeToHistoryList){
	//alert("Pushing "+self.frames[2].location.href+"\non to the history list...")
	historyList.push(frameDoc.location.href);
}
else{
	top.dontAddMeToHistoryList=0
	if(historyList.length>1){historyList.pop()}	 // always keep willkommen page
	}


var divReport="Div Report:\n";

var divColl=frameDoc.getElementsByTagName("DIV")

for(var d=0;d<divColl.length;d++){
divReport =+ divColl[d].id
}
	//alert(divReport)

	frameDoc.onmousemove = mouseCheck;

} // end function writeMenus

//if(window.Event && document.captureEvents){document.captureEvents(Event.MOUSEMOVE);} // no longer needed ??
// no need to target frame here

function mouseCheck(e) {
	//alert()


if (!e) {//alert("internet explorer")
	e = window.event||window.Event;
	xx = self.frames[2].event.x; //  NOT RECOGNIZED BY MACS: +document.body.scrollLeft
	yy = self.frames[2].event.y; //  NOT RECOGNIZED BY MACS: +document.body.scrollTop-1
}

else{ //alert("firefox etc.")
	xx = e.clientX
	yy = e.clientY
}

//window.status="X:"+xx+" Y "+yy;
//alert("X:"+xx+" Y "+yy)

if(
	frameDoc &&
	frameDoc.getElementById(menuNames[p]) &&
	frameDoc.getElementById(menuNames[p]).showing &&
	frameDoc.getElementById(menuNames[p]).showing=="yes"
){

	var bbarray=eval(menuNames[p]+"_bb") //alert(bbarray)

	var xl=bbarray[0] // left limit
	var xr=bbarray[1] // right limit
	//var yt=bbarray[2] // top limit
	// dynamic in case of scroll...
	//alert(frameDoc.body.scrollTop)
	var yt=0; // frameDoc.body.scrollTop in IE adjusts automatically, it seems...
	var yb=yt+bbarray[3] // bottom limit
	//alert("bbarray for "+menuNames[p]+": "+bbarray+"\nxx: "+xx+"\nyy: "+yy)

	if(xx<xl || xx>xr || yy<0 || yy>yb){

		//alert(menuNames[p]+" is Out of range!\nxx: "+xx+" - yy: "+yy+"\nbbarray for "+menuNames[p]+": "+bbarray);
		frameDoc.getElementById(menuNames[p]).style.visibility='hidden';

		frameDoc.getElementById(menuNames[p]).showing="no" //vitalto avoid repeats
	}
}


// Now we handle the pop-down menus in the search page

else if(frameDoc.title.match(/Search/)){self.frames[2].ratCheck(xx,yy)}

return true

} // end mouseCheck


function hideAll(caller){
var aaaaa=0;
for (var h=0;h<menuNames.length;h++) {
	var q=menuNames[h]

	//alert("q:"+q)
	var teshd = frameDoc.getElementById(q);
	if(!teshd  || teshd=="undefined"){alert("445: framedoc undef or nonexistant")}

	else if(frameDoc.getElementById(q) && frameDoc.getElementById(q).style.visibility=="visible"){
		//alert("hideAll called from:"+caller+"\nfor:"+frameDoc.getElementById(q).id)
		frameDoc.getElementById(q).style.visibility='hidden'
		}
	}//end for loop
}

function showIt(p,leftPos) {// p is the number of the menu starting form zero
leftPos+="px";
//alert("p is:"+p+"\nand leftPos is:"+leftPos)


//alert("finishedKlapping: "+finishedKlapping)

if(finishedKlapping==1){

self.p=p; // the index number
p = menuNames[p];

//alert("Full p:"+p)

//first hide all menus:
hideAll(p)

//alert("467: "+frameDoc.getElementById(p).id)

// Now show this menu:
		if(frameDoc.getElementById(p)){

		//	if( !leftPos.toString().match(/px/) ){leftPos+="px"}
		//alert("leftPos for "+p+" is "+leftPos)

			frameDoc.getElementById(p).style.left=leftPos;
			var topPos=frameDoc.body.scrollTop
			frameDoc.getElementById(p).style.top=topPos;
			frameDoc.getElementById(p).style.visibility='visible';


		//alert(frameDoc.getElementById(p).style.left)

		}

//alert("The coordinates:\nLeft: "+leftPos+"\nWidth:"+frameDoc.getElementById(p).offsetWidth+"\nHeight:"+frameDoc.getElementById(p).offsetHeight);

		//alert(frameDoc.getElementById(p).id)

		if(frameDoc.getElementById(p)){
			frameDoc.getElementById(p).showing="yes"
		}

} //end finishedKlapping check

} //endfunct showIt

p=0;


function hideIt(p) {
//alert(1)
if(top.tup && top.tup.match(/balk/i)){
//	alert("Show lower frame!")
	setTimeout("self.frames[2].document.getElementById('vset').rows='130,*'",100)
}
// p is the number of the menu starting from zero

p = menuNames[p];
//alert("Hideit runz for "+toHide)
frameDoc.getElementById(p).style.visibility ='hidden';
frameDoc.getElementById(p).showing="no"
//alert(frameDoc.getElementById(p).showing)

}


// see subbar.txt for submenu code
function replaceString(oldS,newS,fullS) {
 for( var i=0; i<fullS.length; i++) {
		if( fullS.substring(i,i+oldS.length)  == oldS) {
		fullS = fullS.substring(0,i)+newS+fullS.substring(i+oldS.length,fullS.length)
		}
	}
	//alert(fullS);
	return fullS
}
//alert("menudriver has loaded.")

var mac=0;if(navigator.appVersion.indexOf('Mac')!=-1){mac=1;self.resizeTo(1015,548)}
//else{self.resizeTo(1015,578)}


//set desired mouseover color global variables here:
var overTextColor="#990000";
var overBgColor="#FFB703"

function mOver(o){
o.style.origBgcolor=o.style.backgroundColor;o.style.origTextColor=o.style.color;
o.style.backgroundColor=overBgColor;o.style.color=overTextColor
handOver(o)
}

function mOut(o){
o.style.backgroundColor=o.style.origBgcolor;o.style.color=o.style.origTextColor;handOut(o)}

function handOver(o){
if(document.all){o.style.cursor='hand'}
else{o.style.cursor='pointer'}
}

function handOut(o){o.style.cursor='auto'}
// call thus: onmouseover=mOver(this)  onmouseout=mOut(this)

function colorNaviButs(ref){
	var controlAColl=self.frames[1].document.getElementsByTagName("A");
	for(t=0;t<controlAColl.length;t++){
		if(controlAColl[t]){controlAColl[t].className=""} // removes green color from all navipanel links
	}
	if(ref && self.frames[1].document.getElementById(ref)){self.frames[1].document.getElementById(ref).className='linkarrived';}
	// adds green color to this link
}


var deptDescr="";

function registerMe(tup){

	cameFromHere=self.frames[2].location.href;
	//alert("cameFromHere:"+cameFromHere)

	self.tup=tup;
	var butName=tup+"BUT";
	//alert(butName)
	if(tup!="BALKAN"){colorNaviButs(butName)}
	currentPage=self.frames[2].document.location.href;
	setTimeout('writeMenus(tup)',100)

}


function handleErrors(errorMessage, url, line)
	{
	emsg = "There was an error on this page.\n\n";
	emsg += "An internal programming error may keep\n";
	emsg += "this page from displaying properly.\n";
	emsg += "Click OK to continue.\n\n";
	emsg += "Error message: " + errorMessage + "\n";
	emsg += "URL: " + url + "\n";
	emsg += "Line #: " + line;
	if( confirm(emsg) ) {}else{window.close()}
	return true
	}
//onerror = handleErrors;

onerror = function(){return true;}

var currentPage;
topLoaded=1;
