
function printcontent(u,n)
{ var x = null; x = window.open( u, n, 'width=520,height=500,scrollbars=yes,resizable=yes' ); }

function change_img(i,s)
{ document.getElementById(i).src = s; }

function sh_container(d)
{
	var e = document.getElementById(d);
	e.style.display = e.style.display=='none' ? 'block' : 'none';
	var s = e.style.display;
	
	var e = document.getElementById(d+'_img');
	if(e)
	{
		change_img(d+'_img',(s=='block'?'img/formfooter_arrowdown.gif':'img/formfooter_arrow.gif'));
	}
}

function popGalleryWindow(galleryID, edition) {
	var x = null;
	var windowMarginX = 50;
	var windowMarginY = 50;
	
	var w = screen.width - (windowMarginX * 2);
	var h = screen.height - (windowMarginY * 2);

	edition = typeof(edition) != 'undefined' ? edition : "";
	
	wPARAM  = "left=" + windowMarginX + ",top=" + windowMarginY;
	wPARAM += ",WIDTH=" + w + ",HEIGHT=" + h;
	wPARAM += ",location=0,resizable=0,titlebar=1,directories=0";
	wPARAM += ",toolbar=0,menubar=0,scrollbars=0,status=0";

	x = window.open('index.php?page=pics&view=pics-popup&edition=' + edition + '&g=' + galleryID, 'gallery' + galleryID, wPARAM);
	x.focus();
}

function popVideoWindow(videofile) {
	var x = null;
	var _w = 340;
	var _h = 272;
	var _x = (screen.width / 2)  - (_w / 2);
	var _y = (screen.height / 2) - (_h / 2);
	
	wPARAM  = "left=" + _x + ",top=" + _y;
	wPARAM += ",WIDTH=" + _w + ",HEIGHT=" + _h;
	wPARAM += ",location=0,resizable=0,titlebar=1,directories=0";
	wPARAM += ",toolbar=0,menubar=0,scrollbars=0,status=0";

	x = window.open('index.php?page=video&videofile=' + videofile+'&width='+_w+'&height='+_h, 'video', wPARAM);
	x.focus();
}

function popVideoWindow09(videofile) {
	var x = null;
	var _w = 480;
	var _h = 403;
	var _x = (screen.width / 2)  - (_w / 2);
	var _y = (screen.height / 2) - (_h / 2);
	
	wPARAM  = "left=" + _x + ",top=" + _y;
	wPARAM += ",WIDTH=" + _w + ",HEIGHT=" + _h;
	wPARAM += ",location=0,resizable=0,titlebar=1,directories=0";
	wPARAM += ",toolbar=0,menubar=0,scrollbars=0,status=0";

	x = window.open('index.php?page=video&edicio=09&videofile=' + videofile+'&width='+_w+'&height='+_h, 'video', wPARAM);
	x.focus();
}

function popWindow(windowURL, windowName, width, height, options) {
	// calculate the window's X and Y position
	var x = (screen.width  - width ) / 2;
	var y = (screen.height - height) / 2;
	
	// Default the additional options:
	var defaults = {
		resizable : 'yes',
		titlebar : 'no',
		directories : 'no',
		toolbar : 'no',
		menubar : 'no',
		scrollbars : 'yes',
		status : 'no'
	};
	
	if(typeof options == 'undefined') {
		options = {};
	}
	
	for(var i in defaults) {
		if(typeof options[i] == 'undefined') {
			options[i] = defaults[i];
		} else {
		if(typeof options[i] == 'number') {
				options[i] = options[i] == 1 ? 'yes' : 'no';
			}
		}
	}

	// Prepare the popup window's parameter string
	var param = '';
	param +=  'left=' + x.toString();
	param += ',top=' + y.toString();
	param += ',width=' + width.toString();
	param += ',height=' + height.toString();
	param += ',location=no';
	param += ',resizable=' + options.resizable;
	param += ',titlebar=' + options.titlebar;
	param += ',directories=' + options.directories;
	param += ',toolbar=' + options.toolbar;
	param += ',menubar=' + options.menubar;
	param += ',scrollbars=' + options.scrollbars;
	param += ',status=' + options.status;
	
	// open the window
	var x = window.open(windowURL, windowName, param);
	x.focus();
}
