//////////////////////
///Image Randomizer
//////////////////////

var theImages = new Array();
var theLinks = new Array();

theImages[0] = '/images/sid/0.jpg';
//theImages[1] = '/images/sid/1.jpg';
//theImages[2] = '/images/sid/2.jpg';
//theImages[3] = '/images/sid/3.jpg';


theLinks[0] = '/involved/';
theLinks[1] = '/involved/';
theLinks[2] = '/involved/';
theLinks[3] = '/involved/';


var j = 0;
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = theImages[i]
};

var whichImage = Math.floor ( Math.random() * theImages.length ); 
//alert(whichImage);
//var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write('<a href="'+theLinks[whichImage]+'"><img src="'+theImages[whichImage]+'" border="0">');
}

/////////////////////////////////////////
// Styles Large Secondary Nav
/////////////////////////////////////////
function styleSecondaryNav(){	
	var theDiv = document.getElementById('secondary_nav');
	var theItems = theDiv.getElementsByTagName('li');
	var curr_link=0;
	var curr_item=0;
	var match_found=false;
	var sub_match_found=false;
	var activeItem;
	var activeSubLink;
	
	for (curr_item = 0; curr_item < theItems.length; curr_item++)
	{
		
				currentpath=window.location.href;
				curr_array=cleanURL(currentpath.split("/"));
				theLink=theItems[curr_item].getElementsByTagName('a')[0];
				newpath=theLink.href;
				new_array=cleanURL(newpath.split("/"));
				
				//alert((new_array.length-curr_array.length));
				//alert(curr_array[new_array.length-1]+"  :  "+new_array[new_array.length-1]);
					
				//SEE IF THE LINKS MATCH AND MAKE SURE IT IS NOT A # LINK
				var i=0;
				var dir_lvl=0;
				//if(curr_array.length>4) dir_lvl=3;
				
				for(i=(curr_array.length-1);i>dir_lvl;i--){	
					
					if(curr_array[i]==new_array[new_array.length-1] && newpath.lastIndexOf('#')<0){
						//alert(theItems[curr_item].parentNode.parentNode.tagName);
						
						if(curr_array[i-1]==new_array[new_array.length-2]){	
						
							if(theItems[curr_item].parentNode.parentNode=="[object HTMLDivElement]" || theItems[curr_item].parentNode.parentNode.tagName=="DIV"){
								//set highest level in secondary nav
								activeItem=theItems[curr_item];
								match_found=true;
							}
							else{
								//set sub link in secondary nav
									activeSubLink=theLink;
									sub_match_found=true;
								
							}
							
							break;
						
						}
						
					}
					
				}
				
					
	}
	// CHANGE STYLES OF THE MATCHING LINKS
	activeItem.className="mmhide_secondary_nav_select";
	
	theSubList=activeItem.getElementsByTagName('ul')[0];
		
	//make sub links of active Item visible
	if(theSubList!=null){
		theSubList.style.display="block";
	}
	
	if(sub_match_found){
		activeSubLink.className="mmhide_secondary_nav_select_sub";
	}
							
	
}




function cleanURL(dirtyURL){
	while( dirtyURL[dirtyURL.length-1]=="default.aspx" || dirtyURL[dirtyURL.length-1]=="#" || dirtyURL[dirtyURL.length-1]=="" ){		
		dirtyURL.pop();
	}
	return dirtyURL;
}

/////////////////////////////////////////
// Pop Up
/////////////////////////////////////////
function NewWindow(mypage,myname,w,h,wintitle,scroll){
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  var settings  ='height='+h+',';
      settings +='width='+w+',';
      settings +='top='+wint+',';
      settings +='left='+winl+',';
      settings +='scrollbars='+scroll+',';
      settings +='resizable=no';
  win=window.open(mypage,myname,settings);
  if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}
