
function restoreScrollPos()
  {
    var posX = parseInt(getCookie("scrollPosX"));
	var posY = parseInt(getCookie("scrollPosY"));
	// destory cookies
	deleteCookie("scrollPosX");
	deleteCookie("scrollPosY");
	// scroll to recovered position
	window.scroll(posX,posY);
	
	return true;
 }
 
 function saveScrollPos()
 {
 	var expiry = new Date();
	expiry.setSeconds(expiry.getSeconds() + 60);
	setCookie("scrollPosX", window.document.body.scrollLeft, expiry);
	setCookie("scrollPosY", window.document.body.scrollTop, expiry);
 }
 
 // Generic function to set a Cookie
 function setCookie(name, value, expires, path, domain, secure)
 {
  // Derive cookie string
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
	  ((path) ? "; path=" + path : "") +
	  ((domain) ? "; domain=" + domain : "") +
	  ((secure) ? "; secure" : "");
	  
	  // Set the cookie
	  document.cookie = curCookie;
 }
 
 function getCookie(name)
 {
  // Get all cookies for this website
  var dc = document.cookie;
  var prefix = name + "=";
  
  // find our particular cookie in the cookie string
  var begin = dc.indexOf("; " + prefix);
  
  // If found
  if (begin == -1)
  {
     begin = dc.indexOf(prefix);
	 if (begin != 0)
	  return null;
  }
  else
   begin += 2;
   
   var end = document.cookie.indexOf(";",begin);
   
   if (end == -1)
    end = dc.length;
	
	return unescape(dc.substring(begin + prefix.length, end));
 }
 
 function deleteCookie(name)
 {
    var exp = new Date()
	exp.setTime (exp.getTime() - 1);
	var cval = getCookie(name);
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
 }
 

function CatchRightHandClick()
{
	var cP = navigator.appName;if (cP=='Microsoft Internet Explorer')
	
	if (event.button==2)
	{
		str = "Please contact us before using an image from this site";
		str = str + "";
		str = str + "";
		alert (str);
	}
}

function a()
{
	alert("here");
}
 
 
function ShowFlashMovie(width,height,movie)
{		
	var o = 
	    '<noscript>' +
		'<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" width="' + width + 
		'" height="' + height + '" codebase="xhttp://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0">' +
		'<param name="movie" value="/Graphics/Banners/' + movie + '" />' +
		'<param name="quality" value="high" />' + 
		'<embed src="/Graphics/Banners/' + movie + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash">' +
		'</embed></object></noscript>';
	alert(o);
	document.write(o);
}

function addAnalyticsDocTracking() {
	
	var fileTypes = ['doc','xls','pdf','mp3'];
 
	$('a').each(function() {
  		var $a = $(this);
  		var href = $a.attr('href');
  		var hrefArray = href.split('.');
  		var extension = hrefArray[href.length - 1];
 
  		if ($.inArray(extension,fileTypes) != -1) {
    		$a.click(function() { 
      		// get the post title if there is one 
      		// and add it to the string for tracking
      		pageTracker._trackPageview('/documents/' + href);
							  });}
		})
}
