
function deleteCookie(strName,strPath,strDomain){
 if(getCookie(strName)){
  document.cookie = strName + "=" + ((strPath) ? "; strPath=" + strPath : "") + ((strDomain) ? "; strDomain=" + strDomain: "") + "; expires=Thu, 01-Jan-05 00:00:01 GMT";
 }
}

function getCookie(strName){
 strName=strName+'=';
 if(document.cookie.length>0){
  var intOffset=document.cookie.indexOf(strName);
  if(intOffset!=-1){
   intOffset+=strName.length;
   var intEnd=document.cookie.indexOf(';',intOffset);
   if(intEnd==-1){
    intEnd=document.cookie.length;
   }
   return unescape(document.cookie.substring(intOffset,intEnd));
  }
 }
 return false;
}

function setCookie(strName,strValue,intDays){
 strValue=escape(strValue);
 if(intDays>0){
  var e=new Date();
  e.setTime(e.getTime()+((1000*60*60*24)*intDays));
  document.cookie=strName+'='+strValue+'; path=/; expires='+e.toGMTString();
  return true;
 }else{
  document.cookie=strName+'='+strValue+'; path=/;';
  return true;
 }
 return false;
}

function gotCookies(){
 var sC='nse';
 if(getCookie(sC)!=1){
  setCookie(sC,1,365);
  if(getCookie(sC)==1){
   top.location = top.location;
  }else{
   return false;
  }
 }
 return true;
}

function createEmail(u,d,c,s){
 document.write('<A'+(c ? ' CLASS="'+c+'"' : '')+' HREF="mailto:'+u+'&#64;'+d+(s ? '?'+s : '')+'">'+u+'&#64;'+d+'</A>');
}

function printWindow(){
 if(window.print){
  window.print();
 }else{
  alert("Your browser does not support JavaScript printing.  Please select 'Print...' from the File Menu");
 }
 return false;
}

var intLogoutWarning=300000;
var popupWindow;
var bitSPN=0;
function logoutDo(loc){
 if(popupWindow){
  popupWindow=window.open('','popupWindow','width=200,height=140');
  popupWindow.focus();
  popupWindow.document.write('<html><head></head>');
  popupWindow.document.write('<body onblur="this.focus();">');
  popupWindow.document.write('<table width="100%" height="100%"><tr><td><center><table><tr><td><center><font size="2" face="arial,verdana">WARNING: Your Session Timeout has Expired,<br />You are being Logged Out.</font><br /><br /><a href="#" onclick="this.close();">Close this Window</a></center></td></tr></table></center></td></tr></table>');
  popupWindow.document.write('</body></html>');
  popupWindow.document.close();
  this.location=loc;
 }
}
function logoutWarning(intTime){
 popupWindow=window.open('','popupWindow','width=200,height=140');
 if(popupWindow){
  popupWindow.focus();
  popupWindow.document.write('<html><head>');
  popupWindow.document.write('</head>');
  popupWindow.document.write('<body onblur="setTimeout(\'this.focus();\',60000);" onunload="close();" onload="setTimeout(\'this.close()\',(('+intTime+'-1)*1000));">');
  popupWindow.document.write('<table width="100%" height="100%"><tr><td><center><table><tr><td><center><font size="2" face="arial,verdana">WARNING: Your Session is going to Expire in about '+Math.round((intTime/60000))+' Minute(s)!</font><br /><br /><a href="javascript:opener.location.reload()" onclick="opener.location.reload(); setTimeout(\'this.close();\',500);">Continue Session</a><br /><br /><a href="#" onclick="this.close();">Close this Window</a></center></td></tr></table></center></td></tr></table>');
  popupWindow.document.write('</body></html>');
  popupWindow.document.close();
 }
}
function _runLogoutTimeout(intTime){
 if(intTime>1){
  if(intLogoutWarning>0 && intTime<=intLogoutWarning){
   logoutWarning(intLogoutWarning);
   intLogoutWarning=0;
  }
  if(intTime>60000){
   var intTimerIncrement=60000;
  }else{
   var intTimerIncrement=1000;
  }
  _setLogoutTimerDisplay(intTime);
  intTime-=intTimerIncrement;
  setTimeout('_runLogoutTimeout('+intTime+')',intTimerIncrement);
 }else{
  logoutDo(this.location.href=this.location.pathname+'?object=user&action=logout');
 }
}
function _timeoutLabel(intTime){
 var strText;
 var intDivisor=1000;
 var strLabel='Second(s)';
 if(intTime>60000){
  intDivisor=60000;
  strLabel='Minute(s)';
 }
 if(bitSPN){
  strText = 'Auto <a href="'+document.location.href+'?object=user&action=logout">Logout</a> in '+Math.round(intTime/intDivisor)+' '+strLabel;
 }else{
  strText = 'Auto Logout in '+Math.round(intTime/intDivisor)+' '+strLabel;
 }
 return strText;
}
function _setLogoutTimerDisplay(intTime){
 var strText=_timeoutLabel(intTime);
 if(bitSPN){
  document.getElementById('timer').innerHTML=strText;
 }else{
  document.getElementById('timer').value=strText;
 }
}
function setupLogoutTimeout(intTime,bitSPAN){
 bitSPN=bitSPAN;
 var strText=_timeoutLabel(intTime);
 if(bitSPAN){
  document.writeln('<span height="21" class="timer" name="timer" id="timer">'+strText+'</span>');
 }else{
  document.writeln('<input onfocus="this.blur();" class="timer" name="timer" id="timer" value="'+strText+'" />');
 }
 setTimeout('_runLogoutTimeout('+intTime+')',333);
}


function popWindow(l,x,y,b){
 win=window.open(l,'win','width='+x+',height='+y);
 if(b){
  win.blur();
 }else{
  win.focus();
 }
 return false;
}

