function disappear (id,x) {
	if (x == 0) {
		var jsDiv = document.getElementById(id);
		jsDiv.style.display = 'none';
	} else {
		x--;
		setTimeout(disappear(id,x),'2000');
	}
}

function ajaxLoadObject (url, divID) {
//	makeHttpRequest ( url, 'fadeDiv', false, divID );
	makeHttpRequest ( url, 'noFadeDiv', false, divID );
}

function ajaxLoadObjectNoFade (url, divID) {
	makeHttpRequest ( url, 'noFadeDiv', false, divID );
}

function makeHttpRequest(url, callback_function, return_xml, divID)
{
   var http_request = false;
   if (window.XMLHttpRequest) { // Mozilla, Safari,...
       http_request = new XMLHttpRequest();
       if (http_request.overrideMimeType) {
           http_request.overrideMimeType('text/xml');
       }
   } else if (window.ActiveXObject) { // IE
       try {
           http_request = new ActiveXObject("Msxml2.XMLHTTP");
       } catch (e) {
           try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
           } catch (e) {}
       }
   }

   if (!http_request) {
       alert('Unfortunatelly your browser doesn\'t support this feature.<br/> Please upgrade to <a href="http://www.mozilla.com">Mozilla</a>.');
       return false;
   }
   http_request.onreadystatechange = function() {
       if (http_request.readyState == 4) {
           if (http_request.status == 200) {
               if (return_xml) {
                   eval(callback_function + '(http_request.responseXML,divID)' );
               } else {
                   eval(callback_function + '(http_request.responseText,divID)' );
               }
           } else {
               document.getElementById('ERROR_BOX').innerHTML =  'There was a problem with the request.(Code: ' + http_request.status + ') URL:' + url;
           }
       }
   }
   http_request.open('GET', url, true);
   http_request.send(null);
}

function fadeDiv (response, divID) {
	obj = document.getElementById(divID);
	setOpacity(obj,0);
	obj.innerHTML = response;
	fadeIn(divID,0);
}

function noFadeDiv (response, divID) {
	obj = document.getElementById(divID);
	obj.innerHTML = response;
}

function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  obj.style.filter = "alpha(opacity:"+opacity+")";
  obj.style.KHTMLOpacity = opacity/100;
  obj.style.MozOpacity = opacity/100;
  obj.style.opacity = opacity/100;
}

function fadeIn(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 20;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
    }
  }
}

function emailWindow(emailID) {
	var load = window.open('emailForm.php?emailID='+emailID,'','scrollbars=yes,menubar=no,height=550,width=720,resizable=yes,toolbar=no,location=no,status=no');	
}

function changeMainImage (program) {
	document.getElementById('mainImage').src = '/portal/images/'+program+'Picture.jpg';
	document.getElementById(program).src = '/portal/images/'+program+'Thumb.jpg';
	document.getElementById('leftStripe').style.backgroundImage = 'url(/portal/images/'+program+'LeftStripe.gif)';
}

function unGhost (program) {
	document.getElementById(program).src = '/portal/images/'+program+'Thumb-Ghost.jpg';
	document.getElementById('leftStripe').style.backgroundImage = 'url(/portal/images/leftStripe.gif)';
}

function deleteConfirmation (newLocation) {
	if (confirm("Are you really sure you want to delete this?\n\nOnce deleted it will be gone forever.  We will not store a backup of it, so once you delete it, if you made a mistake, you will have to come back and type it in all over again. And any ways, what you probably really want to do - if you meant to hit the delete button in the first place - is just set the status of this record to inactive.")) { 
		ajaxLoadObject(newLocation,'ajaxController');
	} else {
		return false;
	}
}

function pushConfirmation (newLocation) {
	if (confirm("Are you really sure you want push this web site?")) { 
		window.location = newLocation;
	} else {
		return void(0);
	}
}

function setCookie(c_name,value,expiredays) {
	var exdate=new Date()
	exdate.setDate(exdate.getDate()+expiredays)
	document.cookie=c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
}

function switchCSS (option) {
	if (option == 'standard') {
		document.getElementById('stylesheet').href='site.css';	
		setCookie('stylesheet','standard','90');
		thisLink = document.getElementById('cssLink');
		thisLink.href='javascript:switchCSS(\'accessibility\')';
		thisLink.innerHTML='Accessibility';
	} else if (option='accessibility') {
		document.getElementById('stylesheet').href='media/accessibility.css';	
		setCookie('stylesheet','accessibility','90');
		thisLink = document.getElementById('cssLink');
		thisLink.href='javascript:switchCSS(\'standard\')';
		thisLink.innerHTML='Standard';
	}
	void(0);
}