function addSubscription( id ) {
	sendPost( '/api.php', 'addSubscription=1&id=' + id );
	alert( 'Sie erhalten nun Updates fuer diesen Shop per E-Mail' );
	document.getElementById('addAbo').style.display = 'inline';
	document.getElementById('delAbo').style.display = 'none';
	return false;
}

function removeSubscription( id ) {
	sendPost( '/api.php', 'delSubscription=1&id=' + id );
	alert( 'Ihr E-Mail Abo fuer diesen Shop wurde gekuendigt' );
	document.getElementById('addAbo').style.display = 'none';
	document.getElementById('delAbo').style.display = 'inline';
	return false;
}

function removeSubscriptionSilent( id ) {
	sendPost( '/api.php', 'delSubscription=1&id=' + id );
	var n = document.getElementById( 'shop_' + id );
	n.parentNode.removeChild( n );
	return false;
}

function vote( id, vote ) {
	var worked = vote ? '1' : '0';
	sendPost( '/api.php', 'vote='+worked+'&id=' + id );
	document.getElementById('voteUp').style.display = 'none';
	document.getElementById('voteDown').style.display = 'none';
	document.getElementById('voteThanks').style.display = 'inline';
	return false;
}

function sendPost( url, params ) {
	if (window.XMLHttpRequest) { // moz
		req = new XMLHttpRequest();
		req.overrideMimeType( 'text/plain' );
	} 
	else if (window.ActiveXObject) { // ie
		try {
			req = new ActiveXObject( 'Msxml2.XMLHTTP' );
		} 
		catch (e) {
			try {
				req = new ActiveXObject( 'Microsoft.XMLHTTP' );
			} 
			catch (e) {}
		}
	}
	
	if( !req ) return false;
	
	req.open( 'POST', url, true );
	req.setRequestHeader( 'Content-type', 'application/x-www-form-urlencoded; charset=UTF-8' );
	req.setRequestHeader( 'Content-length', params.length );
	req.setRequestHeader( 'Connection', 'close' );
	req.send( params );
}