var web_type="";
var	height=0;
var	height2=0;
var	top_padding=0;
var	submenu_move_top=0;
var	submenu_top=0;
var	submove_add=0;
var	submove_add2=0;
var	submove_add3=0;
var	width_add=0;
var	top_height=0;

if (navigator.userAgent.indexOf("MSIE") !=-1)
{
	web_type="Internet Explorer";
	height=19;
	height2=19;
	top_padding=3;
	submenu_move_top=0;
	submenu_top=22;
	submove_add=8;
	submove_add2=0;
	submove_add3=11;
	width_add=7;
	top_height=0;
	if (navigator.appVersion.indexOf("Macintosh") !=-1)
	{
		web_type="Macintosh";
		submenu_top=23;
		submove_add=2;
		submove_add2=0;
		submove_add3=0;
		height=20;
		width_add=10;
		top_height=10;
	}
}
else if (navigator.userAgent.indexOf("Safari") !=-1)
{
	web_type="Safari";
	height=20;
	height2=20;
	top_padding=3;
	submenu_move_top=2;
	submenu_top=24;
	submove_add=0;
	submove_add2=1;
	submove_add3=0;

	width_add=9;
	top_height=0;
}
else if (navigator.userAgent.indexOf("Firefox") !=-1)
{
	web_type="Firebox";
	height=19;
	height2=21;
	top_padding=0;
	submenu_move_top=0;
	submenu_top=22;
	submove_add=11 + 19;
	submove_add2=6 + 7;
	submove_add3=6 + 14;
	width_add=8;
	top_height=0;
}
else if (navigator.userAgent.indexOf("Netscape") !=-1)
{
	web_type="Netscape";
	height=20;
	height2=21;
	top_padding=0;
	submenu_move_top=0;
	submenu_top=22;
	submove_add=24;
	submove_add2=14;
	submove_add3=19;

}

else
{
	web_type="Unknow Brower";
	height=20;
	height2=21;
	top_padding=0;
	width_add=0;
	top_height=0;
}

var top=20,left=0;

mm =new Array("m0","m1","m2","m3","m4","m5");
umm=new Array("um1","um2","um3","um4","um5","um6");
//msubmenu=new Array("javascript:m1_make()","javascript:m2_make()",'../BrachySeeds/BrachySeeds.htm target ="mainFrame"',"javascript:m4_make()",'../Upcoming_Meetings/Upcoming_Meetings.htm target ="mainFrame"')
msubmenu=new Array("javascript:m1_make()","javascript:m2_find()","javascript:m3_make()","javascript:m4_find()","javascript:m5_make()","javascript:m6_find()")

var ww=new Array()                                            
ww[0]= new Array("&nbsp;&nbsp;Services", "General Activities", '../services/General_Activities.htm" target ="mainFrame"' , "TLD services", '../services/TLD_Services/TLD_objectives.htm" target ="mainFrame"',"On-site Audits", '../services/On_Site_visit_Service/Visit_measurement.htm" target ="mainFrame"',  "Patient chart review",  '../services/Patient_Chart_Review.htm" target ="mainFrame"' , "Study Group interactions", '../services/Study_Group.htm" target ="mainFrame"', "Anthropomorphic Phantoms", '../services/Anthropomorphic_ Phantoms/anth.htm" target ="mainFrame"')
ww[1]= new Array("&nbsp;&nbsp;Forms", '../Forms/Forms.htm" target ="mainFrame"')
ww[2]= new Array("&nbsp;&nbsp;Publications","Report to TPC",'../Publications/AAPM-RTC/RTC-Report_2008.htm" target ="mainFrame"',"Papers",'../Publications/publications_2009.htm" target="mainFrame"', "Presentations and Posters", '../Publications/RPC_Presentations/Posters_2009.htm" target ="mainFrame"',"Newsletter",'../Newsletter/newsletter_2007.htm" target="mainFrame"')
ww[3]= new Array("&nbsp;&nbsp;Brachy Sources", '../BrachySeeds/BrachySeeds.htm" target ="mainFrame"')
ww[4]= new Array("&nbsp;&nbsp;Research/TG-51","General Information" ,'../Research_tg51/Research.htm" target ="mainFrame"',"TG-51 Protocol",'../Research_tg51/TG-51/TG-51_general.htm" target ="mainFrame"',"Photon algorithm verfication data ", '../Reference Information/photon.htm" target="mainFrame"',"Reference Photon Data /  Phase Space Data",'../Reference Information/RPDD_RPSD_README.htm" target="mainFrame"')
ww[5]= new Array("&nbsp;&nbsp;Upcoming Meetings",'../Upcoming_Meetings/Upcoming_Meetings.htm" target ="mainFrame"')

um1 = new Array("Services", "General Services", "services.asp", "TLD services", "http://",  "Forms", "On-site Audit visit", "http://", "Credentialing", "../Credentialing/Credentialing.htm", "Patient chart review", "http://", "Study Group interactions", "http://", "Anthropomorphic Phantoms", "http://", "Benchmark Cases", "http://","","")
um2 = new Array("Forms", "Forms.htm")
um3 = new Array("Publication","Report to RPC","Recent.ASP", "Papers", "AAPM POSTERS.ASP","Presentations and Posters","","Newsletter","newsletter_2007.htm","","")
um4 = new Array("Brachy Seeds", "BrachySeeds.asp")
um5 = new Array("Research/TG-51","General","Research.htm","TG-51","tg-51.htm","Photon algorithm\n&nbsp;&nbsp;&nbsp;&nbsp;verfication data ", '../Reference Information/photon.htm" target="mainFrame"',"Reference&nbsp;Photon\n&nbsp;Data / &nbsp;Phase Space\n&nbsp;Data",'../Reference Information/RPDD_RPSD_README.htm" target="mainFrame"',"","")
um6 = new Array("Upcoming Meetings",'../Upcoming_Meetings/Upcoming_Meetings.htm" target ="mainFrame"')

xx=new Array(80,22,22,22,22,22,22)
yy=new Array(10,0,0,0,0,0,0)

function Change(aa)
{
	aa.style.color='#DCE9F0'; 
	aa.style.backgroundColor='#000066';
}
function Original(aa)
{
	aa.style.color='#000066';
	aa.style.backgroundColor='#DCE9F0';
}

fWholeMenu();

function fcountSpring(strSpring)
{
     var count=0;
	if (strSpring.length>32)
        	count=2;
     else if  (strSpring.length>16 && strSpring.length<=32)
        	count=1;
     else
     	count=0;
     return count;
}

function fcountTurn(strArray)
{
     var cc=0,dd=0;
	for (var i=0; i<strArray.length; i++)
	{
         if (i%2==1)
         {
            cc=fcountSpring(strArray[i]);
            dd=dd+cc;
          }
	}
	return dd;
}

function fWholeMenu()
{
	var k=0;
 	var aa="" ;
	for (var i=0;i<mm.length;i++)
     {
		k=i+1;
		aa=aa+'<div ';
		aa=aa+'id=';
		aa=aa+""+mm[i]+" ";
		aa=aa+' style="position:absolute;top:'+xx[i]+';left:'+yy[i]+';">';
			aa=aa+'<table  border="0" cellpadding=0 cellspacing=0  bgcolor="#DCE9F0" ';
			aa=aa+'style="border-style:solid;';
			aa=aa+'border-width:1px; border-color: #296488;"';
			aa=aa+'>';
			aa=aa+'<tr>';
			aa=aa+'<td>';
			aa=aa+'<div id=';
			aa=aa+'menu';
			aa=aa+""+k+" ";
			aa=aa+' >';
			aa=aa+'<table cellpadding=0 cellspacing=0 style="width:135";'; 
			aa=aa+'>';
			aa=aa+'<tr>';
			aa=aa+'<td width=135  height='+height+' >';
			aa=aa+'<a ';
			aa=aa+'id=menu_aa';
			aa=aa+""+k+" ";
//			aa=aa+' >';
			
			
			aa=aa+' href=';
			aa=aa+""+msubmenu[i]+" ";
	//		aa=aa+'target ="mainFrame"';
			aa=aa+' style="color:#dce9f0;">';
			aa=aa+'<p';
			aa=aa+' onMouseMove=Change(this) ';
			aa=aa+'onmouseout=Original(this)';
			aa=aa+'; style="color:#000066;font-family: Arial;font-size:11px;font-weight:bold;text-align:left;vertical-align:middle; margin:0; padding:0px; padding-top:'+top_padding+';  height:'+height2+';line-height:18px;" >';
		//                  aa=aa+'style="font-family:Arial;  font-size:11px;                text-align:center;vertical-align:middle; padding-top:'+top_padding+'; height:'+height2+'; width:'+width_real+'; line-height:18px; margin:0px; font-weight:bold;color:#000066;">';
			aa=aa+""+ww[i][0]+" ";
			aa=aa+'</p>';
			aa=aa+'</a>';
			aa=aa+'</td>';
			aa=aa+'</tr>';
			aa=aa+'</table>';
			aa=aa+'</div>';
			aa=aa+'</td>';
			aa=aa+'</tr>';
			aa=aa+'</table>';
				
				aa=aa+'<div id=';
				aa=aa+""+umm[i]+" ";
				aa=aa+'style="position:absolute;top:'+submenu_top+';left:0;background-color: #dce9f0;';
				aa=aa+'visibility:hidden;">';
				aa=aa+'<table  border="0" cellpadding=0 cellspacing=0  bgcolor="#DCE9F0"';
				aa=aa+'style="border-style:solid;border-width:1px;border-color:#296488;width:125;"';
				aa=aa+'>';
				for (var n=0;n<(ww[i].length);n++)
				{
					if (n%2==1)
					{
						aa=aa+'<tr>';
						aa=aa+'<td>';
						aa=aa+'<div >';	
						aa=aa+'<table border="0" style="border-width:1px; border-color: #296488;"';
						aa=aa+'>';
						aa=aa+'<tr>';
						aa=aa+'<td valign="top"  align="center">';
						aa=aa+'&bull;';
						aa=aa+'</td>';
						aa=aa+'<td align="left" width=200 height=21';
						aa=aa+'>';
						aa=aa+'<a  href="'+ww[i][n+1]+'" style="color:#dce9f0;" ';
						aa=aa+'>';
						aa=aa+'<p';
						aa=aa+' onMouseMove=Change(this) ';
						aa=aa+' onmouseout=Original(this) ';
						aa=aa+' style=" width:100px; font-family: Arial; font-size:11px; margin:0; padding:0px; color:#000066;"';
//				aa=aa+'style="font-family:Arial;  font-size:11px;text-align:center;vertical-align:middle; padding-top:'+top_padding+'; height:'+height2+'; width:'+width_real+'; line-height:18px; margin:0px; font-weight:bold;color:#000066;">';
						aa=aa+' >';
						aa=aa+""+ww[i][n]+" ";
						aa=aa+'</p>';
						aa=aa+'</a>';
						aa=aa+'</td>';
						aa=aa+'</tr>';
						aa=aa+'</table>';
						aa=aa+'</div>';
						aa=aa+'</td>';
						aa=aa+'</tr>';
					}
				}
				aa=aa+'</table>';
				aa=aa+'</div>';
	}
	for (var m=0;m<mm.length;m++)
 	{
		aa=aa+'</div>';
	}
	document.write(aa);
}

var m1_position=12, m1_jump=-3;
var m2_position=12, m2_jump=-3;
var m3_position=12, m3_jump=-3;
var m4_position=12, m4_jump=-3;
var m5_position=12, m5_jump=-3;
var m6_position=12, m6_jump=-3;

var time=5;

function fhidden_mm()
{
	if ((navigator.appVersion.indexOf("MSIE") !=-1) && (navigator.appVersion.indexOf("4.0") !=-1))
	{
		document.all.um1.style.visibility =  'hidden';
		document.all.um2.style.visibility =  'hidden';
		document.all.um3.style.visibility =  'hidden';
		document.all.um4.style.visibility =  'hidden';
    	document.all.um5.style.visibility =  'hidden';
    	document.all.um6.style.visibility =  'hidden';

	}
	else
	{
		document.getElementById('um1').style.visibility =  'hidden';
		document.getElementById('um2').style.visibility =  'hidden';
		document.getElementById('um3').style.visibility =  'hidden';
		document.getElementById('um4').style.visibility =  'hidden';
    	document.getElementById('um5').style.visibility =  'hidden';
    	document.getElementById('um6').style.visibility =  'hidden';
	}
}

function m1_make()
{
	fhidden_mm();
	
	if(m2_position>0)
 	{
     	m2_jump=-3;
     	if(m2_position>=(um2.length-1)/2*17.5+20)
     		m2_move();
  	}
	
  	if(m3_position>0)
  	{
     	m3_jump=-3;
     	if(m3_position>=(um3.length-1)/2*17.5+20)
     		m3_move();
  	}
   	if(m4_position>0)
  	{
    		m4_jump=-3;
    		if(m4_position>=(um4.length-1)/2*17.5+20)
			m4_move();
  	}
    	if(m5_position>0)
  	{
    		m5_jump=-3;
    		if(m5_position>=(um5.length-1)/2*17.5+20)
			m5_move();
  	}
    if(m6_position>0)
  	{
		m6_jump=-3;
		if(m6_position>=(um6.length-1)/2*17.5+20)
		m6_move();
  	}
	
  	m1_jump=-m1_jump;
  	if(m1_position<=20 || m1_position>=(um1.length-1)/2*17.5+10)
  		{
			m1_move();
			if (m1_position >= 75)
                  	fhidden_mm();
			else
				document.getElementById('um1').style.visibility =  'visible';
		}
}

 function m1_move()
{
	document.getElementById('m1').style.top=m1_position+16+submenu_move_top;
  	m1_position+=m1_jump;
  	if(m1_position>5 && m1_position<((um1.length-1)/2)*17.5+15+submove_add )
  	{
		setTimeout("m1_move()", time);
     }
 }
 function m2_find()
{
	window.open("../Forms/Forms.htm", "mainFrame");
	m2_make();
}


function m2_make()
{
   	fhidden_mm();
	if(m1_position>0)
  	{
    		m1_jump=-3;
    		if(m1_position>=(um1.length-1)/2*17.5+7)
       		m1_move();
 	 }
  	if(m3_position>0)
  	{
    		m3_jump=-3;
    		if(m3_position>=(um3.length-1)/2*17.5+20)
       		m3_move();
 	 }

  	if(m4_position>0)
  	{
    		m4_jump=-3;
    		if(m4_position>=(um4.length-1)/2*17.5+20)
			m4_move();
  	}
    	if(m5_position>0)
  	{
    		m5_jump=-3;
    		if(m5_position>=(um5.length-1)/2*17.5+20)
			m5_move();
  	}
	if(m6_position>0)
  	{
		m6_jump=-3;
		if(m6_position>=(um6.length-1)/2*17.5+20)
		m6_move();
  	}

//  	m3_jump=-m3_jump;
 // 	if(m3_position<=20 || m3_position>=(um3.length-1)/2*17.5+20)
 //    	{
//			m3_move();
//			if (m3_position >=75)
//                 	fhidden_mm();
//			else
//				document.getElementById('um3').style.visibility =  'visible';
//		}
}

function m2_move()
{
  document.getElementById('m2').style.top=m2_position;
  m2_position+=m2_jump;
  if(m2_position>12 && m2_position<(um2.length-1)/2*17.5+35)
		setTimeout("m2_move()", time);

 }
 
function m3_make()
{
  	fhidden_mm();
	if(m1_position>0)
  	{
    	m1_jump=-3;
    	if(m1_position>=(um1.length-1)/2*17.5+20)
       		m1_move();
 	 }
  	if(m2_position>0)
  	{
    	m2_jump=-3;
    	if(m2_position>=(um2.length-1)/2*17.5+20)
			m2_move();
  	}
  	if(m4_position>0)
  	{
    		m4_jump=-3;
    		if(m4_position>=(um4.length-1)/2*17.5+20)
			m4_move();
  	}
    	if(m5_position>0)
  	{
    		m5_jump=-3;
    		if(m5_position>=(um5.length-1)/2*17.5+20)
			m5_move();
  	}
	if(m6_position>0)
  	{
		m6_jump=-3;
		if(m6_position>=(um6.length-1)/2*17.5+20)
		m6_move();
  	}

  	m3_jump=-m3_jump;
  	if(m3_position<=20 || m3_position>=(um3.length-1)/2*17.5)
     	 {
		 	m3_move();
		 	if (m3_position>=75)
                 fhidden_mm();
		 	else
				document.getElementById('um3').style.visibility ='visible';
				
 		 }
}

function m3_move()
{
	document.getElementById('m3').style.top=m3_position+16+submenu_move_top;
  	m3_position+=m3_jump;
   	if(m3_position>3 && m3_position<((um3.length-1)/2)*17.5+28+10+submove_add2)
 		setTimeout("m3_move()", time);
}

function m4_find()
{
	window.open("../BrachySeeds/BrachySeeds.htm", "mainFrame");
	//document.write("1111111");
	m4_make();
}


function m4_make()
{
   	fhidden_mm();
	if(m1_position>0)
  	{
    		m1_jump=-3;
    		if(m1_position>=(um1.length-1)/2*17.5+20)
       		m1_move();
 	 }
  	if(m2_position>0)
  	{
    		m2_jump=-3;
    		if(m2_position>=(um2.length-1)/2*17.5+20)
       		m2_move();
 	 }

  	if(m3_position>0)
  	{
    		m3_jump=-3;
    		if(m3_position>=(um3.length-1)/2*17.5+20)
			m3_move();
  	}
    	if(m5_position>0)
  	{
    		m5_jump=-3;
    		if(m5_position>=(um5.length-1)/2*17.5+20)
			m5_move();
  	}
	if(m6_position>0)
  	{
		m6_jump=-3;
		if(m6_position>=(um6.length-1)/2*17.5+20)
		m6_move();
  	}

//  	m3_jump=-m3_jump;
 // 	if(m3_position<=20 || m3_position>=(um3.length-1)/2*17.5+20)
 //    	{
//			m3_move();
//			if (m3_position >=75)
//                 	fhidden_mm();
//			else
//				document.getElementById('um3').style.visibility =  'visible';
//		}
}

function m4_move()
{
  document.getElementById('m4').style.top=m4_position;
  m4_position+=m4_jump;
  if(m4_position>12 && m4_position<(um4.length-1)/2*17.5+35)
		setTimeout("m4_move()", time);

 }

function m5_make()
{
   fhidden_mm(); 
	if(m1_position>0)
  	{
    		m1_jump=-3;
    		if(m1_position>=(um1.length-1)/2*17.5+20)
       		m1_move();
 	 }
  	if(m2_position>0)
  	{
    		m2_jump=-3;
    		if(m2_position>=(um2.length-1)/2*17.5+20)
       		m2_move();
 	 }

  	if(m3_position>0)
  	{
    		m3_jump=-3;
    		if(m3_position>=(um3.length-1)/2*17.5+20)
			m3_move();
  	}
    	if(m4_position>0)
  	{
    		m4_jump=-3;
    		if(m4_position>=(um4.length-1)/2*17.5+20)
			m4_move();
  	}
	if(m6_position>0)
  	{
		m6_jump=-3;
		if(m6_position>=(um6.length-1)/2*17.5+20)
		m6_move();
  	}

	m5_jump=-m5_jump;
  	if(m5_position<=20 || m5_position>=(um5.length-1)/2*17.5+20)
     	 {
		 	m5_move();
		 	if (m5_position>=75)
                    	fhidden_mm();
   		 	else
				document.getElementById('um5').style.visibility =  'visible';
 		 }
}

  function m5_move()
{
	document.getElementById('m5').style.top=m5_position+16+submenu_move_top;
  	m5_position+=m5_jump;
   	if(m5_position>3 && m5_position<((um5.length-1)/2)*17.5+42+10+submove_add3)
	{
 		setTimeout("m5_move()", time);
	}
}
function m6_find()
{
	window.open("../Upcoming_Meetings/Upcoming_Meetings.htm", "mainFrame");
	m6_make();
}


 function m6_make()
{
   	fhidden_mm();
	
	if(m1_position>0)
  	{
    		m1_jump=-3;
    		if(m1_position>=(um1.length-1)/2*17.5+20)
       		m1_move();
 	 }
  	if(m2_position>0)
  	{
    		m2_jump=-3;
    		if(m2_position>=(um2.length-1)/2*17.5+20)
       		m2_move();
 	 }

  	if(m3_position>0)
  	{
    		m3_jump=-3;
    		if(m3_position>=(um3.length-1)/2*17.5+20)
			m3_move();
  	}
  	if(m4_position>0)
  	{
    		m4_jump=-3;
    		if(m4_position>=(um4.length-1)/2*17.5+20)
			m4_move();
  	}
	if(m5_position>0)
  	{
		m5_jump=-3;
		if(m5_position>=(um5.length-1)/2*17.5+20)
		m5_move();
  	}

//    m5_jump=-m5_jump;
//  	if(m5_position<=20 || m5_position>=(um5.length-1)/2*17.5+20)
//     	 {
//		 	m5_move();
//		 	if (m5_position>=75)
//                    	fhidden_mm();
//   		 	else
//				document.getElementById('um5').style.visibility =  'visible';
// 		 }
}

  function m6_move()
{
    var intMenuLineNumebr=0;
   	var SecondLineNumber;
	SecondLineNumber=fcountTurn(um6);
	document.getElementById('m6').style.top=m6_position;
  	m6_position+=m6_jump;
   	if(m6_position>12 && m6_position<((um6.length-1)/2+ intMenuLineNumebr/2)*17.5+20+5 +SecondLineNumber*10)
 		setTimeout("m6_move()", time);
}


