// Global JavaScript File

// Jump to any of the predefined County exploreable section
function goToPage(strCategory){
	switch(strCategory){
		case
			"county_info":
			document.location = "/portal/general_info.asp";
			break;
		case "business":
			document.location="/portal/business/";
			break;
		case "hhs":
			document.location="/portal/health.asp";
			break;
		case "community_dev":
			document.location="/planning/";
			break;
		case "law":
			document.location="/portal/justice.asp";
			break;
	}
}

// Another jump funciton -- for compatibility
function jump(url){
  if(url !=""){
	  document.location = url;
  }
}

// Example: obj = findObj("image1");
function findObj(theObj, theDoc)
{
  var p, i, foundObj;

  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
	theDoc = parent.frames[theObj.substring(p+1)].document;
	theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  for (i=0; !foundObj && i < theDoc.forms.length; i++)
	foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++)
	foundObj = findObj(theObj,theDoc.layers[i].document);

  return foundObj;
}

// * Dependencies *
// this function requires the following snippets:
// JavaScript/readable_MM_functions/findObj
//
// arg 1: simple name of a layer object, such as "Layer1"
// arg 2: new class name
//
// Example: changeClassName(Layer1,'class2');
function changeClassName(id, newClass) {
    obj=findObj(id);
    obj.className=newClass;
}

// * Dependencies *
// this function requires the following snippets:
// JavaScript/readable_MM_functions/findObj
//
// Accepts a variable number of arguments, in triplets as follows:
// arg 1: simple name of a layer object, such as "Layer1"
// arg 2: ignored (for backward compatibility)
// arg 3: 'hide' or 'show'
// repeat...
//
// Example: showHideLayers(Layer1,'','show',Layer2,'','hide');
function showHideLayers()
{
  var i, visStr, obj, args = showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
  {
	if ((obj = findObj(args[i])) != null)
	{
	  visStr = args[i+2];
	  if (obj.style)
	  {
		obj = obj.style;
		if(visStr == 'show') visStr = 'block';
		else if(visStr == 'hide') visStr = 'none';
	  }
	  obj.display = visStr;
	}
  }
}

// * Dependencies *
// this function requires the following snippets:
// JavaScript/readable_MM_functions/findObj
//
// Accepts the following arguments:
// arg 1: simple name of a layer object, such as "Layer1"
//
// Example: toggleLayerDisplay(Layer1);
function toggleLayerDisplay(layerName)
{
  if ((obj = findObj(layerName)) != null)
  {
	if (obj.style)
	{
	  obj = obj.style;
      obj.visibility = 'visible';
	  if (obj.display.toLowerCase() == 'none' || obj.display.toLowerCase() == 'hidden' ||
	   (obj.display.toLowerCase() != 'block' && obj.display.toLowerCase() != 'visible'))
		obj.display = 'block';
	  else
		obj.display = 'none';
	}
  }
}

// * Dependencies *
// this function requires the following snippets:
// JavaScript/readable_MM_functions/findObj
//
// Accepts the following arguments:
// arg 1: simple name of a layer object, such as "Layer1"
//
// Example: toggleLayerVisibility(Layer1);
function toggleLayerVisibility(layerName)
{
  if ((obj = findObj(layerName)) != null)
  {
	if (obj.style)
	{
	  obj = obj.style;
      obj.display = 'block';
      if (obj.visibility.toLowerCase() == 'hidden' || obj.visibility.toLowerCase() == 'none' ||
       (obj.display.toLowerCase() != 'visible' && obj.display.toLowerCase() != 'block'))
		obj.visibility = 'visible';
	  else
		obj.visibility = 'hidden';
	}
  }
}

function fontSizeUp()
{
	var body = document.getElementsByTagName('body')[0];
	if (!body.style.fontSize) {
		body.style.fontSize = "90%";
	}
	else {
		switch (body.style.fontSize) {
			case "60%":
				body.style.fontSize = "70%";
				break;
			case "70%":
				body.style.fontSize = "75%";
				break;
			case "75%":
				body.style.fontSize = "90%";
				break;
			case "90%":
				body.style.fontSize = "110%";
				break;
		}
	}	
}

function fontSizeDown()
{
	var body = document.getElementsByTagName('body')[0];
	if (!body.style.fontSize) {
		body.style.fontSize = "70%";
	}
	else {
		switch (body.style.fontSize) {
			case "110%":
				body.style.fontSize = "90%";
				break;
			case "90%":
				body.style.fontSize = "75%";
				break;
			case "75%":
				body.style.fontSize = "70%";
				break;
			case "70%":
				body.style.fontSize = "60%";
				break;
		}
	}	
}