
var http = null;
var httpRating = null;

/******* HTTP Object *******/
function getHTTPObject() {
	var xmlhttp;
 	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    	try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp = false; }
	}
	else {
		try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");}
		catch (e) { 
			try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }	catch (E) { xmlhttp = false; } 
		} 
 	}
	return xmlhttp;
}

/******* SAVE PROPERTY *******/
function SaveProperty(mlnum, mlsid, targetDiv){
	var r = parseInt(Math.random() * 99999999);
	var targeturl = '../mynothnagle/saveproperty.asp?action=save&rand=' + r + '&MLNUM=' + mlnum + '&MLSID=' + mlsid + '&targetDiv=' + targetDiv;
	http = getHTTPObject();
	http.open('GET', targeturl, true);
	http.onreadystatechange = function() {
		if (http.readyState == 4) { 
			if(http.responseText != '') {
				var resp = http.responseText;
				arrResponse = resp.split("|");
				document.getElementById(arrResponse[0]).innerHTML = arrResponse[1]; 
			}
		}
	}
	http.send(null);
}
function CheckProperty(mlnum, mlsid, targetDiv) {
	var r = parseInt(Math.random() * 99999999);
	var targeturl = '../mynothnagle/saveproperty.asp?rand=' + r + '&MLNUM=' + mlnum + '&MLSID=' + mlsid + '&targetDiv=' + targetDiv;
	http = getHTTPObject();
	http.open('GET', targeturl, true);
	http.onreadystatechange = function() {
		if (http.readyState == 4) { 
			if(http.responseText != '') {				
				var resp = http.responseText;
				arrResponse = resp.split("|");
				document.getElementById(arrResponse[0]).innerHTML = arrResponse[1]; 
			}
		}
	}
	http.send(null);
}
 
/******* RATE PROPERTY *******/
var currenthover = 0;
function rate(mlnum, mlsid, rating) {
	var myRandom=parseInt(Math.random()*99999999);//cache buster
	var myTarget = '/mynothnagle/propertyratings.asp?rate=true&rand='+myRandom+'&MLNUM='+mlnum+'&mlsid='+mlsid+'&rating='+rating;
	httpRating = getHTTPObject();
	httpRating.open("GET", myTarget, true);
	httpRating.onreadystatechange = function() {
		if (httpRating.readyState == 4) { document.getElementById("divRating").innerHTML = httpRating.responseText; }
	}
	httpRating.send(null);
}
function getRating(mlnum, mlsid) {
	var myRandom=parseInt(Math.random()*99999999);//cache buster
	var myTarget = '/mynothnagle/propertyratings.asp?rand='+myRandom+'&MLNUM='+mlnum+'&MLSID='+mlsid;
	httpRating = getHTTPObject();
	httpRating.open("GET", myTarget, true);
	httpRating.onreadystatechange = function() {
		if (httpRating.readyState == 4) { document.getElementById("divRating").innerHTML = httpRating.responseText; }
	}
	httpRating.send(null);
}
function ratehover(rating) {
	currenthover = 0;
	for(var i = 1; i < 6; i++)
		document.getElementById(i + 'star').src = (i <= rating) ? '/images/graphics/star_filled.gif' : '/images/graphics/star_empty.gif';
}
function revert(hover, rating) {
	currenthover = hover;
	setTimeout('raterevert(' + hover + ',' + rating + ')',1000)
}
function raterevert(hover, rating) {
	if(currenthover == hover) {
		for(var i = 1; i < 6; i++) {
			if (i > rating && i < rating + 1)
				document.getElementById(i + 'star').src = '/images/graphics/star_half.gif';	 
			else if(i <= rating)
				document.getElementById(i + 'star').src = '/images/graphics/star_filled.gif';
			else
				document.getElementById(i + 'star').src = '/images/graphics/star_empty.gif';	
		}
	}
}
function NotLoggedIn() {
	document.getElementById("divMN").innerHTML = 'This feature requires a MyNothnagle account.<br /><a href="/mynothnagle/">Log in here</a>&nbsp;&nbsp;&nbsp;OR&nbsp;&nbsp;&nbsp;<a href="/mynothnagle/createaccount.asp">Register for Free</a>';
}