function loadPage(link, frameName) {
	frames[frameName].location.href = link;
}

function setStyleSheet(newTitle) {
	if(document.styleSheets) {
		for (var StyleSheetIterator = 0; StyleSheetIterator < document.styleSheets.length; StyleSheetIterator++)
		{
			if(document.styleSheets[StyleSheetIterator].title != newTitle)
			{
				document.styleSheets[StyleSheetIterator].disabled = true;
			}
			if(document.styleSheets[StyleSheetIterator].title == newTitle)
			{
				document.styleSheets[StyleSheetIterator].disabled = false;
			}
		}
	}
}

function pageLoader() {
	/* Set style sheet based on screen or frame size*/
	var w;
	var h;
	
	w = screen.width;
	h = screen.height;
	
	/* Dev code -- COMMENT WHEN PUBLISHING */
	if(isNetscape()) {
		if(parent.window.frames["main"]) {
			w = parent.window.frames["main"].innerWidth;
			h = parent.window.frames["main"].innerHeight;
		}
	}
	else {
		if(top.frames["main"]) {
			w = top.frames["main"].document.body.clientWidth;
			h = top.frames["main"].document.body.clientHeight;
		}
	}
	/* End dev code */
	
	if ((w>1024) && (h >= 768))
	{
		setStyleSheet('high');
	}
	else if ((w<=800) && (h <= 600))
	{
		setStyleSheet('disaster');
	}
	else
	{
		setStyleSheet('low');
	}
	
	// Check if page is loaded from mailing form, if so redirect to page requested
	if(readFromUrl("mailing") != window.location.href)
	{
		if(readFromUrl("mailing") == 'true')
		{
			parent._frame.location.href = 'iframe_mailing.html';			
			setTimeout("window.location.href = 'http://www.basjak.org'", 5000);
		};
	}
}

function isNetscape() {
	if(navigator.appName == 'Netscape') {return 1}
	else return 0;
}

function loadGallery()	{
	loadMovie(readFromUrl('mov'), readFromUrl('size'));
}

function readFromUrl(varName) {
	var url = window.location.href;
	var start = url.indexOf('?');
	var startVar = url.indexOf(varName, start);
	var startVarVal = url.indexOf('=', startVar) + 1;
	var endVar = url.indexOf(';', startVar);
	endVar = (endVar==-1?url.length:endVar);
	return url.substring(startVarVal, endVar);
}

function loadMovie (movieName, movieSize) {
	/* Set size */
	var w;
	var h;
	
	if (movieSize=='L') {
		w=800;
		h=600;
	}
	else {
		w=640;
		h=480;
	}
	
	/* Set correct movie */
	if (document.getElementById('gallery_div')) {
		document.getElementById('gallery_div').innerHTML=''
			+ '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + w + '" height="' + h + '" id="gallery" align="middle">'
			+ '		<param name="allowScriptAccess" value="sameDomain" />'
			+ '		<param name="movie" value="flash/' + movieName + '.swf" />'
			+ '		<param name="quality" value="high" />'
			+ '		<param name="bgcolor" value="#0099cc" />'
			+ '		<embed src="flash/' + movieName + '.swf" quality="high" bgcolor="#0099cc" width="' + w + '" height="' + h + '" name="gallery" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
			+ '</object>';
	}
	else {
		alert('Movie ' + movieName + ' does not exist in this website');
	}
}