function writeFlash(id) {
	if( id == "Main" ) {
		document.getElementById('main').innerHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='432' height='340'><param name='movie' value='http://www.depts.ttu.edu/ode/main.swf' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><param name='allowscriptaccess' value='sameDomain'></param><embed src='http://www.depts.ttu.edu/ode/main.swf' quality='high' wmode='transparent' allowscriptaccess='sameDomain' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='432' height='340'></embed></object>";
		
	}
	else if( id == "StudentsSwitcher" ) {
		document.getElementById('StudentsSwitcher').innerHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='200' height='200'><param name='movie' value='http://www.ode.ttu.edu/k-12/StudentsSwitcher.swf' /><param name='quality' value='high' /><param name='allowscriptaccess' value='sameDomain'></param><embed src='http://www.ode.ttu.edu/k-12/StudentsSwitcher.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' allowscriptaccess='sameDomain' type='application/x-shockwave-flash' width='200' height='200'></embed></object>";
	}
	else if( id == "MainK12" ) {
		document.getElementById('MainK12').innerHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='500' height='635'><param name='movie' value='http://www.depts.ttu.edu/ode/k-12/MainK12.swf' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><param name='allowscriptaccess' value='sameDomain'></param><embed src='http://www.depts.ttu.edu/ode/k-12/MainK12.swf' allowscriptaccess='sameDomain' quality='high' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='500' height='635'></embed></object>";
	}
 }
 
function GiveDec(Hex)
{
	if(Hex == "A")
	  Value = 10;
	else
	if(Hex == "B")
	  Value = 11;
	else
	if(Hex == "C")
	  Value = 12;
	else
	if(Hex == "D")
	  Value = 13;
	else
	if(Hex == "E")
	  Value = 14;
	else
	if(Hex == "F")
	  Value = 15;
	else
	  Value = eval(Hex);
	
	return Value;
}

function convert(Input) {
	
	a = GiveDec(Input.substring(0, 1));
	b = GiveDec(Input.substring(1, 2));
	c = GiveDec(Input.substring(2, 3));
	d = GiveDec(Input.substring(3, 4));
	e = GiveDec(Input.substring(4, 5));
	f = GiveDec(Input.substring(5, 6));
	
	x = (a * 16) + b;
	y = (c * 16) + d;
	z = (e * 16) + f;
	return "rgb("+x+", "+y+", "+z+")"
}

function clearSearch() {
	if( document.getElementById('q').value == "Search" )
		document.getElementById('q').value="";
}

function setSearch() {
	if( document.getElementById('q').value == "" )
		document.getElementById('q').value="Search";
}

function fontSize( input ) {

	if( input == 1 ) {
		cs = document.getElementById('content').style.fontSize;
		alert( cs );
		if( cs < 18 ) {
			cs += 2;
			document.getElementById('content').style.fontSize = cs+'px';
		}
	}
	else {
		cs = document.getElementById('content').style.fontSize;
		if( cs > 8 ) {
			cs -= 2;
			document.getElementById('content').style.fontSize = cs+'px';
		}
	}
	
}

var http = createRequestObject();

function createRequestObject() {
	var request_o = false;
	request_o = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
	return request_o;
}

function getEmail() {
	if( http.readyState == 4 ) {
		if( http.status == 200 ) {
			document.getElementById('enrollment').innerHTML = http.responseText;
		}
		else if( http.status == 404)
			document.getElementById('enrollment').innerHTML = "URL does not exist.";
		else
			document.getElementById('enrollment').innerHTML = "Error: status code is " + http.status;
	}
	else {
		document.getElementById('enrollment').innerHTML = "Sending Information...";
	}
}

function doEmail() {
	var name = document.getElementById('name').value;
	var institution = document.getElementById('institution').value;
	var address = document.getElementById('address').value;
	var city = document.getElementById('city').value;
	var state = document.getElementById('state').value;
	var zip = document.getElementById('zip').value;
	var email = document.getElementById('email').value;
	var phone = document.getElementById('phone').value;
	var fax = document.getElementById('fax').value;
	var amount = document.getElementById('amount').value;
	
	http.open("POST", "../counselors/oepFunctions.php", true);
	http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	http.onreadystatechange = getEmail;
	var string = "name="+name+"&institution="+institution+"&address="+address+"&city="+city+"&state="+state+"&zip="+zip+"&email="+email+"&phone="+phone+"&fax="+fax+"&amount="+amount;
	http.send(string);
	
}


function toggleEmail(oEvent) {
	if( (document.getElementById('emailafriendText').innerHTML.substr(0, 2) == "Th" || document.getElementById('emailafriendText').innerHTML.substr(0, 2) == "We") ) {
		//alert("updating");
		updateEmail();
	}
	
	if( document.getElementById('emailafriend').style.visibility == "visible" )
		document.getElementById('emailafriend').style.visibility = "hidden";
	else {
		if (!oEvent) var oEvent = window.event;
		if (oEvent.pageX || oEvent.pageY) 	{
			posx = oEvent.pageX;
			//posy = oEvent.pageY;
			//alert("firefox");
			//alert(posx + 210 +" - "+window.innerWidth+" - "+document.getElementById('emailafriend').style.width);
			if( (posx + 225) >= window.innerWidth) {
				posx -= ((posx+225) - window.innerWidth + 20);
				//alert((posx + 225) + " - " + window.innerWidth +" - "+posx);
			}
		}
		else if (oEvent.clientX || oEvent.clientY) 	{
			posx = oEvent.clientX + document.body.scrollLeft
				+ document.documentElement.scrollLeft;
			//posy = oEvent.clientY + document.body.scrollTop
				//+ document.documentElement.scrollTop;
			//alert("IE");
			if( (posx + 225) >= document.body.clientWidth)
				posx -= ((posx+225) - document.body.clientWidth + 20);
				
		}
		
			
		//var offsetY = 8;
		//if( navigator.appName == "Microsoft Internet Explorer")
			//offsetY += 0;
		
		document.getElementById('emailafriend').style.top = 172+"px" //posy+offsetY+"px";
		document.getElementById('emailafriend').style.left = posx+"px";
		document.getElementById('emailafriend').style.visibility = "visible";
		//alert("top: "+(posy+offsetY)+"px - left: "+(posx+20)+"px");
	}
}

var httpEmail = createRequestObject();

function newEmail( ) {
	if( httpEmail.readyState == 4 ) {
		if( httpEmail.status == 200 ) {
			document.getElementById('emailafriendText').innerHTML = httpEmail.responseText;
		}
		else if( httpEmail.status == 404)
			document.getElementById('emailafriendText').innerHTML = "URL does not exist.";
		else
			document.getElementById('emailafriendText').innerHTML = "Error: status code is " + httpEmail.status;
	}
	else {
		document.getElementById('emailafriendText').innerHTML = "loading...";
	}
}

function sendEmail() {
	httpEmail.open("POST", "http://www.depts.ttu.edu/ode/ode-template/social/email.php", true);
	httpEmail.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	httpEmail.onreadystatechange = newEmail;
	var fromEmail = document.getElementById('emailThisFrom').value;
	var toEmail = document.getElementById('emailThisTo').value;
	var message = document.getElementById('emailThisMsg').value;
	httpEmail.send("fromEmail="+fromEmail+"&toEmail="+toEmail+"&message="+message+"&location="+location.href);
}

function updateEmail() {
	httpEmail.open("POST", "http://www.depts.ttu.edu/ode/ode-template/social/email.php", true);
	httpEmail.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	httpEmail.onreadystatechange = newEmail;
	httpEmail.send("update="+true);
}

function checkSSL() {
	if( "http:" == window.location.protocol ) {
		window.location = "https://"+document.location.hostname+document.location.pathname;
	}
}

