<!-- hide it ...
var _messwin5;
var _messwin1;
var _ramwin;
var _chatwin=null;
var chaton = false;
//var _url=null;
//var _timeouturl = null;
//var _timeouturl5 = null;
//var _refreshurl = null;

var tout;
var idleb = new Date();
var features =  'scrollbars=yes,resizable=yes,width=410,height=450' ;
//var chatfeatures =  'scrollbars=yes,resizable=yes,width=710,height=550' ;
var chatfeatures = 'toolbar=yes,status=yes,scrollbars=yes,location=yes,menubar=yes,directories=yes,resizable=yes,width=800,height=500';


function extendSession() {
	if (chaton) {
	alert("Chat session is on. Timeout is off.");
	}
	else {
	  window.open(_refreshurl,'',features);
	  refreshTimer();
	}
}

function setChatOn(on) {
	chaton = on;
}
function goToURL(form) {	
	var sbox=form.serviceselect;
	var options = form.serviceselect.options
	if (sbox.selectedIndex >0) {
	  var service = options[sbox.selectedIndex].value;
	  if ("chat"==service) {
	  open_chatwin("about:blank", form.autho.value);
	  form.target="chat_window"+form.autho.value;
	  form.submit();	
       	  options[0].selected=true;
	  _chatwin.focus();
	  }
          else {
		form.target="_self";
		form.submit();	
	  }	

	}
	else {
	 options[0].selected=true;
	}
}
					

function open_chatwin(url, autho){	
	if (_chatwin == null || _chatwin.closed) {
	_chatwin=window.open(url, 'chat_window'+autho, chatfeatures);
	chaton=true;
	_chatwin.focus();
	}
}

function open_win(url){
	if (_ramwin == null || _ramwin.closed) {
	_ramwin=window.open(url, 'qp_view', features);
	_ramwin.focus();	
	}
	else {
	_ramwin.document.location=url;
	_ramwin.focus();
	}
}
function close_messwin5(){
// if the _messwin exists, close it.
   if ((_messwin5 != null) && !(_messwin5.closed)) _messwin5.close();
}
function close_messwin1(){
// if the _messwin exists, close it.
   if ((_messwin1 != null) && !(_messwin1.closed)) _messwin1.close();
}

function refreshTimer() {	
	   
	//win.open(_refreshurl," ");	   
	idleb = new Date();
	display_time(_limit);	
}
function setChat(co) {
	chaton=co;
	if (!chaton) {
	idleb = new Date();
	 display_time(_limit);
	}
}
function display_time(limit) {
  if (_limit==null) {
  	_limit = limit;	
  }
  else {
     limit=_limit;
  }
  if (chaton) {
      defaultStatus="Your Chat is on -- Timeout is off.";	
      return;
  } 	
  var now = new Date();
  var idlebegin = idleb;
  var sessiontime = 1000*60*limit;
 // alert(now.getTime()/1000*60);
  // document.writeln("idlebegin = " + idlebegin.getTime());
  // document.writeln("now = " + now.getTime());
   var remainingm = (idlebegin.getTime() + sessiontime - now.getTime())/(1000 * 60);
   var remainm= Math.floor(remainingm);
   var remainings = (idlebegin.getTime() + sessiontime - now.getTime())/(1000) - (remainm*60);
   var remains= Math.floor(remainings);
   var idletime = remainm*60 + remains;
   var t = "Your QuestionPoint session will end in "+ remainm + ":";
   if ( remains < 10 )  {
      t = t + "0";
      }
   t = t + remains  +  " minutes";
 // Show wmsg on the status bar.
   defaultStatus = t; 
   if (idletime == 1*60) { 
      tout = 1; 
      close_messwin5();	  
     if (_messwin1!= null && !_messwin1.closed) {
		_messwin1.focus();
     }
     else {
      _messwin1=window.open(_timeouturl, '', features);
     }
   }
   if (idletime == 5*60) { 
      tout = 5;
     // wmsg("");
//	alert("open window 5 now");
	if (_messwin5!= null && !_messwin5.closed) {
		_messwin5.focus();
	}
	else {
        _messwin5=window.open(_timeouturl5, '', features);
    }
   }
   var fname = "display_time("+limit+")";
   if (idletime <=0 ) {
      close_messwin5();
      close_messwin1();
      document.location=_url;
   }
   else {
	setTimeout(fname, 1000);       
   }

}

function open_appsharewin(url) {
 if (parent && parent.openfn) {
     //   alert("call parent.open_win");
        parent.openfn(url);
 }
 else {
        
       var features =  'scrollbars=no,resizable=yes,width=250,height=30';
       window.open(url,'', features);
   }    
}
//-->
