

function openalerts(base){
	var theurl = base + '/cgi-bin/kindle-q.pl?type=list'
	emailwindow=dhtmlmodal.open('EmailBox', 'iframe', theurl, 'Mysteria watch list', 'width=400,height=600px,center=1,resize=0,scrolling=1')

emailwindow.onclose=function(){ //Define custom code to run when window is closed
	var theform=this.contentDoc.forms[0] //Access first form inside iframe just for your reference
	var theemail=this.contentDoc.getElementById("emailfield") //Access form field with id="emailfield" inside iframe
	if (theemail.value.indexOf("@")==-1){ //crude check for invalid email
		alert("Please enter a valid email address")
		return false //cancel closing of modal window
	}
	else{ //else if this is a valid email
		document.getElementById("youremail").innerHTML=theemail.value //Assign the email to a span on the page
		return true //allow closing of window
	}
}
} //End "openalerts" function

function getemail(base, user, mybook, mytype){
	var theurl = base + "/cgi-bin/kindle-q.pl?type=signup&user=" + user + "&book=" + mybook + "&itemtype=" + mytype
	getemail=dhtmlmodal.open('EmailBox1', 'iframe', theurl, 'Simple Signup', 'width=350px,height=400px,center=1,resize=0,scrolling=1')

getemail.onclose=function(){ //Define custom code to run when window is closed
	parent.history.go(0)
	return true
}
} //End "getemail" function

function loadbook(mybook, image, mytype, base){
	var theurl = base + "/cgi-bin/kindle-q.pl?type=load&book=" + mybook + "&image=" + image + "&itemtype=" + mytype
	emailwindow=dhtmlmodal.open('EmailBox1', 'iframe', theurl, 'Get Mysteria looking!', 'width=400px,height=300px,center=1,resize=0,scrolling=1')

emailwindow.onclose=function(){ //Define custom code to run when window is closed
	return true
	// Idally we would reload mysteria
}
} //End "loadbook" function

function deregister(base, user){
	var theurl = base + "/cgi-bin/kindle-q.pl?type=deregister&user=" + user
	dereg=dhtmlmodal.open('EmailBox1', 'iframe', theurl, 'Deregistration', 'width=400px,height=300px,center=1,resize=0,scrolling=1')

dereg.onclose=function(){ //Define custom code to run when window is closed
	parent.history.go(0)
	return true
}
} //End "deregister" function


function aboutus(base){
	var theurl = base + "/docs/About.html"
	window.location.href = theurl
	//emailwindow=dhtmlmodal.open('EmailBox1', 'iframe', theurl, 'About Us', 'width=400px,height=300px,center=1,resize=0,scrolling=1')

} //End "aboutus" function

function howitworks(base){
	var theurl = base + "/docs/Mysteria.html"
	window.location.href = theurl
	//emailwindow=dhtmlmodal.open('EmailBox1', 'iframe', theurl, 'How It Works', 'width=400px,height=300px,center=1,resize=0,scrolling=1')
} //End "howitworks" function

function clearForm() {
	document.SearchForm.keys.value = "";
}

function validate_form( )
{
    valid = true;
    if ( document.SearchForm.keys.value == "" )
    {
        valid = false;
	document.SearchForm.keys.focus();
    }
    return valid;
}
