//Banner Rotation Script written by Jim Morrissey
//This script was written for Correlog.com
//For questions on script please email jimmo@thejimmo.com

// Banner rotates every 7 secs. 
var bn_timeout = 7000;
//Click is variable that lets us know if the naviation was clicked, if true timeout = 10 sec
var click = false;
//When clicked = true then we set this var to 10 sec
var bn_clicked = 10000;

////////////////////////////////////////////////////////////////
//******INSERT BANNER IMAGES AND LINKS INTO ARRAYS BELOW******//
//This is the only part of the script that you'll need to edit//
////////////////////////////////////////////////////////////////

// Build the array for the banners
var banners=new Array(); 
banners[0]="http://correlog.com/Images/a-slide7.jpg";       
banners[1]="http://correlog.com/Images/a-slide3.jpg";
banners[2]="http://correlog.com/Images/a-slide2.jpg";
banners[3]="http://correlog.com/Images/a-slide6.jpg";
banners[4]="http://correlog.com/Images/a-slide4.jpg";
//Build the array for the links for the banners,
var links = new Array();
links[0]="http://info.correlog.com/Rounding-out-Your-SIEM-Strategy-with-SNMP/";
links[1]="http://info.correlog.com/correlation_white_paper/";
links[2]="http://www.correlog.com/solutions-and-services/index.html";
links[3]="http://www.correlog.com/solutions-and-services/MTS_Allstream_case-study.html";
links[4]="http://www.correlog.com/solutions-and-services/sas-correlog.html";

var targets = new Array();
targets[0]="_self";
targets[1]="_self";
targets[2]="_self";
targets[3]="_self";
targets[4]="_self";

/////////////////////////////////////////////////////////////////////////
//This is as far as you'll need to go to change the banners or settings//
/////////////////////////////////////////////////////////////////////////

var i = 1;
var j = 1;
var bannersNum = banners.length - 1;
//adjustWidth();


function init_rotate()

{
	adjustWidth();
	//Pre-load the banners into the page so we can access them without load time delay.


	   var k = 0;
	   while (k < banners.length){
		   k = new Image(); k.src = banners[k];
		k++;   
	   }


/*      i1=new Image(); i1.src="http://correlog.com/Images/a-slide1.jpg"

      i2=new Image(); i2.src="http://correlog.com/Images/a-slide2.jpg"

      i3=new Image(); i3.src="http://correlog.com/Images/a-slide3.jpg"

      i4=new Image(); i4.src="http://correlog.com/Images/a-slide4.jpg"

      i5=new Image(); i5.src="http://correlog.com/Images/a-slide5.jpg"*/

   
	document.getElementById('change0').className = 'hoverNavA';
   //setTimeout('rotate_image(1, false)',  bn_timeout);
 	rotate_image(0, false);
}

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



function rotate_image(i, click)

{
	clearHover();
	//Setting up rotation of banner, first we will clear the timeout set.
	//clearTimeout();
	//alert(banners.length);
	// Check to see if we're in bounds of how many banners we have
	if (i < banners.length) {
		//Execute the actual change of the banner image
		document.getElementById('banner').src=banners[i];
		document.getElementById('change'+ i).className = 'hoverNavA';
		document.getElementById('links').href = links[i];
		document.getElementById('links').target = targets[i];
		//Setup i to go to the next one
		i = i + 1;
		//If we're above our banner limit go back to the first one which in our case is an array so it's 0
		if (i > bannersNum) {
			i = 0;
		}
		//Check to see if we have a click on the navigation, if we do then cleartimeout and set timeout to 10 sec
		if (click == true){
			//i = i + 1;
			//clearTimeout();
			bn_timeout = bn_clicked;
			//setTimeout("rotate_image("+ i +", false)",  bn_clickedt);
		}
		//If no click cleartimeout and continue on as business as usual
		else if (click == false){
			//i = i + 1;
			//clearTimeout();
			setTimeout("rotate_image("+ i +", false)",  bn_timeout);			
		}
		
	}


}
//<img onmouseover='document.images['rotate'].src='some.png';' id='rotate' src='images/square.jpg' style='margin-left:10px;' border='0' /> 
function buttons() {
	//Setup our buttons, check to see how many banners we have in the que then lineup a button for each
	document.write("<div class='nav' id='adjust' style='width: auto; visibility: visible;'><img src='images/left_end.png' />");
	var j = 0;
	while (j < banners.length) {
		document.write("<a class='hoverNav' id='change"+j+"' onClick='rotate_image("+j+", true)' href='#'><img id='' border='0' src='images/square_hover.jpg' style='vertical-align: top;margin-left:10px;margin-top:8px;' /></a>");
	j++;	
	}
	document.write("<img src='images/right_end.png' style='margin-left:15px;' /></div>");
	
}

function clearHover() {
	var f = 0;
	while (f < banners.length) {
		document.getElementById('change'+ f).className = 'hoverNav';
	f++;	
	}
}

function adjustWidth(){
	 if ( banners.length > 1) {
            var obj = document.getElementById('adjust')
            obj.style.width = banners.length * 25 + 14 + "px";
            obj.style.visibility = 'visible';
			
        }
}

function image() {
	document.write("<a id='links' border='0' href='solutions.html' target='_self'><img border='0' id='banner' src='" + banners[0] + "' width='900' height='270' alt='Correlog'></a>");
}

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



