/* Do nothing at this stage in an empty basket */
function getHTTPObject() {
    if (typeof XMLHttpRequest != 'undefined') {
        return new XMLHttpRequest();
    }
    try {
        return new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        try {
            return new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {}
    }
    return false;
}


function sendEmail() {

    var contactEmail    = document.getElementById('contactEmail').value;
    var position        = document.getElementById('position').value;

    window.location.href = "mailto:" + contactEmail + "?subject=" + position + " Position"; 
    
}

function loadBasket() {

http2 = getHTTPObject()

var url2 = "basket.asp";
var params2 = "action=view";
http2.open("GET", url2+"?"+params2, true);
http2.onreadystatechange = function() {//Call a function when the state changes.
	if(http2.readyState == 4 && http2.status == 200) {
		document.getElementById('basket').innerHTML = http2.responseText;
	}
}

http2.send(null);
}


function addItem(idProduct,method) {

http = getHTTPObject()

var url = "basket.asp";
var params = "action=add&idProduct=" + idProduct + "&method=" + method;
http.open("GET", url+"?"+params, true);
http.onreadystatechange = function() {//Call a function when the state changes.
	if(http.readyState == 4 && http.status == 200) {
		loadBasket();
	}
}
http.send(null);
}


function remove(idRow) {

http = getHTTPObject()

var url = "basket.asp";
var params = "action=remove&idRow=" + idRow;
http.open("GET", url+"?"+params, true);
http.onreadystatechange = function() {//Call a function when the state changes.
	if(http.readyState == 4 && http.status == 200) {
		loadBasket();
	}
}
http.send(null);
}
