// JavaScript Document

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}

function setCookie(c_name,value,expire)
//$mosConfig_lifetime
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expire);
document.cookie=c_name+ "=" +escape(value)+
((expire==null) ? "" : ";expires="+exdate.toGMTString());
}

function checkCookie()
{

username=getCookie('username');
if (username!=null && username!="")
  {
//  alert('Welcome again '+username+'!');
  } 
  else 
  { 
//  username=prompt('Please enter your name:',"");
// session_id=prompt('Please enter sessionid value:',"");
//alert (document.getElementById('user_applet').value);
//alert (document.getElementById('session_applet').value);
 username= document.getElementById('user_applet').value;
 session_id= document.getElementById('session_applet').value;

if (username!=null && username!="")
    {
 //  alert ('cucu');
   setCookie('sesion_id',session_id,'1');
   setCookie('username',username,'1');
 	
    }
  }
}

