// Javascript functions for CS40 site

//***************************************************************************
//Script copyright (c) 2001 - 2006 www.ukarchaeology.co.uk
function open_window(filename, windowname, properties) {
	
	var currentwidth, currentheight;
	
	
	//var isfound, re;
	//re = /laarc|source|herts|action/; //create regexp to check if this is about page - so can make it bigger
	//isfound = filename.search(re);
	
	//if (isfound == -1){ // expressions not found  in filename
		currentheight = ((screen.height/100) * 80);
		currentwidth = ((screen.width/100) * 80);
	//}else{
	//	currentheight = ((screen.height/100) * 80); 
	//	currentwidth = ((screen.width/100) * 80); //make about wider
	//}
	window.open(filename, windowname, properties + ",width=" + currentwidth + ",height=" + currentheight);
}
//***************************************************************************

// Browser Slide-Show script.
// With image cross fade effect for those browsers that support it.
// Script copyright (c) 2004-2006 www.cryer.co.uk.
// Script is free to use provided this copyright header is included.
var slideCache = new Array();
function RunSlideShow(pictureName,imageFiles,displaySecs,titleCaption)
{
  var imageSeparator = imageFiles.indexOf(";");
  var nextImage = imageFiles.substring(0,imageSeparator);
  if (document.all)
  {
    document.getElementById(pictureName).style.filter="blendTrans(duration=2)";
    document.getElementById(pictureName).filters.blendTrans.Apply();
  }
  document.getElementById(pictureName).src = nextImage;
  if (document.all)
  {
    document.getElementById(pictureName).filters.blendTrans.Play();
  }
  
  //new saj to update caption
  //var txt = 'hello';
  //document.getElementById(titleCaption).innerHTML=txt;
  
  var futureImages= imageFiles.substring(imageSeparator+1,imageFiles.length)
    + ';' + nextImage;
  setTimeout("RunSlideShow('"+pictureName+"','"+futureImages+"',"+displaySecs+")",
    displaySecs*1000);
  // Cache the next image to improve performance.
  imageSeparator = futureImages.indexOf(";");
  nextImage = futureImages.substring(0,imageSeparator);
  if (slideCache[nextImage] == null) {
    slideCache[nextImage] = new Image;
    slideCache[nextImage].src = nextImage;
  }
}

// Gallery script.
// With image cross fade effect for those browsers that support it.
// Script copyright (C) 2004 www.cryer.co.uk.
// Script is free to use provided this copyright header is included.
function LoadGallery(pictureName,imageFile,titleCaption,captionText)
{
  if (document.all)
  {
    document.getElementById(pictureName).style.filter="blendTrans(duration=1)";
    document.getElementById(pictureName).filters.blendTrans.Apply();
  }
  document.getElementById(pictureName).src = imageFile;
  if (document.all)
  {
    document.getElementById(pictureName).filters.blendTrans.Play();
  }
  document.getElementById(titleCaption).innerHTML=captionText;
}



