function addToFavorites(id, thisPathEncoded) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('GET', "addToFavorites.aspx?id=" + id, true);
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
			switch(self.xmlHttpReq.responseText)
			{
				case "error":
					alert("There was an error while trying to add this project to your favorites.");
					break;
				case "success":
					window.location.reload();
					break;
				case "timeout":
					window.location = "/qk2/loginCustomer.aspx?redirect=" + thisPathEncoded;
					break;
			}
        }
    }
    self.xmlHttpReq.send(null);
}

function goToPage(pageStr) {
	var pageNo = parseInt(pageStr, 10);
	if (pageNo) {
		var startId = (pageNo - 1) * ideasPerPage;
		var str = "ideas.aspx?start=" + startId;
		str += qs;
		window.location = str;
	}
}

function loadGalleryIdeas() {
	var str = "ideas.aspx?q=" + encodeURIComponent(document.getElementById('ideaQuery').value);
	for (i=1; i<=numProjTypes; i++) {
		if (document.getElementById('t'+i+'Filter') && document.getElementById('t'+i+'Filter').checked)
			str += "&t"+i+"=t";
	}
	window.location = str;
}
function catchEnter(evt) {
	if (evt.keyCode == 13 || evt.which == 13) {
		loadGalleryIdeas();
		return false;
	}
	return true;
}
