/*@cc_on _d=document;eval('var document=_d')@*/

// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function toggleDisplay(id1,id2) {
	// if id1 is hidden, then show it and hide id2. else do the opposite.
	if (document.getElementById(id1).style.display == 'none') {
		document.getElementById(id1).style.display = 'block'
		document.getElementById(id2).style.display = 'none'
	} else {
		document.getElementById(id1).style.display = 'none'
		document.getElementById(id2).style.display = 'block'
	}
	return false;
}

function toggleDisplayInline(id1,id2) {
	window.alert('hi');
	// if id1 is hidden, then show it and hide id2. else do the opposite.
	if (document.getElementById(id1).style.display == 'none') {
		document.getElementById(id1).style.display = 'inline'
		document.getElementById(id2).style.display = 'none'
	} else {
		document.getElementById(id1).style.display = 'none'
		document.getElementById(id2).style.display = 'inline'
	}
	return false;
}

// For more explicit on and off switching
function turnDisplay(id, onOrOff)  {
    if (onOrOff == 'off') {
		 document.getElementById(id).style.display = 'none'
    } else if (onOrOff == 'on') {
		 document.getElementById(id).style.display = 'block'
    }
    return false;
}

// Yellow Fade Technique (tm 37 Signals)
var Color= new Array();
Color[2] = "ee";
Color[3] = "dd";
Color[4] = "cc";
Color[5] = "bb";
Color[6] = "aa";
Color[7] = "99";

function waittofade() {
	if (document.getElementById('fade')) {
    setTimeout("fadeIn(10)", 1000);
	 }
}

function fadeIn(where) {
    if (where >= 1) {
        document.getElementById('fade').style.backgroundColor = "#ffff" + Color[where];
		  if (where > 1) {
			  where -= 1;
			  setTimeout("fadeIn("+where+")", 200);
			} else {
			  where -= 1;
			  setTimeout("fadeIn("+where+")", 200);
			  document.getElementById('fade').style.backgroundColor = "transparent";
			}

    }
}

function popWindow(url,name,options){
        var ContextWindow = window.open(url,name,options);
        ContextWindow.opener = this;
        ContextWindow.focus();
}

function flashTest() {
  if (!hasRightVersion) {
    turnDisplay('flashMap','off')
    turnDisplay('noFlashMap','on')
  }
}

function isNotEmpty(elem) {
    var str = elem.value;
    if(str == null || str.length == 0) {
      alert("Please, supply your query.");
      return false;
    } else {
      return true;
    }
}

function ajax_status(node,status_string,replace)
{
  if (!node) return false;
  if (typeof node == 'string')
    node = document.getElementById(node);
  if (node) {
    if (replace)
      node.innerHTML = status_string
    else
      node.innerHTML = status_string + node.innerHTML 
  }
}