function addBasket(id,str) {
	var poststr = "id=" + encodeURI(id) + "&str=" + encodeURI(str);
	ajaxpack.postAjaxRequest("ajax/addbasket.asp", poststr, processGetPost, "txt")
	return false;
}

function addBasketMore(f) {
	var poststr = "id=" + encodeURI(f.pizzaid.value) + "&small=" + encodeURI(f.s.value) + "&medium=" + encodeURI(f.m.value) + "&large=" + encodeURI(f.l.value);
	ajaxpack.postAjaxRequest("../ajax/addbasketmore.asp", poststr, processGetPost, "txt")
	return false;
}

//Step 2: Define a "callback" function to process the data returned by the Ajax request:
function processGetPost(){
	var myajax=ajaxpack.ajaxobj
	var myfiletype=ajaxpack.filetype
	if (myajax.readyState == 4){ //if request of file completed
	if (myajax.status==200 || window.location.href.indexOf("http")==-1){ //if request was successful or running script locally
	if (myfiletype=="txt")
		if(myajax.responseText.length > 1) {
			document.getElementById('antal_varer').innerHTML = myajax.responseText;
			showNews();
		}
	else
		if(myajax.responseXML.length > 1) alert(myajax.responseXML)
	}
	}
}


function showNews() {
	//var element = document.createElement("span");
	//var text = document.createTextNode('<img src="img/done.png" /> Produktet er nu tilføjet i indkøbskurven, se din kurv længere nede');
	//element.appendChild(text);
	//document.getElementById('popUpNews').appendChild(element);

	document.getElementById('popUpNews').style.display = 'block';
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) { //Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	}

	document.getElementById('popUpNews').style.top = myHeight/2 + document.documentElement.scrollTop;
	document.getElementById('popUpNews').style.left = myWidth/2-250;


	setTimeout("document.getElementById('popUpNewss').style.display = 'none';", 500);
	setTimeout("document.getElementById('popUpNewss').style.display = 'block';", 1000);
	setTimeout("document.getElementById('popUpNewss').style.display = 'none';", 1500);
	setTimeout("document.getElementById('popUpNewss').style.display = 'block';", 2000);
	setTimeout("document.getElementById('popUpNews').style.display = 'none';", 7000);

//, i stedet for style.width så offsetWidth, i stedet for style.top så offsetTop og style.left bliver så selvfølgelig til offsetLeft.
}
//ajaxpack.getAjaxRequest("example.htm", "", processGetPost, "txt")


function checkPostcode(field) {
   var sPostcode = field;
   var iLength =  sPostcode.length;

   var valid_char = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
   var sNumberPart = sPostcode.substring(0, 4);
   var sTextPart = sPostcode.substring(0, iLength);

   if (iLength == 4 ) {
	if (isNaN(sNumberPart)) {
		alert ('De 4 karakterer af dit postnr skal være numre!');
		return false;
	} else  {
		return true;
		exit;
	}
   } else {
	alert('The length of your postcode is incorrect. \nPlease type your postcode as four numbers. \nPlease check your input for errors and try again.');
	return false;
   }
   return true;
}
