// Functie bestand Catalogus module

var rotateMsg = false;
function MsgStatus() {
if(rotateMsg) {
window.status = '';
window.defaultStatus = '';
}
if(!rotateMsg) {
window.status = '';
window.defaultStatus = '';
}
setTimeout("MsgStatus();rotateMsg=!rotateMsg", 900);
}
//MsgStatus();



function changeborder(color, id){
	a = document.getElementById(id);
	a.style.borderColor = color;
	return;
}

function getItem(id){
 location.href = '/cat/front/item_info.asp' + id;
}

function getimage(afbeelding){
	a = document.getElementById('img_big');
	a.src = afbeelding;
	
	if (a.width > 200) a.width = 200;
	if (a.Height > 200) a.Height = 200;
}

function numbersonly(){
 if (event.keyCode<48||event.keyCode>57)
  return false
}

function submitForm(formulier){
	formulier.submit();
}

function emailonly(veld,melding){
	
	p1=0;
	p2=0;
	startPos = 0;
	email = veld.value;
	
	while (startPos != veld.value.length){
		if ((email.charAt(startPos)=='@')&&(p1==0)) p1=startPos;
		if ((email.charAt(startPos)=='.')&&(p2==0)) p2=startPos;
		
		startPos++;
	}
	
	if ((p1==0)||(p2==0)){
		alert("U dient een geldig e-mail adres op te geven");
	  return false;
	}
}

function checkEmail(veld,melding){

}

function printInfo(id){
	window.print();
}

function changeClass(id, klasse){
 document.getElementById(id).className = klasse;
}

function bagAddItem(){
	location.href = '/cat/front/items.asp';
}

function showInfo(id){
/* 	
	if (id == 1)
		document.getElementById('infolayer').style.display = '';
	if (id == 0)
		document.getElementById('infolayer').style.display = 'none';
*/
var submenu = $("infolayer");
var menu = $("info_button");

if (id == 1) {
	var menu_size = menu.getDimensions();
	var cloneoptions = {
		setLeft: true,
		setTop: true, 	
		setWidth: false,
		setHeight: false,
		offsetLeft: -200 + menu_size.width,
		offsetTop: menu_size.height	
	}	
	submenu.clonePosition(menu, cloneoptions);
	submenu.show();
} else {
	submenu.hide();
}
}

function submitForm(formulier){
	document[formulier].submit();
}

function ordertyp(id)
{
 var dhl = document.getElementById("dhl");
 var haal = document.getElementById("haal");
 if (id == 1){
	haal.style.display = "none";
	dhl.style.display = "";
 }
 if (id == 2){
	haal.style.display = "";
	dhl.style.display = "none";
 }
}

/* Formulier check functies */

// Controleren van alleen getallen die ingevoerd mogen worden
function checkInteger(FormObject,melding){
	var checkOK = "0123456789";	
	var FieldFilled = true;
	for(var c=0; c <= FormObject.value.length -1; c++) {
		if (checkOK.indexOf(FormObject.value.charAt(c)) == -1) {
			FieldFilled = false;				
		}
	}
	if (FieldFilled == false){ 
		alert(melding);
		FormObject.select();
		FormObject.focus();
		return false;
	}
}


// Controleren van alleen prijzen die ingevoerd mogen worden
function checkPrice(FormObject,melding){
	var checkOK = "0123456789,";	
	var FieldFilled = true;
	for(var c=0; c <= FormObject.value.length -1; c++) {
		if (checkOK.indexOf(FormObject.value.charAt(c)) == -1) {
			FieldFilled = false;				
		}
	}
	if (FieldFilled == false){ 
		alert(melding);
		FormObject.select();
		FormObject.focus();
		return false;
	}
}

function setVerplicht(){
	td = document.getElementsByTagName('td');
	for (i = 0; i <= td.length-1; i++){
		if (td[i].id){
			if (td[i].id == 'form_verplicht'){
					td[i].className = 'form_verplicht_red';
			}
		}
	}
	
	return false;
}

function checkForm(id){
	a = document['itmFrm' + id].aantal;
	if (a.value == '' || parseInt(a.value) == 0){
	 alert('U dient een geldig aantal op te geven');
	 a.focus();
	 return;
	}
	
	document['itmFrm' + id].action = '/cat/front/item_to_bag.asp';
	document['itmFrm' + id].submit();
}
/* Einde Formulier check functies */


function bagDelete(txt){
	if (confirm(txt)){
	 location.href = 'bag_item_delete.asp?id=all';
	}
	return;
}

function bagRecalc(){
 document.frmCheck.action = 'bag_recalc.asp';
 document.frmCheck.submit();
 return;
}

function bagStep(page){
 location.href = page;
 return;
}

function bagSaveStandard() {
	location.href = '/cat/front/standaard_bestellijst/standard_from_bag.asp';
	return;	
}

function bagNextStep(page){
 //document.frmCheck.action = page;
 if (document.frmCheck.onsubmit() == true){
	 document.frmCheck.action = page;
	 document.frmCheck.submit();
 }
}

function bagSend(){
	document.frmCheck.submit();
	return;
}

function bestellijst_to_bag(id,txt) {
	if (confirm(txt)) {
		document.location = '/cat/front/standaard_bestellijst/standard_order_add_to_bag.asp?id='+ id;
	}
}

function history_to_bag(id,txt) {
	if (confirm(txt)) {
		document.location = '/cat/front/standaard_bestellijst/historisch_order_add_to_bag.asp?id='+ id;
	}
}

function bestellijst_edit(id) {
	document.location = '/cat/front/standaard_bestellijst/standard_order_info.asp?bestellijstid='+ id;
}

function history_edit(id) {
	document.location = '/cat/front/standaard_bestellijst/historisch_order_info.asp?bestellijstid='+ id;
}

function bestellijst_delete(id,txt) {
	if (confirm(txt)) {
		document.location = '/cat/front/standaard_bestellijst/standard_order_delete.asp?id='+ id;
	}
}

function bestellijst_item_delete(bestellijstid,id,txt) {
	if (confirm(txt)) {
		document.location = '/cat/front/standaard_bestellijst/standard_item_delete.asp?bestellijstid='+ bestellijstid +'&id='+ id;
	}
}

function bestellijst_recalc(){
 document.frmCheck.action = '/cat/front/standaard_bestellijst/standard_order_recalc.asp';
 document.frmCheck.submit();
 return;
}

function history_to_standard(id) {
	location.href = '/cat/front/standaard_bestellijst/standard_from_history.asp?id='+ id;
	return;	
}

function openTechLink(id) {
	var info_window_width = 800;
	var info_window_height = 600;

	var info_window_left = (screen.width - info_window_width) / 2;
	var info_window_top  = (screen.height - info_window_height) / 2;
	

	window.open("/Cat/custom/files/technischeinfo/" + id + ".htm" , "InfoWindow_" + id , "location=0,scrollbars=0,menubar=0,toolbar=0,resizable=1,left="+ info_window_left +",top=" + info_window_top +",width=" + info_window_width + ",height=" + info_window_height);
}
