var current = 0;

// fix de png transparantie in IE
function fix_png() {
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])

	if ((version >= 5.5) && (document.body.filters)) {
		if(document.getElementById('div')) {
			document.getElementById('div').innerHTML = '<span id="div" style="width: 414px; height: 62px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader (src=\'images/div.png\', sizingMethod=\'scale\');"></span>'
		}
	} else {
		if(document.getElementById('div')) {
			document.getElementById('div').innerHTML = '<img src="images/img.png">';
		}
	}
}

function prijs(value) {
	value = value.toString();
	if(value.indexOf('.') == -1) {
		return '&euro; '+ value + '.00';
	} else {
		if(value.substr(value.indexOf('.')).length < 3)	{
			return '&euro; ' + value + '0';
		} else {
			var prijs = Math.round(value*100)/100;
			prijs = prijs.toString();
			if(prijs.substr(prijs.indexOf('.')).length < 3)	{
				return '&euro; ' + prijs + '0';
			} else {
				return '&euro; ' + prijs;
			}
		}
	}
}

function wsTooltip(id, titel) {
	TagToTip(id, TITLE, titel, DELAY, 0, FADEIN, 300, FADEOUT, 300, FOLLOWMOUSE, false, OFFSETX, 10, OFFSETY, 5, STICKY, true, CLOSEBTN, true, WIDTH, 0);
}

function delAdminProdLink(id) {
	if(confirm('Weet u zeker dat u dit product wilt verwijderen?')) {
		parent.location='?id=admin/producten&action=del&p='+id;
	}
}

function delAdminCatLink(id) {
	if(confirm('Weet u zeker dat u deze subcategorie wilt verwijderen?')) {
		parent.location='?id=admin/categories&action=del&c='+id;
	}
}

// forward one image
function next() { 
	if(document.formname.slide[current+1]) {
		document.images.show.src = document.formname.slide[current+1].value;
		document.formname.slide.selectedIndex = ++current;
	} else {
		first();
	}
}

// back on image
function previous() { 
	if((current-1) >= 0) {
		document.images.show.src = document.formname.slide[current-1].value;
		document.formname.slide.selectedIndex= --current;
	} else {
		last();
	}
}

// jump to first image
function first() { 
	current=0;
	document.images.show.src = document.formname.slide[0].value;
	document.formname.slide.selectedIndex=0;
}

// this is jump to last image
function last() { 
	current=(document.formname.slide.length-1);
	document.images.show.src = document.formname.slide[current].value;
	document.formname.slide.selectedIndex=current;
}

// this controls the auto-play and/or auto-stop
function ap(text) { 
	document.formname.slidebutton.value=(text == "Stop") ? "Start" : "Stop";
	rotate();
}

// this is for the pulldown menu
function change() { 
	current=document.formname.slide.selectedIndex;
	document.images.show.src = document.formname.slide[current].value;
}

function rotate() {
	if(document.formname.slidebutton.value == "Stop") {
		current = (current == document.formname.slide.length-1) ? 0 : current+1;
		document.images.show.src = document.formname.slide[current].value;
		document.formname.slide.selectedIndex = current;
		window.setTimeout("rotate()", 5000);
	}
}
