// JavaScript Document
/*@cc_on @if (@_win32 && @_jscript_version >= 5) if (!window.XMLHttpRequest)
window.XMLHttpRequest = function() { return new ActiveXObject('Microsoft.XMLHTTP') }
@end @*/
function cleanItUp(passedURL,passedID)
{
	var httpRequest = new XMLHttpRequest();
	httpRequest.open('GET', passedURL, false);
	httpRequest.send(null);
	var theText = httpRequest.responseText;
	//alert(theText + ' - Original Code');
	// go through and remove the data identifier first
	//theText = theText.replace('myHTMLdata=',''); 
	//remove the menucontainer/menulist... will have to work with Joe to ensure that
	//everything between <!-- and //--> is removed correctly - alternately, this CAN 
	//be styled (even though menulist and menucontainer are ID's, not classes)
	theText = theText.replace('<!-- <div id="menucontainer">  <ul id="menulist">    <li id="active"><a href="index.html">Home</a></li>    <li><a href="mediaTop.html">mediaTop</a></li>    <li><a href="mediaBottom.html">mediaBottom</a></li>    <li><a href="programs1.html">programs1</a></li>    <li><a href="programs2.html">programs2</a></li>    <li><a href="programs3.html">programs3</a></li>    <li><a href="staff.html">staff</a></li>    <li><a href="testimonials.html">testimonials</a></li>  </ul></div> //-->','');
	//a regular expression that can be saved for later...
	var myRegExp = "/(?<=^|>)[^><]+?(?=<|$)/g";
	// use replaceAll function to change other tags as needed... unneeded if we're writing to HTML, 
	//uncomment below if you have specific stuff to remove in multiple places
		//theText = theText.replaceAll('stringToReplace','replacementText');
	//TRAVIS: below writes information from a specified file to a DIV from within Flash
	var myNew = document.getElementById(passedID);
	myNew.innerHTML = theText;
}
String.prototype.replaceAll = function(strTarget, strSubString)
{
	var strText = this;
	var intIndexOfMatch = strText.indexOf( strTarget );
	// Keep looping while an instance of the target string
	// still exists in the string being passed currently.
	while (intIndexOfMatch != -1)
	{
		// Relace out the current instance.
		strText = strText.replace( strTarget, strSubString )
		// Get the index of any next matching substring.
		intIndexOfMatch = strText.indexOf( strTarget );
	}
// Return the updated string with ALL the target strings
// replaced out with the new substring.
return(strText);
}

function clearItOut()
{
	//clear out the current innerHTML
	var myNew1 = document.getElementById('thisIsTheNew1');
	var myNew3 = document.getElementById('thisIsTheNew3');
	var myNew4 = document.getElementById('thisIsTheNew4');
	myNew1.innerHTML = myNew3.innerHTML = myNew4.innerHTML = "Cleared.";
}

var myRatio = 1;
var myW = 0;
var myH = 0;
function changePic(myID)
{
	var myPicDiv = document.getElementById('photoArea');
	var mySRC = document.getElementById(myID).getAttribute('src');
	//alert(mySRC);
	mySRC = mySRC.replace('/thumbs/','/LARGE/');
	//alert(mySRC);
	// What do we do if both height and width are both over the needed size?  
	//Determine which would have the larger % of change first:
	//compareWH(mySRC);	
	//alert("Height = " + myH + ", Width = " + myW + ", Ratio = " + myRatio);
	myPicDiv.innerHTML = "<img src='" + mySRC + "' border='0' />"
	//alert(myPicDiv.innerHTML);
	//return our variables back to initial states for next click.
	myRatio = 1;
	myW = 0;
	myH = 0;

}
function compareWH(pSrc)
{
	var theImg = new Image();
	theImg.src = pSrc;
	//alert(theImg.src);
	myW = theImg.width;
	myH = theImg.height;
	//alert(myW + ":width, " + myH + ":height");
	//run the below function if either height or width are over the allotted size limits.
	if(myW > 795 || myH > 500)
	{
		if(myW > myH)
		{
			if (myW > 795)
			{
				var myNewW = 795;
				myRatio = ((myNewW/myW));
				myW = (myW * myRatio);
				myH = (myH * myRatio);
			}
		}
		if(myH > myW)
		{
			if (myH > 500)
			{
				//alert("height = " + myH);
				var myNewH = 500;
				myRatio = ((myNewH/myH));
				myH = (myH * myRatio);
				myW = (myW * myRatio);
			}
	
		}
		if(myH == myW)
		{
			myH = 500;
			myW = 500;
		}
	}
	//Set theImg back to nothing and ready for our next image...
	theImg = "";
	//alert(theImg);
}
function changeTitle(theIMG)
{
	var theDiv = document.getElementById("aboutTitle");
	theDiv.style.backgroundImage = theIMG;
}