/*
Open a new image window
Source the script in the head of your document
Add the following code to the term in your html
<a href="javascript:openImageWin('path/to/page', 'width', 'height')">thumbnail</a>

*/


function openImageWin (url, IMG_WIDTH, IMG_HEIGHT)
{
  var imageWin;
  var finalWidth = parseInt(IMG_WIDTH) + 50;
  var finalHeight = parseInt(IMG_HEIGHT) + 150;
  
  if ( imageWin == null || imageWin.closed )
  {
    imageWin = window.open(url,"imageWin","width="+finalWidth+",height="+finalHeight+",resizable=1,scrollbars=1,left=10,top=10,toolbar=0,menubar=0");
  }
   
  if ( !imageWin.closed )
  {
    imageWin.resizeTo ( finalWidth, finalHeight );
  }
  
  imageWin.focus();
}

function showPopup() {
  var newwindow;
  set_cookie("mycook","yes",1);
  newwindow=window.open('http://www.bmu.unimelb.edu.au/notice.html','newwin','height=250,width=550,left=10,top=10,toolbar=0,menubar=0');
	if (window.focus) {newwindow.focus()}
	return false;
}

function get_cookie(name) {
  var search = name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    // if cookie exists
    if (offset != -1) { 
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1) end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}

function set_cookie(name, value, expires) {
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
";path=/";
}

function delete_cookie( name ) {
if ( get_cookie( name ) ) document.cookie = name + "=" +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function check_cookie()
{
//delete_cookie('mycook');
cook=get_cookie('mycook');
if (!(cook!=null && cook!=""))
  {
//	  thetext = "On June 1st 2009, the Biomedical Multimedia Unit was disestablished as a Unit within the Faculty of Medicine, Dentistry and Health Sciences.\n\nMany of the BMU's current activities have been reorganised into other areas of the Faculty.\n\nEnquiries relating to the development and use of educational technology can be directed to Lindsay Guy (Acting Manager, Medical Education Unit: l.guy@unimelb.edu.au).\n\nEnquiries relating to potential or ongoing research collaborations can be directed to Gregor Kennedy (Senior Lecturer, Informatics, MDHS: gek@unimelb.edu.au).\n\nAll other enquiries can be directed to Richard Frampton (Faculty General Manager, MDHS: r.frampton@unimelb.edu.au).";
//	  alert(thetext);
 showPopup();
}
}

check_cookie();

