function closeNewsletterAsk(){
    document.getElementById('nl_popup_outer').style.display = 'none';
}

function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}

function doSubscribeTwo(){
    var forename = document.getElementById('nlpop_forename').value;
    var emailaddress = document.getElementById('nlpop_email').value;
    var randone = Math.floor(Math.random()*1000000);
    
    if(forename == ""){
        alert("You must enter your first name!");
    }
    else if(emailaddress == ""){
        alert("You must enter your email address!");
    }
    else{
        xmlhttp.open("GET", "/signup_newsletter.php?r="+randone+"&a=subscribe&forename="+forename+"&email="+emailaddress, true);
        //xmlhttp.open("GET", "testpage.php?r="+randone, true);
        
        xmlhttp.onreadystatechange=function(){
            if(xmlhttp.readyState==4){
                if(xmlhttp.responseText == "OK"){
                    document.getElementById('nlpop_details').style.display = 'none';
                    document.getElementById('nlpop_thanks').style.display = 'inline-block';
                    
                }
                else{
                    alert(xmlhttp.responseText);
                }
            }
        }        
        xmlhttp.send(null);
    }
    
    return false;
}

function doSubscribe(){
    var forename = document.getElementById('forename').value;
    var emailaddress = document.getElementById('email').value;
    var randone = Math.floor(Math.random()*1000000);
    
    if(forename == ""){
        alert("You must enter your first name!");
    }
    else if(emailaddress == ""){
        alert("You must enter your email address!");
    }
    else{
        xmlhttp.open("GET", "/signup_newsletter.php?r="+randone+"&a=subscribe&forename="+forename+"&email="+emailaddress, true);
        //xmlhttp.open("GET", "testpage.php?r="+randone, true);
        
        xmlhttp.onreadystatechange=function(){
            if(xmlhttp.readyState==4){
                if(xmlhttp.responseText == "OK"){
                    document.getElementById('btnSubmit').disabled = true;
                    document.getElementById('msgThanks').style.display = 'block';
                }
                else{
                    alert(xmlhttp.responseText);
                }
            }
        }        
        xmlhttp.send(null);
    }
    
    return false;
}


function sendForm(){
    
    // Send AJAX
    var randnum1 = Math.floor(Math.random()*1000000);
    
    var first_name = document.getElementById('first_name').value;
    var email_address = document.getElementById('email_address').value;

    xmlhttp.open("GET", "/ajax_splashsubscribe.php?r="+randnum1+"&first_name="+first_name+"&email_address="+email_address,true);
    xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState==4) {
      if(xmlhttp.responseText == "OK"){
        alert("Thank you. Please check your email!");
        document.getElementById('btnSignup').disabled = true;
      }
      else{
        alert(xmlhttp.responseText);
      }
    }
    }
    xmlhttp.send(null);
    
    return false;
    
}

// AJAX Functions
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}