function XmlHttp() {
	var W = window, T = this, C = T.constructor, I = function(){return T!=W}(), r, i;
	if (!I) return;

	if (W.XMLHttpRequest) {
		r = new XMLHttpRequest();

		if (r.readyState == null) {
			r.readyState = 1;
			r.addEventListener("load", function () { r.readyState = 4; if (typeof r.onreadystatechange == "function") r.onreadystatechange(); }, false);
		}
		return r;
	}
	if (W.ActiveXObject) {
		for (i=0;i<=4;i++) {
			try { return new ActiveXObject(["MSXML2", "Microsoft", "MSXML", "MSXML3"][i] + ".XmlHttp"); }
			catch (e) {};
		}
		throw new Error("Could not find an installed XML parser");
	}
	alert("Your browser does not support XmlHttp objects");
}

function setRequest(module, action, request)
{
	var h = new XmlHttp()

	h.open('GET', module + '/'+ action+'/' + request, false);
	
	h.send(null);
	return h.responseText;;
}

function setRequestA(module, action, request, obj)
{
	
	var h = new XmlHttp()

	h.open('GET', module + '/'+ action+'/' + request, true);
	
	h.onreadystatechange = function () 
	{
		if (h.readyState == 4)
		{
			obj.src = h.responseText;
		}
	}
	h.send(null);
	
}
function popupWithName(s,w,h, name)
{
	var o=window.open(s,name,'width='+w+',height='+h+',toolbar=no,location=no,status=no,resizable=no,scrollbars=no,left='+(screen.width/2-w/2)+',top='+(screen.height/2-h/2));
	return false;
}

function popup(s,w,h)
{
	var o=window.open(s,'popup','width='+w+',height='+h+',toolbar=no,location=no,status=no,resizable=no,scrollbars=yes,left='+(screen.width/2-w/2)+',top='+(screen.height/2-h/2));
	return false;
}
function savePositions(module, a, lang)
{
	var img = document.getElementById("user-photo");
	var params = "?"
	if (img)
	{
		params += "&img_x="+img.style.left+"&img_y="+img.style.top+"&img_w=" + img.style.width+"&img_h="+img.style.height;
	}
	var t1 = document.getElementById("user-text-1");
	if (t1)
	{
		params += "&t1_x="+t1.style.left+"&t1_y="+t1.style.top;
	}
	var t2 = document.getElementById("user-text-2");
	if (t2)
	{
		params += "&t2_x="+t2.style.left+"&t2_y="+t2.style.top;
	}
	
	var t3 = document.getElementById("user-text-3");
	if (t3)
	{
		params += "&t3_x="+t3.style.left+"&t3_y="+t3.style.top;
	}
	
	var t4 = document.getElementById("user-text-4");
	if (t4)
	{
		params += "&t4_x="+t4.style.left+"&t4_y="+t4.style.top;
	}
	var t5 = document.getElementById("user-text-5");
	if (t5)
	{
		params += "&t5_x="+t5.style.left+"&t5_y="+t5.style.top;
	}
	var t6 = document.getElementById("user-text-6");
	if (t6)
	{
		params += "&t6_x="+t6.style.left+"&t6_y="+t6.style.top;
	}
	var t7 = document.getElementById("user-text-7");
	if (t7)
	{
		params += "&t7_x="+t7.style.left+"&t7_y="+t7.style.top;
	}
	var t8 = document.getElementById("user-text-8");
	if (t8)
	{
		params += "&t8_x="+t8.style.left+"&t8_y="+t8.style.top;
	}
	var t9 = document.getElementById("user-text-9");
	if (t9)
	{
		params += "&t9_x="+t9.style.left+"&t9_y="+t9.style.top;
	}
	var t10 = document.getElementById("user-text-10");
	if (t10)
	{
		params += "&t10_x="+t10.style.left+"&t10_y="+t10.style.top;
	}
	if ( params.lenght != 0)
	{
		var i = document.getElementById("save-pos");
		
		if ( module == "posters")
		{
			i.src = "/images/"+lang+"/fixpl2.gif";
		}
		else
		{	
			i.src = "/images/"+lang+"/fix2.gif";
		}
		//alert(params);
		setRequestA(module, "savepositions", params, i);
	}
}
