/*************************************************/
/****Variabler for slideshow/gallerinavigasjon****/
/*************************************************/
var imgObj 		= '';
var imgList 	= '';
var textList	= '';
var imgPath		= '';
var imgPath2		= '';
var headerObj	= '';
var tekstObj	= '';
var header		= '';
var img			= '';
var text		= '';
var boolSlide   = '';
var linkObj		= '';
/*********************End*************************/

function init_gallery(path)
{
	imgObj 		= document.images['fullimg'];
	imgList 	= document.getElementById('imglist');
	textList	= document.getElementById('textlist');
	imgPath		= 'http://kundeweb.aggressive.no/users/' + path;
	imgPath2	= 'http://kundeweb.aggressive.no/users/tempupload/';
	headerObj	= document.getElementById('header');
	tekstObj	= document.getElementById('tekst');
	linkObj		= document.getElementById('imglink12');
	boolSlide	= false;
	
}

function move_prev()
{
	var index = imgList.selectedIndex;
	
	if(index != 1)
	{
		if(header != null) header	= imgList.options[index-1].text;
		if(img != null)    img		= imgList.options[index-1].value;
		if(text != null)   text		= textList.options[index-1].text;		
		
		index -= 1;
	}
	else
	{
		index = imgList.options.length-1;

		if(header != null) header	= imgList.options[index].text;
		if (img != null)   img		= imgList.options[index].value;
		if (text != null)  text		= textList.options[index].text;
	}
	
	if(imgList != null)		imgList.selectedIndex = index;
	if(textList != null)	textList.selectedIndex = index;
	
	if(imgObj != null)
	{
		imgObj.src = imgPath + img;
		imgObj.alt = header;
	}
		
	if(headerObj != null) headerObj.innerText = header;
	if(tekstObj != null) tekstObj.innerText = text;
	if(linkObj != null) linkObj.href = imgPath + img;
}

function move_next()
{
	var index = imgList.selectedIndex;
	
	if(index == (imgList.options.length-1))
	{
		if(header != null) 	header	= imgList.options[0].text;
		if(img != null)		img		= imgList.options[0].value;
		if(text != null) 	text	= textList.options[0].text;
		
		index = 0;	
	}
	else
	{		
		if(header != null)	header	= imgList.options[index+1].text;
		if(img != null)		img		= imgList.options[index+1].value;
		if(text != null)	text	= textList.options[index+1].text;
		
		index += 1
	}
	
	if(imgList != null)		imgList.selectedIndex = index;
	if(textList != null)	textList.selectedIndex = index;

	if(imgObj != null)
	{
		imgObj.src = imgPath + img;
		imgObj.alt = header;
	}
	
	if(headerObj != null)	headerObj.innerText = header;
	if(tekstObj != null)		tekstObj.innerText = text;
	if(linkObj != null) linkObj.href = imgPath + img;
}
	
function slide_start()
{
	if(boolSlide)
	{
		move_next();
		setTimeout('slide_start()',3000);
	}
}

function switch_img(img)
{

	var linkObj =  document.getElementById('imglink12');
	
	if(linkObj != null)
	{
		linkObj.href = imgPath2 + img;
	}
	if(imgObj != null)
	{
		imgObj.src = imgPath + img;			
	}	
}

function resize_border()
{
	var wObj = document.getElementById('img_t');
	var lObj = document.getElementById('img_l');
	var rObj = document.getElementById('img_r');
	var bObj = document.getElementById('img_b');
	var hObj = document.getElementById('img_height');
	var divObj	= document.getElementById('img_div');

	wObj.style.width = 245-29;
	lObj.style.height = 184-26;	
	rObj.style.height = 184-26;
	bObj.style.width = 245-29;
	hObj.style.height = 184-26;
	
}

function resize_border2(count)
{
	for(i = 0; i < count; i++)
	{
		var wObj = document.getElementById('img_t'+i);
		var lObj = document.getElementById('img_l'+i);
		var rObj = document.getElementById('img_r'+i);
		var bObj = document.getElementById('img_b'+i);
		var hObj = document.getElementById('img_height'+i);

		wObj.style.width = 75-19;
		lObj.style.height = 56-18;	
		rObj.style.height = 56-18;
		bObj.style.width = 75-19;
		hObj.style.height = 56;
	}
	
}


