function reload(intItemId) {
	document.location = 'index.asp?ItemId=' + intItemId;
}


// postcode checks

function zoekPC2() {
	checkPC(document.forms.frmZoekPostcode2);
}

function checkPC(objForm) {
	var strPostCode = objForm.zipcode.value;
	var objRegExp = new RegExp('^[1-9][0-9]{3}( ?[a-zA-Z]{2})?$');
	if (objRegExp.test(strPostCode)) {
		objForm.submit();
	} else {
		alert('U heeft geen geldige postcode ingevuld.');
	}
}


// shoppinglist

function addShoplistItem(strType, intId, strHtml) {
	var objTR = document.getElementById('trSL_' + strType + intId);
	if (objTR) {
		// already on shoplist
		return;
	}
	var objShopList = document.getElementById('tbShopList');
	if (objShopList) {
		var strFunction;
		if (strType == 'R')
			strFunction = 'removeRecept';
		else if (strType == 'L')
			strFunction = 'removeProductList';
		else
			strFunction = 'removeProduct';
		objTR = document.createElement('tr');
		objTR.id = 'trSL_' + strType + intId;
		var objTD1 = document.createElement('td');
		objTD1.innerHTML = '<a href="javascript:' + strFunction + '(' + intId + ')"><img src="/images/list_boodschappenlijst.gif"/></a>';
		objTR.appendChild(objTD1);
		var objTD2 = document.createElement('td');
		objTD2.innerHTML = strHtml;
		objTR.appendChild(objTD2);
		objShopList.appendChild(objTR);
	}
	// remove empty text
	displayEmptyShopListText(false);
}

function removeShoplistItem(strType, intId) {
	var objShopList = document.getElementById('tbShopList');
	var objTR = document.getElementById('trSL_' + strType + intId);
	if (objShopList && objTR) {
		objShopList.removeChild(objTR);
	}
	if (!objShopList.hasChildNodes()) {
		// add empty text
		displayEmptyShopListText(true);
	}
}

function changeButton(strLinkId, blnAddable) {
	var objLink = document.getElementById(strLinkId);
	if (objLink) {
		if (blnAddable) {
			objLink.style.visibility = 'visible';
		} else {
			objLink.style.visibility = 'hidden';
		}
	}
}

function addProduct(intProductId, strProductHtml) {
	// add to database
	var objImage = new Image();
	objImage.src = '/boodschappen/addboodschap.asp?Aanbieding_ProductID=' + intProductId;
	objImage = null;
	// add to list on page
	addShoplistItem('P', intProductId, strProductHtml);
	// change button
	changeButton('AddProduct_' + intProductId, false);
}

function addProductList(intProductId, strProductHtml) {
	// add to database
	var objImage = new Image();
	objImage.src = '/boodschappen/addboodschap.asp?ProductList_ProductID=' + intProductId;
	objImage = null;
	// add to list on page
	addShoplistItem('L', intProductId, strProductHtml);
	// change button
	changeButton('AddProductList_' + intProductId, false);
}

function removeProductList(intProductId) {
	// remove from database
	var objImage = new Image();
	objImage.src = '/boodschappen/deleteboodschap.asp?ProductList_ProductID=' + intProductId;
	objImage = null;
	// remove from list on page
	removeShoplistItem('L', intProductId);
	// change button
	changeButton('AddProductList_' + intProductId, true);
}

function addRecept(intReceptenId, strIngredientenHtml) {
	// add to database
	var objImage = new Image();
	objImage.src = '/boodschappen/addboodschap.asp?ReceptenID=' + intReceptenId;
	objImage = null;
	// add to list on page
	addShoplistItem('R', intReceptenId, strIngredientenHtml);
	// change buttons
	changeButton('AddWeeklyRecept_' + intReceptenId, false);
	changeButton('AddRecept_' + intReceptenId, false);
}

function removeProduct(intProductId) {
	// remove from database
	var objImage = new Image();
	objImage.src = '/boodschappen/deleteboodschap.asp?Aanbieding_ProductID=' + intProductId;
	objImage = null;
	// remove from list on page
	removeShoplistItem('P', intProductId);
	// change button
	changeButton('AddProduct_' + intProductId, true);
}

function removeRecept(intReceptenId) {
	// remove from database
	var objImage = new Image();
	objImage.src = '/boodschappen/deleteboodschap.asp?ReceptenID=' + intReceptenId;
	objImage = null;
	// remove from list on page
	removeShoplistItem('R', intReceptenId);
	// change buttons
	changeButton('AddWeeklyRecept_' + intReceptenId, true);
	changeButton('AddRecept_' + intReceptenId, true);
}

function displayEmptyShopListText(blnDisplay) {
	var objTextDiv = document.getElementById('divShopListEmpty');
	if (objTextDiv) {
		objTextDiv.style.display = blnDisplay ? "block" : "none";
	}
}

function printBoodschappenlijst() {
	var objIFrame = document.getElementById('PrintFrame');
	if (objIFrame) {
		objIFrame.src = '/Boodschappen/index.asp';
	}
}

function openPopup(strUrl, strName, intWidth, intHeight) {
	// open a centered popup window
	var intLeft = parseInt((screen.availWidth - intWidth) / 2)
	var intTop = parseInt((screen.availHeight - intHeight) / 2)
	var strAttrib = 'height=' + intHeight + ',width=' + intWidth + ',screenX=' + intLeft + ',screenY=' + intTop + ',left=' + intLeft + ',top=' + intTop + ',scrollbars=0,toolbar=0,menubar=0,resizable=1,location=0'
	window.top.popDialog = window.open(strUrl, strName, strAttrib)
	// focus to popup
	window.top.popDialog.focus();
}


// flash menu scripts

function Toonmuh(id, visibility) {
	var divOverlay = document.getElementById(id);
	if (divOverlay) {
		divOverlay.style.visibility = visibility; 
	}
}

function Toonmuh2(urlletje) {
	var divOverlay = document.getElementById('overlay');
	if (divOverlay) {
		divOverlay.style.visibility = 'hidden'; 
		document.location.href  = urlletje
	}
}



var isInternetExplorer = navigator.appName.indexOf('Microsoft') != -1;

// Handle all the FSCommand messages in a Flash movie.
function menuBoven_DoFSCommand(command, args) {
	//var menuBovenObj = isInternetExplorer ? document.all.menuBoven : document.menuBoven;
	if (command == 'Openen') {
		Toonmuh('overlay', 'visible');
	}
}
function menuOnder_DoFSCommand(command, args) {
	//var menuOnderObj = isInternetExplorer ? document.all.menuOnder : document.menuOnder;
}

// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub menuBoven_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call menuBoven_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('Sub menuOnder_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call menuOnder_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}











