//Genuine code by Corneliu Lucian 'Kor' RUSU corneliulucian[at]gmail[dot]com
//rollover and slide the competences icons and texts within Competences box
AttachEvent(window,'load',attachCompetences,false);
isIE6?AttachEvent(window,'load',ie6PNG,false):null;
var globalmoveTick;
var globalmoveSquare;
function attachCompetences(){
var parDiv=document.getElementById('com_sus');
var d=parDiv.getElementsByTagName('div'), lung=0;
d[0].style.backgroundColor='rgb(246, 212, 162)';
for(var i=0;i<d.length-1;i++){
lung+=d[i].offsetWidth;
d[i].key=d[i].getAttributeNode('myval').nodeValue;
}
parDiv.style.width=lung+'px';
parDiv.style.left=0;
	parDiv.style.visibility='visible';
globalmoveSquare=setTimeout(function(){moveSquare(parDiv,lung,0)},2000);
}
function rollOnCompetences(obj,q,lung){
var d=obj.parentNode.getElementsByTagName('div');
	for(var i=0;i<d.length-1;i++){
	obj==d[i]?writeCompetences(obj,q,lung):d[i].style.backgroundColor='';
	}
}
function moveSquare(parDiv,lung,q){

var d=parDiv.getElementsByTagName('div'), s, obj;
	for(var i=0;i<d.length-1;i++){
	s=d[i].style.backgroundColor.replace(/\s+/g,'');
		
	if(s=='rgb(246,212,162)'||s=='#f6d4a2'){//Opera fix - Opera returns only hexa color values
		if(i==d.length-2){
			obj=parDiv.getElementsByTagName('div')[0];
		parDiv.style.left=0;obj.style.backgroundColor='rgb(246, 212, 162)';setTimeout(function(){writeCompetences(obj,0,lung),2000});break
		}
		else {d[i].style.backgroundColor='transparent';q++;rollOnCompetences(d[i+1],q,lung);break}
	}
	}
}
function writeCompetences(obj,q,lung){

var parDiv=obj.parentNode;
obj.style.backgroundColor='rgb(246, 212, 162)';
var divTxt=document.getElementById('text_jos');
var data=allComp[obj.key].split('|');
!data[1]?data[1]='':null;
var txt=data[0]+'<br>'+data[1];
divTxt.innerHTML=txt;
	if(q<3){globalmoveSquare=setTimeout(function(){moveSquare(parDiv,lung,q)},2000);}
	else{horizontalTick(parDiv,lung);}
}
//fix for IE6 PNG bug
function ie6PNG(){
var d=document.getElementById('com_sus').getElementsByTagName('div');
for(var i=0;i<d.length-1;i++){
d[i].key=d[i].getAttributeNode('myval').nodeValue;
d[i].style.background=i==0?'rgb(246, 212, 162)':'none';
d[i].style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src="img/com_'+d[i].key+'.png")';
}
document.getElementById('com_sus').style.visibility='visible';
}
//ticker functions
function horizontalTick(parDiv,lung){
var delay=10;
moveTick(parDiv,lung,0,delay);
}
function moveTick(parDiv,lung,q,delay){
var leng=61*3;
var step=q<leng?3:1;

parDiv.x=parseInt(parDiv.style.left,10);
if (q<leng){
parDiv.style.left=(parDiv.x-step)+'px';
q+=step;
delay=10;
globalmoveTick=setTimeout(function(){moveTick(parDiv,lung,q,delay)},delay)
}
else{globalmoveSquare=setTimeout(function(){moveSquare(parDiv,lung,0)},2000);}
}