//begin Ajax Functions
function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

function saveListing(value){
	var ajx1 = createRequestObject();
	ajx1.open('get', 'includes/siteFunctions.php?id=' + value + '&act=saveListing');
    ajx1.onreadystatechange = function() {
		if(ajx1.readyState == 4){
			var response = ajx1.responseText;
			var update = new Array();
			alert(ajx1.responseText);
			window.location=("sitePage.php?con=coupon&id=" + value);
		}
	}
    ajx1.send(null);
}

function gotoListing(id) {
	window.location	= "sitePage.php?con=coupon&id=" + id;
}

function savedOver(id) {
	document.getElementById("savedRemove" + id).style.backgroundColor = '#F3F3F3';	
	document.getElementById("featListing" + id).style.backgroundColor = '#F3F3F3';
}
function savedOut(id) {
	document.getElementById("savedRemove" + id).style.backgroundColor = '#FFFFFF';
	document.getElementById("featListing" + id).style.backgroundColor = '#FFFFFF';
}
function removeListing(id) {
	if(confirm("Are you sure you wish to remove this coupon?")) {
		document.getElementById("featListing" + id).innerHTML = "<img src='images/indicator.gif'>";
		var ajx = createRequestObject();
		ajx.open('get', 'includes/siteFunctions.php?act=removeListing&id=' + id);
		ajx.onreadystatechange = function() {
			if(ajx.readyState == 4) {
				document.getElementById("savedRemove" + id).style.display = "none";
				document.getElementById("featListing" + id).innerHTML = "<span style='color:#990000;'>This coupon has been removed.</span>"
			}
		}
		ajx.send(null);
	}
}
function animateButton(element, act){
	if(act == 1){
		document.getElementById(element).style.backgroundPosition = "top";
	} else {
		document.getElementById(element).style.backgroundPosition = "bottom";	
	}
}
