// -------------------------------------------------------------------------------
// Setup ajax environment depending on page being viewed.
if (window.addEventListener) { window.addEventListener('load', ajaxSelector, false); }
else { /*window.onload = ajaxSelector;*/ }

function ajaxSelector() {
	sHref = document.location.href;
	adminPage = sHref.substr(sHref.lastIndexOf('/')+1);
	switch(adminPage) {
	default: break;
	}
}

// -------------------------------------------------------------------------------
// Image Rating System
var imageId = false;
var imageName = false;
var imageFunction = false;
var imageVote = false;

function imageRating_exec() {
	switch(imageFunction) {
	case 'vote': vars = '&vote='+parseFloat(imageVote, 1); break;
	case 'lookupRating': vars = ''; break;
	default: vars = ''; break;
	}

	if (imageName && imageFunction) {
		//alert(vars);
		makeRequest('classes/imageRatings.php?imageName='+imageName+'&function='+imageFunction+'&'+vars, 'imageRating_handleAJAX', false);
	}
}

function imageRating_lookup(thisImageName) { imageName = thisImageName; imageFunction = 'lookupRating'; imageRating_exec(); }
function imageRating_vote(thisImageId, thisVote) { imageId = thisImageId; imageVote = thisVote; imageFunction = 'vote'; imageRating_exec(); }

function imageRating_handleAJAX(xml) {
	if (xml) {
		oRatingTab = document.getElementById('ratingTab');
		if (xml.indexOf('<select') < 0) { 
			oRatingTab.style.visibility = 'hidden';
			alert(xml);
		}
		else {
			oRatingTab.innerHTML = xml;
		}
	}
	//showCode(xml);
	
	function showCode(codeStr) {
		codeStr = (new XMLSerializer()).serializeToString(codeStr);
		thisString = codeStr;
		thisString = thisString.replace(/</g, '&lt;');
		thisString = thisString.replace(/>/g, '&gt;');
		document.getElementById('xmlOutput').innerHTML = thisString;
	}
}




// -------------------------------------------------------------------------------
