function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function getHTTPObject(){
	if (window.ActiveXObject) 
		return new ActiveXObject("Microsoft.XMLHTTP");
	else if (window.XMLHttpRequest) 
		return new XMLHttpRequest();
	else {
		alert("Your browser does not support AJAX.");
	return null;
	}
}

function showMemorial(THE_ID){
	writeCookie("petID_" + THE_ID);
	httpObject = getHTTPObject();
	if (httpObject != null) {
		httpObject.open("GET", "petpage_justData.php?THE_ID="+THE_ID, true);
		httpObject.send(null);
		httpObject.onreadystatechange = function setOutput(){
	THE_ID = readCookie("THE_ID");
	var tempStr = httpObject.readyState;
	if(httpObject.readyState == 4){
		var newText = httpObject.responseText;
		if(document.getElementById(THE_ID)){
			document.getElementById(THE_ID).innerHTML = newText;
			document.getElementById(THE_ID).style.display = "block";
		}
	}
}

	}
}

function hideMemorial(THE_ID){
	document.getElementById(THE_ID).innerHTML = "";
	document.getElementById(THE_ID).style.display = "none";
}



function writeCookie(THE_ID){
	document.cookie = "THE_ID" + "=" + THE_ID ;
}

function readCookie(name){
	var cookieValue = "";
	var search = name + "=";
	if(document.cookie.length > 0) { 
		offset = document.cookie.indexOf(search);
		if (offset != -1) { 
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if (end == -1) end = document.cookie.length;
			cookieValue = unescape(document.cookie.substring(offset, end))
		}
	}
	return cookieValue;
}


	imagesList = new Array("butterfly.jpg", "clouds.jpg", "iris.jpg", "lake.jpg", "lily.jpg", "mountain.jpg", "rose.jpg", "sunrise.jpg", "sunset.jpg", "waterfall.jpg", "balloon.gif", "poppies.jpg", "rainbow.jpg", "falls.jpg", "tulip.jpg", "pansies.jpg", "bridge.jpg", "purpleSky.jpg", "sunflower.jpg", "roses.jpg", "fallColor.jpg", "fog.jpg", "coast.jpg") 
	
	function swapImage(whatDirection) { 
		if(document.images) { 
			currentElement = document.petMem.counter.value ; 
			newElement = eval(currentElement + "+" + whatDirection);
			if ((newElement < 23) && (newElement > -1)){
				document.petMem.counter.value = newElement ;
				document.petMem.THE_PHOTO.value = imagesList[newElement] ;
				document.photoSelect.src = "petPhotos/" + imagesList[newElement] ; 
			}
		} 
	}
	
	function swapColor(whatColor) { 
		obj = document.getElementById('photoBorder') ;
		obj.style.backgroundColor = whatColor ;
		document.petMem.THE_BGND.value = whatColor ;
	}
	
	function tellTheUser(msgID) { 
		if (msgID == "11"){
			alert("The page was successfully created and will be posted in the next few days.") ; 
			window.location = "index.php"
		}else if (msgID == "1"){
			alert("Only .jpg images may be uploaded to this site.") ; 
		//	window.location = "index.php"
		}else if (msgID == "2"){
			alert("An error occured in trying to upload your image file.  Please check the guidelines and try again.") ; 
		//	window.location = "index.php"
		}else if (msgID == "3"){
			alert("Your image file did not upload. Please try again.") ; 
		//	window.location = "index.php"
		}else if (msgID == "4"){
			alert("Your image file does not appear to be a correctly formatted .jpg file.  Please try another.") ; 
		//	window.location = "index.php"
		}else if (msgID == "5"){
			alert("A process error has occured.  Please try again.") ; 
		//	window.location = "index.php"
		}else if (msgID == "6"){
			alert("The information you provided could not be written to the database.  Please try again.") ; 
		//	window.location = "index.php"
		}else if (msgID == "7"){
			alert("Your image file can not be found on your hard drive.  Please try again.") ; 
		//	window.location = "index.php"
		}else if (msgID == "8"){
			alert("There is something wrong with the file you are trying to upload. Please make sure it is of the type .jpg and try again.") ; 
		//	window.location = "index.php"
		}else if (msgID == "9"){
			alert("Your image file is too big for this site to process. Please reduce it's size to about 1MB and try again.") ; 
		//	window.location = "index.php"
		}else{
			alert("The field " + msgID + " is empty. Please try again."); 
			if ((msgID == "wldRegion")||(msgID == "THE_COUNTRY")){
				eval("document.petMem.wldRegion[15].focus( )");
			}else{
				eval("document.petMem." + msgID + ".focus( )");
			}
	   }
	}

	function showCountries(whatID) {
		var countriesArray = ['s_Africa', 's_AmCan', 's_AmUSA', 's_AmOth', 's_AsaNor', 's_AsaEst', 's_AsaSou', 's_AsaSEa', 's_AsaSWt', 's_AsaCtr', 's_EurNor', 's_EurSou', 's_EurWst', 's_EurUK', 's_EurOth', 's_OceAus', 's_OceOth'];
		for ( var i in countriesArray ) {
			switchDisplay(countriesArray[i], "none") ;
		} 
		switchDisplay(whatID, "block") ; 
	}
	
	function switchDisplay(whatID, blockOrNone) {
		theElement = document.getElementById(whatID) ;
		theElement.style.display=blockOrNone ;
		whatID = whatID.replace("s_","");
		theSelectElement = document.getElementById(whatID) ;
		theSelectElement.selectedIndex = 0;
	}



window.onerror = null;  	


