
function optin_stats(ad_id) {


var http_request = false;

	// If *POST* occurs in Netscape (disables script in MSIE if not run inside an IF statement!)
	if (http_request.overrideMimeType)
	{ http_request.overrideMimeType('text/xml');
	}

// Create a xmlhttp request...

	// Mozilla, Safari, etc
	if (window.XMLHttpRequest)
	{ http_request = new XMLHttpRequest();
	}
	// MSIE
	else if (window.ActiveXObject)
	{ http_request = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{ alert('Your browser settings don\'t seem to support AJAX,\n or you need to upgrade your browser :(');
	return false;
	}

// Javascript function to call as the xmlhttp request is processed and sent back
http_request.onreadystatechange = function() { alertContents(http_request, ad_id); };

// Were're ready to make the xmlhttp request now...

// SEND GET DATA
http_request.open('GET', script_path + 'link.php?id=' + ad_id, true);
http_request.send(null);

}

//////////////////////////////////////////////////////////////////////////////////////

function alertContents(http_request, ad_id) {

/* 
Display "Loading...", and see if the request has been responded to, and that it wasn't a 404/500 etc...
*/
	if (http_request.readyState == 4 && http_request.status == 200) {
	// MSIE needs the "value" attribute used instead of "inerHTML" for data that includes HTML tags, or it throws an error
	//document.getElementById("ad_headline").value = http_request.responseText;
	//document.getElementById("ad_headline").innerHTML = http_request.responseText;
	}
	else if (http_request.readyState == 4 && http_request.status != 200) {
	//document.getElementById("ad_headline").innerHTML = "There was a problem with the request. \n Please Try Again.";
	}
	else {
	//document.getElementById("ad_headline").innerHTML = "Loading, Please Wait...";
	}

}


///////////////////////////////////////////////////////////////////////////////////////


function validate_catchall(ad_id) {

	var loop = 0;
	while ( loop < document.forms.length ) {
	
		var loop2 = 0;
		while ( loop2 < document.forms[loop].elements.length ) {
	
		
			if ( document.forms[loop].elements[loop2].type
			&& document.forms[loop].elements[loop2].type != 'hidden'
			&& !document.forms[loop].elements[loop2].value ) {
			alert('Sorry, please fill in all fields...thank you.');
			return;
			}
			
			if ( (document.forms[loop].elements[loop2].value.indexOf(".") > 0)
			&& (document.forms[loop].elements[loop2].value.indexOf("@") > 0) ) {
			var ok = 1;
			}
		
		
		var loop2 = loop2 + 1;
		}
	
	var loop = loop + 1;
	}

	if ( ok ) {
	optin_stats(ad_id);
	return ok;
	}
	else {
	alert(' Sorry, no email address was detected. \n Please verify all fields were completed correctly...thank you. ');
	return;
	}
	
}

