var currentID;
function navigate(id,type)
{
	//alert(id);
	document.getElementById(currentID).src='images/bluearrow.gif';
	document.getElementById(currentID + '1').bgColor='#7fccf0'
	document.getElementById(currentID + '2').style.display="none";
	document.getElementById(id).src='images/OrangeArrow.gif';
	document.getElementById(id + '1').bgColor='#ff9600';
	if (type == 1)
		document.getElementById(id + '2').style.display="block";
	currentID=id;
}

function omo(id)
{
    if (id != currentIDd)
    document.getElementById(id).setAttribute('src','./bimages/'+id+'_mouseover.png');
}
function omt(id)
{   
    if (id != currentIDd)
    document.getElementById(id).setAttribute('src','./bimages/'+id+'_normal.png');
}
function omc(id)
{
    if (currentIDd !=null){
       document.getElementById(currentIDd).setAttribute('src','./bimages/'+ currentIDd +'_normal.png');
    }
    currentIDd = id;
    document.getElementById(id).setAttribute('src','./bimages/'+id+'_clicked.png');
}
function clearom()
{
    //document.getElementById(currentIDd).setAttribute('src','./bimages/'+currentIDd+'_normal.png');
    //currentIDd = 'none';
}
var currentIDd;

function checkLink()
{
	if (location.search.length < 2) //make sure we are not looking at an empty string
		return; //return if we are
	else
	    document.getElementById('graphic').style.display = "block";
	var query = location.search.substring(1); //remove the '?' from the string
	var pairs = query.split(","); //split all setctions of the string
	if (pairs.length < 1) //if there is nothing after the '?' return, empty set
		return;
	else
	{
	    
		var i = parseInt(pairs[1].substring(0));
		var j = parseInt(pairs[2].substring(0));
		var k = pairs[0].substring(0);
		//alert(k + " " + i + " " + j);
		navigate(k,i); //display the area requested
	    setText(j);
	    
	}
}
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 shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
	if(document.getElementById(id).style.opacity == 0) {
		opacity(id, 0, 100, millisec);
	} else {
		opacity(id, 100, 0, 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++;
	}
	//document.getElementById(divid).style.backgroundImage = "none";
}

function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;
	
	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}

	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}

var myimages = new Array();

myimages[0]="cs_logos/awwu_logo.gif";
myimages[1]="cs_logos/carlile_logo.gif";
myimages[2]="cs_logos/GCI_logo.gif";
myimages[3]="cs_logos/HL_logo.gif";
myimages[8]="cs_logos/SOA_logo.gif";
myimages[5]="cs_logos/acs_logo.gif";
myimages[6]="cs_logos/UAA_logo.jpg";
myimages[7]="cs_logos/ARR_logo.jpg";
myimages[4]="cs_logos/DLA_logo.jpg";

var x = 5;
var y = 1;
var count=myimages.length;
var q=1;
function rotateimages() {
  x = x-y;
  if (count > 0)
  {
    setTimeout("rotateimages()", 500);
    if(x==0){
         q= (++q)%count; 
         blendimage('blenddiv','img1', myimages[q],500);
        x=5;
    }
  }
} 

//var x = 5;
//var y = 1;
//var count=3;
//var q=0;
//   function startClock(){
//      x = x-y;
//      if (count > 0)
//      {
//        setTimeout("startClock()", 1000);
//        if(x==0){
//            fadeout("q"+q);
//            q= (++q)%count; 
//            fadein("q"+q);
//            x=5;
//        }
//      }
//   } 
//   
//var speed = Math.round(1000 / 100);
//var timer = 0;

//function fadein(id) {

//		for(i = 0; i <= 235; i++) {
//		    setTimeout("fade('" + id +"',"+i+")",(timer*speed));
//			timer++;
//		}
//}
//function fadeout(id) {

//		for(i = 0; i <= 235; i++) {
//		    setTimeout("fade('" + id +"',"+i+")",(timer*speed));
//			timer--;
//		}
//}
//var bkg = new Array();
//function makeArray()
//{
//        for (var j=235; j>0; j--)
//        {
//             bkg[235 - j] = "rgb(255,"+(220 +Math.round(.14893617*(j)))+","+ (20+Math.round(j))+")";
//        }
//        bkg[0] = "white";
//}
//function fade(id, i)
//{   
//    if (count > 0) {
//        var obj = document.getElementById(id).style;    
//        obj.backgroundColor = bkg[i];
//    }
//}