function popupSAF(pl){
	var w=529;
	var h=454;
	var x=(screen.width/2)-(w/2);
	var y=(screen.height/2)-(h/2)-30;
	var safPopup=window.open('http://www.ellegirl.nl/elle/EGN_send_a_friend.php?	pl='+pl,'SAF','left='+x+',top='+y+',width='+w+',height='+h+',scrollbars=no');
	if (safPopup) safPopup.focus();
}

function popupUpload(){
	var w=668;
	var h=554;
	var x=(screen.width/2)-(w/2);
	var y=(screen.height/2)-(h/2)-30;
	var uploadPopup=window.open('http://194.146.127.36/egwh/','upload','left='+x+',top='+y+',width='+w+',height='+h+',scrollbars=yes');
	if (uploadPopup) uploadPopup.focus();
}

function setSearch(obj){
	if(obj.zoeken[0].checked){
		obj.action = "http://forum.ellegirl.nl/search.php";
		document.getElementById("searchTxt").name = "query";
	} 
}


var AjaxObjLFP = {
	handleSuccess:function(o){
		this.processResult(o);
	},
	handleFailure:function(o){},
	processResult:function(o){
		if(o.responseText != ""){
			document.getElementById('forumTopicsWrap').innerHTML = o.responseText;
		}
	},
	startRequest:function(filename) {
		url = "http://www.ellegirl.nl/forum/" + filename;
		YAHOO.util.Connect.asyncRequest('POST', url, callback, "ajax=1");
	}
};

var callback = {
	success:AjaxObjLFP.handleSuccess,
	failure:AjaxObjLFP.handleFailure,
	timeout: 20000,
	scope: AjaxObjLFP
};

var AjaxObjAgenda = {
	handleSuccess:function(o){
		this.processResult(o);
	},
	handleFailure:function(o){},
	processResult:function(o){
		if(o.responseText != ""){
			document.getElementById('agenda').innerHTML = o.responseText;
			showhideAgendaScroll();
		}
	},
	startRequest:function(datum,dir,cat) {
		url = "http://www.ellegirl.nl/agenda/getAgenda.php";
		var postdata = "ajax=1&date="+datum+"&dir="+dir+"&cat="+cat;
		YAHOO.util.Connect.asyncRequest('POST', url, callbackAgenda, postdata);
	}
};

var callbackAgenda = {
	success:AjaxObjAgenda.handleSuccess,
	failure:AjaxObjAgenda.handleFailure,
	timeout: 20000,
	scope: AjaxObjAgenda
};

/* agenda scroll */
var agendaOffsetTop = 0;
var agendaScrollLines = 3;
var agendaSteps = 5;
var agendaStep = 0;
var agendaSpeed = 40;
var agendaScrollAmount = 3 * agendaScrollLines;
var agendaWrapDiv, agendaScrollInt;

function showhideAgendaScroll(){
	agendaWrapDiv = document.getElementById('agendaWrap');
	var agendaLines = agendaWrapDiv.getElementsByTagName('DIV');
	var agendaLineAmount = 0;
	for(i=0; i < agendaLines.length; i++){
		if(agendaLines[i].className == 'agendaLine') agendaLineAmount++;
	}
	if(agendaLineAmount > 10) document.getElementById('agendaScroll').style.display = 'block';
	else document.getElementById('agendaScroll').style.display = 'none';	
}

function clearAgendaInt(){
	agendaStep=0;
	clearInterval(agendaScrollInt);
}

function scrollAgenda(direction){
	clearAgendaInt();
	agendaScrollInt=setInterval('scrollAgendaStep(\''+direction+'\')',agendaSpeed);
}

function scrollAgendaStep(direction){
	if(agendaStep < agendaSteps){
		if(direction == 'down') {
			agendaOffsetTop = agendaOffsetTop + agendaScrollAmount;
			if(agendaOffsetTop >= (150-agendaScrollAmount)) {
				agendaOffsetTop = 150-agendaScrollAmount;
				clearAgendaInt();
			}
		} else if(direction == 'up') {
			agendaOffsetTop = agendaOffsetTop - agendaScrollAmount;
			if(agendaOffsetTop < 0) {
				agendaOffsetTop = 0;
				clearAgendaInt();
			}
		}
		agendaWrapDiv.scrollTop = agendaOffsetTop;
		agendaOffsetTop = agendaWrapDiv.scrollTop;
		agendaStep++;
	} else {
		clearAgendaInt();
	}
}