var bIsNS, bIsIE, bOther;
bIsNS=bIsIE=bOther=false;
var sBName = navigator.appName;

if (sBName.indexOf("Internet Explorer")>0)
	bIsIE=true;
else if (sBName.indexOf("Netscape")>0)
	bIsNS=true;
else
	bOther=true;
var nBVer = parseInt(navigator.appVersion.substr(0,3));
//alert(sBName);

function ObjImagesClient_AddImage(src,txt,uid,click)
{
	this.ImageCounter++;
	this.Imagearray[this.ImageCounter]=src;
	this.Imageidarray[this.ImageCounter]=uid;
	this.Textarray[this.ImageCounter]=txt;
	this.Clickarray[this.ImageCounter]=click;
	 
}
function ObjImagesClient_SetConnectedImageFirstImageFromUID(huvudbildref,uid)
{
	for(i=0;i<=huvudbildref.ImageCounter;i++)
	{
		if(huvudbildref.Imageidarray[i]==uid)
		{
			huvudbildref.SetFirstImage(i);
		}
	}		
	if(this.GetImObj(this.lastid)) this.GetImObj(this.lastid).className="objimgcellstyle";
	if(this.GetImgObjFromUID(uid)) this.GetImgObjFromUID(uid).className="objimgselcellstyle";
	this.lastid=this.GetIdFromUID(uid);
}
function ObjImagesClient_GetImgObjFromUID(uid)
{
	for(i=0;i<=this.ImageCounter;i++)
	{
		if(this.Imageidarray[i]==uid)
		{
			return this.GetImObj(i);
		}
	}		
}
function ObjImagesClient_GetIdFromUID(uid)
{
	for(i=0;i<=this.ImageCounter;i++)
	{
		if(this.Imageidarray[i]==uid)
		{
			return i;
		}
	}		
}
function ObjImagesClient_SetConnectedImageFirstImage(huvudbildref,id)
{
	huvudbildref.SetFirstImage(this.FirstImage+id-1);
	this.GetImObj(this.lastid).className="objimgcellstyle";
	this.GetImObj(id).className="objimgselcellstyle";
	this.lastid=id;
}
function ObjImagesClient_NextImage()
{
	if (this.lastid + 1 <= this.ImageCounter)
	{
		this.SetFirstImage(this.lastid+1);
		this.lastid=this.lastid+1;		
	}

}
function ObjImagesClient_PrevImage()
{
	if (this.lastid-1 >= 1)
	{
		this.SetFirstImage(this.lastid-1);
		this.lastid=this.lastid-1;

	}
	
}
function ObjImagesClient_SetFirstImage(imageno)
{	
	var placeno=1;
	this.FirstImage=imageno;
	this.InitImages();
	//alert("placeno:" + placeno + " noof:" + this.NoOfVisibleImages + " imageno:" +imageno + " imagecounter:" +this.ImageCounter);
	while(placeno<=this.NoOfVisibleImages && imageno<=this.ImageCounter)
	{
		this.SetImage(placeno,imageno);
		placeno++;
		imageno++;
	}
	
	while(placeno<=this.NoOfVisibleImages)
	{
		this.SetHidden(this.image[placeno]); //.style.visibility='hidden';
		if (!document.layers)
			this.SetHidden(this.text[placeno]); //.style.visibility='hidden';
		placeno++;
	}

}
function ObjImagesClient_SetImage(placeno,imageno)
{
	this.InitImages();
	this.image[placeno].src=this.Imagearray[imageno];
	this.SetVisible(this.image[placeno]); //.style.visibility='visible';
	
	if (!document.layers)
	{
		if(this.text[placeno])
			this.text[placeno].innerHTML=this.Textarray[imageno];

		if(this.image[placeno])
			this.image[placeno].alt=this.Textarray[imageno];

		this.SetVisible(this.text[placeno]); //.style.visibility='visible';
		if(this.td[placeno])
			this.td[placeno].onclick=new Function(this.Clickarray[imageno]);
	}
}
function ObjImagesClient_InitImages()
{
	if(this.Imagesinitiated==1) return;
	this.Imagesinitiated=1;
	this.image=new Array();
	this.text=new Array();
	this.td=new Array();
	//Ökade från 20 till 30. Borde kunna ta reda på hur många "bildplatser" som finns på sidan dynamiskt. /Alö/DK 050909
	for(i=1;i<30;i++)
	{
		var im = this.GetImObj(i);
		if(im)
		{
			this.image[i]=im;
			this.NoOfVisibleImages++;
	
			var parentTd=this.GetObj(this.id+"_tdonclick_"+i);
			if(parentTd)
				this.td[i]=parentTd;
			else
				this.td[i]=null;
			
			var txt=this.GetObj(this.id+"_text"+i);
			if(txt)
				this.text[i]=txt;
			else
				this.text[i]=null;
		}
	}
}
function ObjImagesClient(id)
{
	this.GetIdFromUID=ObjImagesClient_GetIdFromUID;
	this.GetImgObjFromUID=ObjImagesClient_GetImgObjFromUID;
	this.lastid=1;
	this.AddImage=ObjImagesClient_AddImage;
	this.SetFirstImage=ObjImagesClient_SetFirstImage;
	this.InitImages=ObjImagesClient_InitImages;
	this.SetImage=ObjImagesClient_SetImage;
	this.SetConnectedImageFirstImage=ObjImagesClient_SetConnectedImageFirstImage;
	this.id=id;
	this.Imagearray=new Array();
	this.Imageidarray=new Array();
	this.ImageCounter=0;
	this.Imagesinitiated=0;
	this.NoOfVisibleImages=0;
	this.FirstImage=1;
	this.Textarray=new Array();
	this.Clickarray=new Array();
	this.GetImObj=ObjImagesClient_GetImObj;
	this.SetHidden=ObjImagesClient_SetHidden;
	this.SetVisible=ObjImagesClient_SetVisible;
	this.GetObj=ObjImagesClient_GetObj;
	this.SetConnectedImageFirstImageFromUID=ObjImagesClient_SetConnectedImageFirstImageFromUID;

	//Detta är en felaktig namngivelse av funktionerna, går snart ta bort (200407)
	this.SetConnectedImagePrevImage = ObjImagesClient_PrevImage;
	this.SetConnectedImageNextImage = ObjImagesClient_NextImage;
	//

	this.PrevImage = ObjImagesClient_PrevImage;
	this.NextImage = ObjImagesClient_NextImage;
	
}
function ObjImagesClient_SetHidden(obj)
{
	if(!obj) return;
	if (document.layers)
	{
		obj.visibility="hide";
	}
	else if (document.all)
		 obj.style.visibility="hidden";
	else
		obj.style.visibility="hidden";
}
function ObjImagesClient_SetVisible(obj)
{
	if(!obj) return;
	if (document.layers)
		obj.visibility="show";
	else if (document.all)
		 obj.style.visibility="visible";
	else
		obj.style.visibility="visible";
}
function ObjImagesClient_GetObj(id)
{
	if (document.getElementById)
		return document.getElementById(id);
	else if (document.all) //IE4
		return document.all[id];
	else if (document.layers) //NS
		return document.layers[id];
}
function ObjImagesClient_GetImObj(k)
{
	if (document.getElementById)
		return document.images[this.id+"_image"+k];
	else if (document.all) //IE4
		return document.images[this.id+"_image"+k];
	else if (document.layers) //NS
	{
		k=k+1;
		for (j=1;j < this.ImageCounter; j++)
		{
			if (document.images[k])
			{
				if (document.images[k].src != "" && document.images[k].src == this.Imagearray[j])
				{
						return document.images[k];
				}
			}
		}
	}
}

function ObjImages_ShowBigImage(sURL)
{
	window.open(sURL,"cpx_ObjImages_Big","width=683px, resizable=yes,toolbar=yes,scrollbars=yes,menubar=yes");
}

function Link(sURL)
{
	location.href=sURL;
	
}