function goToLowRes() {
	if (screen.width < 1024) {
		if (confirm("Wilt u doorgeleid worden naar onze oudere website die meer geschikt is voor uw schermresolutie?")) 
		  window.location = "http://lowres.degaragedeurexpert.nl/";
		else window.location = "http://www.degaragedeurexpert.nl/?hiRes";
	}
}

function menuColor(t, bool) {
	t = t.getElementsByTagName("div");
	t.item(0).style.backgroundPosition = "left "+(bool ? "top" : "bottom");
	t.item(1).style.backgroundPosition = "right "+(bool ? "top" : "bottom");
}

// controleer of opgegeven string integer bevat
function isInt(str){
	if (str.length < 1) return false;
	strValidChars = "0123456789";
	
	// bekijk ieder teken in string afzonderlijk
	// als huidig teken niet in bovenstaande geldige string voorkomt, fout
	for (i = 0; i < str.length; i++) if (strValidChars.indexOf(str.charAt(i)) == -1) return false;
	
	return true;
}

// Gooi een bepaald formulier in een string
function buildFormString(form_id, w_disabled) {
	w_disabled = w_disabled || true;
	var str = '';
	
	for (e = 0; e < document.forms[form_id].elements.length; e++) {
		element = document.forms[form_id].elements[e];
		if (!w_disabled && element.disabled) { } // Niets doen
		else if (element.type == "text" || element.type == "hidden") str += '&'+element.name+'='+escape(element.value);
		else if (element.type == "checkbox") str += '&'+element.name+'='+(element.checked ? "1" : "0"); 
		else if (element.type == "radio") { if (element.checked) str += '&'+element.name+'='+element.value; }
		else if (element.tagName.toLowerCase() == "select") str += '&'+element.name+'='+element.value;
	}
	return str.substr(1); // Zonder eerste &
}

function openActie(root, ie) {
	w = window.open((root ? "" : "../../")+"paasactie.php", "paas", "status=yes, width=400, height="+(ie ? "391" : "400"));
	w.moveTo(225, 150);
}

function daysInMonth(month, year) {
	days = new Array(31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
	// february has 29 days in any year evenly divisible by four,
    // except for centurial years which are not also divisible by 400.
	days[1] = year % 4 == 0 && (year % 100 != 0 || year % 400 == 0) ? 29 : 28;
	return days[month - 1];
}

function isDate(datum){
	if (datum.length < 1) return false;

	// explode dag, maand en jaar
	pos1 = datum.indexOf("-");
	pos2 = datum.indexOf("-", pos1 + 1);
	strDay = datum.substring(0, pos1);
	strMonth = datum.substring(pos1 + 1, pos2);
	strYear = datum.substring(pos2 + 1);
	
	// bruikbare integers van maken
	if (strDay.charAt(0) == "0" && strDay.length > 1) strDay = strDay.substring(1);
	if (strMonth.charAt(0) == "0" && strMonth.length > 1) strMonth = strMonth.substring(1);
	day = parseInt(strDay);
	month = parseInt(strMonth);
	year = parseInt(strYear);
	
	// en nu checken
	if (pos1 == -1 || pos2 == -1 || dtStr.indexOf("-", pos2 + 1) != -1) return false;
	else if (!isInt(strDay) || strDay.length < 1 || day < 1 || day > daysInMonth(month, year)) return false;
	else if (!isInt(strMonth) || strMonth.length < 1 || month < 1 || month > 12) return false;
	else if (!isInt(strYear) || strYear.length != 4 || year < 1900 || year > 2100) return false;
	else return true;
}


function changeView(e) {
	d = document.getElementById("main").getElementsByTagName("div");
	for (i = 0; i < d.length; i++) d[i].style.display = d[i].id == "docu_"+e ? "block" : "none";
}
