// javascript Document

function menuImage(url,id){
	this.url=url;
	this.id=id;
}

function setMenuImageArray(){
	/*
	establish all site links; note that main menu items are only notated by their directory - not the top file.
	
	each entry=new menuImage(full URL of actual link, id of image you want changed, i.e.,
	if id="establish_cr8ive4u_account_arrow" then the second part of this entry would be
	"establish_cr8ive4u_account_arrow".
	NOTE main menu has different id name suffix' than submenu entries, i.i., design_services_arrow & 
	design_services_subarrow
	*/
	//=======================================================BEGIN main menu;
	/*
	ACTUAL CODE FOR USE WHEN SITE GOES LIVE ON http://www.microgreeninc.com
	menu_image_array=new Array();
	menu_image_array[0]=new menuImage("http://www.microgreeninc.com/about_microgreen/about_microgreen.html","about_us_arrow");
	menu_image_array[1]=new menuImage("http://www.microgreeninc.com/thermoformed_plastics_applications/applications.html", "applications_arrow");
	menu_image_array[0]=new menuImage("http://www.microgreeninc.com/http://www.microgreeninc.com/advanced_plastics_technology/plastics_technology.html","technology_arrow");
	menu_image_array[0]=new menuImage("http://www.microgreeninc.com/http://www.microgreeninc.com/contact_microgreen/contact_microgreen.html","contact_us_arrow");
	*/
	
	menu_image_array=new Array();
	menu_image_array[0]=new menuImage("http://www.barrallen.com/microgreen/about_microgreen/","about_us_arrow");
	menu_image_array[1]=new menuImage("http://www.barrallen.com/microgreen/thermoformed_plastics_applications/", "applications_arrow");
	menu_image_array[2]=new menuImage("http://www.barrallen.com/microgreen/advanced_plastics_technology/","technology_arrow");
	menu_image_array[3]=new menuImage("http://www.barrallen.com/microgreen/contact_microgreen/","contact_us_arrow");
	
 	//alert("menu_image_array[1].url = "+menu_image_array[1].url);
	return (menu_image_array);
}

function setAlternateImageSource(current_page_url){
	//alert("current_page_url = "+current_page_url);
	var i,j,k,m,n,p,q,r,t,u,w;
	setMenuImageArray();
	//alert("menu_image_array[0].id = "+menu_image_array[0].id);
	/*
	The following checks the current window.location (i.e., current_page_url) to the menu_image_array.url entry.
	The menu_image_array consists of evey url in the site. If a match is found it swaps the regular menu item 
	image with the active menu item image. For purposes of ease name menu image(s) main_menu_arrw01.* and 
	main_menu_arrwact01.gif
	*/
	for(var i=0;i<menu_image_array.length;i++){
		q='"'+current_page_url+'"';
		/*
		alert("q = "+q);
		alert("q.indexOf(menu_image_array[i].url) = "+q.indexOf(menu_image_array[i].url));
		alert("q.length-2 = "+(q.length-2));  //-2 compensates for the qoutes required to convert window.location for the string comparison
		alert("menu_image_array[i].url.length = "+menu_image_array[i].url.length);
		*/
		if((q.indexOf(menu_image_array[i].url)>-1)&&((q.length-2)>=menu_image_array[i].url.length)){
			//alert("inside q to menu_image_array comparison");
			j=menu_image_array[i].id;
			k=document.images[j].src;
			m=k.slice(0,(k.lastIndexOf(".")-2));
			n=k.substr(k.lastIndexOf(".")-2);
			p=m+"act"+n;
			document.images[j].src=p;
			/*
			the following checks to see if the image swap is in the sub menu ----"indexOf("subarrow")- the second 
			part of the associative array 'menu_image_array.id'------- if so, it adjusts the width property of 
			the menu image to the size of the active version of the menu image, i.e., 16px to 12px wide.
			it then sets the <a href> to javascript:void; to disable the link i.e., id="mylinkname_a_tag". 
			It then changes the name of the menu-item's-image to "temp_rename_to_void_rollover" disabling 
			any rollover/out scripts that may be present, i.e. avoiding runtime errors.
			*/
			if(j.indexOf("subarrow")>-1){
				t=j.indexOf("subarrow");
				r=document.getElementById(j);
				r.setAttribute("width","12");
				r.removeAttribute("name");
			}else{
				t=j.indexOf("arrow");
			}
			
				
				u=j.slice(0,t);
				u=u+"a_tag";
				w=document.getElementById(u);
				w.href="javascript:void(0);"
				w.style.color='#0E7128'  //sets the link's text color of the current page being viewed.
				w.style.textDecoration="none";
		}
	}
}