function MM_swapImgRestore() { //v3.0

  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}



function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}



function MM_findObj(n, d) { //v4.01

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}



function return_short_filename(filename)

{	



	var re = new RegExp();

	re.compile("\\w*\\.\\w*$", "gi");

	matchArray = re.exec(filename);	

	t = matchArray[0];

	return t;

}



function valid_attr(i_string, i_attr)

{

	r_value = false;

	if (i_string && i_attr)

	{

		t = i_string.indexOf(i_attr);

		if (t > -1) { r_value = true; }

	}

	return r_value;

}



function valid_change_image(img_name, filename)

{

	return_value = false;

	

	x = MM_findObj(img_name)

	f = return_short_filename(filename)

	if (x != null)

	{

		if (!valid_attr(x.src, f))

		{			

			return_value = true

		}

	}

	

	return return_value;

}



function MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}



function MM_reloadPage(init) {  //reloads the window if Nav4 resized

  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {

    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}

  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();

}

MM_reloadPage(true);



function MM_showHideLayers() { //v6.0

  var i,p,v,obj,args=MM_showHideLayers.arguments;

  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];

    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }

    obj.visibility=v; }

}





// set subdirectory names

document.current_menu = -1;

var top_levels = new Array();

top_levels[0] = "what_we_offer";

top_levels[1] = "company_profile";

top_levels[2] = "disease_focus";

top_levels[3] = "technologies";

top_levels[4] = "products";

top_levels[5] = "collaborations";

top_levels[6] = "news";

top_levels[7] = "investor_relations";

top_levels[8] = "contact_us";

top_levels[9] = "rule26";



// set constants

l_has_attached_layer = 0;

l_layer_on = 1;

l_image_on = 2;



// sets what section you are on



for (i in top_levels)

{

	if (document.location.href.indexOf(top_levels[i]) != -1) 

	{ 

		document.current_menu = i; 

		document.topnav_part = "x" + i;

		var re = new RegExp();

		re = re.compile("\\\/" + top_levels[i] + "\\\/(\\d)\\\/", "i");

		var matchArray = re.exec(document.location.href);				

		document.subnav_part = "y" + matchArray[1];		

	}

}





function NewWindow(mypage) 

{

	

	myname = 'windowname';

	w = 530;

	h = 400;

	var winl = (screen.width - w) / 2;

	var wint = (screen.height - h) / 2;

	winprops = 'toolbar=no,location=no,status=no,menubar=yes,scrollbars=no,resizable=no,width=530,height=400,top='+wint+',left='+winl;

   windowname =  window.open(mypage, myname, winprops); //winprops



}



function return_empty_menu_array()

{

	var menu_array = new Array();

	var temp = new Array();



	// how many sub navs each section has		





	menu_array["x0"] = Array(1,0,0);

	menu_array["x0y0"] = Array(0,0,0);	



	menu_array["x1"] = Array(1,0,0);

	menu_array["x1y0"] = Array(0,0,0);	

	menu_array["x1y1"] = Array(0,0,0);	

	menu_array["x1y2"] = Array(0,0,0);	menu_array[document.topnav_part] = Array(1,0,0);		

	menu_array["x1y3"] = Array(0,0,0);

	menu_array["x1y4"] = Array(0,0,0);	

	menu_array["x1y5"] = Array(0,0,0);	

	menu_array["x1y6"] = Array(0,0,0);		



	menu_array["x2"] = Array(1,0,0);

	menu_array["x2y0"] = Array(0,0,0);		

	menu_array["x2y1"] = Array(0,0,0);	

	menu_array["x2y2"] = Array(0,0,0);

	menu_array["x2y3"] = Array(0,0,0);

	menu_array["x2y4"] = Array(0,0,0);



	menu_array["x3"] = Array(1,0,0);

	menu_array["x3y0"] = Array(0,0,0);		

	menu_array["x3y1"] = Array(0,0,0);	

	menu_array["x3y2"] = Array(0,0,0);	



	menu_array["x4"] = Array(1,0,0);

	menu_array["x4y0"] = Array(0,0,0);		

	menu_array["x4y1"] = Array(0,0,0);	

	menu_array["x4y2"] = Array(0,0,0);	



	menu_array["x5"] = Array(1,0,0);

	menu_array["x5y0"] = Array(0,0,0);		

	menu_array["x5y1"] = Array(0,0,0);	

	menu_array["x5y2"] = Array(0,0,0);	

	menu_array["x5y3"] = Array(0,0,0);	



	menu_array["x6"] = Array(1,0,0);

	menu_array["x6y0"] = Array(0,0,0);	

	menu_array["x6y1"] = Array(0,0,0);	

	menu_array["x6y2"] = Array(0,0,0);	

	menu_array["x6y3"] = Array(0,0,0);	

	menu_array["x6y4"] = Array(0,0,0);	

	menu_array["x6y5"] = Array(0,0,0);
	
	menu_array["x6y6"] = Array(0,0,0);	



	menu_array["x7"] = Array(1,0,0);	

	menu_array["x7y0"] = Array(0,0,0);	

	menu_array["x7y1"] = Array(0,0,0);	

	menu_array["x7y2"] = Array(0,0,0);	

	menu_array["x7y3"] = Array(0,0,0);	

	menu_array["x7y4"] = Array(0,0,0);	



	menu_array["x9"] = Array(1,0,0);

	menu_array["x9y0"] = Array(0,0,0);	



	menu_array["x8"] = Array(1,0,0);

	menu_array["x8y0"] = Array(0,0,0);		

	menu_array["x8y1"] = Array(0,0,0);	
	

	//menu_array[document.topnav_part] = Array(1,0,0);	

				

	return menu_array;

}



empty_state = return_empty_menu_array();



current_state = empty_state;



function set_state(state_array, array_index)

{



	if (array_index == document.topnav_part)

	{

		state_array[array_index][l_image_on] = 2;

	}

	else

	{

		state_array[array_index][l_image_on] = 1;

	}

	

	//alert("has layer attached: (" +  array_index + ") " + state_array[array_index][l_has_attached_layer]);

	if (state_array[array_index][l_has_attached_layer] == 1)

	{

		state_array[array_index][l_layer_on] = 1;

	}

	

	return state_array;

}



function draw_changes(state_array)

{



	var change_array = new Array();

	for (i in state_array)

	{

		for (j in state_array[i])

		{

			if (state_array[i][j] != current_state[i][j])

			{

				//alert(state_array[i][j] + " != " + current_state[i][j]);

				change_array[i] = state_array[i];

			}

		}

	}

	

	draw_state(change_array);

	current_state = state_array;	

}



function alert_add(txt)

{

	document.o_txt = document.o_txt + " [" + txt + "] ";

}



function alert_write()

{

	//alert(document.o_txt);

	document.o_txt = "";	

}



function alert_clear()

{

	document.o_txt = "";

}



function draw_state(state_array)

{	

	for(i in state_array)

	{

		if (state_array[i][l_has_attached_layer] == 1)

		{	

			if (state_array[i][l_layer_on] == 1)

			{

				MM_showHideLayers("layer" + i,'','show');

			}

			else

			{

				MM_showHideLayers("layer" + i,'','hide');

			}

		}

		

		if ((state_array[i][l_image_on] == 1) || (state_array[i][l_image_on] == 2))

		{

			if (state_array[i][l_image_on] == 1)

			{

				if (valid_change_image('image' + i, i + '_on.gif'))

				{

					MM_swapImage('image' + i,'','../../../images/nav/' + i + '_on.gif',1);		

				}

			}

			if (state_array[i][l_image_on] == 2)

			{

				if (valid_change_image('image' + i, i + '_select.gif'))

				{

					MM_swapImage('image' + i,'','../../../images/nav/' + i + '_select.gif',1);		

				}

			}

		}

		else

		{

			if (valid_change_image('image' + i, i + '.gif'))

			{

				MM_swapImage('image' + i,'','../../../images/nav/' + i + '.gif',1);		

			}

		}

		alert_add(i + "(layer: " + state_array[i][l_layer_on] + ")"+ "(image: " + state_array[i][l_image_on] + ")");

	}

	alert_write();

}



function menu_item_over(item_num)

{



	

	var new_state = return_empty_menu_array();



	var re = /(x\d)*(y\d)*(z\d)*/

	var found_array = re.exec(item_num)



	x_part ="";

	y_part ="";

	z_part ="";

	

	if (item_num.indexOf("x") != -1) 

	{ 

		x_part = found_array[1]; 

		new_state = set_state(new_state, x_part)			

	}



	if (item_num.indexOf("y") != -1) 

	{ 

		y_part = found_array[2]; 

		new_state = set_state(new_state, x_part + y_part)			

	}



	if (item_num.indexOf("z") != -1) 

	{ 

		z_part = found_array[3]; 

		new_state = set_state(new_state, x_part + y_part + z_part)			

	}	

	

	//alert("x[" + x_part + "]y[" + y_part + "]z[" + z_part +  "]");	

	//new_state = set_state(new_state, document.topnav_part); // add this line in if you want to disable sub layer activation

				

	new_state[document.topnav_part][l_image_on] = 2;			



	draw_state(new_state);

	//draw_changes(new_state);



}



function start_state()

{

	//alert(document.topnav_part);

	new_state = empty_state;

	new_state = set_state(new_state, document.topnav_part);

	//alert(document.topnav_part + document.subnav_part);

	if (new_state[document.topnav_part + document.subnav_part] != null)

	{

		new_state[document.topnav_part + document.subnav_part][l_image_on] = 1;	

		draw_state(new_state);	

	}

}

