pic1= new Image(16,16); 
pic1.src="/util/email/loading.gif"; 
pic2= new Image(16,16); 
pic2.src="/util/email/x.png"; 
pic3= new Image(16,16); 
pic3.src="/util/email/valid.png"; 

function writecookie(content){
var expiredate = new Date
expiredate.setMonth(expiredate.getFullYear()+9)
document.cookie = "email="+ content+";expires="+expiredate.toGMTString()
}

function checkemail(){
  var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
  var returnval=emailfilter.test(document.getElementById('email').value)
  if (returnval==false){
    document.getElementById('valid').src = '/util/email/x.png'
    document.getElementById('sending').innerHTML = ''
  }
  else {
    document.getElementById('valid').src = '/util/email/valid.png'
    document.getElementById('sending').innerHTML = '<input type="submit"  value="Sign Up Now!" name="send_button" class="button" style="display:inline;margin:2px 2px 1px -12px; padding:2px;width:90px;height:15pt;text-align:left;font-size:8pt;">'
  }
}

function checkemailv1b(){
  var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
  var returnval=emailfilter.test(document.getElementById('email').value)
  if (returnval==false){
    document.getElementById('valid').src = '/util/email/x.png'
    document.getElementById('sending').innerHTML = ''
  }
  else {
    document.getElementById('valid').src = '/util/email/valid.png'
    document.getElementById('sending').innerHTML = '<input type="submit"  value="Sign Up" name="send_button" class="button" style="display:inline;float:right;padding:2px;width:70px;height:15pt;text-align:left;font-size:8pt;background-color: #9AB6C2;color:#ffffff;">'
  }
}

function checkemailv2(){
  var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
  var returnval=emailfilter.test(document.getElementById('email').value)
  if (returnval==false){
    document.getElementById('valid').src = '/util/email/x.png'
    document.getElementById('sending').innerHTML = ''
  }
  else {
    document.getElementById('valid').src = '/util/email/valid.png'
  }
}


function checkQuestion(){
  var botcheck = ""
  var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
  var returnval=emailfilter.test(document.getElementById('email').value)
  if (returnval==false){
    document.getElementById('valid').src = '/util/email/x.png'
    document.getElementById('sending').innerHTML = ''
  }
  else {
    document.getElementById('valid').src = '/util/email/valid.png'
    botcheck = document.getElementById('botcheck').value 
//alert("botcheck=*"+botcheck+"*");
    // don't submit this if it is spam 
    if (botcheck == "")
    {		
      document.getElementById('sending').innerHTML = '<input type="submit"  value="Submit Now!" name="send_button" class="button" style="display:inline;margin:2px 2px 1px -12px; padding:2px;width:90px;height:15pt;text-align:left;font-size:8pt;">'
    }
    else
    {
      document.getElementById('sending').innerHTML = ''
    }  
  }
}

function submitemail(){
document.getElementById('sending').innerHTML = '<img src="email/loading.gif">';
var postStr = "email=" + encodeURI(document.getElementById('email').value) + 
	"&type=" + encodeURI(document.getElementById('type').value) +
	"&other=" + encodeURI(document.getElementById('other').value);
saveEmail(postStr)

}

//// Place failure message here
function Failed()
{
document.getElementById('results').innerHTML = 'Sorry, operation failed. Refresh browser and try again!'
}

//// Place confirm message here
function Rcvd()
{
//writecookie(document.getElementById('email').value)
document.getElementById('results').innerHTML = 'Your e-mail address has been succesfully submitted!'
}

//// Don't edit this.
function getcookie(c_name) {
    if(document.cookie.length > 0) {
        var c_start = document.cookie.indexOf(c_name + "=");
        if(c_start != -1) {
            c_start = c_start + c_name.length + 1;
            var 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));
        }
    }
}

function saveEmail(postStr)
{ 
var url="writeEmail.asp?" + postStr;
new Ajax.Request( '/util/email/writeEmail.asp?'+postStr, {method:'post', onSuccess:Rcvd, onFailure:Failed});
}



