var DHTML = (document.getElementById || document.all || document.layers);

function windowopen(URL) {

	window.open(URL, "Graemont.com", "width=500,height=300,scrollbars=no,resizable=yes,menubar=no,status=no");

}

function getObj(name)	{
	  if (document.getElementById)	{    	// DOM level 1 browsers: IE 5+, NN 6+
	  	this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
	  }
	  else if (document.all)	{  			// IE 4
		this.obj = document.all[name];
		this.style = document.all[name].style;
	  }
	  else if (document.layers)  { 			// NN 4
	   	this.obj = document.layers[name];
	   	this.style = document.layers[name];
	  }
}

// this function makes the object visible
function showpic(visiblechunk) {
		if (!DHTML){
		 alert ('Sorry, your browser can\'t show the login box!');
		 return;
		}
		var displayedpic = new getObj(visiblechunk);
		
		displayedpic.style.visibility = 'visible';
		document.theForm.username.focus();
	}
	
// this function makes the object invisible	
function hidepic(invisiblechunk) {
		if (!DHTML){
		 alert ('Sorry, your browser can\'t hide the login box!');
		 return;
		}
	
		var hiddenpic = new getObj(invisiblechunk);
		
		hiddenpic.style.visibility = 'hidden';
	}
	
function toggle(theChunk) {
		if (!DHTML){
		 alert ('Sorry, your browser can\'t hide the login box!');
		 return;
		}
	
		var hiddenpic = new getObj(theChunk);
		
		if (hiddenpic.style.visibility != 'hidden' && hiddenpic.style.visibility!="visible")
			hidepic(theChunk);

		if (hiddenpic.style.visibility == 'hidden')
			showpic(theChunk);
		else
			hidepic(theChunk);
	}







		//WARNING: all values in MenuLength[] must add up to 800px! for optumum viewing expecience.
		//Also the zero before each submenu is a flag for a submenu (when set to 1 the option for a submenu is turned on).  that feature is currently not implamented with this version of Jon Francis' menu system.


		/*	****************************************
			**********TEMPLATE TO FOLLOW************
			****************************************
			*		x = the current submenu        *
			****************************************

			MenuItem[which menu-1][0]		= "Menu header!./menuClick.html?x";				//notice the !./menuClick.html?x
			MenuItem[which menu-1][0+x]		= "0submenu title!URL assoc. with submenu		//notice the 0 before the menu title
			.
			.
			.
			MenuLength = # of pixels wide you want the menu to be.  Note that all menu widths must add up to 800px
	
		*/


		MenuItem		= new Array();
		MenuLength		= new Array();

		MenuItem[0]		= new Array();
		MenuItem[0][0]	= "Home!./index.html";
		MenuItem[0][1]	= "0Home!./index.html";
		MenuItem[0][2]	= "0Site&nbsp;Map!site_map.php";
		MenuItem[0][3]	= "0Contact&nbsp;Info!contact_info.php";
		MenuItem[0][4]	= "0Login!javascript:toggle(\"login\");";
		MenuLength[0]	= 94;

		MenuItem[1]		= new Array();
		MenuItem[1][0]	= "For&nbsp;Sale!./for_sale.php";
		MenuItem[1][1]	= "0In&nbsp;the&nbsp;USA!./for_sale_domestic.php ";
		MenuItem[1][2]	= "0In&nbsp;Europe!./for_sale_europe.php ";
		MenuItem[1][3]	= "0FSBO!./for_sale_classified.php ";
		MenuItem[1][4]	= "0Virtual!./for_sale_virtual.php";
		MenuItem[1][5]	= "0Articles!./for_sale_articles.php";
		MenuLength[1]	= 94;

		MenuItem[2]		= new Array();
		MenuItem[2][0]	= "Selling!./selling.php ";
		MenuItem[2][1]	= "0Help!./selling_info.php ";
		MenuItem[2][2]	= "0Classifieds!./selling_classifieds.php ";
		MenuItem[2][3]	= "0Network!./network.php ";
		MenuLength[2]	= 89

		MenuItem[3]		= new Array();
		MenuItem[3][0]	= "Shopping&nbsp;in&nbsp;Europe!./europe.php ";
		MenuItem[3][1]	= "0Why&nbsp;Europe!./europe_why.php ";
		MenuItem[3][2]	= "0Why&nbsp;Graemont!./europe_services.php ";
		MenuItem[3][3]	= "0Learn&nbsp;More!./europe_signup.php ";
		MenuLength[3]	= 164;

		MenuItem[4]		= new Array();
		MenuItem[4][0]	= "Professionals!./pro.php ";
		MenuItem[4][1]	= "0Affiliates!./pro_connecting.php ";
		MenuItem[4][2]	= "0Services!./pro_web_build.php ";
		MenuItem[4][3]	= "0Directory of Professionals!http://www.dressageprofessionals.com/member_directory.php ";
		MenuItem[4][4]	= "0Opportunities!./pro_opportunities.php ";
		MenuLength[4]	= 164;
		
		MenuItem[5]		= new Array();
		MenuItem[5][0]	= "About&nbsp;Graemont!./about.php ";
		MenuItem[5][1]	= "0About&nbsp;Steven!./about_steven.php ";
		MenuItem[5][2]	= "0About&nbsp;Lori!./about_lori.php ";
		MenuItem[5][3]	= "0Facility!./about_graemont.php ";
		MenuItem[5][4]	= "0Testimonials!./about_testimonials.php ";
		MenuItem[5][5]	= "0Directions!javascript:windowopen(\"about_directions.php\"); ";  
		MenuLength[5]	= 164;

		var bName = navigator.appName;
		var bVer = parseInt(navigator.appVersion);
		var NS4 = (bName == "Netscape" && bVer >= 4);
		
		function isNS4() {
		
			if (NS4)
				return "<font color='#000000'>";
			else
				return "";
	
		}
		//only writes for the dropdown menu.	
		function getContent(which) {
			HTMLcode = "<layer top='0' left='"+getLeft(which-1)+"' width='"+MenuLength[which-1]+"'><table border=0 width='" + MenuLength[which-1] +"' cellpadding=0 cellspacing=0><tr><td width='8px' onmouseout='out("+which+");'><ilayer id='outer'><layer id='inner' width='8px' height='100px' onmouseout='out("+which+");'><img src='./images/clpix.gif' width='8px' height='1px'></layer></ilayer></td><td width='1px' bgcolor='#666666'><img src='./images/clpix.gif' width='1px' height='1px'></td><td height='25px'><table border=0 cellpadding=0 cellspacing=0 bgcolor='#8598B8'>";
			
			horiz_line			= "<tr><td bgcolor='#666666' width='100%' height='1px'><img src='./images/clpix.gif' width='" + MenuLength[which-1] +"' height='1px'></td></tr>";		
			HTML_start_cell		= "<tr><td height='25' bgcolor='#ffffcc'><font size=-1>&nbsp;<a href='";
			HTML_link_class		= "' class='menu'"; 
			HTML_link_class2	= "><nobr>";
			
			HTML_onmouseover	= ""; //" onmouseover=\"DropDown(" + (which-1);
			HTML_onmouseover1	= ""; //");\"";		

			HTML_end_cell		= "</nobr></a>&nbsp;</font>";
			HTML_end_cell2		= "</td></tr>";
			
			HTML_sub_menu		=""; // "<table border=0 cellpadding=0 cellspacing=0><tr><td id='JonDrop"+(which-1)+"'><layer id='JonDrop"+(which-1)+"SubInner' width='114px' left='" + (getLeft((which-1))+114) +"px' top'31px' style='position:absolute;visibility:hidden;'><div id='JonDrop"+(which-1)+"SubInner' style='position:absolute;visibility:show;'><table cellpadding=2 cellspacing=0><tr><td>TEST&nbsp;</td></tr></table></div></layer></td></tr></table>";
			
			NSworkaround = isNS4();

			for (i=1; i<MenuItem[(which-1)].length; i++) {
				
				HTMLcode += HTML_start_cell;
				HTMLcode += MenuItem[(which-1)][i].substr((MenuItem[(which-1)][i].lastIndexOf('!')+1), (MenuItem[(which-1)][i].length-1));
				HTMLcode += HTML_link_class;

				if (MenuItem[(which-1)][i].substr(0,1) == "1") {
				
					HTMLcode += HTML_onmouseover +  HTML_onmouseover1; // i + HTML_onmouseover1;

				}
				
				HTMLcode += HTML_link_class2 + NSworkaround;
				HTMLcode += MenuItem[(which-1)][i].substr(1, MenuItem[(which-1)][i].lastIndexOf('!')-1);

				HTMLcode += HTML_end_cell;
				
				//if a sub menu is needed then
				if (MenuItem[(which-1)][i].substr(0,1) == "1") {
				
					HTMLcode += HTML_sub_menu; //alert("hey");

				}
				
				HTMLcode += HTML_end_cell2;

				//if a submenu is needed then...
				if ( i != MenuItem[(which-1)].length-1 ) {
					HTMLcode +=horiz_line;
				}

			}
			
			HTMLcode += horiz_line;

			HTMLcode += "</table></td><td width='8px' onmouseout='out("+which+");'><ilayer id='outer'><layer id='inner' width='4px' height='100px' onmouseout='out("+which+");'><img src='./images/clpix.gif' width='5px' height='1px'></layer></ilayer></td></tr><tr><td width='155px' height='10px' colspan=4 onmouseover='out("+which+")' valign=top><ilayer id='outer'><layer id='inner' width='100%' height='5px' onmouseout='out("+which+");'><img src='./images/clpix.gif' width='" + (MenuLength[which-1] + 10) +"' height='1px'></layer></ilayer></td></tr></table></layer>";
			//alert(HTMLcode);
			return HTMLcode;

		}

		function DropDown(which) {
			hideAll(MenuLength.length);
			id = "JonDrop" + which;
			writeTo(id, getContent(which));
			visibility(id, 1);	
		}

		function out(which) {
		
			id = "JonDrop" + which;
			visibility(id, 0);
		
		}

		function writeTo(id, content, bit) {
			//alert(id+" "+content);
			
			if (document.layers){
				if (bit==1)
					obj=document[id + 'Outer'].document[id + 'Inner'];
				 else
					obj=document['menuDOuter'].document['menuDInner']; //.document[id + 'Inner'];
				
				obj.document.write(content);
				obj.document.close();
			
			} else if (document.all) {

				obj = document.all[id];
				obj.innerHTML = content;

			} else if (document.getElementById) {

				document.getElementById(''+id+'').innerHTML = '';
				document.getElementById(''+id+'').innerHTML = content;

			}
		}

		function hideAll(number) {
			
			for (i=1;i<=number;i++) {
				id = "JonDrop" + i;
				visibility(id, 0);
			}

		}

		function visibility(id, visible) {
			//alert(id+" "+visible);
			if (visible == 1) {
				if (document.layers) 
					document['menuDOuter'].document['menuDInner'] = 'visible'; //.document[id + 'Inner'] = 'visible';
					//document[id +'Inner'].visibility = "show";
				else if (document.all) 
					document.all[id].style.visibility = "visible";
				else if (document.getElementById)
					document.getElementById(id).style.visibility = "visible";
			} else {
				if (document.layers) 
					writeTo(id, "");
					//document['menuDOuter'].document['menuDInner'] = 'hide'; //.document[id + 'Inner'] = 'hide';
					//document[id +'Inner'].visibility = "hide";
				else if (document.all) 
					document.all[id].style.visibility = "hidden";
				else if (document.getElementById)
					document.getElementById(id).style.visibility = "hidden";
			}
		
		}
	
		function writeHead() {
			numOfMenus = MenuItem.length;
			menuHATMLcode = "<table border=0 cellpadding=0 cellspacing=0><tr>";
			for (i=0; i<numOfMenus; i++) {
				//write the cell and its width.  include the bullet and spacing
				menuHATMLcode += "<td width='" + MenuLength[i] + "px'><img src='./images/pix.gif' height='3px' width='1px' align=left valign=middle><!--<img src='./images/bullet.jpg' width='9px' height='9px' alt='bullet'>//--><font size=-1><a href='";
				
				//write the address of the link
				menuHATMLcode += MenuItem[i][0].substr((MenuItem[i][0].lastIndexOf('!')+1), (MenuItem[i][0].length-1));
				
				//include the class and javascript events
				menuHATMLcode += "' class='menuHAead' onmouseover=DropDown(" + (i+1) +")>&nbsp;";
				
				//with netscapes limited support of style sheets we need to include a font tag
				if (NS4) 
					menuHATMLcode += "<font color='#485b74'>";
				
				//include the link label
				menuHATMLcode += MenuItem[i][0].substr(0, MenuItem[i][0].lastIndexOf('!'));

				//end the link and close the cell
				menuHATMLcode += "</a></font></td>";
			}
			
			menuHATMLcode +="</tr></table>";
			writeTo("menuHA", menuHATMLcode, 1);
		}

		function getLeft(i) {
			total=0;

			for (x=0; x<i; x++) {
				total += MenuLength[x];
			}
		
			return total;
		}

		function writeDropDownArea() {
			numOfMenus = MenuItem.length;
			menuHATMLcode = "<table border=0 cellpadding=0 cellspacing=0><tr>";
			for (i=0; i<numOfMenus; i++) {
				menuHATMLcode += "<td width='" + MenuLength[i] + "px' valign=top><layer id='JonDrop"+(i+1)+"Inner' width='114px' left='" +getLeft(i) +"px' top'31px' style='position:absolute;visibility:hidden;'><div id='JonDrop"+(i+1)+"' style='position:absolute;visibility:show;'><table cellpadding=2 cellspacing=0><tr><td>&nbsp;</td></tr></table></div></layer></td>";
			}
			
			menuHATMLcode +="</tr></table>";
			writeTo("menuD", menuHATMLcode, 1);
		}

		function writeMenu() {
			
			writeHead();
			writeDropDownArea();

		}