/* CREATES HTTP OBJECT */
function getHTTPObject() { var xmlhttp; /*@cc_on @if (@_jscript_version >= 5) try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } @else xmlhttp = false; @end @*/  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp = false; } } return xmlhttp; } var http = getHTTPObject(); // We create the HTTP Object 

var undefMatch;

function readAJAX(theData,readURL,theResponse)
{
	http.open("GET", readURL+theData, true);
	http.onreadystatechange = theResponse;
	http.send(null);
}
/***********************************************************************/

function updateShirtImage(theParams)
{

	readAJAX(theParams,'http://www.cheekyteez.com.au/designModule/ajaxshirt.php?',displayShirtImage);
}
function displayShirtImage()
{
	if (http.readyState == 4)
	{
		imFree=true;
		var source = http.responseText;

		source = source.split("^");
		imgSrc = source[0];
		imageX = source[1];
		imageY = source[2];

		$textDim = new Array();
		$textDim[0] = new Array(source[3],source[4]);
		$textDim[1] = new Array(source[5],source[6]);
		$textDim[2] = new Array(source[7],source[8]);
		$textDim[3] = new Array(source[9],source[10]);
		$textDim[4] = new Array(source[11],source[12]);
		$textDim[5] = new Array(source[13],source[14]);

		var theImage = document.getElementById('imageHolder');
		theImage.innerHTML = imgSrc;
		var theHolder = document.getElementById('comboImage');
		imgSrc = imgSrc.substring(0,imgSrc.indexOf('" alt='));
		imgSrc = imgSrc.substring(imgSrc.indexOf('src="')+5,imgSrc.indexOf('?'));
		theHolder.value = imgSrc;

		var xPos = document.getElementById('imageXOffset');
		var yPos = document.getElementById('imageYOffset');

		if (xPos.value!="df") yPos.value = (imageX=="") ? "df" : imageX;
		if (yPos.value!="df") yPos.value = (imageY=="") ? "df" : imageY;

		for (i=0;i<6;i++) {
			var textX = document.getElementById('lineX'+i);
			var textY = document.getElementById('lineY'+i);

			if ((textX.value=="0" && textX.value=="0")) {
				textX.value = ($textDim[i][0]=="") ? "0" : $textDim[i][0];
				textY.value = ($textDim[i][1]=="") ? "0" : $textDim[i][1];
			}
		}
	}
}