/*
	Author: J. Knitel
	Company: Paperkudt.nl

*/

 $(document).ready(function(){
		
	$("input").focus(function() {
		if ($(this).val() == "Gebruiker" || $(this).val() == "Wachtwoord") {
			$(this).val("");
		}
	});
	
	$(".boxpop").colorbox();
	
	$(".mInfo").live("click", function() {
		
		contid = $(this).attr("title");
		if (contid.substring(0, 1) == "o") {
			contid = contid.substring(1);
			$(this).attr("title", contid);
			$("#info-"+contid).slideUp();
			$(this).children("span").removeClass("anchor-up-arrow");
			$(this).children("span").addClass("anchor-down-arrow");
		} else {
			$("#info-"+contid).slideDown();
			$(this).children("span").removeClass("anchor-down-arrow");
			$(this).children("span").addClass("anchor-up-arrow");
			$(this).attr("title", "o"+contid);
		}
		
	});
	
	$('#profile').submit(function() {
		var values = $('#profile').serialize();
		$.get("/cms/users.php?mode=edit", { value : values }, function(res) {
			$("#cb").html(res);
		});
		return false;
	});
	
	/* auto login voor forum */
	$("#loginform").submit(function() {
		var p_username = $("#userfield").val();
		var p_password = $("#passfield").val();
		$.post("/forum/people.php", { Username : p_username, Password : p_password, PostBackAction : "SignIn", ReturnUrl : "http%253A%252F%252Fnvgtk.nl" }, function(res) { 
		});
		return true;
	});
	
	
});
function doIframe(){
	o = document.getElementsByTagName('iframe');
	for(i=0;i<o.length;i++){
		if (/\bautoHeight\b/.test(o[i].className)){
			setHeight(o[i]);
			addEvent(o[i],'load', doIframe);
		}
	}
}

function setHeight(e){
	if(e.contentDocument){
		e.height = e.contentDocument.body.offsetHeight + 35;
	} else {
		e.height = e.contentWindow.document.body.scrollHeight;
	}
}

function addEvent(obj, evType, fn){
	if(obj.addEventListener)
	{
	obj.addEventListener(evType, fn,false);
	return true;
	} else if (obj.attachEvent){
	var r = obj.attachEvent("on"+evType, fn);
	return r;
	} else {
	return false;
	}
}

if (document.getElementById && document.createTextNode){
 addEvent(window,'load', doIframe);	
}
