// script ajax.js

//this page creates an ajax request object
//this page is included by other pages that need to perform an XMLHttpRequest.


//initalize the object
var ajax = false;

//create the object

//choose object type based upon whats supported

if (window.XMLHttpRequest) { //IE 7 , Safari, Firefox, Opera, most browsers
	ajax = new XMLHttpRequest();
}
else if (window.ActiveXObject) { //older IE browsers
	
	//create type Msxml2.XMLHTTP if possible:
	try {
		ajax = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e1) { //create the older type.
		try {
			ajax = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e2) {}
	}
	
}// close the else if 

//send an alert if the object wasn't created. 
if (!ajax) {
	alert('Some page functionality is unavailable.'); 
}


//These functions relate specifically to the Fashion Factory site
function times_clicked(dress_name) { //this registers everytime one of the small dress images is clicked
	if (ajax) {
		ajax.open('get', 'includes/register_click.php?dress=' + encodeURIComponent(dress_name));
		
		ajax.onreadystatechange = handle_clicks;
		
		ajax.send(null);
	}
}

function handle_clicks() {
	if ((ajax.readyState == 4) && (ajax.status == 200) ) {
		//document.getElementById('result').innerHTML = ajax.responseText;
	}
}



		
		