/**
 * @author Sam Reynoso
 *
*/


function openWindow(filename, sExtension, sPath, iWidth, iHeight)
{
	var myWin = "" ;
	var x = screen.width ;
	var y = screen.height ;
	var width = iWidth;
	var height = iHeight;
	var top = parseInt( ( y - height ) / 2 ) ;
	var left = parseInt( ( x - width  ) / 2 ) ;
	var props = "toolbars=no,status=no,resizable=yes,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top;

	if (sPath !='')
	{
		filename = sPath + filename;
	}	

	var popUp = window.open(filename,"ImageWindow",props);

	popUp.focus();
}

function setOpacity(obj, opacity) 
{
  	opacity = (opacity == 100)?99.999:opacity;
  
  	// IE/Win
  	obj.style.filter = "alpha(opacity:"+opacity+")";
  
  	// Safari<1.2, Konqueror
  	obj.style.KHTMLOpacity = opacity/100;
  
  	// Older Mozilla and Firefox
  	obj.style.MozOpacity = opacity/100;
  
  	// Safari 1.2, newer Firefox and Mozilla, CSS3
  	obj.style.opacity = opacity/100;
}

function fadeIn(objId,opacity) 
{
  	if (document.getElementById) 
	{
		obj = document.getElementById(objId);
		if (opacity <= 100) 
		{
  			setOpacity(obj, opacity);
  			opacity += 10;
  			window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
		}
  	}
}

function startImageCycle()
{
	window.setTimeout("cycleImages(1,'dvRightImg')", 8000);	
}

function cycleImages(i,sImagesID)
{
	var oImageGroup = document.getElementById(sImagesID);
	
	if (oImageGroup) 
	{
		var iPrev;
		if (i-1 >= 0)
		{
			iPrev = i-1;
		}
		else
		{
			iPrev = oImageGroup.childNodes.length-1
		}
		
		oImageGroup.childNodes[iPrev].style.display='none';
		
		oImageGroup.childNodes[i].style.display='';
		fadeIn(oImageGroup.childNodes[i].id,0);
		
		var iNext;
		if (i < oImageGroup.childNodes.length-1)
		{
			iNext = i+1;	
		}
		else
		{
			iNext = 0;
		}
		
		window.setTimeout("cycleImages(" + iNext + ",'" + sImagesID + "')", 8000);	
	}
}