compress = function(obj){
	temp=false
	test = (obj.parentNode.parentNode)
	for (var i=0; i<test.childNodes.length;i++){
	//alert(test.childNodes[i].className)
		if (test.childNodes[i].nodeType== 1 && test.childNodes[i].className != "editbar" && temp==false){
			test.childNodes[i].style.display = "none";
			temp=true
		}else if (test.childNodes[i].nodeType== 1 && test.childNodes[i].className != "editbar" && temp==true){
		test.childNodes[i].style.display = "block";
			temp=false
		}
	}
}



Array.prototype.in_array = function(valor) {
	for(var i in this) {
	if(this[i] == valor) return i;
	}
	return false;
}

function setDragger(idA){
	divs = document.getElementsByClassName(idA)
	for (var i=0;i<divs.length;i++){
		divs[i].onmouseover = function(){
			currentDrag = (this.parentNode.parentNode.id)
			currentBlocco = (this.parentNode.parentNode.parentNode.id)
		}
	}
}


function changeOrder(cpath){
	newOrder = deserialize(currentBlocco)
	arr = currentDrag.split("_")
	res = newOrder.in_array(arr[1])
	url = cpath+"/updateItems.do?operation=3&"
	top.location.href = url +"oldOrdine="+arr[1]+"&ordine="+(parseInt(res)+1)+"&modBlocco="+currentBlocco
}

function deserialize(idBlocco){
	newarray  = new Array();
	stringa = Sortable.serialize(idBlocco)
	arr = stringa.split('&')
	for (var i=0, j = 0;i<arr.length;i++){
		arr2 = arr[i].split("[]=")
		if (arr2[1] != "undefined"){
			newarray[j] = arr2[1]
			j++
		}
	}
	return newarray
}
