var is_ie6 = (navigator.userAgent.toLowerCase().indexOf("msie 6") > -1)?true:false;
var userAgent				= navigator.userAgent.toLowerCase();
var is_ie					= (userAgent.indexOf("msie") > -1)?true:false;
var site = null;
var siteleft = 0;
var sitetop = 0;

var scrollerMainText		= null;
var scrollerCount       = 0;
function setup_global()
{
	initialize();
}

function initialize()
{
    if(window.captureEvents){
		window.onmousemove=sourceCheck;
	} else {
		document.onmousemove=sourceCheck;
	}
	if (window.location.href.toLowerCase().indexOf("print.asp")  > -1 ) return;

	site = g("divSite");
	if (blnFirstRun) nextImage();
	reposition();
	setupLayout();
	setupContents();
	addPngFix();
}

function reposition()
{
	siteleft = ( pageWidth / 2)  - (site.offsetWidth / 2);
	sitetop  = ( pageHeight / 2) - (site.offsetHeight / 2) ; //- (boxbreadcrumb.offsetHeight / 2)
	site.style.left = ( (siteleft > 0)?siteleft :0 ) + "px";
	site.style.top  = ( (sitetop  > 0)?sitetop-2:0 ) + "px";
}

function addPngFix()
{
	if (navigator.userAgent.toLowerCase().indexOf("msie 7") > -1) return;
	pngimg = document.getElementsByTagName("img");
	for(var i = 0, len = pngimg.length; i < len; i++)
	{
		if (pngimg[i].src.toLowerCase().indexOf(".png") > -1)
		{
			pngimg[i].className += " overlay";
		}
	}
}

function createLine(X,Y,W,H,bgcolor,zindex,line_id)
{
	var line = null;
	var is_new_line = (document.getElementById(line_id) == null);
	if (is_new_line)
	{
		line = document.createElement("img");
		line.setAttribute("id", line_id);
		line.setAttribute("src", "gfx/space.gif");
		line.style.position = "absolute";
		document.body.appendChild(line);
	} else {
		line = document.getElementById(line_id);
	}
	line.style.left = ((X)?X:1) + "px";
	line.style.top = ((Y)?Y:1) + "px";
	line.style.width  = ((W)?W:1) + "px";
	line.style.height = ((H)?H:1) + "px";
	line.style.backgroundColor = ((bgcolor)?bgcolor:'#000000');
	if (zindex) line.style.zIndex = zindex;
}

function resValue(r0,r1,r2)
{
	if (jsres == 0)
	{
		return r0;
	} else {
		if (jsres == 1)
		{
			return r1;
		} else {
			return r2;
		}
	}
}

function setFocusInput(obj) { obj = (typeof(obj) == "string")?g(obj):obj; if (obj != null) obj.focus(); }

function right(obj) {  obj = (typeof(obj) == "string")?g(obj):obj; return rxpos(obj.id) + obj.offsetWidth; }

function bottom(obj) { obj = (typeof(obj) == "string")?g(obj):obj; return rypos(obj.id) + obj.offsetHeight; }

function centerVert(objToCenter, objCenterTo)
{
	objCenterTo = (typeof(objCenterTo) == "string")?g(objCenterTo):objCenterTo;
	objToCenter = (typeof(objToCenter) == "string")?g(objToCenter):objToCenter;
	return (rypos(objCenterTo.id) + objCenterTo.offsetHeight / 2) - (objToCenter.offsetHeight /2);
}

function centerHori(objToCenter,objCenterTo)
{
	objCenterTo = (typeof(objCenterTo) == "string")?g(objCenterTo):objCenterTo;
	objToCenter = (typeof(objToCenter) == "string")?g(objToCenter):objToCenter;
	return (rypos(objCenterTo.id) + objCenterTo.offsetWidth / 2) - (objToCenter.offsetWidht /2);
}

function setupLayout()
{
    g("divTopLogo").style.left = rxpos("divSite")+ 1 + "px";
	g("divTopLogo").style.top  = rypos("divSite")+ 1 + "px";
	
	g("divHomePrint").style.left = rxpos("divSite")+ 1 + g("divTopLogo").offsetWidth - g("divHomePrint").offsetWidth - crf * 10 + "px";
	g("divHomePrint").style.top  = rypos("divSite")+ 1 + crf * 5 + "px";
	
	g("divTopImages").style.left = rxpos("divSite")+ 1 + g("divTopLogo").offsetWidth + "px";
	g("divTopImages").style.top  = rypos("divSite")+ 1 + "px";
	
	g("divMenu1Background").style.left = rxpos("divSite")+ 1 + "px";
	g("divMenu1Background").style.top  = rypos("divSite")+ 1 + g("divTopLogo").offsetHeight + "px";
	
	g("divMenu1").style.left = rxpos("divSite") + crf*242 + 1 + "px"; //TODO...REDO OFFSET TO 3 HARDCODED VALUES.
	g("divMenu1").style.left = rxpos("divSite") + resValue(155,194,242) + 1 + "px";
	g("divMenu1").style.top  = rypos("divSite")+ 1 + 1+ g("divTopLogo").offsetHeight + "px";
	
	g("divMenu2").style.left = rxpos("divSite")+ 1 + "px";
	g("divMenu2").style.top  = rypos("divMenu1Background") + g("divMenu1Background").offsetHeight + "px";
	
	g("divBottomField").style.left = rxpos("divSite")+ 1 + "px";
	g("divBottomField").style.top  = rypos("divMenu2")+ g("divMenu2").offsetHeight + "px";
	
	g("divBottomFieldLeftText").style.left = rxpos("divBottomField") + 25 + "px";
	g("divBottomFieldLeftText").style.top = rypos("divBottomField") +1+ "px";
	
	g("divBottomFieldRightText").style.left = rxpos("divBottomField") + g("divBottomFieldLeftText").offsetWidth +"px";
	g("divBottomFieldRightText").style.top = rypos("divBottomField") +1+ "px";
	
	g("divContents").style.left = rxpos("divMenu2") + g("divMenu2").offsetWidth +"px";
	g("divContents").style.top = rypos("divMenu2") + "px";
}

function setupContents()
{
    /* TODO...*/
    switch(pageType)
    {
        case 0:
            /*Frontpage*/
            if(g("imgFullSizeImage"))
						{
            	g('imgFullSizeImage').style.left = 0 + "px";
            	g('imgFullSizeImage').style.top = 0 + "px";
            }
            
            if(g("imgFullSizeImageLeftArrow"))
						{            
	            var arrowsOffset = 5;
	            
	            g('imgFullSizeImageLeftArrow').style.left = crf * arrowsOffset + "px";
	            g('imgFullSizeImageLeftArrow').style.top = g('imgFullSizeImage').offsetHeight/2 - g('imgFullSizeImageLeftArrow').offsetHeight/2 + "px";
	            
	            g('imgFullSizeImageRightArrow').style.left = g('imgFullSizeImage').offsetWidth - g('imgFullSizeImageRightArrow').offsetWidth - (crf * arrowsOffset) + "px";
	            g('imgFullSizeImageRightArrow').style.top = g('imgFullSizeImage').offsetHeight/2 - g('imgFullSizeImageRightArrow').offsetHeight/2 + "px";
	          	
          	}
            
            
             if(g("divFlash"))
						{
            	g('divFlash').style.left = 0 + "px";
            	g('divFlash').style.top = 0 + "px";
            }           
            
            
            g('imgLogoBanner').style.left = crf * 209 + "px";
            g('imgLogoBanner').style.top = crf * 516 + "px";
        break;
        case 1:
            /*Article*/
            g('divTextFieldBackground').style.left = crf * 58 + "px";
            g('divTextFieldBackground').style.top = crf * 58 + "px";
            
            g('imgArticleImage').style.left = crf * 658 + "px";
            g('imgArticleImage').style.top = crf * 58 + "px";
            
            var leftBasePoint = crf * 658 + g('imgArticleImage').offsetWidth/2;
            g('imgArticleImageLeftArrow').style.left = leftBasePoint - g('imgArticleImageLeftArrow').offsetWidth - crf * 5 + "px";
            g('imgArticleImageLeftArrow').style.top = crf * 58 + g('imgArticleImage').offsetHeight + crf * 5 + "px";
            
            g('imgArticleImageRightArrow').style.left = leftBasePoint + g('imgArticleImageLeftArrow').offsetWidth + crf * 5 + "px";
            g('imgArticleImageRightArrow').style.top = crf * 58 + g('imgArticleImage').offsetHeight + crf * 5 + "px";
            
            //Setup textfield scrollbars
            setupScrollbars()
        break;
        case 2:
            /* Imageseries*/
            g('imgFullSizeImage').style.left = 0 + "px";
            g('imgFullSizeImage').style.top = 0 + "px";
            
            var arrowsOffset = 5;
            g('imgFullSizeImageLeftArrow').style.left = crf * arrowsOffset + "px";
            g('imgFullSizeImageLeftArrow').style.top = g('imgFullSizeImage').offsetHeight/2 - g('imgFullSizeImageLeftArrow').offsetHeight/2 + "px";
            
            g('imgFullSizeImageRightArrow').style.left = g('imgFullSizeImage').offsetWidth - g('imgFullSizeImageRightArrow').offsetWidth - (crf * arrowsOffset) + "px";
            g('imgFullSizeImageRightArrow').style.top = g('imgFullSizeImage').offsetHeight/2 - g('imgFullSizeImageRightArrow').offsetHeight/2 + "px";
            
			g("photoinfoOpen").style.display = "block";
			g('photoinfoOpen').style.left = rxpos('imgFullSizeImage') + g("imgFullSizeImage").offsetWidth - g("photoinfoOpen").offsetWidth - crf*0 + "px";
			g('photoinfoOpen').style.top = rypos('imgFullSizeImage') + g("imgFullSizeImage").offsetHeight - g("photoinfoOpen").offsetHeight + crf*0 + "px";
			
			showHideImageInfo();
			resizeTextDiv();
			
			if (blnFirstRun){
				g("photoinfoClose").style.display = "none";
				g("Imgtxt").style.display = "none";
			}
			
			applyOpacity("Imgtxt");
			applyOpacity("photoinfoClose");
			applyOpacity("photoinfoOpen");
        break;
        case 3:
            /*Image series with text and sub imagemenu2*/
            var offsetLeft = 0;
            var offsetTop = 65;
            g('divTextFieldBackground').style.left = crf * 58 + crf * offsetLeft + "px";
            g('divTextFieldBackground').style.top = crf * 18 + crf * offsetTop + "px";
            g('divTextFieldBackground').style.width = crf * 475 + "px";
            g('divTextFieldBackground').style.height = (crf * 416) - (offsetTop * crf) + (crf * 30) + "px";
            g('divTextFieldBackground').style.width =  (crf * 500) - (offsetLeft * crf) - (25 * crf) + "px";

            g('divTextField').style.width = g('divTextFieldBackground').style.width;

            g('divImageBackgroundField').style.left = crf * 582 + "px";
            g('divImageBackgroundField').style.top = crf * 18 + "px";
            
            g('divImageLeftBorder').style.left = crf * 582 + crf * 30 - 1 + "px";
            g('divImageLeftBorder').style.top = (crf * 18) + 1 + "px";
            g('divImageLeftBorder').style.height = g('divImageBackgroundField').style.height;
            
            g('divImageRightBorder').style.left = crf * 582 + g('divImageBackgroundField').offsetWidth - crf * 30 - 1 + "px";
            g('divImageRightBorder').style.top = (crf * 18) + 1 + "px";
            g('divImageRightBorder').style.height = g('divImageBackgroundField').style.height;
                     
            g('imgLeftArrow').style.left = crf * 582 + crf * 30 - crf * 5 - g('imgLeftArrow').offsetWidth + "px";
            g('imgLeftArrow').style.top = crf * 18 + g('divImageBackgroundField').offsetHeight/2 - g('imgLeftArrow').offsetHeight/2 + "px";
            
            g('imgRightArrow').style.left = crf * 582 + g('divImageBackgroundField').offsetWidth - crf * 30 + crf * 5 + "px";
            g('imgRightArrow').style.top = crf * 18 + g('divImageBackgroundField').offsetHeight/2 - g('imgRightArrow').offsetHeight/2 + "px";
            
            g('imgActiveImagelistImage').style.left = crf * 582 + crf * 30 + "px";
            g('imgActiveImagelistImage').style.top = (crf * 18) + 1 + "px";
            
            g('divImageMenu2Background').style.left = crf * 58 + "px";
            g('divImageMenu2Background').style.top = (crf * 486) + "px";
            
            g('imgImageMenu2LeftArrow').style.left = crf * 58 + (crf * 30) - (crf * 5) - g('imgImageMenu2LeftArrow').offsetWidth + "px";
            g('imgImageMenu2LeftArrow').style.top = (crf * 486) + (crf * 158)/2 - g('imgImageMenu2LeftArrow').offsetHeight/2 + "px";
            
            g('divImageMenu2Container').style.left =(crf * 30) + "px";
            g('divImageMenu2Container').style.top = 0 + "px";
            
            g('imgImageMenu2RightArrow').style.left = crf * 58 + (crf * 30) + (crf * 1190) + (crf * 5) + "px";
            g('imgImageMenu2RightArrow').style.top = (crf * 486) + (crf * 158)/2 - g('imgImageMenu2RightArrow').offsetHeight/2 + "px";          
            
            g('divImageMenuLeftBorder').style.left = crf * 58 + (crf * 30) + "px";
            g('divImageMenuLeftBorder').style.top = (crf * 486) + 1 + "px";
            g('divImageMenuLeftBorder').style.height = g('divImageMenu2Container').style.height;
            
            g('divImageMenuRightBorder').style.left = crf * 58 + (crf * 30) + (crf * 1190) + "px";
            g('divImageMenuRightBorder').style.top = (crf * 486) + 1 + "px";
            g('divImageMenuRightBorder').style.height = g('divImageMenu2Container').style.height;
                
            //Setup textfield scrollbars
            setupScrollbars()
            
            //Load menupage if needed
            LoadImageMenuPage();
        break;
        case 4:
            /* Contact*/
            g('divTextFieldBackground').style.height = g('divContents').offsetHeight - crf * 58 + "px";
            g('divTextFieldBackground').style.width = g('divContents').offsetWidth - crf * 58 - crf * 50 +  "px";
            g('divTextFieldBackground').style.left = crf * 58 + "px";
            g('divTextFieldBackground').style.top = crf * 58 + "px";
            
            g('divTextField').style.width = g('divTextFieldBackground').style.width;
            
            //Setup textfield scrollbars
            setupScrollbars()
        break;
        case 5:
            /* Imageshow*/
            g('imgFullSizeImage').style.left = 0  + "px";
            g('imgFullSizeImage').style.top = 0  + "px";
            
            startImageShow('imgFullSizeImage');
        break;
    }//switch
}

/* Functions for rolling */
function rollLeft(containerId, scrollerId) {
    imgrow = document.getElementById(scrollerId);
    scrollframe = document.getElementById(containerId);
    scroll(1);
}
function rollRight(containerId, scrollerId) {
    imgrow = document.getElementById(scrollerId);
    scrollframe = document.getElementById(containerId);
    scroll(-1);
}
function stopRoll() {
    speed(1);
    clearInterval(timer);	
}

var timer;
var retning;
var speedy=1;
var imgrow;
var scrollframe;
function scroll(ret) {
		retning=parseInt(ret);
		//status=retning;
		timer=setInterval('Doooscroll()',10);	
	}
function Doooscroll() {	
	inW=parseInt(imgrow.offsetWidth);
	outW=parseInt(scrollframe.offsetWidth);
	
	//alert(imgrow.offsetHeight);
	
	diff=inW-outW;
	//status=diff;
	if((retning >0) && (parseInt(imgrow.style.left)>=1-speedy)){		
	    stopRoll();
	    status = "diff=" + diff;
	}else if((retning <0) && (parseInt(imgrow.style.left)<=-diff+speedy)){
	    stopRoll();	
	    status = "diff=" + diff;
    }else{
	    imgrow.style.left=parseInt(imgrow.style.left)+(speedy*1*retning)+'px';	
	    status = "diff=" + diff;
	}	
}	
function speed(tempo) {
	speedy=tempo;
	status = speedy;	
	}


/* Function for image change on mouse over*/
function changeImage(elementId, newImageScr){
    document.getElementById(elementId).src = newImageScr;
}

var imageListIndex = 0;
var imageListImages = "";

function nextImageListImage(elementId){
    var localImageSrcList = imageListImages.substring(0, imageListImages.length -1);
    var imageSrcArray = new Array();
    imageSrcArray = localImageSrcList.split(',');

    if(imageListIndex < imageSrcArray.length - 1)
    {
        imageListIndex = imageListIndex + 1;
        document.getElementById(elementId).src = imageSrcArray[imageListIndex];
        
        //Set image text
        var textArray = imageListTexts.split("',");
        
        if(textArray.length > imageListIndex)
            g("Imgtxt").innerHTML = textArray[imageListIndex].substring(1, textArray[imageListIndex].length -2); 
	    
	    showHideImageInfo();
	    resizeTextDiv();
    }//if
}

function previousImageListImage(elementId){
    var localImageSrcList = imageListImages.substring(0, imageListImages.length -1);
    var imageSrcArray = new Array();
    imageSrcArray = localImageSrcList.split(',');

    if(imageListIndex > 0)
    {
        imageListIndex = imageListIndex - 1;
        document.getElementById(elementId).src = imageSrcArray[imageListIndex];
        
        //Set image text
        var textArray = imageListTexts.split("',");
        
        if(textArray.length > imageListIndex)
            g("Imgtxt").innerHTML = textArray[imageListIndex].substring(1, textArray[imageListIndex].length -2);
	    
	    showHideImageInfo();
	    resizeTextDiv();
    }//if
}

function link(path){
window.location = path;
}

function fakePostBack(_url, callerId){
    /*
    if (document.getElementById("ifrm") != null) {
        document.getElementById("ifrm").setAttribute("src", "nopostback_handler.asp?" + url + "&res=" + jsres);
    }
    
    //Update selected image
    var childNodeArray = document.getElementById('divImageMenu2Scroller').childNodes;
    for(var i = 0; i < childNodeArray.length; i++)
    {
        if(childNodeArray[i].id == callerId)
            childNodeArray[i].className = "aSelectedImageLink";
        else
            childNodeArray[i].className = "aImageLink";
    }
*/

	

	window.location.href = "index.asp?" + _url + "#" + callerId.split("_")[2];
    return false;
}

String.prototype.endsWith = function(str)
{
    return (this.match(str+"$")==str)
}

function LoadImageMenuPage(){
    //Check hash
    if(window.location.hash.replace("#", "").length > 0){
        var pageId = window.location.hash.replace("#", "");
        var childNodeArray = document.getElementById('divImageMenu2Scroller').childNodes;
        for(var i = 0; i < childNodeArray.length; i++)
        {
            if(childNodeArray[i].id.endsWith("_" + pageId))
            {
                childNodeArray[i].className = "aSelectedImageLink";
                var linkPath = childNodeArray[i].href;
                var params = linkPath.substring(linkPath.indexOf("?") +1);
                if (document.getElementById("ifrm") != null)
                    document.getElementById("ifrm").setAttribute("src", "nopostback_handler.asp?" + params + "&res=" + jsres +""+ window.location.hash);
                    
               //Srcoll imagemenu
               if( rxpos(childNodeArray[i].id) > g('divImageMenu2Container').offsetWidth)
               {
                    g('divImageMenu2Scroller').style.left = 0 - (rxpos(childNodeArray[i].id) - g('divImageMenu2Container').offsetWidth - rxpos('divImageMenu2Container') + g(childNodeArray[i].id).offsetWidth ) + "px";
               }
            }//if
            else
            {
                childNodeArray[i].className = "aImageLink";
            }//else
        }//for
    }//if
}//LoadImageMenuPage

function showHideImageScrollArrows(){
    var localImageSrcList = imageListImages.substring(0, imageListImages.length -1);
    var imageSrcArray = new Array();
    imageSrcArray = localImageSrcList.split(',');
    if(imageListImages.length > 0){
        g('imgArticleImage').style.visibility='visible';
      if(g("imgFullSizeImage"))
			{        
        g('imgFullSizeImage').style.visibility='visible';
      }
    }
    else{
        g('imgArticleImage').style.visibility='hidden';
      if(g("imgFullSizeImage"))
			{        
        g('imgFullSizeImage').style.visibility='hidden';
      }
    }    
        
    if(imageSrcArray.length > 1)
    {
        //Show next/previous arrow
        g('imgArticleImageLeftArrow').style.visibility='visible';
        g('imgArticleImageRightArrow').style.visibility='visible';
        
        if(g("imgFullSizeImageLeftArrow"))
				{
        g('imgFullSizeImageLeftArrow').style.visibility='visible';
        g('imgFullSizeImageRightArrow').style.visibility='visible';
        }
        
        g('imgLeftArrow').style.visibility='visible';
        g('imgRightArrow').style.visibility='visible';
    }
    else
    {
        //Hide next/previous arrow
        g('imgArticleImageLeftArrow').style.visibility='hidden';
        g('imgArticleImageRightArrow').style.visibility='hidden';
        if(g("imgFullSizeImageLeftArrow"))
						{
        	g('imgFullSizeImageLeftArrow').style.visibility='hidden';
        	g('imgFullSizeImageRightArrow').style.visibility='hidden';
      	}
        g('imgLeftArrow').style.visibility='hidden';
        g('imgRightArrow').style.visibility='hidden';
    }
}

function showHideTextScrollArrows(containerId, scrollerId, arrowContainerId){
    if (document.getElementById(containerId) != null && document.getElementById(scrollerId) != null && document.getElementById(arrowContainerId) != null)
    {
        if(document.getElementById(containerId).offsetHeight < document.getElementById(scrollerId).offsetHeight)
        {
            showdiv(arrowContainerId);
        }//if
        else
        {
            hidediv(arrowContainerId);
        }//else
    }//if
}//

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

var imageShowPointer = 0;
var imageShowMaxCount = 0;
function startImageShow(imageElement){
    //init
    imageShowPointer = 0;
    imageShowMaxCount = imageListImages.substring(0, imageListImages.length -1).split(',').length;
    
    setInterval('imageshowNextImage('+imageElement +')',4000);
}

function imageshowNextImage(imageElement){
    if(imageShowPointer < imageShowMaxCount - 1)
        imageShowPointer++;
    else
        imageShowPointer = 0;
        
    var nextImage = imageListImages.substring(0, imageListImages.length -1).split(',')[imageShowPointer];
    
    imageElement.src = nextImage;
}

function setupScrollbars()
{
	if (blnHideScrollbars != 0) return;
	
	intSpace = -1;
	if (is_ie) intSpace = 0;

	if (
	
			   g("divTextFieldBackground")
			&& g("divTextField")
			&& g("divScrollbarMainText")
			&& g("divScrollSliderMainText")
			&& g("imgArrowScrolbarMainTextUp")
			&& g("imgArrowScrolbarMainTextDown")
		)
	{
		if (g("divTextFieldBackground").offsetHeight >= g("divTextField").offsetHeight)
		{
			// hide scrollbar
			g("divScrollbarMainText").style.display         = "none";
			g("divScrollSliderMainText").style.display      = "none";
			g("imgArrowScrolbarMainTextUp").style.display   = "none";
			g("imgArrowScrolbarMainTextDown").style.display = "none";
		} else {
		
			// setup scrollbar
			g("divScrollbarMainText").style.display         = "block";
			g("divScrollSliderMainText").style.display      = "block";
			g("imgArrowScrolbarMainTextUp").style.display   = "block";
			g("imgArrowScrolbarMainTextDown").style.display = "block";

			g("imgArrowScrolbarMainTextUp").style.left = right("divTextFieldBackground") + crf*15 + "px";
			g("imgArrowScrolbarMainTextUp").style.top  = top("divTextFieldBackground") + "px";

			g("imgArrowScrolbarMainTextDown").style.left = left("imgArrowScrolbarMainTextUp") + "px";
			g("imgArrowScrolbarMainTextDown").style.top  = bottom("divTextFieldBackground") - g("imgArrowScrolbarMainTextDown").offsetHeight + "px";


			g("divScrollbarMainText").style.left   = rxpos("imgArrowScrolbarMainTextUp") + g("imgArrowScrolbarMainTextUp").offsetWidth/2 + intSpace + "px";
			g("divScrollbarMainText").style.top    = bottom("imgArrowScrolbarMainTextUp") + crf*10 + "px";
			g("divScrollbarMainText").style.height = top("imgArrowScrolbarMainTextDown") - bottom("imgArrowScrolbarMainTextUp") - crf*10*2 + "px";

            
    
			if (blnHideScrollbars == 0)
			{
			    if (scrollerMainText == null)
			    {
				    scrollerMainText = new textScroller(scrollerCount++);
			    }
			    scrollerMainText = new textScroller(scrollerCount++);
			    scrollerMainText.masterobj = 'divTextFieldBackground';
			    scrollerMainText.scrollerobj = 'divTextField';
			    scrollerMainText.scrollbar = 'divScrollbarMainText';
			    scrollerMainText.arrowobj = 'divScrollSliderMainText'; //fake shit
			    scrollerMainText.scrollslider = 'divScrollSliderMainText';
			    scrollerMainText.prepare();
			}
		}
	}
}

function printPage()
{
    window.open("print.asp?page=" + pageId + "&vpath=" + vpath, "Print")
}

//********** show/hide imagetext
var lukstateimg=2;
function toggleImgTxt() {	
	if (lukstateimg == 1) {
		lukstateimg=2;	
		g("Imgtxt").style.display = "none";
		g("photoinfoClose").style.display = "none";
		g("photoinfoOpen").style.display = "block";
	}else{		
		lukstateimg=1;		
		g("Imgtxt").style.display = "block";
		g("photoinfoClose").style.display = "block";
		g("photoinfoOpen").style.display = "none";		
		//g('Imgtxt').style.top = rypos('photoinfo') - g("Imgtxt").offsetHeight + g("photoinfo").offsetHeight - p(jsRF * 1) + "px";
	}
	
	showHideImageInfo();
	resizeTextDiv();
}

function resizeTextDiv(){
    if (g("Imgtxt").style.display != "none")
    {
        /*g("Imgtxt").style.width = crf * 400 + "px";
        alert(g("Imgtxt").offsetHeight + " ¤ " + g("imgFullSizeImage").offsetHeight/2);
        if(g("Imgtxt").offsetHeight > g("imgFullSizeImage").offsetHeight/2 - crf*25 - g("photoinfoClose").offsetHeight){
            alert("TOO HIGH!");
            g("Imgtxt").style.height = g("imgFullSizeImage").offsetHeight/2 - crf*25 - g("photoinfoClose").offsetHeight + "px";
            g("Imgtxt").style.width = "auto";
        }//if*/
        
        g('Imgtxt').style.left = rxpos('imgFullSizeImage') + g("imgFullSizeImage").offsetWidth - g("Imgtxt").offsetWidth +"px";//- crf*0 + "px";
        g('Imgtxt').style.top = rypos('imgFullSizeImage') + g("imgFullSizeImage").offsetHeight - g("Imgtxt").offsetHeight + crf*0 + "px";
    }

    if (g("photoinfoClose").style.display != "none")
    {		
        //g("photoinfoClose").style.height = crf*15 + "px";
        g('photoinfoClose').style.left = rxpos('imgFullSizeImage') + g("imgFullSizeImage").offsetWidth - g("photoinfoClose").offsetWidth - crf*0 + "px";
        g('photoinfoClose').style.top = rypos('Imgtxt') - g("photoinfoClose").offsetHeight + 1 + "px";
    }
}

function applyOpacity(elementId){
    g(elementId).style.MozOpacity  = 0.7;
    g(elementId).style.filter = "alpha(opacity=70);";
}

function showHideImageInfo(){
    //Check for empty text
    /*var imageText = g("Imgtxt").innerHTML;
    if(trim(imageText.replace("<br>","").replace("</br>","").replace("<BR>","").replace("</BR>","")).length == 0){
        g("Imgtxt").style.display = "none";
		g("photoinfoClose").style.display = "none";
		g("photoinfoOpen").style.display = "none";
		alert("HIDE");		
    }//if
    else
    {
        if (lukstateimg == 1) {
		    g("Imgtxt").style.display = "none";
		    g("photoinfoClose").style.display = "none";
		    g("photoinfoOpen").style.display = "block";
	    }else{			
		    g("Imgtxt").style.display = "block";
		    g("photoinfoClose").style.display = "block";
		    g("photoinfoOpen").style.display = "none";		
		    //g('Imgtxt').style.top = rypos('photoinfo') - g("Imgtxt").offsetHeight + g("photoinfo").offsetHeight - p(jsRF * 1) + "px";
	    }
        alert("SHOW");	
    }//else*/
}
