// JavaScript Document
/* NOTE: eff_length is in MILLI-SECONDS and not seconds
		 so for if duration is 1 second long, you should
		 enter 1000 in your function calls. */


function ajaxSlideDown(url, div_id, eff_length){
	//$(div_id).hide(); 
	ajax(url, div_id, 'slidedown', eff_length/1000);
}
function ajaxFadeOutIn(url, div_id, eff_length){
	Effect.Fade(div_id, { duration: eff_length/1000 });
	setTimeout("ajax('"+url+"', '"+div_id+"', 'fadein', "+eff_length/1000+")", eff_length);
}
function ajaxFadeIn(url, div_id, eff_length){
	setTimeout("ajax('"+url+"', '"+div_id+"', 'fadein', "+eff_length/1000+")", eff_length);
}
/*NOTE: This function works with special effects. 
		For this function to work, you need to include
		scriptaculous.js, prototype.js, and unittest.js
		in your .cfm or .html pages. These files are
		in nd/js/effects/ folder. */
function ajax(url, div_id, effect, eff_length) {
	var xmlhttp;
	if (window.XMLHttpRequest) {
  		// code for IE7+, Firefox, Chrome, Opera, Safari
 		xmlhttp=new XMLHttpRequest();
	} else {
		// code for IE6, IE5
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function() {
		if(xmlhttp.readyState==4) {
			document.getElementById(div_id).innerHTML=xmlhttp.responseText;
			if(effect=="fadein"){
				Effect.Appear(div_id, { duration: eff_length });
			} else if(effect=="slidedown") {Effect.SlideDown(div_id, {queue:'end'});
				//Effect.SlideDown(div_id,{duration:eff_length});
			} else {
				changeOpac(100, div_id);
			}
		}
	}
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function fade(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}
//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
	object.zoom=1;
} 

