var http = false;

if(navigator.appName == "Microsoft Internet Explorer") {
  http = new ActiveXObject("Microsoft.XMLHTTP");
} else {
  http = new XMLHttpRequest();
}

function confirm_remove_item(url)	{
	var answer = confirm(" Bent u zeker dat u dit item wenst te verwijderen?");
//alert(url+'& referer='+escape(window.location));
	if (answer){
		window.location = url+'&referer='+escape(window.location);
	}
}

function toggleDiv(divid){
    if(document.getElementById(divid).style.display == 'none'){
      document.getElementById(divid).style.display = 'block';
    }else{
      document.getElementById(divid).style.display = 'none';
    }
  }


function getLang() {
	var mymetatags = document.getElementsByTagName("meta");
	var return_str = '';
	for (var i=0; i<mymetatags.length; i++) {
		if (mymetatags[i].getAttribute("name") == "language") {
			return_str = mymetatags[i].getAttribute("content");
		}
	}
	if (return_str == 'NL') {
		return_str = '';
	}
	return return_str;
}


function add2cart(id, nocache) {
	next_id = id*1+1;
	if (document.getElementById('qt'+next_id)) {
		document.getElementById('qt'+next_id).select();
	}
	var val =parseFloat(document.getElementById('qt'+id).value);
	var lang = getLang();
	if (val>=1) {
		http.abort();
		http.open("GET", window.location+"&add2cart="+id+"&qt="+val+"&order_id="+nocache, true);
		http.send(null);
		//document.getElementById("tr_"+(id*1+1)).className='added';
		document.getElementById("cart_div_"+(id*1)).innerHTML = "<a href=\"gen.php?page=order\">"+val+"</a>";
	} else {
		alert_mess = Array();
		alert_mess[''] = "'"+val+"' is geen geldige hoeveelheid...";
		alert_mess['FR'] = "'"+val+"' n'est pas un quantité valable";
		alert_mess['EN'] = "'"+val+"' is not a valid quantity...";
		alert_mess['DE'] = "'"+val+"' is not a valid quantity...";
		alert(alert_mess[lang]);
		document.getElementById('qt'+id).focus();
	}
}

function removefromcart(id) {
	var lang = getLang();
	confirm_mess = Array();
	confirm_mess[''] = "Weet u zeker dat u dit item wilt verwijderen?";
	confirm_mess['FR'] = "Vous êtes sur?";
	confirm_mess['EN'] = "Are you sure you wish to remove this item?";
	confirm_mess['DE'] = "Sicher?";
	x = confirm(confirm_mess[lang]);
	if (x) {
		window.location = window.location+"&amp;removefromcart="+id;
	}
}

function playVideo(video) {
    thisMovie("externalInterfaceExample").playVideo(video);
}

function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
}

function isNumeric(val){return(parseFloat(val,10)==(val*1));}


function removeOrder(id,type) {
	var lang = getLang();
	confirm_mess = Array();
	confirm_mess[''] = "Weet u zeker dat u dit item wilt verwijderen?";
	confirm_mess['FR'] = "Vous êtes sur?";
	confirm_mess['EN'] = "Are you sure you wish to remove this item?";
	confirm_mess['DE'] = "Sicher?";
	x = confirm(confirm_mess[lang]);
	if (x) {
		if(type==''){
		window.location = window.location+"&amp;remove_order="+id;
		}
		else{
		window.location = window.location+"&amp;sent=true&amp;remove_order="+id;
		}
		
	}
}

function encode_utf8( s )
{
  return unescape( encodeURIComponent( s ) );
}

function decode_utf8( s )
{
  return decodeURIComponent( escape( s ) );
}

