function learnmore()
{                                            
var win;
var features = "menubar=no,location=no,resizable=no,scrollbars=no,status=no,width=450,height=450";
    
    if (window.showModalDialog) {
        /* Gray out the whole browser page */
        grayOut(true, {'opacity':'50'});
        /* now pop the Contact form on */
        window.showModalDialog('prebuy.php',"","dialogHeight:450px; dialogWidth:450px;status: no;unadorned: yes;scroll: no;help: no;resizable: no");
        
        /* restore the whole browser page whe form is done */
        grayOut(false, {'opacity':'50'});
        
    }
    else {
        // FF
        win = window.open("prebuy.php", "CNN_WindowName", features);
    }    
}
var activeDialog=0;
  
//OpenDialog: opens given URL as dialog window - focus can't be set on parent until child is closed.
function OpenDialog(strURL, properties)
{
    //maybe we have IE?
    if (typeof window.showModalDialog != "undefined") {
        window.showModalDialog(strURL);
        return true;
    }
     
    //non IE browser
    window.onfocus = WindowFocus;
    activeDialog = window.open(strURL, "dialog", properties);
    return true;
}
  
function WindowFocus(event)
{
    if (activeDialog) {
        try {
            activeDialog.focus();
        }
        catch (e) {
            activeDialog = 0;
        }
    }
}



function Lost() 
{
    
    lostwin=dhtmlwindow.open("lostbox", "ajax", "resend.php", "Timms Petroleum","width=400px,height=200px,left=300px,top=130px,resize=0,scrolling=0")
      
} 
function ProcResend() 
{
    
    var thedata = new Array();
    
    thedata[0] = document.getElementById("firstname").value; 
    thedata[1] = document.getElementById("lastname").value;
    thedata[2] = document.getElementById("mailbox").value;   
     
    if (window.XMLHttpRequest) {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    }
    else {
        // code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4 && xmlhttp.status==200) {
            var resp = xmlhttp.responseText;  
            if(resp == 'OK') {
                lostwin.close();  
                alert('Your account information will be sent to '+thedata[2]); 
                //location.replace('index.php')   
            }
            else {
                alert(resp);
                lostwin.close();   
            }    
        }
    }
    xmlhttp.open("GET","processresend.php?userdata="+thedata);
    xmlhttp.send(); 
    
}   




function openmypage(ordertype)
{ //Define arbitrary function to run desired DHTML Window widget codes
    
    ajaxwin=dhtmlwindow.open("ajaxbox", "ajax", "getemail.php?order="+ordertype, "Timms Petroleum","width=460px,height=140px,left=300px,top=130px,resize=0,scrolling=0")
    //ajaxwin=dhtmlwindow.open("ajaxbox", "ajax", "external.php?replyto="+from, "Reply To:", "width=500px,height=200px,left=300px,top=130px,resize=0,scrolling=0")
}



function show_boxZone(zone) {
    
    switch(zone) {
        case 2:
            document.getElementById('popupBoxZ2').style.visibility = "visible";
            break;
        case 3:
            document.getElementById('popupBoxZ3').style.visibility = "visible";
            break;
        case 4:
            document.getElementById('popupBoxZ4').style.visibility = "visible";
            break;
        case 5:
            document.getElementById('popupBoxZ5').style.visibility = "visible";
            break;
        case 6:
            document.getElementById('popupBoxZ6').style.visibility = "visible";
            break;
            
    }        
}

function hide_boxZone(zone) {
    
    switch(zone) {
        case 2:
            document.getElementById('popupBoxZ2').style.visibility = "hidden";
            break;
        case 3:
            document.getElementById('popupBoxZ3').style.visibility = "hidden";
            break;
        case 4:
            document.getElementById('popupBoxZ4').style.visibility = "hidden";
            break;
        case 5:
            document.getElementById('popupBoxZ5').style.visibility = "hidden";
            break;
        case 6:
            document.getElementById('popupBoxZ6').style.visibility = "hidden";
            break;
            
    }        
}



function ValidateMail()
{
    //alert('here');
    
    var email = document.getElementById('mailbox').value;
    var town = document.getElementById('mytown').value;
    
    if (window.XMLHttpRequest) {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    }
    else {
        // code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4) {
            var resp = xmlhttp.responseText;
            if(resp.substr(0,2) == "OK") {     
                //location.replace('https://timms.accountsupport.com/signup.php?town='+town+'&email='+email);
                location.replace('https://timmspetroleum.com/signup.php?town='+town+'&email='+email);     
            }
            else {
                alert(resp);
            }        
        }
    }    
    xmlhttp.open("GET","recordmail.php?email="+email+"&town="+town);
    xmlhttp.send(); 
    
     
}  

