var apptodl;

function bgr_color(obj, color) {
    obj.style.backgroundColor=color;
}

function validate_emailform() {
	emailwin.hide();
	return false;
}

function validate_pbform() {
	pbwin.hide();
	return false;
}

function validate_pubform() {
	pubbwin.hide();
	return false;
}

function clearEmailFld(){
	var theemail=document.getElementById("emailfield");
	if(theemail.value=="Mobile Email Address")
		theemail.value = "";
}

function clearPubEmailFld(){
	var theemail=document.getElementById("pubbemailfield");
	if(theemail.value=="Mobile Email Address")
		theemail.value = "";
}

function clearPBEmailFld(){
	var theemail=document.getElementById("pbemailfield");
	if(theemail.value=="Mobile Email Address")
		theemail.value = "";
}

function showPvtBeta(appid){
	apptodl = appid;

	pbwin = dhtmlmodal.open('pvtbbox', 'div', 'pvtbetadiv', 'Notify when available', 'width=270px, height=100px, center=1, resize=0,scrolling=0');

	pbwin.onclose = function() {
		var theemail=document.getElementById("pbemailfield");

		if (theemail.value.indexOf("@")==-1){
			alert("Please enter a valid email address.");
			return false;
		} else{
			ajaxwin=dhtmlwindow.open('ajaxbox', 'ajax', 'd.php?email='+theemail.value+'&appid='+apptodl+'&n=1', 'Notify when available', 'width=300px, height=50px,center=1,resize=0,scrolling=0');
			return true;
		}
	}
}

function showPubBeta(appid){
	apptodl = appid;
	pubbwin = dhtmlmodal.open('pubbbox', 'div', 'pubbetadiv', 'Notify when available', 'width=270px, height=150px, center=1, resize=0,scrolling=0');

	pubbwin.onclose = function() {
		var theemail=document.getElementById("pubbemailfield");

		if (theemail.value.indexOf("@")==-1){
			alert("Please enter a valid email address.");
			return false;
		} else{
			ajaxwin=dhtmlwindow.open('ajaxbox', 'ajax', 'd.php?email='+theemail.value+'&appid='+apptodl, 'Notify when available', 'width=300px, height=50px,center=1,resize=0,scrolling=0');
			return true;
		}
	}
}


function showDlOptions(appid){
	apptodl = appid;

	divwin = dhtmlmodal.open('divbox', 'div', 'dldiv', 'Download file to', 'width=280px, height=160px, center=1, resize=0,scrolling=0');
}

function otaDownload(yesorno){
	if (yesorno=="no") {
		divwin.hide();
		window.location.href = "d.php?appid=" + apptodl;
	}
	else {
		divwin.hide();

		emailwin = dhtmlmodal.open('emailbox', 'div', 'emaildiv', 'Your Mobile Email', 'width=270px, height=100px, center=1, resize=0,scrolling=0');

		emailwin.onclose = function() {
			var theemail=document.getElementById("emailfield");

			if (theemail.value.indexOf("@")==-1){
				alert("Please enter a valid email address");
				return false;
			} else{
				ajaxwin=dhtmlwindow.open('ajaxbox', 'ajax', 'd.php?email='+theemail.value+'&appid='+apptodl, 'Sending file..', 'width=300px, height=50px,center=1,resize=0,scrolling=0');
				return true;
			}
		}
	}
}
