/////////////////////////////////////////
// Rollover Buttons
/////////////////////////////////////////
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 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];}
}

/////////////////////
//Simple Secondary Nav
/////////////////////
function simpleSecNav(){	
	for (x=1;x<4;x++){
		var theTable = document.getElementById('secondaryNavTable' + x);
		var theRows = theTable.getElementsByTagName('tr');
		var theLinks = theTable.getElementsByTagName('a');
		var curr_row;
		
		for (curr_row = 0; curr_row < theRows.length; curr_row++)
		{
			currentpath=window.location.href;
			newpath=theLinks[curr_row].href;
			curr_array=currentpath.split("/");
			new_array=newpath.split("/");
	
			if(curr_array[curr_array.length-1]=="" || curr_array[curr_array.length-1]=="#"){
					//remove empty value or test link
					curr_array.pop();
			}
			if(new_array[new_array.length-1]==""){
					new_array.pop();
			}
			//alert(curr_array[curr_array.length-1]+" = "+new_array[new_array.length-1]);
			theRow=curr_row;
			theLinks[curr_row].className="secondaryNav";
			
				if(curr_array[curr_array.length-1]==new_array[new_array.length-1] && newpath.lastIndexOf('#')<0){
					theRows[curr_row].className="secondaryNavSelect secondaryNavTD";
					theLinks[curr_row].style.color="#e67b0f";
				}else{
					theRows[curr_row].className="secondaryNavOut secondaryNavTD";
			
					theLinks[curr_row].onmouseover = function() {
						this.parentNode.className="secondaryNavOver secondaryNavTD";		
					}
					theLinks[curr_row].onmouseout = function() {
						this.parentNode.className="secondaryNavOut secondaryNavTD";	
					}
					
				}
		
			}
	
		}
	}


/////////////////////////////////////////
// Styles 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 Image
/////////////////////////////////////////
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);
  //win.document.write('<head><title>'+wintitle+'</title></head>');
  //win.document.write('<body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">');
  //win.open.(mypage);
  if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}
	
	
	
/////////////////////////////////////////
// Submit a Ticket - Form Validation
/////////////////////////////////////////
function validate(f) {
	if (f.name.value == ""){
		alert("Please insert your name");
		f.name.focus();
		return false;
	}
	else if (f.location.value == "Select Location") {
		alert("Please Select a Location");
		return false;
	}
	else if (f.email.value == "" && f.phone.value == "") {
		alert("Please insert either phone number or e-mail address");
		return false;
	}
	else {
	return true;
	}
}
	
	
	
