//fade implement
var Color= new Array();
Color[1] = "ff";
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(7)", 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 selectProject() {
        var selector = $('projectSelector');
        if (selector.options[selector.selectedIndex].value != "")
          window.location.href = "/projects/" + selector.options[selector.selectedIndex].value + "/logs";
      }
function selectAdminLink() {
        var selector = $('adminSelector');
          window.location.href = selector.options[selector.selectedIndex].value;
      }

var checkflag = "true";
function togglePeople(id) {
  field = document.getElementsByClassName( id );
  if (checkflag == "false") {
     for (i = 0; i < field.length; i++) {
        field[i].checked = true;
     }
    checkflag = "true";
  } else {
    for (i = 0; i < field.length; i++) {
      field[i].checked = false; 
    }
    checkflag = "false";
  }
}


    function getElement(aID)
    {
        return (document.getElementById) ?
            document.getElementById(aID) : document.all[aID];
    }

    function getIFrameDocument(aID){ 
        var rv = null; 
        var frame=getElement(aID);
        // if contentDocument exists, W3C compliant (e.g. Mozilla) 
        if (frame.contentDocument)
            rv = frame.contentDocument;
        else // bad IE  ;)
            rv = document.frames[aID].document;
        return rv;
    }
 function updateChart2(originalRequest) {  
            var a=originalRequest.responseText.replace(/"/g,"'"); 
            var chart = new FusionCharts("/charts/FCF_MSLine.swf", "ChartId", "500", "350"); 
            chart.setDataXML(a); 
           chart.render("chart");  
 }  

function addfavorite(url,name)
{
if (document.all)
{
window.external.addFavorite('http://' + url + '.trikr.com',name);
}
else if (window.sidebar)
{
window.sidebar.addPanel(name,'http://' + url + '.trikr.com','');
}
}

function setMaxLength() {
	var x = document.getElementsByTagName('textarea');
	var counter = document.createElement('div');
	counter.className = 'counter';
	for (var i=0;i<x.length;i++) {
		if (x[i].getAttribute('maxlength')) {
			var counterClone = counter.cloneNode(true);
			counterClone.relatedElement = x[i];
			counterClone.innerHTML = '<span>0</span>/'+x[i].getAttribute('maxlength');
			x[i].parentNode.insertBefore(counterClone,x[i].nextSibling);
			x[i].relatedElement = counterClone.getElementsByTagName('span')[0];

			x[i].onkeyup = x[i].onchange = checkMaxLength;
			x[i].onkeyup();
		}
	}
}

function checkMaxLength() {
	var maxLength = this.getAttribute('maxlength');
	var currentLength = this.value.length;
	if (currentLength > maxLength)
		this.relatedElement.className = 'toomuch';
	else
		this.relatedElement.className = '';
	this.relatedElement.firstChild.nodeValue = currentLength;
	// not innerHTML
}

