//////////////////////////////////////////////////////

//

//	The purpose of this file is to

//	apply a hover class on mouseover

//	on the <li> elements in the nav.

//	This is because IE doesn't put

//	the pseudo class :hover on <li> elements

//

//	This is code that uses the

//	jquery javascript library (http://jquery.com/)

//

//////////////////////////////////////////////////////

counterFile=0;

FilesArray = new Array();
FilesArray[0] = "cmsimages/news2.jpg";
FilesArray[1] = "cmsimages/news1.jpg";
FilesArray[2] = "cmsimages/news3.jpg";

LinksArray = new Array();
LinksArray[0] = "electronic_ekeel.html";
LinksArray[1] = "newsPhoenixDetail.html";
LinksArray[2] = "newsMarineExpoDetail.html";


function changeImage(filename)
{
  var image =  document.getElementById('mainimage');
  image.src = filename;
}

function changeNewsImage(divid, imageid, imagefile, millisec, direction)
{
	if(direction == 0)
	{
		counterFile = counterFile + 1;
    	if(counterFile >=3)
    	{
    		counterFile=0;
    	}
    }
    else
    {
    	counterFile = counterFile - 1;
   		 if(counterFile < 0)
    		{
    			counterFile=3;
    		}
    }
	
	
    document.getElementById('newslink').href= LinksArray[counterFile];
	
    imagefile = FilesArray[counterFile];
    

	blendimage(divid, imageid, imagefile, millisec);
}

function blendimage(divid, imageid, imagefile, millisec) {

    
    var speed = Math.round(millisec / 100);
    var timer = 0;
    
    //set the current image as background
    document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
    
    
    
    //make image transparent
    changeOpac(0, imageid);
    
    //make new image
    document.getElementById(imageid).src = imagefile;

    //fade in image
    for(i = 0; i <= 100; i++) {
        setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
        timer++;
    }
}

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 + ")";
} 