var today = new Date( )
var twodays = new Date( )
twodays.setTime(today.getTime( ) + 1000*60*60*48)

function getCookie(cookLbl)
{  var search=cookLbl + "="
   if (document.cookie.length>0)
   {  offset=document.cookie.indexOf(search)
      if (offset!=-1)
      {  offset +=search.length
         end=document.cookie.indexOf(";",offset)
         if (end==-1)
            end=document.cookie.length
            return unescape(document.cookie.substring(offset, end))
       }
   }
}

function validate() 
{ var testu=document.makeform1.myuser.value
  if (!ckemail(testu))
  {  alert ('Please enter a valid email address')
     document.makeform1.myuser.focus()
     return false
  }
  var testm=document.makeform1.emessage.value
  if (testm.length<10)
  {  alert ('Please enter a message of at least 10 characters.')
     document.makeform1.emessage.focus()
     return false
  }
  if (testm.length>500)
  {  alert ('500 characters max.')
     document.makeform1.emessage.focus()
     return false
  }

  var tests=document.makeform1.esubject.value
  tests=testu+" asks craig "+tests
  document.form1.esubject.value=tests+" other questions"

  document.form1.emessage.value=testm
  comeback()
  document.form1.submit()
  return true
}

function ckemail(inEm)
{ var testEm = inEm
  var AtSym    = testEm.indexOf('@')
  var Period   = testEm.lastIndexOf('.')
  var Space    = testEm.indexOf(' ')
  var Length   = testEm.length - 1   // Array is from 0 to length-1
  
  if  ((AtSym < 1) ||                     // '@' cannot be in first position
      (Period <= AtSym+1) ||             // Must be atleast one valid char btwn '@' and '.'
      (Period == Length ) ||             // Must be atleast one valid char after '.'
      (Space  != -1))                     // No empty spaces permitted
  { return 0
  }
  return 1
}

function setCookie(cookLbl, value, expire)
{  document.cookie=cookLbl + "=" + escape(value)
   + ((expire==null) ? "" : ("; expires=" + expire.toGMTString( )))
}

function popcw()
{ window.open("http://eduhosting.org")
  window.open("http://craigsworld.org")
}

function comeback()
{ setTimeout("location.replace('http://craigsworld.org/popworld.html?thankyou')",8000)
}

function ckpop()
{ var test=getCookie("popworld")
  if ((!test) || (test!="done"))
  {  setCookie("popworld","done",twodays)
     var test=getCookie("popworld")
     if (test)
     { document.form1.eto.value="kckclass@yahoo.com"
       document.form1.esubject.value="windgenzen pop by a visitor"
       document.form1.emessage.value="Visitor stopped by windgenzen"
       comeback()
       document.form1.submit()
     }
  }
}