/* Controle zoek knop */
function app_for_key_submit() {
	if (document.app_for_key.k.value == '' || document.app_for_key.k.value == 'zoek uw machine' || document.app_for_key.k.value == 'vul een zoekwoord in a.u.b'){
		document.app_for_key.k.value = 'vul een zoekwoord in a.u.b'; document.app_for_key.k.style.color = '#FF0000';
	} else {document.app_for_key.submit();}
}

/* Favorieten beheer */
function bookmark() {
	if (window.sidebar) { // Mozilla Firefox 
        window.sidebar.addPanel(document.title, document.location.href + "", "", "", "");
    } else {
        if (window.external) { // Internet Explorer
           window.external.AddFavorite(document.location.href + "", document.title);
     	} else {
        if (window.opera && window.print) { // Opera
           	window.alert("kies toetsencombinatie CTRL + T om " + document.title + " als favoriet toe te voegen.");
     	}
     	}
	}
}

/* Achtergrond kleur geven na laden. */
function content_onload() {
	document.getElementById("content").style.backgroundImage = "url(/image/content.jpg)";
	document.getElementById("content").style.backgroundPosition = "bottom";
	document.getElementById("content").style.backgroundRepeat = "repeat-x";
	document.getElementById("content").style.borderBottom = "1px solid #003366";
	document.getElementById("content").style.backgroundColor = "#E4ECF6";
}

/* Vergelijk */

function app_vergelijk(id,v_artikel_titel,v_action)
{	
	
	/* Op vorige pagina's */
	var v_other = document.getElementById('v_other').value;

	/* Remove item uitschakelen of v_other van andere pagina's verminderen. */
	if (v_action == 'remove'){ 
	if (document.getElementById('app_vergelijk_' + id) != null){document.getElementById('app_vergelijk_' + id).checked = false;} else {document.getElementById('v_other').value = (v_other-1); v_other = (v_other-1);}
	try { xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
	xmlhttp.open("GET", "/app_vergelijk.php?v=" + id + "&a=remove");
	xmlhttp.send(null);
	}
	
	/* Op deze pagina */
	var v_this = 0;
	for (i=0;i<v_totaal;i++){
	if (document.getElementsByName("app_vergelijk_" + i)[0].checked == true){v_this++;}    
	}
	
	if (v_action != 'remove'){ 

	/* Als checkbox nog is aangevinkt */
	if (document.getElementById('app_vergelijk_' + id).checked == true){
	
	/* Melding dat er niet meer mogen en checkbox uitschakelen. */
	if (((v_other*1) + (v_this*1)) > 4){
	document.getElementById('app_vergelijk_' + id).checked = false;
	alert ("U kunt maximaal 4 machines vergelijken. De-selecteer eerst een andere machine.");
	
	/* Toevoegen */
	} else {
	try { xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
	xmlhttp.open("GET", "/app_vergelijk.php?v=" + id + "&a=add&t=" + v_artikel_titel);
	xmlhttp.send(null);
	}
	
	/* Verwijderen */
	} else {
	try { xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
	xmlhttp.open("GET", "/app_vergelijk.php?v=" + id + "&a=remove");
	xmlhttp.send(null);
	}
	
	}
	
	/* Buttons */
	if ((v_this > 0) || (v_other > 0)){
	document.getElementById("app_vergelijk_button").innerHTML = "<a href=\"" + v_url + ".html?v=1\"><img src=\"/image/vergelijk_button_active.jpg\" alt=\"Vergelijk machines\" border=\"0\"/></a>	";
	document.getElementById("app_vergelijk_button_180").innerHTML = "<a href=\"" + v_url + ".html?v=1\"><img src=\"/image/vergelijk_button_180_active.jpg\" alt=\"Vergelijk machines\" border=\"0\"/></a>";
	} else {
document.getElementById("app_vergelijk_button").innerHTML = "<a onclick=\"app_vergelijk_notactive();\" style=\"cursor: pointer;\"><img src=\"/image/vergelijk_button.jpg\" alt=\"Selecteer tenminste 1 machine!\" border=\"0\"/></a>";
	document.getElementById("app_vergelijk_button_180").innerHTML = "<a onclick=\"app_vergelijk_notactive();\" style=\"cursor: pointer;\"><img src=\"/image/vergelijk_button_180.jpg\" alt=\"Selecteer tenminste 1 machine!\" border=\"0\"/></a>";
	}

	
	/* Weergave items herladen */
	try { xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
	xmlhttp.onreadystatechange = function() {if (xmlhttp.readyState==4){if (xmlhttp.status==200){document.getElementById('app_vergelijk_items').innerHTML=xmlhttp.responseText;} else {alert("Problem retrieving data:" + xmlhttp.statusText);}  }};
	xmlhttp.open("GET", "/app_vergelijk_items.php");
	xmlhttp.send(null);

}

/* Melding als er geen machine is geselecteerd. */
function app_vergelijk_notactive(){
	alert("Selecteer tenminste 1 machine!");	
}

/* Taal voor shadowbox */
Shadowbox.init({
    language:   "nl"
});

/* Tooltip functie */
$(document).ready(function() {
$("#specs_blok img[title]").tooltip({tip: '#tooltip', position: 'top right', relative: false});
$("#specs_blok_overzicht img[title]").tooltip({tip: '#tooltip', position: 'top right', relative: false});
$("#overzicht_filter_kolom img[title]").tooltip({tip: '#tooltip', position: 'top right', relative: false});
});

