var xmlHttp
var picCurentaAct='0';

function changePic(id)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	  {
	  alert ("Browser does not support HTTP Request")
	  return
	  }

	var url="putPic"+id+".html"
	picCurentaAct=id;
	document.getElementById('idpic').value = id;
	xmlHttp.onreadystatechange=stateChanged2
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChanged2()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById("pics").innerHTML=xmlHttp.responseText
		opacity('pics',0, 100, 1000);
		//setTimeout("document.getElementById('pics').style.display = 'none'", 500);
	}
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
		 // Internet Explorer
		 try
		  {
		  	xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		  }
		 catch (e)
		  {
		  	xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
	 }
	return xmlHttp;
}


function opacity(id, opacStart, opacEnd, millisec)
{
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd)
	{
		for(i = opacStart; i >= opacEnd; i--)
		{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
	else if(opacStart < opacEnd)
	{
		for(i = opacStart; i <= opacEnd; i++)
		{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id)
{
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}



function updateResults(pic)
{
  for(i = 1;i<=3;i++)
  {
    if(i==3)
      document.getElementById('tab'+i).className = 'tabInact3';
    else
      document.getElementById('tab'+i).className = 'tabInact';

    document.getElementById('tableft'+i).className = 'tabInactLeft';
    document.getElementById('tabright'+i).className = 'tabInactRight';

  }
	var val= parseInt(pic)+1;
	if (val>3)
		val=1;
	changePic(val);
  picCurentaAct=pic;

	if(val==3)
	 document.getElementById('tab'+val).className = 'tabAct3';
	else
	 document.getElementById('tab'+val).className = 'tabAct';
  document.getElementById('tableft'+val).className = 'tabActLeft';
  document.getElementById('tabright'+val).className = 'tabActRight';
}

/**
 *
 * @access public
 * @return void
 **/
function changeClass(pic){
  for(i = 1;i<=3;i++)
  {
    if(i==3)
      document.getElementById('tab'+i).className = 'tabInact3';
    else
      document.getElementById('tab'+i).className = 'tabInact';
    document.getElementById('tableft'+i).className = 'tabInactLeft';
    document.getElementById('tabright'+i).className = 'tabInactRight';
  }

   if(pic==3)
      document.getElementById('tab'+pic).className = 'tabAct3';
    else
      document.getElementById('tab'+pic).className = 'tabAct';
  document.getElementById('tableft'+pic).className = 'tabActLeft';
  document.getElementById('tabright'+pic).className = 'tabActRight';
}

function showClass(pic){
 if(picCurentaAct!=pic){
  	if(pic==3)
  		document.getElementById('tab'+pic).className = 'tabAct3';
  	else
  	 	document.getElementById('tab'+pic).className = 'tabAct';
	document.getElementById('tableft'+pic).className = 'tabActLeft';
	document.getElementById('tabright'+pic).className = 'tabActRight';
 }
}

function hideClass(pic){
	if(picCurentaAct!=pic){
	if(pic==3)
		document.getElementById('tab'+pic).className = 'tabInact3';
	else
	 	document.getElementById('tab'+pic).className = 'tabInact';
    document.getElementById('tableft'+pic).className = 'tabInactLeft';
		document.getElementById('tabright'+pic).className = 'tabInactRight';
	}
}

/*function deactivate()
{
	var a = document.getElementsByTagName('a');
	for (var k=0;k<a.length;k++)
	{
		if (a[k].getAttribute('id')!=null)
		if (a[k].getAttribute('id').match("^link")=="link")
		{
			a[k].className = 'numbers';
		}
	}
}*/