function setCookie(cookieId, value, expireminutes) 
{

  var ExpireDate = new Date ();
  ExpireDate.setTime(ExpireDate.getTime() + (expireminutes  * 60 * 1000));
  document.cookie = cookieId + "=" + escape(value) + 
  ((expireminutes == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function getCookie(cookieId)
{
    if (document.cookie.length > 0) 
{ 
    begin = document.cookie.indexOf(cookieId+"="); 
    if (begin != -1)  
   { 
    begin += cookieId.length+1; 
      end = document.cookie.indexOf(";", begin);
      if (end == -1) end = document.cookie.length;
      return unescape(document.cookie.substring(begin, end));       } 
  }
return null;  
}

function delCookie (cookieId) 
{
  if (getCookie(cookieId)) {
  document.cookie = cookieId + "=" +
   "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}


//*********************************************//

//function to detect browser

function Attachment()
{// to get attachemnts
  var sIndex,statename,ctl,win
  ctl = document.thisForm;
  win = window.open("attachments.asp" ,"newwin","toolbar=no,location=no,directories=no,status=yes,menubar=no,top=15,left=25,width=500, scrollbars=yes,resizable=no")

}


// Validate Email
//str is the email to be validated
//ident is the identification name of the control in question 

function validateEmail(str,ident)
{
  var i,errormsg;
        errormsg = "" ;
         if( str == "")
         errormsg = "Please Enter " + ident
         else
         {
			if(str.indexOf("/") != -1)
			errormsg = " / not allowed -Invalid  " + ident
			if(str.indexOf("@") == -1)
			errormsg = " @ not Present -Invalid  " + ident
			if(str.indexOf(".") == -1)
			errormsg = " Dot Not Present - Invalid  " + ident
			if(str.indexOf(" ") != -1)
			errormsg = " Spaces not Allowed - Invalid  " + ident
			if(str.indexOf('@')!=-1 && str.indexOf('.',str.indexOf('@'))!=-1)
			{	//
			}
			else
			{

				errormsg = "Invalid " + ident
			}

        //if(str.indexOf(".") != str.length-4)
        //errormsg = " Invalid " + ident

         atcount = 0;
         for (i = 0;i < str.length ; i++)
         {
			ch = str.charAt(i);
			if (ch == "@" )
			atcount ++
         }
         if (atcount > 1)
			errormsg = " Invalid " + ident

	 }
	  return errormsg ;

}



function LTrimStr(Str)
{
  mval = ""
  val = Str
  stat = true
  for (i=0;i < val.length ;i++)
  {
    ch = val.charAt(i)
    if (stat )
      {
       if (ch == " ")
        {
         mval = mval
        }
       else
        {
         mval = mval + ch
         stat = false
        }
      }
   else
     {
     mval = mval + ch
     }
   }
   return mval
}
function RTrimStr(Str)
{
  sval = ""
  stat = true
  ipos = Str.length - 1
  for (i=ipos ;i > -1 ;--i)
  {
    ch = Str.charAt(i)
    if (stat)
      {
        if (ch == " ")
        {
         sval = sval
        }
        else
        {
        sval = ch + sval
        stat = false
        }
      }
     else
     {
     sval = ch + sval
     }
   }
return sval
}

function TrimStr(Str)
{
  Lstr = LTrimStr(Str)
  BStr = RTrimStr(Lstr)
  return BStr
}
