/* ========================================
 * Nectyr Productions
 * David Michael Lavoie
 *
 * 215-442-5696
 * david@nectyr.com
 * ======================================== */

/* ========================================
 * AJAX SETUP
 * ======================================== */

var req;
var target;
var isIE;
           
function initRequest(url) {
	if (window.XMLHttpRequest) {
	req = new XMLHttpRequest();
			} else if (window.ActiveXObject) {
				isIE = true;
				req = new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		
		
function getXmlHttpRequest() {
	if (typeof XMLHttpRequest != 'undefined')
		return new XMLHttpRequest();
	else if (window.ActiveXObject) {
		var avers = ["Microsoft.XmlHttp", "MSXML2.XmlHttp",
		"MSXML2.XmlHttp.3.0", "MSXML2.XmlHttp.4.0",
		"MSXML2.XmlHttp.5.0"];
	for (var i = avers.length -1; i >= 0; i--) {
		try {
			httpObj = new ActiveXObject(avers[i]);
				return httpObj;
			} catch(e) {}
		}
	}
throw new Error('XMLHttp (AJAX) not supported');
alert('You must be running a newer, javascript enabled browser to use this system,');
}
function ToggleContent(d) {
	if (document.getElementById(d).style.display=='none') {
		document.getElementById(d).style.display='block';
	} else {
		document.getElementById(d).style.display='none';
	}
}


/* ========================================
 * TEXT CAPITALIZATION
 * ======================================== */	


function capitalize(obj) {
   var val = obj.value.toLowerCase();
   if(!val) return;
   val=val.toUpperCase();
   obj.value=val;
}


/* ========================================
 * REMOVE / ADD DIVS+ELEMENTS
 * ======================================== */	
 

function RemoveContent(d) {
	document.getElementById(d).style.display="none";
}

function InsertContent(d) {
	document.getElementById(d).style.display="";
}

/* ========================================
 * DELETION CONFIRMATION
 * ======================================== */	

function delconf(acctdetails) {
	return confirm ("Are you sure you want to delete the following: "+acctdetails+" ?")
}


/* ========================================
 * OPACITY MODIFICATION / SCALING
 * ======================================== */	

function opacity(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++;
        }
    }
}

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 + ")";
    if (opacity<1) {object.display="none";} else { object.display="block"; }
} 

