// JavaScript Document

// please keep these lines on when you copy the source
// made by: Nicolas - http://www.javascript-page.com
var clockID = 0;

function UpdateClock() {
   if(clockID) {
      clearTimeout(clockID);
      clockID  = 0;
   }

   	var tDate = new Date();

	var currentHours = tDate.getHours ( );
	var currentMinutes = tDate.getMinutes ( );
	var currentSeconds = tDate.getSeconds ( );
	
	var time_string = ( currentHours < 10 ? "0" : "" ) + currentHours + ":" 
                                   + ( currentMinutes < 10 ? "0" : "" ) + currentMinutes + ":" 
                                   +( currentSeconds < 10 ? "0" : "" ) + currentSeconds;
   
   var timeID = document.getElementById("time");
   
   if( timeID != null )
   {
		timeID.firstChild.nodeValue = time_string;
   }
   
   clockID = setTimeout( "UpdateClock()", 1000 );
}

function StartClock() {
   
   UpdateClock();
   //clockID = setTimeout( "UpdateClock()", 0 );
}

function KillClock() {
   if(clockID) {
      clearTimeout(clockID);
      clockID  = 0;
   }
}


function researchAbstractPopUp( ID )
{
		var URL =  "?location=/web/Research abstract/" +  ID;
		
		popUp(URL);
}


function emailPopUp( Name, Subject )
{
	Subject = typeof( Subject ) != 'undefined' ? Subject : '';
	
	var URL =  "?location=/web/Email/" + escape( Name );
	
	if( Subject != '' )
	{
		URL = URL + "/" + escape( Subject );
	}
	
	popUp(URL);
}




function popUp(URL) 
{
	var swfId = "liquid_swf";
	
	var day = new Date();
	var id = day.getTime();
	//eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=372,height=433');");

	var winNew = window.open(URL, id, 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=372,height=433');
	
	if(!winNew) 
	{
		//alert( "Bet this is Safari" );
		//alert( getSwf(swfId) );
		
		getSwf(swfId).openWindowFromSwf(URL);
	}
	else 
	{
		winNew.focus();
	}
}


function getSwf(id) 
{
        if (navigator.appName.indexOf("Microsoft") != -1) {
            return window[id];
        } 
        else {
            return document[id];
        }
 }    



function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
