
var newwindow = '';
function callRoadReports(page, id){
if(id != null && id != '')  {
  switch(page){
   case 'highways':
    url = 'Highways.htm?' + id; 
    break;  
   case 'regions':
    url = id;
    break;
   case 'routes':
    url = 'Route.htm?' + id;
    break;
   case 'cameras':
    url = id;
    break;
   default:
    alert("Error");
  }
  
  this.location.href = url;
  /*
     if (!newwindow.closed && newwindow.location) {
      newwindow.location.href = url;
     }
     else {
      newwindow=window.open(url,'name','height=600,width=750,scrollbars=1,resizable=1');
      if (!newwindow.opener) newwindow.opener = self;
     }
      
     if (window.focus) {newwindow.focus()}
 */
 }
     return false;
}
function activeTab(tab){
	for (i = 1; i < 6; i++){
		document.getElementById('tab' + i).className = "nonactive_tab";
	}
	document.getElementById(tab).className = 'active_tab';

	switch(tab){
		case 'tab1':
			document.getElementById('related_links').style.display = 'none';
			document.getElementById('regions').style.display = 'block';		
			break;
		case 'tab4':
			document.getElementById('related_links').style.display = 'none';
			document.getElementById('regions').style.display = 'none';		
			break;		
		case 'tab5':
			document.getElementById('related_links').style.display = 'block';
			document.getElementById('regions').style.display = 'none';		
			break;			
	}

}
 function popupGlossary(winLoc, winSettings)  {
         // Location where to put the top left corner of the Popup window.
         // From the left side of the screen.
         var popupLeft = 250; 
         // From the top of the screen.
         var popupTop = 300; 
         var popupSettings = 
         "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,height=200,width=350,screenY="+popupTop+",screenX="+popupLeft+",top="+popupTop+",left="+popupLeft;
         // Set the name of this browser window before loading the popup browser window.(JS1.1)
         window.name = 'AMA_Main'; 
         // Open the popup screen. (JS1.0)
         popupWindows = window.open(winLoc, 'Glossary_Popup', popupSettings);
         // Check if the popup Window was opened. If it was make sure it has focus.
         if (popupWindows != null)  {
          popupWindows.focus();
         }
         return popupWindows;
}

function popupCamera(winLoc, winSettings)  {
	// Location where to put the top left corner of the Popup window.
	// From the left side of the screen.
	var popupLeft = 50; 
	// From the top of the screen.
	var popupTop = 40; 
	var popupSettings = 
	"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,height=660,width=440,screenY="+popupTop+",screenX="+popupLeft+
	      ",top="+popupTop+",left="+popupLeft;
	 // Set the name of this browser window before loading the popup browser window.(JS1.1)
	 window.name = 'AMA_Main'; 
	 // Open the popup screen. (JS1.0)
	 popupWindows = window.open(winLoc, 'Package_Popup', popupSettings); 
	 // Check if the popup Window was opened. If it was make sure it has focus.
	 if (popupWindows != null)  {
	  popupWindows.focus();
	 }
	 return false;
}
	
// test functions

function goAnchor(id)
{
	document.getElementById("conditions_div").scrollTop = document.getElementById(id).offsetTop
}

function Querystring(qs) { // optionally pass a querystring to parse
	this.params = new Object()
	this.get=Querystring_get
	
	if (qs == null)
		qs=location.search.substring(1,location.search.length)

	if (qs.length == 0) return

// Turn <plus> back to <space>
// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
	qs = qs.replace(/\+/g, ' ')
	var args = qs.split('&') // parse out name/value pairs separated via &
	
// split out each name=value pair
	for (var i=0;i<args.length;i++) {
		var value;
		var pair = args[i].split('=')
		var name = unescape(pair[0])

		if (pair.length == 2)
			value = unescape(pair[1])
		else
			value = name
		
		this.params[name] = value
	}
}

function Querystring_get(key, default_) {
	// This silly looking line changes UNDEFINED to NULL
	if (default_ == null) default_ = null;
	
	var value=this.params[key]
	if (value==null) value=default_;
	
	return value
}

// test functions

function popupDisclaimer(winLoc, winSettings)  {
	// Location where to put the top left corner of the Popup window.
	// From the left side of the screen.
	var popupLeft = 50; 
	// From the top of the screen.
	var popupTop = 40; 
	var popupSettings = 
	"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,height=500,width=400,screenY="+popupTop+",screenX="+popupLeft+
	      ",top="+popupTop+",left="+popupLeft;
	 // Set the name of this browser window before loading the popup browser window.(JS1.1)
	 window.name = 'AMA_Main'; 
	 // Open the popup screen. (JS1.0)
	 popupWindows = window.open(winLoc, 'Popup', popupSettings); 
	 // Check if the popup Window was opened. If it was make sure it has focus.
	 if (popupWindows != null)  {
	  popupWindows.focus();
	 }
	 return false;
}

var newwindow = '';
function callRoadReports(page, id){
  switch(page){
   case 'highways':
    url = 'Highways.htm?' + id; 
	//url = 'Highways.htm?'+id;
    break;  
   case 'regions':
    url = id;
    break;
   case 'routes':
    url = 'Route.htm?' + id;
    break;
   case 'cameras':
    url = id;
    break;
   default:
    alert("Error");
  }
  
  this.location.href = url;
  /*
     if (!newwindow.closed && newwindow.location) {
      newwindow.location.href = url;
     }
     else {
      newwindow=window.open(url,'name','height=600,width=750,scrollbars=1,resizable=1');
      if (!newwindow.opener) newwindow.opener = self;
     }
      
     if (window.focus) {newwindow.focus()}
 */
     return false;
}
function scrollRight(){
	var x = screen.width;
	var y = screen.height;
	if ((x <= 800) && (y <= 600))
	{
		self.scroll(x, 0);
	}
}

function selectRegionTab(lastActiveTabId)  {
	document.getElementById(lastActiveTabId+'-content').style.display = 'none';
	document.getElementById(lastActiveTabId+'-header').className = 'accordion_headings';
	document.getElementById('test1-content').style.display = 'block';
	document.getElementById('test1-header').className = 'accordion_headings header_highlight';
}
