/*
	xxxverhalen.js
	v1.0 - 16/aug/2006 - Initial version.
	All rights reserved.
*/

function selectLanguage(lang_) {
	location.href = 'xf.language.php?lang=' + lang_ + '&uri=' + escape(location.href);
}

function windowOpen(mypage,myname,w,h,features) {
	if (screen.width) {
		var winl = (screen.width-w) / 2;
		var wint = (screen.height-h) / 2;
	}else {
		winl = 0;
		wint =0;
	}
	if (winl < 0) winl = 0;
	if (wint < 0) wint = 0;
	var settings = 'height=' + h + ',';
	settings += 'width=' + w + ',';
	settings += 'top=' + wint + ',';
	settings += 'left=' + winl + ',';
	settings += features;
	win = window.open(mypage,myname,settings);
	win.window.focus();
}

function selectItem(url_) {
	windowOpen(url_, 'player', 930, 700, 'scrollbars=yes,resizable=yes,');
	return false;
}

function voteFor(id_, score_, ref_) {
	location.href = "xf.score.php?id=" + id_ + "&score=" + score_ + '&ref=' + ref_;

}

function mailFriend(id_, title_, button_send_, button_cancel_) {
	dialog.open( {
		title:title_,
		modal:true,
		width:400,
		duration:0.5,
		background:'#a4a4a4',
		source:'form.mailfriend.php?id=' + id_ + '&rn=' + Math.random(),
		buttons:button_send_ + ',' + button_cancel_,
		button_cancel:button_cancel_,
		callback:function(button_, dialog_) {
			// This function is executed whenever the user presses a button on the dialog.
			switch(button_) {
				case button_cancel_: /* cancel button pressed */
					dialog_.close();
				break;
				case button_send_: /* send button pressed */
					new Ajax.Request(
						$('friendForm').getAttribute('action'), {
							method:'post',
							parameters:Form.serialize('friendForm'),
							onComplete:function(req_) {
								// This function is executed whenever the server returns the contact form result.
								if ((result = req_.responseText).indexOf('|') > -1) {
									var parts = result.split('|');
									dialog.open( {
										title:title_,
										modal:false,
										width:300,
										duration:0.5,
										background:'#a4a4a4',
										content:parts[1],
										buttons:button_cancel_,
										button_cancel:button_cancel_
									} );
								} else dialog_.close();
							}
						}
					);
				break;
			}
		}
	} );
}

function addGuestbook(id_, title_, button_send_, button_cancel_) {
	dialog.open( {
		title:title_,
		modal:true,
		width:400,
		duration:0.5,
		background:'#a4a4a4',
		source:'form.guestbook.php?id=' + id_ + '&rn=' + Math.random(),
		buttons:button_send_ + ',' + button_cancel_,
		button_cancel:button_cancel_,
		callback:function(button_, dialog_) {
			// This function is executed whenever the user presses a button on the dialog.
			switch(button_) {
				case button_cancel_: /* cancel button pressed */
					dialog_.close();
				break;
				case button_send_: /* send button pressed */
					new Ajax.Request(
						$('guestbookForm').getAttribute('action'), {
							method:'post',
							parameters:Form.serialize('guestbookForm'),
							onComplete:function(req_) {
								// This function is executed whenever the server returns the contact form result.
								if ((result = req_.responseText).indexOf('|') > -1) {
									var parts = result.split('|');
									dialog.open( {
										title:title_,
										modal:false,
										width:300,
										duration:0.5,
										background:'#a4a4a4',
										content:parts[1],
										buttons:button_cancel_,
										button_cancel:button_cancel_
									} );
								} else dialog_.close();
							}
						}
					);
				break;
			}
		}
	} );
}

function bookmark() {
	if (navigator.appVersion.indexOf("MSIE") > 0) {
		if (parseInt(navigator.appVersion)>=4) {
			window.external.AddFavorite(location.href= window.location, document.title= "xxxverhalen.nl!");
		}
	}
}