 // Thanks to Bill Bercik for the code on which the below snippet is based
// http://www.webpasties.com/xmlHttpRequest/

var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/

if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
  xmlhttp = new XMLHttpRequest();
}

function getMyHTML(serverPage, objID) {
  var obj = document.getElementById(objID); 
  xmlhttp.open("GET", serverPage);
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      obj.innerHTML = xmlhttp.responseText;
    }
  }
  new Effect.Highlight(obj);
  xmlhttp.send(null); 
}

if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
  xmlhttp = new XMLHttpRequest();
}

function getMyPhoto(serverPage, objID) {
  var obj = document.getElementById(objID); 
  xmlhttp.open("GET", serverPage);
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      obj.innerHTML = xmlhttp.responseText;
    }
  }
  xmlhttp.send(null); 
}

function ActionDeterminator() {
	if(document.forms.searchForm.forums[0].checked == true) {
		document.forms.searchForm.action = '/forums/search.php';
	}
	if(document.forms.searchForm.forums[1].checked == true) {
		document.forms.searchForm.action = 'http://forums.newbeetle.org/search.php?action=simplesearch&searchin=subject&searchdate=-1&forumschoice=-1&booleanand=yes';
		document.forms.searchForm.method = 'post';		
	}
	return true;
}

function turnOn() {
	new Effect.Appear('photoDetails');

}
function turnOff() {
	new Effect.Fade('photoDetails');
}

function displayPhotoInfo() {
		turnOn();
		setTimeout('turnOff()', 5000);
}


function updateHomePagePhoto(action,index) {
	if (action == 'random') {
		var url = '/apps/submit-photo/getPhoto.php';
	} else if (action == 'next') {
		var url = '/apps/submit-photo/getPhoto.php?action=next&current=' + index;
	} else if (action == 'previous') {
		var url = '/apps/submit-photo/getPhoto.php?action=previous&current=' + index;
	}	
	// alert (url);
	new Ajax.Updater('feature', url,{asynchronous:true});
}