// Example function 
// purpose: to state an example
// params: n/a
// returns: n/a
function example() {
	alert('This is an example function.');
}
// OpenWin
// purpose: generic popup function
// params: 
//		url		- URL to the page to open in the window
//		bClean	- If the windows is to be presented "clean" without toolbar etc.
//		iWidth	- width of the window
//		iHeight	- height of the window
// returns: n/a
function openWin(url, bClean, iWidth, iHeight){
	var sWinProp = '';	
	if(bClean){
		sWinProp = 'toolbar=no,location=no,directories=no,status=no,menubar=no,';
	}
	else {
		sWinProp = 'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,';
	}
	
	
	var newWin = window.open(url, '', sWinProp+'scrollbars=yes,resizable=yes,width='+iWidth+',height='+iHeight);
	
	if(newWin)
	{
		newWin.focus();
	}
	return false;
}

// OpenWin
// purpose: generic popup function
// params: 
//		url		- URL to the page to open in the window
//		bClean	- If the windows is to be presented "clean" without toolbar etc.
//		iWidth	- width of the window
//		iHeight	- height of the window
// returns: n/a
function openWinEx(url, name, bClean, iWidth, iHeight, advanced){
	var sWinProp = '';	
	if(bClean){
		sWinProp = 'toolbar=no,location=no,directories=no,status=no,menubar=no,';
	}
	else {
		sWinProp = 'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,';
	}
	
	if(advanced != "")
	{
		sWinProp = sWinProp + "," + advanced;
	}
	
	var newWin = window.open(url, name, sWinProp+'scrollbars=yes,resizable=yes,width='+iWidth+',height='+iHeight);

	if(newWin)
	{
		newWin.focus();
	}
	
	return false;
}


/*
function openPlan(ritning){
	var Plan;
	Plan = window.open('/soklagenhetlokal/planlosning.asp?'+ritning,'plan','left=0,top=0,width=500,height=540,scrollbars=1,resizable=1,toolbar=0,menubar=0');
	if (Plan) {
		Plan.focus();
	}
}

openWin
*/

function ImagePreloader(images, texts, callback)
{
	// store the call-back
	this.callback = callback;

	// initialize internal state.
	this.nLoaded = 0;
	this.nProcessed = 0;
	this.aImages = new Array;
	this.aTexts = new Array;

	// record the number of images.
	this.nImages = images.length;
	this.nTexts = texts.length;

	// for each image, call preload()
	for ( var i = 0; i < images.length; i++ )
	{
		this.preload(images[i], texts[i]);
	}
}

ImagePreloader.prototype.preload = function(image, text)
{
	// create new Image object and add to array
	var oImage = new Image;
	this.aImages.push(oImage);

	// set up event handlers for the Image object
	oImage.onload = ImagePreloader.prototype.onload;
	oImage.onerror = ImagePreloader.prototype.onerror;
	oImage.onabort = ImagePreloader.prototype.onabort;

	// assign pointer back to this.
	oImage.oImagePreloader = this;
	oImage.bLoaded = false;

	// assign the .src property of the Image object
	oImage.src = image;
	oImage.alt = text;
	oImage.title = text;
}

ImagePreloader.prototype.onComplete = function()
{
   this.nProcessed++;
   if ( this.nProcessed == this.nImages )
   {
      this.callback(this.aImages, this.nLoaded);
   }
}

ImagePreloader.prototype.onload = function()
{
   this.bLoaded = true;
   this.oImagePreloader.nLoaded++;
   this.oImagePreloader.onComplete();
}

ImagePreloader.prototype.onerror = function()
{
   this.bError = true;
   this.oImagePreloader.onComplete();
}

ImagePreloader.prototype.onabort = function()
{
   this.bAbort = true;
   this.oImagePreloader.onComplete();
}

var imagePreloader = null;
function onPreload(aImages, nImages)
{
	swapImage(0);
}

function allImages()
{
	return arrImages;
}

function imgPreloader()
{
	imagePreloader = new ImagePreloader(arrImages, arrTexts, onPreload);
}

function viewAllImages()
{
	window.open('/lokalbilder.htm','LokalBilder','directories=0,height=480,width=600,location=0,menubar=0,status=0,toolbar=0,scrollbars=1');
}