// switch article
function switchArticle(id){
	if(id == 'artwork'){
		document.getElementById('description').style.display = 'none';
		document.getElementById('artwork').style.display = 'block';	
		document.getElementById('conditions').style.display = 'none';
		document.getElementById('btDescription').className = 'liSubmenu';
		document.getElementById('btArtwork').className = 'liSubmenuActive';
		document.getElementById('btConditions').className = 'liSubmenu';
	} else if(id == 'description'){
		document.getElementById('description').style.display = 'block';
		document.getElementById('artwork').style.display = 'none';	
		document.getElementById('conditions').style.display = 'none';
		document.getElementById('btDescription').className = 'liSubmenuActive';
		document.getElementById('btArtwork').className = 'liSubmenu';
		document.getElementById('btConditions').className = 'liSubmenu';
	} else if(id == 'conditions'){
		document.getElementById('description').style.display = 'none';
		document.getElementById('artwork').style.display = 'none';	
		document.getElementById('conditions').style.display = 'block';
		document.getElementById('btDescription').className = 'liSubmenu';
		document.getElementById('btArtwork').className = 'liSubmenu';
		document.getElementById('btConditions').className = 'liSubmenuActive';
	}		
}

function copyValue(id, value){
	var destination = document.getElementById('d' + id);

	if(destination.value == '')
		destination.value = value;
}

//holds an instance of XMLHttpRequest
var xmlHttp = createXmlHttpRequestObject();
//initialize the validation requests sache
var cache = new Array();
//when set to true, display detailed error messages
var showErrors = false;

//function for displaing error messages
function displayError($message){
	//ignore errors if showErrors is false
	if(showErrors){
		//turn error displaying off
		showErrors = true;
		//display error message
		alert("Error encountered: \n" + $message);
	}
}

//creates an XmlHttpRequest instance
function createXmlHttpRequestObject(){
	//will store the reference to the XmlHttpRequest object
	var xmlHttp;
	//this should work for all browsers except IE6 and older
	try{
		//try to create a XmlHttpRequest object
		xmlHttp = new XMLHttpRequest();
	}catch(e){
		//assume IE6 or older
		var xmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
										"MSXML2.XMLHTTP.5.0",
										"MSXML2.XMLHTTP.4.0",
										"MSXML2.XMLHTTP.3.0",
										"MSXML2.XMLHTTP",
										"Microsoft.XMLHTTP");
		//try every prog id until one works
		for(var i = 0; i < xmlHttpVersions.length && !xmlHttp; i++){
			try{
				//try to create a xmlHttpRequest object
				xmlHttp = new ActiveXObject(xmlHttpVersions[i]);
			}catch(e){}
		}
	}
	//return the created object or display an error message
	if(!xmlHttp)
		alert("Error creating the XMLHttpRequest object.");
	else
		return xmlHttp;
}

