$(document).ready(function() {
	$("#faqList").accordion({ header: "h2" });
	$("img").tooltip({showURL: false});
	$("span").tooltip({showURL: false});
	$("#tabs").tabs();

});

function doZip(){
	this.document.leverform.oper.value = "zip";
	this.document.leverform.submit();
}

function doMarkChange(){
	this.document.orderform.changed.value = "Y";
}

function doDel(id){
	if (confirm(this.document.jsform.basket_del.value)){
		myelement = this.document.getElementById("quantity_" + id);
		if (myelement){
			myelement.value = "0";
		}
	}
	this.document.orderform.oper.value = "savebasket";
	this.document.orderform.submit();
}

function sendbasket(){
	if(this.document.orderform.changed.value == "Y"){
		alert(this.document.jsform.basket_changed.value);
	} else {
		this.document.orderform.oper.value = "overview";
		this.document.orderform.submit();
	}
}

function backtobasket(page){
	this.document.location = page;
}

function confirmbasket(){
	this.document.orderform.oper.value = "confirm";
	this.document.orderform.submit();
}

function startTime(warningtype){
	var warning="N";
	var today=new Date();
	var day=today.getDate();
	var month=today.getMonth()+1;
	var year=today.getFullYear();
	var h=today.getHours();
	var m=today.getMinutes();
	var s=today.getSeconds();
	// add a zero in front of numbers<10
	m=checkTime(m);
	s=checkTime(s);
	month=checkTime(month);
	day=checkTime(day);
	
	if (warningtype == 2){
		if (h == 8 && m >= 55){
			warning = "Y";
		}
	}
	if (warningtype == 3){
		if (h == 11 && m >= 55){
			warning = "Y";
		}
	}
	
	if (warning == "N"){
		document.getElementById('datetime').innerHTML=day+"-"+month+"-"+year+" "+h+":"+m;
	} else {
		if (s%2 == 0){
			document.getElementById('datetime').innerHTML="<span style='color:red'>"+day+"-"+month+"-"+year+" "+h+":"+m+"</span>";
		}else{
			document.getElementById('datetime').innerHTML="";
		}
	}
	t=setTimeout('startTime('+warningtype+')',500);
}
	
function checkTime(i){
	if (i<10) {
		i="0" + i;
	}
	return i;
}

function doArchive(){
	if (confirm("Archiveer/desarchiveer de aangevinkte nota's?")){
		this.document.leverform.oper.value = "archive";
		this.document.leverform.submit();
	}
}

function doArchiveChange(){
	this.document.leverform.oper.value = "list";
	this.document.leverform.submit();
}

$("#tabs").tabs({
        show:function(event, ui) {
        var rel = $(ui.panel).find('iframe').attr('rel');
    	$(ui.panel).find('iframe').attr('src',rel);
	}
});


function doRemoveFromFav(id){
	if (confirm("Wissen uit favorietenlijst?")){
		this.document.productForm.oper.value = "delfav";
		this.document.productForm.delid.value = id;
		this.document.productForm.submit();
	}
}
