function checkState(inID, newStock, originalStock) {
    articleID = 'a' + inID;
    if (newStock == 0) {
        newClass = 'sold';
        removePercentClass(articleID);
        $(articleID).addClassName(newClass);
        aa = 'article' + inID;
        aa.stop;
    } else {
        percent = 10 * Math.round(newStock / originalStock * 10);
        if (percent > 90) {
            removePercentClass(articleID);
        } else {
            if (percent < 10) {
                percent = 10;
            }
            newClass = 'p' + percent;
            if (!$(articleID).hasClassName(newClass)) {
                removePercentClass(articleID);
                $(articleID).addClassName(newClass);
            }
        }
    }
}

var percentClasses = new Array('p90', 'p80', 'p70', 'p60', 'p50', 'p40', 'p30', 'p20', 'p10');
function removePercentClass(articleID) {
    for (var i = 0; i < percentClasses.length; i++) {
        if ($(articleID).hasClassName(percentClasses[i])) {
            $(articleID).removeClassName(percentClasses[i]);
        }
    }
}


function changeOffer(inIndex,stopTimeout) {
	    	offerIndex = inIndex;
	    	if (stopTimeout) {
	    		clearTimeout(offerTimout);
	    	}
			elementOffset = $("a"+inIndex).positionedOffset().toArray();
			new Effect.Move('container', { x: (1-elementOffset[0]), y: 0, mode: 'absolute', duration: 0.5 });	
			var ts = $$('.FRONT_NEW ul.tabs li a.selected');
			ts[0].removeClassName('selected');
			$("t"+inIndex).addClassName('selected');
		}

		
offerIndex = -1;

function autochangeOffer(offerIndexMax) {
    if(offerIndex == -1){
        offerIndex = Math.floor(offerIndexMax*Math.random()) + 1; }
    else {     
	offerIndex++; }
	if (offerIndex > offerIndexMax) { 
		offerIndex = 1; 
	}
	changeOffer(offerIndex,0);
	offerTimout = setTimeout('autochangeOffer(' + offerIndexMax + ')', 5000);
}

