
var capa = null;
var antes = null;
var z = 10;

function Switch(idCapa){
if (document.all) capa = eval(idCapa + ".style");
if (document.getElementById) capa = eval('document.getElementById("' + idCapa + '").style');
capa.zIndex = ++z;
/*if (capa.visibility != "visible") {
if(antes != null) {
antes.visibility="hidden";
}
capa.visibility="visible";
antes=capa;
} */
}


function findEl(elName) 
{	
	var obj = getEl(elName);	
	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 getEl(nomEl)
{
	if(document.getElementById) return document.getElementById(nomEl);
	else if(document.all) return document.all[nomEl];
	else if(document.layers) return document.layers[nomEl];
}

var httpObj;

function getWork(id) 
{
	if(window.XMLHttpRequest )
		httpObjCarga = new XMLHttpRequest(); // No Internet Explorer
	else
		httpObjCarga = new ActiveXObject("Microsoft.XMLHTTP"); // Internet Explorer
	
	httpObjCarga.onreadystatechange = function() { myCallResult(); };
	httpObjCarga.open( "GET", "ajwork.php?id=" + id, true );
	httpObjCarga.send( null );	
}
	
function myCallResult()
{		
	if(httpObjCarga.readyState == 4 )
	{
		if(httpObjCarga.status == 200 )
		{
			getEl('jobContent').innerHTML = httpObjCarga.responseText;
			startRot();
		}
	}
}

var acPic = null;
var opDesc = 10;
var opAsc = 0;
//var arrow = null;
//var opArrow = 3;
var timeOut = 30;
var first = 0;
var last = 0;

function startRot()
{
	last = 0;
	var auxArr = getEl('imagenWork').childNodes;
	for(i=0;i<auxArr.length;i++)
	{
		if(auxArr[i].className == 'itRot')
		{
			if(auxArr[i].id.substr(2) > last) last = auxArr[i].id.substr(2);
			if(auxArr[i].id == 'im0') 
			{
				chgOpac(opDesc, auxArr[i]);
				acPic = auxArr[i];
			}
			else chgOpac(opAsc, auxArr[i]);
			auxArr[i].style.visibility = 'visible';
		}
	}
	//arrow = getEl('flechas');
	//chgOpac(opArrow, arrow);
}

function chgPicture(id)
{	
	if(opDesc > 0)
	{
		opDesc--;
		opAsc++;
		chgOpac(opDesc, acPic);
		chgOpac(opAsc, getEl('im' + id));
		setTimeout( 'chgPicture(' + id + ');', timeOut );
	} 
	else 
	{
		opDesc = 10;
		opAsc = 0;
		acPic = getEl('im' + id);
	}
}
/*
function next(dir)
{
	var neIndex = 0;
	var acIndex = acPic.id.substr(2);

	if( ( dir == -1 && acIndex > first ) || ( dir == 1 && acIndex < last ) ) 
		neIndex = parseInt(acIndex) + dir;
	else if( dir == -1 && acIndex == first ) neIndex = last;
	else neIndex = first;

	chgPicture(neIndex);
}

function show()
{
	opArrow++;
	if(opArrow < 10) 
	{
		chgOpac(opArrow, arrow);
		setTimeout("show();", timeOut);
	}
}

function hide()
{
	opArrow--;
	if(opArrow > 1) 
	{
		chgOpac(opArrow, arrow);
		setTimeout("hide();", timeOut);
	}
}
*/
function chgOpac(opacity, object) 
{
	object.style.opacity = (opacity / 10);
	object.style.MozOpacity = (opacity / 10);
	object.style.filter = "alpha(opacity=" + (opacity*10) + ")";
}

