function data() {
};
data.prototype.init = function() {
	try {
		// Mozilla / Safari
		this._xh = new XMLHttpRequest();
	} catch (e) {
		// Explorer
		var _ieObject = new Array(
		'MSXML2.XMLHTTP.5.0',
		'MSXML2.XMLHTTP.4.0',
		'MSXML2.XMLHTTP.3.0',
		'MSXML2.XMLHTTP',
		'Microsoft.XMLHTTP'
		);
		var success = false;
		for (var i=0;i < _ieObject.length && !success; i++) {
			try {
				this._xh = new ActiveXObject(_ieObject[i]);
				
				success = true;
			} catch (e) {
			}
		}
		if ( !success ) {
			
			return false;
		}
		return true;
	}
}

data.prototype.getdata = function() {
	estadoActual = this._xh.readyState;
	return (estadoActual && (estadoActual < 4));
}

data.prototype.processed = function() {
	if (this._xh.readyState == 4 && this._xh.status == 200) {
		this.processed = true;
	}
}

data.prototype.Dsend = function(urlget,Data) {
	
	if (!this._xh) {
		this.init();
	}
	if (!this.getdata()) {
		this._xh.open("GET",urlget,false);
		this._xh.send(Data);
		if (this._xh.readyState == 4 && this._xh.status == 200) {
			return this._xh.responseText;
		}
		
	}
	return false;
}

function _gr(reqseccion,divcont) {
	Dremote = new data;
	nt = Dremote.Dsend(reqseccion,"");
	document.getElementById(divcont).innerHTML = nt;
}

// sets and reads a cookie
function createCookie(name,value,std) {
	if (std) {
		var date = new Date();
		date.setTime(date.getTime()+(std*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
	//alert(name+"="+value+expires+"; path=/");
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}


var urlBase = "/typo3conf/ext/hk_luxory_shop/ext_update.php?";

function rateImg(rating,imgId)  {
		Dremote = new data;
		nt = Dremote.Dsend('/typo3conf/ext/hk_luxory_shop/ext_update.php?rating='+rating+'&imgId='+imgId);
		rating = rating * 12;
		
		document.getElementById('current-rating').style.width = rating+'px';
		document.getElementById('ratelinks').style.display = 'none';
		if (readCookie('netluxury')!=null) {
			var str = readCookie('netluxury');			
			eraseCookie('netluxury');
			createCookie('netluxury',str+','+imgId,2);
		}
		else {
			createCookie('netluxury','voted: '+imgId,2);	
		}
		location.reload(true);
}