productId = 1;

function changeProduct(direction, amount) {	
	hideProductId = productId;

    if(direction == "back"){
        productId--;     
    }else{
        productId++;
    }
    
    if(productId > amount) // ett ta mindre än vad som är max
        productId = 1;
    if(productId == 0)
        productId = amount;

    // turn off div
    objectNameString = "productInfo_"+productId;
    objectName = document.getElementById(objectNameString);
    objectName.style.visibility = 'visible';

    // turn on next div
    objectNameString = "productInfo_"+hideProductId;
    objectName = document.getElementById(objectNameString);
    objectName.style.visibility = 'hidden';
}

function startLoop(objectAmount) {
	if(objectAmount > 1){		
		window.setTimeout('rotateObject('+objectAmount+')' , 3000);
	}
}

function rotateObject(objectNr) {	
	if(document.getElementById('control').value=='run'){		
		changeProduct("forward", objectNr);		
	}
	startLoop(objectNr);
}

//function registerClick(id, keyword, format) {
function updateAll(keyword, id, format, dblclick) {

	var xmlhttp=false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.
	 try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }
	 }
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}

	xmlhttp.open("GET", "includes/register_clicks.php?kw="+keyword+"&id="+id+"&format="+format+"&dbl="+dblclick,true);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			//alert(xmlhttp.responseText)
		}	
	}
	xmlhttp.send(null);
}