 
  function getElementsByStyleClass (className) {
  var all = document.all ? document.all :
    document.getElementsByTagName('*');
  var elements = new Array();
  for (var e = 0; e < all.length; e++)
    if (all[e].className == className)
      elements[elements.length] = all[e];
  return elements;
}
  
  

  
  
  $(document).ready(function(){
    
    // Declare the starting variables
	
	var spotlightId = "d1-1";
	var folioDivs = getElementsByStyleClass ('folio');
	var items = folioDivs.length;
	var xx=0;
	var kk = 0;
	var theinterval = 600;
	var xShift = 545;
	var yShift = 455;
	var disab = false;
	var curCol = 1;
	var curRow = 1;
	var rowCount = 7;
	var rowLimit = 7;
	var colLimit = 5;
	
	updateTech(1);
	
	function updateTech(curRow) {
	
		for (kkk=1; kkk<=8; kkk++) {	
			if (tech[curRow][kkk] != true) {	
			$("#tech"+kkk).css({ opacity: 0.2});
			}
			else {		
				$("#tech"+kkk).css({ opacity:1});		
			}
			
			
				
		}
			
		for (kkk=1; kkk<=3; kkk++) {	
			if (summ[curRow][kkk]) {	
			$("#summ"+kkk).html(summ[curRow][kkk]);
			}
			else {		
				$("#summ"+kkk).html("n/a");		
			}	
		}
		if (links[curRow]) {
				$("#visitlink").attr({href: links[curRow], target: "_blank"});
				$("#visitlink").css({opacity:1});	
			}
			else {
			$("#visitlink").attr({href: "#", target: "_self"});	
			$("#visitlink").css({opacity:0.3});	
			}
	}
	
	
	function getNumCols(row, colLimit) {
		for (x=1; x<=(colLimit+1); x++)
			{
			flag = true;
				for (xx=0; xx<items; xx++)
				{
				
					 if (('d'+row+'-'+x) == folioDivs[xx].id) {
					flag = false;
					}	
					
				 }	
				 if (flag == true) {
				numCols = x;
				numCols--;	
				return numCols;
				
				break;
				}
			}
	}
	
	
	function isValidCell(row, col) {
		row++;
	toCheck = 'd'+col+'-'+row;
	valid= false;
				for (xx=0; xx<items; xx++)
				{
					 if (toCheck == folioDivs[xx].id) {
					 valid = true;
					 }
				 }
				 return valid;
	}
	
	
	var iconshtml = '';
	
	
	for (y=curRow; y<=rowCount; y++) {
		for (x=0; x<colLimit; x++) {
			if (isValidCell(x, y)) {
			iconshtml += '<a id="i'+y+'-'+x+'" href="#i'+y+'-'+x+'" class="jumpic"></a>';	
			}
			else {
			iconshtml += '<div id="i'+y+'-'+x+'" href="#i'+y+'-'+x+'" class="jumpdis"></div>';	
			}
		}
		iconshtml += '<br/><br/>';
	}
	
	
	$("#icons").html(iconshtml);
	$("#summary").html(abstractText[1]);
	

		for(y=curRow; y<=rowCount; y++) {
			
			thisNumCols = getNumCols(y, colLimit);
		

				for (x=0; x<=colLimit; x++) {

				if  ((x < thisNumCols) ) {
				$("#i"+y+"-"+x).css({opacity: 0.3});
				}
				else {
				$("#i"+y+"-"+x).css({opacity: 0.1});	
				}
				
				if ((y == curRow) && (x == 0)) {
				$("#i"+y+"-"+x).css({opacity: 1});	
				}
				
				
				
			}
			
				if (y != curRow) {
				$("#title-"+y).css({opacity: 0.3});	
				}
		}
	
	$("div.testinner, div.testinner2").css({opacity: 0.5});


	
	
	for (xx=0; xx<items; xx++)
		{

	
		thisid = folioDivs[xx].id;

			if (thisid == spotlightId) {	
			newOpacity = 1;
			}
			else {	
			newOpacity = 0.3;
			}
	  
	  $("#"+thisid).animate({ 
		opacity: newOpacity
     	 }, 0 );
	
	
		}
	


	$.hotkeys.add('left', function(){ $("#back").click();} );
	$.hotkeys.add('right', function(){ $("#forward").click();} );
	$.hotkeys.add('up', function(){ $("#up").click();} );
	$.hotkeys.add('down', function(){ $("#down").click();} );
	

	$("#forward, #back, #up, #down, .jumpic").bind("click", function(event){ 		
 
	
	var iconsflag = false;  

			if (disab != true) {
			
			disab = true;
			
			e=event;
			if (e.target)
			  {
			  targ=e.target;
			  }
			else if (e.srcElement)
			  {
			  targ=e.srcElement;
			  }
			if (targ.nodeType==3) // defeat Safari bug
			  {
			  targ = targ.parentNode;
			  }
			   
			targ2 = targ.alt;
			
			if (targ.className == 'jumpic') {
				//window.alert("Jump");
			targ2 = String(targ);
			targ2 = targ2.split("#");
			targ2 = String(targ2[1]);
			}
			 
			targ = String(targ);
			targ = targ.split("#");
			targ = String(targ[1]);
			
			
			  
			curCol = spotlightId.substr(3, 1);
			curRow = spotlightId.substr(1, 1);	
			newRow = curRow;
			newCol = curCol;
			oldRow = curRow;
			oldCol = curCol;
			 // targ is now defined as back, forward, up or down
			 
			 	
			numCols = parseInt(numCols);
			curRow = parseInt(curRow);
			numCols = getNumCols(curRow, colLimit);
			//window.alert('just found '+numCols);
			//window.alert("numcols="+numCols+" thisrow="+curRow);
			numColsNxt = getNumCols((curRow+1), colLimit);
			numColsPrev = getNumCols((curRow-1), colLimit);
			//window.alert("numcolsnxt="+numCols+" next"+(curRow+1));
			 
			 // test jump 
			 
			 if (targ2) {
				newCol=targ2.substr(3,1);
				newRow=targ2.substr(1,1);
				newCol++;
				newspotlightId = "d"+newRow+"-"+newCol;
				validshift= false;
				for (xx=0; xx<items; xx++)
				{
					 if (newspotlightId == folioDivs[xx].id) {
					 validshift = true;
					 //window.alert("VALID: "+newspotlightId);
					 }
				 }		
				
					if (validshift == true) {
					spotlightId = newspotlightId;
					
					changeX = -(xShift) * (curCol - newCol);
					changeY = 0;
					//window.alert("valid");
					changeX = -(xShift) * ((newCol - curCol));
					changeY =  -(yShift) * ((newRow - curRow));
					
					}
					else {
					changeX = 0;
					changeY = 0;
					}
					
					
					
					
				
			 }
			 
			 
			 // if grid constraints have not been reached define new x and new y location
			 // check for constraints in each function
			 
			if (targ == 'forward') {
			
			validshift = false;
			
			newCol++;
			newspotlightId = "d"+newRow+"-"+newCol;
			
			// if this is a valid div, set the new spotlight and update x y movement
			for (xx=0; xx<items; xx++)
			{
				 if (newspotlightId == folioDivs[xx].id) {
				 validshift = true;
				 //window.alert("VALID: "+newspotlightId);
				 }
			 }		
				if (validshift == true) {
				spotlightId = newspotlightId;
				changeX = -(xShift);
				changeY = 0;
				}
				else {
				targ = "down";
				changeX = 0;
				changeY = 0;
				newCol--;
				}

			} 
			
			if (targ == 'back') {
			
			validshift = false;
			newCol--;
			newspotlightId = "d"+newRow+"-"+newCol;
			
			// if this is a valid div, set the new spotlight and update x y movement
			
			for (xx=0; xx<items; xx++)
			{
				 if (newspotlightId == folioDivs[xx].id) {
				 validshift = true;
				 }
			 }		
				if (validshift) {
				spotlightId = newspotlightId;
				changeX = (xShift);
				changeY = 0;
				}
				else {
				targ = "up";
				changeX = 0;
				changeY = 0;
				newCol++;
				}

			} 	

			if (targ == 'up') {
			
			validshift = false;
			curCol = newCol;
			newRow--;
			curRow--;
			// return to left most row
			newspotlightId = "d"+newRow+"-1";
			
			// if this is a valid div, set the new spotlight and update x y movement
			
			for (xx=0; xx<items; xx++)
			{
				 if (newspotlightId == folioDivs[xx].id) {
				 validshift = true;
				 }
			 }		
				if (validshift) {
				spotlightId = newspotlightId;
				changeX = ((curCol-1) * xShift);
				changeY = (yShift);
				}
				else {
				changeX = 0;
				changeY = 0;
				}

			} 	

			
			if (targ == 'down') {
			
			validshift = false;
			curCol = newCol;
			newRow++;
			curRow++;
			// return to left most row
			newspotlightId = "d"+newRow+"-1";
			
			// if this is a valid div, set the new spotlight and update x y movement
			
			for (xx=0; xx<items; xx++)
			{
				 if (newspotlightId == folioDivs[xx].id) {
				 validshift = true;
				 }
			 }		
				if (validshift) {
				spotlightId = newspotlightId;
				changeX = ((curCol-1) * xShift);
				changeY = -(yShift);
				}
				else {
				changeX = 0;
				changeY = 0;
				}

			} 	
			//window.alert(newCol);
			
			var x=0;
			for (x=0; x<items; x++)
				{

					thisid = folioDivs[x].id;
					
					if (thisid == spotlightId) {	
					newOpacity = 1;
					}
					else {	
					
					newOpacity = 0.4;
					}
	
				
				  newX = folioDivs[x].style.left;
				  newX = newX.replace(/px,*\)*/g,"");
				  newX = parseInt(newX);
				  newX = newX + changeX;
				  
				  newY = folioDivs[x].style.top;
				  newY = newY.replace(/px,*\)*/g,"");
				  newY = parseInt(newY);
				  newY = newY + changeY;

				
				  	kk ++;
					

					
					
						  $("#"+thisid).animate({ 
							left: newX+"px",
							top: newY+"px",
							opacity: newOpacity
							
							 }, theinterval );
						  
					 numCols = getNumCols(curRow, 9);
					 //window.alert(numCols);
						if (iconsflag == false) {	
						
						
							for (k=0; k<=colLimit; k++) {
							  //window.alert('checking i'+k);
							 
								//window.alert('target '+targ+' and cols '+numCols);	
								
								if (targ == 'forward') {
									
										if ((k != curCol) && (k < numCols)) {
										$("#i"+curRow+"-"+k).animate({opacity: 0.3}, theinterval);
										}
										else if (k == curCol) {
										$("#i"+curRow+"-"+k).animate({opacity: 1}, theinterval);	
										}
										else {
										$("#i"+curRow+"-"+k).css({opacity:0.1});	
										}
									}
									if (targ == 'back') {
									
										if ((k != (newCol-1)) && (k < numCols)) {
										$("#i"+curRow+"-"+k).animate({opacity: 0.3}, theinterval);
										}
										else if (k == (newCol-1)) {
										$("#i"+curRow+"-"+k).animate({opacity: 1}, theinterval);	
										}
										else {
										$("#i"+curRow+"-"+k).css({opacity:0.1});	
										}
									}
									
									if ((targ == 'down') && (validshift==true)) {
										//window.alert("down");
										if ((k != 0) && (k < (numColsNxt))) {
										$("#i"+(curRow)+"-"+k).css({opacity: 0.3});
										}
										else if (k == 0) {
										$("#i"+(curRow)+"-"+k).css({opacity: 1});	
										}
										else {
										$("#i"+(curRow)+"-"+k).css({opacity:0.1});	
										}
										
										//clear the last highlighted box!
										//$("#i1-1").animate({opacity:0}, theinterval);
										$("#i"+oldRow+"-"+(oldCol-1)).css({opacity:0.3});
										$("#title-"+oldRow).css({opacity:0.3});
										$("#title-"+curRow).css({opacity:1});
										
									}
									
									
									if ((targ == 'up') && (validshift==true)) {
						
										if ((k != 0) && (k < (numColsPrev))) {
										$("#i"+(curRow)+"-"+k).css({opacity: 0.3});
										}
										else if (k == 0) {
										$("#i"+(curRow)+"-"+k).css({opacity: 1});	
										}
										else {
										$("#i"+(curRow)+"-"+k).css({opacity:0.1});	
										}
										
										//the bottom row too
										
										$("#i"+(oldRow)+"-"+(oldCol-1)).css({opacity:0.3});
										
										// adjust titles
										$("#title-"+oldRow).css({opacity:0.3});
										$("#title-"+curRow).css({opacity:1});
			
										
									}
									
									if ((targ2) && (validshift == true)) {
										
										if ((k != 0) && (k < (getNumCols(oldRow, 9)))) {
										$("#i"+(oldRow)+"-"+k).css({opacity: 0.3});
										}
										else if (k == 0) {
										$("#i"+(newRow)+"-"+(newCol-1)).css({opacity: 1});	
										}
										else {
										$("#i"+(curRow)+"-"+k).css({opacity:0.1});	
										}
										
										$("#i"+oldRow+"-"+(oldCol-1)).css({opacity:0.3});
										$("#i"+(newRow)+"-"+(newCol-1)).css({opacity: 1});	
										$("#title-"+oldRow).css({opacity:0.3});
										$("#title-"+newRow).css({opacity:1});
									
									}
									
									
								}
								
								if (((targ == 'up') || (targ == 'down') || ((targ2) && (changeY))) && (validshift == true)) {
								updateTech(newRow);	
								}
						}
						iconsflag = true;
				
					
						}
						
				
						if (((targ == 'down') && (validshift == true)) || ((targ == 'up') && (validshift == true))   || ((targ2) && (validshift == true) && (changeY)) ) {
				
							$("#summary").fadeOut(theinterval/2);
							$("#proTitle").fadeOut(theinterval/2);	
							newtext('summary', abstractText[newRow], (theinterval/2));
						
							$("#summary").fadeIn(theinterval/2);
							$("#proTitle").fadeIn(theinterval/2);
			
						}
						
						
						 $("#"+thisid).animate({ 
							
							opacity: newOpacity
							 }, 1, function() {
				
							
							if (kk == items) {
						
							disab = false;
							kk = 0;
							}
						
							
							})
						
					}	
				
				
    });
	




  });
 
 
		
		
		function newtext(id, text, delay)
		{
		 setTimeout("replacetext('"+id+"', '"+text+"')", delay);
		 }
		function replacetext(id, text)
		{
		//window.alert(id);
		var t = document.getElementById(id, text);
		t.innerHTML=text;
		}
		
		
		


 function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}
function checkVersion()
{
  //var msg = "You're not using Internet Explorer.";
  var ver = getInternetExplorerVersion();

  if ( ver > -1 )
  {
    if ( ver <= 6.0 )  {
      //msg = "Internet Explorer 6.0 or earlier detected. This site appears best in Internet Explorer 7.0+"
	  var g = document.getElementById('grad');
	  g.style.display = 'none';
	  //alert( msg );
	  }
   // else
     // msg = "You should upgrade your copy of Internet Explorer.";
  }
  
}
 