function opener(fails, w, h) 
{
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	var settings ='height='+h+',';
	settings +='width='+w+',';
	settings +='top='+wint+',';
	settings +='left='+winl+',';
	settings +='scrollbars=no,';
	settings +='resizable=no';
	window.open(fails, '', settings);
}

function a(Dati)
{
	var Dati = 'Dati='+Dati;
	var G_POST_Adrese = '/ajax/';
	var Metode = 'POST';
	Adrese = G_POST_Adrese;
	xmlhttp = null;
	if (window.XMLHttpRequest)
	xmlhttp = new XMLHttpRequest;
	else if (window.ActiveXObject)
	xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.open(Metode, Adrese, false);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlhttp.onreadystatechange = function()
	{
		if (xmlhttp.readyState == 4)
		{
			if (xmlhttp.status == 200)
			{
				atbilde = null; 
				atbilde = xmlhttp.responseText;
			}
		}
	};
	xmlhttp.send(Dati);
	atbilde = null; 
	atbilde = xmlhttp.responseText;
}

function activeProject(nr, act)
{
	if(nr==null || nr=='') return;
	var d = document.getElementById('project_'+nr);
	var more_but = document.getElementById('more_but_'+nr);
	if(d==null) return;
	if(act == 'hide')
	{
		more_but.style.display = 'none';
		d.style.backgroundPosition = "0px -158px";
	}
	else
	{
		more_but.style.display = 'block';
		d.style.backgroundPosition = "0px 0px";
	}
}

function loadThumb(f, id,k)
{
	document.getElementById('largeImage').src = f;
	a('getImegeDescription|'+id);
	if(atbilde!=null && atbilde.length>0) document.getElementById('description').innerHTML = atbilde;
	else document.getElementById('description').innerHTML = '';
	curr_k = k;
}

function scrollUp()
{
	var step = 50;
	var sh = document.getElementById('thumb_field').scrollHeight;
	var ch = document.getElementById('thumb_field').clientHeight;
	if(document.getElementById('thumb_field').scrollTop>0 && sh>ch)
	{
		document.getElementById('thumb_field').scrollTop -= step;
	}
	scrollingControllBar();
}

function scrollDown()
{
	var step = 50;
	var sh = document.getElementById('thumb_field').scrollHeight;
	var ch = document.getElementById('thumb_field').clientHeight;
	if(document.getElementById('thumb_field').scrollTop<sh && sh>ch)
	{
		document.getElementById('thumb_field').scrollTop += step;
	}
	scrollingControllBar();
}

function scrollingControllBar()
{
	var sh = document.getElementById('thumb_field').scrollHeight;
	var ch = document.getElementById('thumb_field').clientHeight;
	var sp = document.getElementById('thumb_field').scrollTop;
	
	if(sp>0 && sh>ch)//aktiivs
	{
		document.getElementById('upButton').style.backgroundPosition = '-19px 0px';
	}
	else//neaktiivs
	{
		document.getElementById('upButton').style.backgroundPosition = '0px 0px';
	}

	if(sp<sh && ch<sh && sp+ch<sh)
	{
		document.getElementById('downButton').style.backgroundPosition = '-19px 0px';
	}
	else
	{
		document.getElementById('downButton').style.backgroundPosition = '0px 0px';
	}
}


function scrollBack()
{
	var step = 50;
	var sw = document.getElementById('panoramaField').scrollWidth;
	var cw = document.getElementById('panoramaField').clientWidth;
	if(document.getElementById('panoramaField').scrollLeft>0 && sw>cw)
	{
		document.getElementById('panoramaField').scrollLeft -= step;
	}
	scrollingPanoramaControllBar();
}

function scrollRight()
{
	var step = 50;
	var sw = document.getElementById('panoramaField').scrollWidth;
	var cw = document.getElementById('panoramaField').clientWidth;
	if(document.getElementById('panoramaField').scrollLeft<sw && sw>cw)
	{
		document.getElementById('panoramaField').scrollLeft += step;
	}
	scrollingPanoramaControllBar();
}

function scrollingPanoramaControllBar()
{
	var sw = document.getElementById('bilde1212').offsetWidth;
	var cw = document.getElementById('panoramaField').clientWidth;
	var sl = document.getElementById('panoramaField').scrollLeft;
	if(sl>0 && sw>cw)//aktiivs
	{
		document.getElementById('leftButton').style.backgroundPosition = '0px -19px';
	}
	else//neaktiivs
	{
		document.getElementById('leftButton').style.backgroundPosition = '0px 0px';
	}

	if(sl<sw && cw<sw && sl+cw<sw)
	{
		document.getElementById('rightButton').style.backgroundPosition = '0px -19px';
	}
	else
	{
		document.getElementById('rightButton').style.backgroundPosition = '0px 0px';
	}
}
