var pas = 5;
var sec = 100;
var ids = new Array();
var defilare1 = true, defilare2 = true, defilare3 = true;

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function setSCPos(){
	var id;
	while (ids.length > 0){
		id = ids.pop();
		clearTimeout(id);
	}
	var pos1 = findPos(document.getElementById("id_sc11"));
	initDef("id_sc1", tl1, 0, pos1[0] + wb1, "defilare1", wb1);
	initDef("id_sc2", tl2, 0, pos1[0] + wb2, "defilare2", wb2);
	initDef("id_sc3", tl3, 0, pos1[0] + wb3, "defilare3", wb3);
}

function initDef(id, w, pc, x, defilare, wb){
	var obj = document.getElementById(id);
	
	obj.style.left = "";
	try{
		obj.style.clip = "rect(0px, 950px 28px, 0px)";
	}
	catch (e){
		obj.style.clip = "rect(0px 950px 28px 0px)";
	}
	def(id, w, pc, x, defilare, wb);
}

function def(id, w, pc, x, defilare, wb){
	var cond; 
	eval("cond = (" + defilare + " == true)");
	if (cond) {
		var obj = document.getElementById(id);
		pc += pas;
		if (pc >= w - 950) {
			pc = 0;
		}
		
		obj.style.clip = "rect(0px, " + (950 + pc) + "px, 28px, " + (pc + wb) + "px)"; 
		obj.style.left = (x - pc + 10 - wb) + "px";
	}
	var id = setTimeout("def('" + id + "', " + w + ", " + pc + ", " + x + ", '" + defilare + "', " + wb + ")", sec);
	ids.push(id); 
}