// JavaScript Document
function displaySeries(series, i) {
   document.getElementById('p').src = series[i].imgsrc;
   document.getElementById('title').childNodes[0].nodeValue = series[i].title;
   document.getElementById('description').childNodes[0].nodeValue = series[i].description;
   document.getElementById('medium').childNodes[0].nodeValue = series[i].medium;
    document.getElementById('size').childNodes[0].nodeValue = series[i].size;
}
 
function updateImage(index, series)  {
	
	
	//alert(series);
	if (index < 0)
		index = series.length -1;
	else if (index > series.length)
		index  = 0;
				
	lastImg = index;
	 displaySeries(series, index);
		
		
}




function CJL_BrowserSniffer()
{
   var ua = navigator.userAgent;
//   alert(ua);
   this.isOpera = function()
   {
      return /Opera/.test(ua);
   }

   this.isSafari = function()
   {
      return /Safari/.test(ua);
   }

   this.isGecko = function()
   {
      return navigator.product == "Gecko" &&
	     ! ( this.isOpera() || this.isSafari() );
   }

   this.isIEWin = function()
   {
      return window.external && /Win/.test(ua);
   }

   this.isIEMac = function()
   {
      return window.external && /Mac/.test(ua);
   }

   this.getVersion = function()
   {
      if( this.isIEWin() || this.isIEMac() )
      {
         return Number(ua.match(/MSIE ([0-9.]+)/)[1]);
      }
      else if( this.isSafari() )
      {
         return Number(ua.match(/[0-9.]+$/));
      }
      else if( this.isGecko() )
      {
         var n = ua.match(/rv:([0-9.]+)/)[1];

         var ar = n.split(".");

         var s = ar[0] + ".";

         for(var i = 1; i < ar.length; ++i)
         {
            s += ("0" + ar[i]).match(/.{2}$/)[0];
         }

         return Number(s);
      }
      else if( this.isOpera() )
      {
         return Number(ua.match(/Opera.([0-9.]+)/)[1]);
      }
      else
      {
         return null;
      }
   }
}

var is = new CJL_BrowserSniffer();


var cssType = '<link rel="styleSheet" type="text/css"  href="';
var cssDef = '<link rel="styleSheet" type="text/css"  href="';

function browserSetup(dirPrefix, isIndex) {
	var canRun = false;
	var browserType;
	
	if (is) {
			canRun= true;
	}
	if (!canRun) {
		alert("It is highly recommended that you upgrade your browser to a more modern browser e.g. Firefox or IE6");
		cssType = null;
		return;
	}  else {
		if (is.isIEWin())  {			
				browerType="winIE";
				if (isIndex) {
					cssType += dirPrefix + 'ie-index.css">';
				} else {
					cssType += dirPrefix + 'ie.css">';
				}
				//alert("ie found");
		} else {
				cssType = null;
		}
		
     }
	
	//alert(cssType);
	
	if (cssType != null) 
	   document.write(cssType);
}


var sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
	}

  


function getObj(elementID){
if (typeof elementID == "string") {
return document.getElementById(elementID);
}else{
return elementID;
}
}

function SetActiveAndOpen(section, subsection) {

	
	if ((subsection != "") && (subsection != null)) {
	var sfEls = document.getElementById(section);
	   sfEls.className = "show";
		
    var subSec = document.getElementById(subsection);
	
		subSec.className = "highlight";
		
	} else {
			var sec = document.getElementById(section);
	            sec.className = "highlight";
	}
}

function getWindowHeight() {
 var wHeight = 0;
 
 if (typeof(window.innerHeight)=='number') {
 wHeight=window.innerHeight;
 
 }
 else {
 if (document.documentElement&&
 document.documentElement.clientHeight) {
 wHeight=
 document.documentElement.clientHeight;
 
 }
 else {
 if (document.body&&document.body.clientHeight) {
 wHeight=document.body.clientHeight;
 
 }
 }
 }
 
 return wHeight;
 }
 
 var windowHeight = getWindowHeight();

function mystart()
{
 document.getElementById("container").style.height = windowHeight + 'px';


}

if (window.attachEvent) window.attachEvent("onload", sfHover)
