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

var noContent = '';
var liveReq = false;
var liveReqLast = '';
var liveReqDestination = '';

if (window.XMLHttpRequest) {
	liveReq = new XMLHttpRequest();
	if (liveReq.overrideMimeType) {
		liveReq.overrideMimeType('text/xhtml; charset=iso-8859-1');
	}
}

function loadContent(destination, uri) {
	
	liveReqDestination = destination;

	if (liveReqLast != liveReqDestination && liveReqDestination != '') {
	
		if (window.XMLHttpRequest) {
		} else if (window.ActiveXObject) {
			liveReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
	
		liveReq.onreadystatechange = liveReqProcessReqChange;
		liveReq.open('GET', uri);
		liveReq.send(null);

	}

}

function liveReqProcessReqChange() {

	if (liveReq.readyState == 4) {
		document.getElementById(liveReqDestination).innerHTML = liveReq.responseText;
	}
}


function showContentBlock(showID, blocksTotal) {

	for(i=0; i<blocksTotal; i++)
		document.getElementById('contentBlock'+i).style.display = 'none';
	document.getElementById('contentBlock'+showID).style.display = 'block';

}


function checkEmail(emailAddress) {

	var str = emailAddress;
	if ((str.indexOf(".") > 2) && (str.indexOf("@") > 0) == true) {
		return true;
	} else {
		//window.alert('Please enter a valid email address');
		return false;
	}
}


function checkForm(type) {
	errors = '';
	if (type==1) {
		if (document.addContentForm.image.value == '')
			errors += 'Image';
	} else if (type==2) {
		if (document.addContentForm.release.value == '')
			errors += 'Release\n';
		if (document.addContentForm.image.value == '')
			errors += 'Image';
	} else if (type==3) {
		if (document.addContentForm.title.value == '')
			errors += 'Title\n';
		if (document.addContentForm.text.value == '')
			errors += 'Text\n';
		if (document.addContentForm.release.value == '')
			errors += 'Release\n';
	} else if (type==6) {
		if (document.addContentForm.title.value == '')
			errors += 'Title\n';
		if (document.addContentForm.url.value == 'http://')
			errors += 'URL\n';
	} else {
		if (document.addContentForm.title.value == '')
			errors += 'Title\n';
		if (document.addContentForm.text.value == '')
			errors += 'Text\n';
	}
	
	if (errors.length > 0) {
		window.alert('Please complete the following fields:\n'+errors);
		return false;
	} else {
		return true;
	}
	
}
