function toggle(targetId) {
	target = document.all(targetId);
	if (target.style.display == "none"){
		target.style.display="";
	} else {
		target.style.display="none";
	}
}

function computeDivWidth() {
	var imageW;
	var scale=1;
	var divWidth;
	var divHeight;
	var newImageW;
	imageW = document.getElementById("largeImage").width;
	if(imageW>290) {
		scale = 290/imageW;
	newImageW = 290;
	//alert(imageWidth);	
	document.getElementById("largeImage").width = newImageW;
	
	divWidth = Math.round(150*scale);
	divHeight = Math.round(200*scale);
	
	document.getElementById("imageDiv").style.width = divWidth;
	document.getElementById("imageDiv").style.height = divHeight;
	}

}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


  function showHideLayer(layerRef, showOrHide)
  {
  
  
	if (document.all) { //IS IE 4 or 5 (or 6 beta)
		eval( "document.all." + layerRef + ".style.visibility = showOrHide");
	}
	if (document.layers) { //IS NETSCAPE 4 or below
		document.layers[layerRef].visibility = showOrHide;
	}

	if (document.getElementById && !document.all) {
		layer = document.getElementById(layerRef);
		layer.style.visibility = showOrHide;
	}
	
  }

var tggling = false;
function tggle(tggler, tggled, quick, hiddenWhile) {
  var img_up = document.getElementById("img_up");
  var img_down = document.getElementById("img_down");

  if (tggling==true) {
    return;
  }
  tggling = true;
  if (quick == null) {
    quick = false;
  }
  if (navigator.userAgent.indexOf("irefox")!=-1) {
    quick = true;
  }

 	tggled = document.getElementById(tggled);
  hiddenWhile = document.getElementById(hiddenWhile);
  
	if (tggler.src!=null && tggler.src == img_up.src){
		tggler.src = img_down.src;
    //if (!quick && $(tggled.firstChild).getStyle) {	
    //  Effect.toggle(tggled, 'blind', {afterFinish: afterFinish});	
  	//} else {
  		tggled.style.display = 'none';
      tggling = false;
  	//}
	} else {
		tggler.src = img_up.src;
   // if (!quick && $(tggled.firstChild).getStyle) {	
   //   Effect.toggle(tggled, 'blind', {afterFinish: afterFinish});
  	//} else {
     	tggled.style.display = 'block';
      tggling = false;
    //}
	}
}

function afterFinish(obj){
  tggling = false;
}

    var currentHovered = new Array();
    var currentShowing = new Array();
    function testHover(source, panelIndex){
      if (source == currentShowing[panelIndex]) {
        return;
      } 
      if (currentHovered[panelIndex] != null) {
        currentHovered[panelIndex].style.background="";
      }
      if (currentShowing[panelIndex] != null) {
        currentShowing[panelIndex].style.display="none";
      }

      currentHovered[panelIndex] = source;
      currentHovered[panelIndex].style.background="#cccccc";

      var targetShowingId;
      if(document.all){
        targetShowingId = currentHovered[panelIndex].innerText;
      } else{
        targetShowingId = currentHovered[panelIndex].textContent;
      }
      targetShowingId = targetShowingId.replace(/ /g, "_");

      currentShowing[panelIndex] = document.getElementById(targetShowingId);

      if (currentShowing[panelIndex] != null) {
        currentShowing[panelIndex].style.display="block";
      }

    }
    
function escapeXMLEntities(s) {
	//return s.replace(/'/g, "&apos;").replace(/"/g, "&quot;" ).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"); 
	return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"); 
}

function escapeJSQuotes(s) {
	return s.replace(/'/g, "\'").replace(/"/g, "\"");
}

function addEvent(obj, evType, fn){
 if (obj.addEventListener){
   obj.addEventListener(evType, fn, false);
   return true;
 } else if (obj.attachEvent){
   var r = obj.attachEvent("on"+evType, fn);
   return r;
 } else {
   return false;
 }
}

    function prettyHtmlRaw(raw) {

      
      var pretty = "";

      var position = {
        inStartTag:false,
        inEndTag:false,
        inAttributes:false,
        inAttributeValue:"",
        justOpenedBlock:false
      };

      var openedSpans = 0;
      var c;


      for (var r = 0; r < raw.length; r++) {
        c = raw.substr(r, 1);
        if (c == "&" && raw.substr(r, 10)=="&amp;apos;") {
          c = "'";
          r += 9;
        }
        if (position.inStartTag && !position.inAttributes && c == " ") { //after tag name, into attributes
          pretty += "<span class='attribute'> ";
          openedSpans++;
          position.inAttributes = true;
        }
        if (position.inAttributes && (c == "'" || c == '"')) { //after tag name, into attributes
          if (position.inAttributeValue == c) {//closing value
            pretty += c + "</span>";
            openedSpans--;
            position.inAttributeValue = "";
          } else { //opening value
            pretty += "<span class='value'>" + c;
            openedSpans++;
            position.inAttributeValue = c;
          }
        } else if (raw.substr(r, 5) == "&lt;/") { //start of end tag
          pretty += "</span><span class='tag'>&lt;/";
          position.inStartTag = false;
          position.inEndTag = true;
          r += 4;
        } else if (raw.substr(r, 4) == "&lt;") { //start of start tag
          if (!position.justOpenedBlock) {
            pretty += "<br />";
          }
          pretty += "<span class='tag'>&lt;";
          openedSpans++;
          position.inStartTag = true;
          position.inEndTag = false;
          r += 3;
        } else if (raw.substr(r, 5) == "/&gt;") { //end of singleton tag
          if (position.inAttributes) {
            position.inAttributes = false;
            pretty += "</span>";
            openedSpans--;
          }
          position.inAttributes = false;
          position.inStartTag = false;
          pretty += "/&gt;</span>";
          openedSpans--;
          r += 4;
        } else if (raw.substr(r, 4) == "&gt;") { //end of start or end tag
          if (position.inAttributes) {
            position.inAttributes = false;
            pretty += "</span>";
            openedSpans--;
          }
          pretty += "&gt;</span>";
          openedSpans--;
          if(position.inStartTag) {
            position.inStartTag = false;
            pretty += "<span class='tagblock'>";
            position.justOpenedBlock = true;
            openedSpans++;
          }
          if(position.inEndTag) {
            position.inEndTag = false;
          }
          r += 3;
        } else {
          if (c != " " && c != "\t" && c != "\r" && c != "\n") {
            position.justOpenedBlock = false;
          }
          if (!position.justOpenedBlock) {
            pretty += c;
          }
           
        }
      }

      for(var i = 0; i < openedSpans; i++) {
        pretty += "</span>";
      }
		return pretty;
     // element.innerHTML = pretty;
    }