var xmlhttp
var progress_bar = new Image();
	progress_bar.src = 'http://www.avidrc.com/images/load.gif';

function notifyBegin(form) {
	if (document.getElementById("product[id]").value != '') {
		document.getElementById("beginNotify").innerHTML = '<div class="notifyBlock"><input type="hidden" name="productid2" id="productid2" value="'+document.getElementById("product[id]").value+'" /><h2>Email notification</h2>By adding your email address below, we will send a friendly email update only once when the stock levels of this product change.<div class="product_row"><input type="input" name="email2" id="email2" class="input_notify" value="'+document.getElementById("email").value+'" /><input name="notifySubmit" type="button" onclick="notifyAdd(document.notify);" value="Notify Me"/></div></div>';
	}
}




function notifyAdd(form) {
	var selectResults = '';

	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var address = document.getElementById("email2").value;
	if(reg.test(address) == false) {
		document.getElementById("beginNotify").innerHTML = '<div class="notifyBlock"><input type="hidden" name="productid2" id="productid2" value="'+document.getElementById("productid2").value+'" /><h2>Email notification error</h2><font color="#FF0000">Please enter a valid email address.</font><div class="product_row"><input type="input" name="email2" id="email2" class="input_notify" value="'+document.getElementById("email2").value+'" /><input name="notifySubmit" type="button" onclick="notifyAdd(document.notify);" value="Notify Me"/></div></div>';
	} else {
		selectResults = document.getElementById("productid2").value+'|'+document.getElementById("email2").value;
		//alert ( document.getElementById("productid2").value );
		prodNotify(selectResults);
	}
}


function prodNotify(str)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }

var url="/ajax/notify/notify.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChangedNotified;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}




function stateChangedNotified()
{
	if(xmlhttp.readyState == 4){
	  document.getElementById("txtNotify").innerHTML = '<div class="notifyBlock"><h2>You are all set!</h2>'+xmlhttp.responseText;
	} else {
	  document.getElementById("txtNotify").innerHTML= '<img style="margin-left:5px" src="http://www.avidrc.com/images/load.gif">';
	}
}



function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}