// JavaScript Document

function setup() {
	var mStr, strID, watched, excluded
	
	watched = false;
	excluded = false;
	
	strID = "," + id + ","
	mStr = "";
	mStr = GetCookie("WatchList");

	if (mStr.length > 0) {
		if (mStr.indexOf(strID) >= 0) { // found the ID
			document.trckFm.track.value = 1; // set to watch
			document.images['track_img'].src = host+"images/box_watch.gif";
			document.images['track_img'].alt = "Click here to add this property to your exclude list. Click twice to remove from both lists.";
			watched = true;
		}
	}
	
	mStr = "";
	mStr = GetCookie("ExcludeList");

	if (mStr.length > 0) {
		if (mStr.indexOf(strID) >= 0) { // found the ID
			document.trckFm.track.value = -1;
			document.images['track_img'].alt = "Click here to remove this property from your exclude list.";
			document.images['track_img'].src = host+"images/box_exclude.gif";
			excluded = true;
		}
	}

	if (! watched && ! excluded) {
		document.trckFm.track.value = 0;
		document.images['track_img'].alt = "Click here to add this property from your watch list.";
		document.images['track_img'].src = host+"images/box_empty.gif";
	}
}

function toggle_track() {
	if (document.trckFm.track.value < 0) {
		document.trckFm.track.value = 0;
		document.images['track_img'].src = host+"images/box_empty.gif";
		document.images['track_img'].alt = "Click here to add this property from your watch list.";
		remove_from_cookie(id, 'ExcludeList');
	} else if (document.trckFm.track.value > 0) {
		document.trckFm.track.value = -1;
		document.images['track_img'].src = host+"images/box_exclude.gif";
		document.images['track_img'].alt = "Click here to remove this property from your exclude list.";
		remove_from_cookie(id, 'WatchList');
		add_to_cookie(id, 'ExcludeList');
	} else {
		document.trckFm.track.value = 1;
		document.images['track_img'].src = host+"images/box_watch.gif";
		document.images['track_img'].alt = "Click here to remove this property from your watch list.";
		add_to_cookie(id, 'WatchList');
	}
}

	function tracking_cookie(val){
		var exp = new Date();
		var oneYearFromNow = exp.getTime() + (365 * 24 * 60 * 60 * 1000);
		exp.setTime(oneYearFromNow);
		SetCookie("tracking",val,exp);
	}

	function turn_tracking_on(){
		tracking_cookie(2);
		document.location.href = loc;
	}
	
	function turn_tracking_off(){
		tracking_cookie(0);
		document.location.href = loc;
	}
	
