﻿var ie5, ie7;
var ns6;
var blnFirstRun = false;
var blnIsPositioning = false;
var strLastTab = "tab8";


function startup() {
	ie5=document.all&&document.getElementById&&!window.XMLHttpRequest;
	ns6=document.getElementById&&!document.all;
	ie7=document.all&&document.getElementById&&window.XMLHttpRequest;
}

function delayPositionThings() {
	
	if(blnIsPositioning) { 
		return; 
	} else {
		blnIsPositioning = true;
	}
	setTimeout("positionThings()", 750);
}

function positionThings() {
	
	var pageSize = getPageSize();
	var pageHeight = (ie5 ? pageSize[1] : pageSize[3]);
	var objRel = (intCompanyId==8 ? g("imgTopTabRight") : g("imgTopRedCorner"));

	// *** center the main div to screen
	g("divMain").style.left = p((pageSize[0] - g("divMain").offsetWidth) / 2) + "px";
	if(p(g("divMain").style.left) < 0)
		g("divMain").style.left = "0px";
		
	if(p((pageHeight - g("divMain").offsetHeight) / 2) < 0 ) {
		g("divMain").style.top = "0px";
	} else {
		g("divMain").style.top = p((pageHeight - g("divMain").offsetHeight) / 2) + "px";
	}


		//**************** 29-09-2009 11:40
		
		if(g("divCompanyAddressbottom") ) {
			// venstrestillet:
			//g("divCompanyAddressbottom").style.left = rxpos("divMain") + p(crf*0) + "px"; 
			// højrestillet:
			g("divCompanyAddressbottom").style.left = rxpos("divMain")+ g("divMain").offsetWidth - g("divCompanyAddressbottom").offsetWidth + p(crf*0) + "px";
			g("divCompanyAddressbottom").style.top = rypos("divMain") + p(crf*562) + "px";
		}
		//****************	

	
	// *** place IAT Group (with the "Group" text) at the top left of layout
	g("imgLogo").style.left = rxpos("divMain") + p(crf*20) + "px";
	g("imgLogo").style.top = rypos("divMain") + p(crf*9) + "px";
	
	positionTabs()
	
	var intTotalTabWidth = (rxpos(strLastTab) + g(strLastTab).offsetWidth) - rxpos("tab1") + g("imgTopTabRight").offsetWidth;
	
	// *** position the image behind the tabs
	if(intCompanyId > 0) {
		g("divTabBgImage").style.left = rxpos("tab1") + (jsres == 2 ? 2 : 0) + 1 + "px";
		g("divTabBgImage").style.top = rypos("tab1") + p(jsres) + "px";
		g("divTabBgImage").style.height = g("tab1").offsetHeight - 2 + "px"; 		//g("divTabBgImage").style.width = intTotalTabWidth + "px";
		colorizeTab(intCompanyId);
	}
	
		
	
	
	// *** place the red corner (top right) below the tabs
	g("imgTopRedCorner").style.left = rxpos("imgTopTabRight") + g("imgTopTabRight").offsetWidth - g("imgTopRedCorner").offsetWidth + "px";
	g("imgTopRedCorner").style.top = rypos(strLastTab) + g(strLastTab).offsetHeight - 1 + "px";
	
	// *** place the red corder (bottom right) at a given distance from top
	g("imgBottomRedCorner").style.left = rxposObj(objRel) + objRel.offsetWidth - g("imgBottomRedCorner").offsetWidth + "px";
	g("imgBottomRedCorner").style.top = rypos("imgTopTabRight") + g("imgTopTabRight").offsetHeight + p(crf*459) + "px";
	
	// *** if companyId is zero, meaning we're at the front page, then position red lines and hide then tab background image
	if(intCompanyId==0) {
		g("imgRedLineTop2").style.display = "none";
		g("imgRedLineTop1").style.left = rxpos("tab1") + "px";
		g("imgRedLineTop1").style.top = g("imgTopRedCorner").style.top;
		g("imgRedLineTop1").style.height = g("imgRedLineTop1").offsetHeight + "px";
		g("imgRedLineTop1").style.width = rxpos("imgTopRedCorner") - rxpos("tab1") + "px";
		g("divTabBgImage").style.display = "none";
		// *** if companyId is eight (the last one) then alter the last tab image and position red lines
	} else if (intCompanyId==8) {
		g("imgRedLineTop2").style.display = "none";
		g("imgRedLineTop1").style.left = rxpos("tab1") + "px";
		g("imgRedLineTop1").style.top = g("imgTopRedCorner").style.top;
		g("imgRedLineTop1").style.height = g("imgRedLineTop1").offsetHeight + "px";
		g("imgRedLineTop1").style.width = rxpos("tab8") - rxpos("tab1") + "px";
		g("imgTopRedCorner").style.display = "none";
		g("imgRedTopTab").src = "img/top_tab_red_right_" + jsres + ".png";
		// *** if companyId is > 0 and < 8 then wrap the top red lines around the selected tab
	} else {
		g("imgRedLineTop1").style.left = rxpos("tab1") + "px";
		g("imgRedLineTop1").style.top = p(g("imgTopRedCorner").style.top) + (jsres==0 ? 1 : 0) + "px";
		g("imgRedLineTop1").style.height = g("imgRedLineTop1").offsetHeight + "px";
		g("imgRedLineTop1").style.width = rxpos("tab" + intCompanyId) - rxpos("tab1") + "px";
		
		g("imgRedLineTop2").style.left = rxpos("tab" + intCompanyId) + g("tab" + intCompanyId).offsetWidth - 2 + "px";
		g("imgRedLineTop2").style.top = g("imgTopRedCorner").style.top;
		g("imgRedLineTop2").style.height = g("imgRedLineTop2").offsetHeight + "px";
		g("imgRedLineTop2").style.width = rxpos("tab8") + g("tab8").offsetWidth - rxpos("tab" + intCompanyId) - g("tab" + intCompanyId).offsetWidth + g("imgTopTabRight").offsetWidth - g("imgTopRedCorner").offsetWidth - (ie5&&jsres==2 ? 4 : 0) + "px";
	}
	// *** if companyId is different from zero position the red "selected tab" on top of the selected tab
	if(intCompanyId!=0) {
		g("imgRedTopTab").style.left = rxpos("tab" + intCompanyId) + "px";
		g("imgRedTopTab").style.top = rypos("tab" + intCompanyId) + "px";
	}
	// *** place the red lines around the main contents area
		g("imgRedLineRight").style.left = rxposObj(objRel) + objRel.offsetWidth - g("imgRedLineRight").offsetWidth + "px";
		g("imgRedLineRight").style.top = ryposObj(objRel) + objRel.offsetHeight - (jsres==2?1:0)+ "px";
		g("imgRedLineRight").style.width = g("imgRedLineRight").offsetWidth + "px";
		g("imgRedLineRight").style.height = rypos("imgBottomRedCorner") - ryposObj(objRel) - objRel.offsetHeight + (jsres==2?1:0) + "px";

		g("imgRedLineLeft").style.left = rxpos("tab1") - (jsres==1 ? 0 : 1) + "px";
		g("imgRedLineLeft").style.top = rypos("tab1") + g("tab1").offsetHeight + "px";
		g("imgRedLineLeft").style.width = g("imgRedLineLeft").offsetWidth + "px";
		g("imgRedLineLeft").style.height = rypos("imgBottomRedCorner") - rypos("tab1") - g("tab1").offsetHeight + g("imgBottomRedCorner").offsetHeight - 1 - jsres + (jsres==2?1:0) +  "px";

		g("imgRedLineBottom").style.height = g("imgRedLineBottom").offsetHeight + "px";
		g("imgRedLineBottom").style.left = rxpos("imgRedLineLeft") + (jsres==0 ? 1 : 0) + "px";
		g("imgRedLineBottom").style.top = rypos("imgRedLineLeft") + g("imgRedLineLeft").offsetHeight + "px";
		g("imgRedLineBottom").style.width = rxpos("imgBottomRedCorner") - rxpos("imgRedLineBottom") + "px";
		
		// *** position and resize the white background
		g("divWhiteBackground").style.left = rxpos("imgRedLineLeft") + 1 + "px";
		g("divWhiteBackground").style.top = rypos("imgRedLineLeft") + 2 + "px";
		g("divWhiteBackground").style.width = rxpos("imgRedLineRight") - rxpos("imgRedLineLeft") + "px";
		g("divWhiteBackground").style.height = rypos("imgRedLineBottom") - rypos("imgRedLineTop1") - 3 + "px";
		// / white background
		
		// *** if companyId > zero then place the middle red divider line with a corner on bottom
		if(intCompanyId!=0) {
			g("imgRedDivider").style.width = g("imgRedDivider").offsetWidth + "px";
			g("imgRedDivider").style.top = rypos("divTabBgImage") + p(crf*100) + "px";
			g("imgCornerDivider").style.left = rxpos("imgRedLineLeft") + p(crf*600) + "px";
			g("imgRedDivider").style.left = rxpos("imgCornerDivider") + g("imgCornerDivider").offsetWidth - g("imgRedDivider").offsetWidth + "px";
			// *** If resolution is 1600 move then divider corner slightly to the left
			if(jsres==2) {
				g("imgCornerDivider").style.left = p(g("imgCornerDivider").style.left) - 1 + "px";
			}
			g("imgCornerDivider").style.top = g("imgBottomRedCorner").style.top;
			g("imgRedDivider").style.height = rypos("imgCornerDivider") - p(g("imgRedDivider").style.top) + "px";
			// / divider
			
			// *** position and resize the main contents image
			g("divContentsImage").style.left = rxpos("divWhiteBackground") + 1 + "px";
			g("divContentsImage").style.top = rypos("imgRedDivider") + "px";
			g("divContentsImage").style.width = rxpos("imgRedDivider") - rxpos("divWhiteBackground") - 1 + (jsres==2 ? 1 : 0) + "px";
			g("divContentsImage").style.height = rypos("imgRedLineBottom") - rypos("imgRedDivider") - p(crf*25) + "px";
		} else {
			// *** if companyId is in fact zero, then resize then main contents image to fill the entire area (except from top and bottom margins).
			
			g("divContentsImage").style.left = rxpos("imgRedLineLeft") + g("imgRedLineLeft").offsetWidth + "px";
			g("divContentsImage").style.top = rypos("imgRedLineTop1") + p(crf*26) + "px";
			g("divContentsImage").style.width = rxpos("imgRedLineRight") - rxpos("imgRedLineLeft") - g("imgRedLineLeft").offsetWidth + "px";
			g("divContentsImage").style.height = rypos("imgRedLineBottom") - rypos("divContentsImage") - p(crf*24) + "px";
			
			//alert("intJsDoFlash: " + intJsDoFlash)
			if(intJsDoFlash == 1) {
				//alert("intJsDoFlash: " + intJsDoFlash)
				g("divContentsFlash").style.left = rxpos("imgRedLineLeft") + g("imgRedLineLeft").offsetWidth + "px";
				g("divContentsFlash").style.top = rypos("imgRedLineTop1") + p(crf*26) + "px";
				
				//g("divContentsFlash").style.width = g("divContentsImage").offsetWidth + "px";
				//g("divContentsFlash").style.height = g("divContentsImage").offsetHeight + "px";
				

				g("divContentsFlash").style.width = p(crf*817) + "px";
				g("divContentsFlash").style.height = p(crf*426) + "px";
								
				g("divContentsImage").style.display = "none";	
				g("imgGalleryRight").style.display = "none";	
				g("imgGalleryLeft").style.display = "none";	
			} else {
				g("divContentsFlash").style.display = "none";		
			}
			

			
			
		}
		
		// contents & shit
		// *** if large contents area has been chosen resize the main background and documentContainers
		if(blnIsLargeTextArea) {
			g("divMasterBg").style.left = rxpos("divWhiteBackground") + 1 + "px";
			g("divMasterBg").style.top = rypos("imgRedDivider") + "px";
			g("divMasterBg").style.width = g("divContentsImage").offsetWidth + 0 + "px";
			g("divMasterBg").style.height = rypos("imgRedLineBottom") - rypos("divMasterBg") - p(crf*25) + "px";
		} else {
			g("divMasterBg").style.left = rxpos("divWhiteBackground") + 1 + "px";
			g("divMasterBg").style.top = rypos("imgRedDivider") + p(crf*241) + "px";
			g("divMasterBg").style.width = g("divContentsImage").offsetWidth + 0 + "px";
			g("divMasterBg").style.height = rypos("imgRedLineBottom") - rypos("divMasterBg") - p(crf*25) + "px";
		}
		g("divMasterContainer1").style.left = rxpos("divMasterBg") + "px";
		g("divMasterContainer1").style.top = rypos("divMasterBg") + "px";
		if(g("divMasterBg").offsetHeight > 0 && g("divMasterBg").offsetWidth) {
			g("divMasterContainer1").style.height = g("divMasterBg").offsetHeight - p(crf*6) + "px";
			g("divMasterContainer1").style.width = g("divMasterBg").offsetWidth + "px";
			g("divDocumentContainer1").style.width = g("divMasterBg").offsetWidth - p(crf*30) + "px";
		}
		// / contents & shit
		
		// icons & arrows
		if(intCompanyId!=0) {
			// *** if companyid > zero position the icons on the bottom and the background image browse arrows on the top right
			// *** also place the logo of the firma currently being viewed
			g("divIcon").style.left = rxpos("imgRedDivider") - g("divIcon").offsetWidth - p(crf*3) + "px";
			g("divIcon").style.top = rypos("divWhiteBackground") + g("divWhiteBackground").offsetHeight - g("divIcon").offsetHeight - p(crf*3) + "px";
			
			g("imgGalleryRight").style.left = rxpos("divContentsImage") + g("divContentsImage").offsetWidth - g("imgGalleryRight").offsetWidth - p(crf*10) + "px";
			g("imgGalleryRight").style.top = rypos("divContentsImage") + p(crf*10) + "px";
			g("imgGalleryLeft").style.left = rxpos("imgGalleryRight") - g("imgGalleryLeft").offsetWidth - p(crf*10) + "px";
			g("imgGalleryLeft").style.top = g("imgGalleryRight").style.top;
			
			// logo
				g("imgLogoCompany").style.left = rxpos("tab8") + g("tab8").offsetWidth - g("imgLogoCompany").offsetWidth - p(crf*10) + "px";
				var intLogoCompanyTop = (rypos("divTabBgImage") + g("divTabBgImage").offsetHeight) - p(crf*61/2) - p(g("imgLogoCompany").offsetHeight / 2);
				intLogoCompanyTop = rypos("imgRedDivider") - p(crf*40) - p(g("imgLogoCompany").offsetHeight / 2);
				g("imgLogoCompany").style.top = intLogoCompanyTop + "px";
			// / logo
		} else {
			// *** if company is zero then hide the icons and position the browse arrows according to the background image (which is now large)
			g("divIcon").style.display = "none";
			g("imgGalleryRight").style.left = rxpos("divWhiteBackground") + g("divWhiteBackground").offsetWidth - g("imgGalleryRight").offsetWidth - p(crf*10) + "px";
			g("imgGalleryRight").style.top = rypos("divWhiteBackground") + p(crf*24) + "px";
			g("imgGalleryLeft").style.left = rxpos("imgGalleryRight") - g("imgGalleryLeft").offsetWidth - p(crf*10) + "px";
			g("imgGalleryLeft").style.top = g("imgGalleryRight").style.top;
		}
		// / icons & arrows
		
		// *** position the left hand menu and the language selection flags
		g("divMenu").style.left = rxpos("imgRedLineLeft") - g("divMenu").offsetWidth + "px";
		g("divMenu").style.top = rypos("imgRedLineTop1") + p(crf*72) + "px";
		
		g("divFlags").style.left = rxpos("divMenu") + g("divMenu").offsetWidth - g("divFlags").offsetWidth - p(crf*15) + "px";
		g("divFlags").style.top = rypos("divWhiteBackground") + g("divWhiteBackground").offsetHeight - g("divFlags").offsetHeight + "px";
		// / menu, language flags
		
		// *** prep the background images for browsing
		if(!blnFirstRun) {
			if(typeof(arrPageImages) == "undefined") {
				g("imgGalleryLeft").style.display = "none";
				g("imgGalleryRight").style.display = "none";
			} else {
				 if(arrPageImages.length < 2) {
						g("imgGalleryLeft").style.display = "none";
						g("imgGalleryRight").style.display = "none";
						if(arrPageImages.length==1) {
							nextImage();
						}
				} else {
					nextImage();
				}
			}
		}
	// *** position the menu at the bottom left belonging to the group thingy
		if(g("divBottomLeftMenu")) {
			g("divBottomLeftMenu").style.left = rxpos("divMenu") + g("divMenu").offsetWidth - g("divBottomLeftMenu").offsetWidth + "px";
			g("divBottomLeftMenu").style.top = rypos("divFlags") - g("divBottomLeftMenu").offsetHeight - p(crf*20) + "px";
		}
	// / bottom left menu
	
	// *** 	if companyid is zero then hide the scroll arrows and the document containers background
	if(intCompanyId==0) {
		//alert('test');
		if(g("divScrollArrows")){
		g("divScrollArrows").style.display = "none";
		}
		g("divMasterBg").style.display = "none";
	}	

	if(intSpe > 0) {
		
		
		g("divMasterContainer1").style.width = p(crf*500) + "px";
		g("divMasterContainer1").style.height = p(crf*300) + "px";
		g("divDocumentContainer1").style.width = p(g("divMasterContainer1").style.width) - p(crf*30) + "px";
		g("divMasterBg").style.width = g("divMasterContainer1").style.width;
		g("divMasterBg").style.height = g("divMasterContainer1").style.height;
		
		
		g("divMasterContainer1").style.left = rxpos("divWhiteBackground") + p(g("divWhiteBackground").offsetWidth / 2) - p(g("divMasterContainer1").offsetWidth / 2) + "px";
		g("divMasterContainer1").style.top = rypos("divWhiteBackground") + p(g("divWhiteBackground").offsetHeight / 2) - p(g("divMasterContainer1").offsetHeight / 2) + "px";
		
		g("divMasterBg").style.top = g("divMasterContainer1").style.top;
		g("divMasterBg").style.left = g("divMasterContainer1").style.left;
		if(g("divScrollArrows")){
		g("divScrollArrows").style.display = "block";
		}
		g("divMasterBg").style.display = "block";
	}
	
	// *** position the scroll arrows to the bottom right of document containers
	if(g("divScrollArrows")){
	g("divScrollArrows").style.left = rxpos("divMasterContainer1") + g("divMasterContainer1").offsetWidth - g("divScrollArrows").offsetWidth - p(crf*4) + "px";
	g("divScrollArrows").style.top = rypos("divMasterContainer1") + g("divMasterContainer1").offsetHeight - g("divScrollArrows").offsetHeight - p(crf*10) + "px";
	}
	// *** hide the document div permanently - for Group Site only if not special page (of course)
		if(intSpe == 0 ) 
			g("divMasterContainer1").style.display = "none";
		
	// *** is this is the first run-through and the browser is Internet Exploder 6 (I know, I know the variable is called ie5)
	// *** then add classNames to png images
	if(!blnFirstRun&&ie5) {
		addPngFix();
	}
	
	// *** set first run-through var and position the front page info boxes
	blnFirstRun = true;
	positionInfoBoxes();
	blnIsPositioning = false;
}

function positionInfoBoxes() {
	if(typeof(arrFrontDivs)=="undefined") return; // *** if an integer array is not found then fuck off!
	if(intSpe > 0 ) return;
	var intDivWidth = p(crf*170); // *** set the width of the info boxes. Four boxes is the maximum thus the width is content area width minus a little padding divided by four
	
	for(var i = 0; i < arrFrontDivs.length;i++) { // *** the integer array doesn't actually contain integer (but strings)...so convert 'em
		arrFrontDivs[i] = p(arrFrontDivs[i]);
	}
	
	var intToCount = (arrFrontDivs.length > 4 ? 4 : arrFrontDivs.length); // *** if no. of boxes is > four then loop count is four
	
	// *** store the left(x) value of the first infobox
	var intStartX = rxpos("divWhiteBackground") + p(g("divWhiteBackground").offsetWidth / 2) - p(intDivWidth / 2);

	if(Math.floor(intToCount-1) > 0) { // *** startX should be less if no of boxes is more (?...get it)
		intStartX -= (Math.floor(intToCount-1) * intDivWidth) - p(crf*10*2);
	}
	if(intStartX < rxpos("imgRedLineLeft")) { // *** is startX is less than red line left then add a little to startX (it should be inside the contents area)
		intStartX = rxpos("imgRedLineLeft") + p(crf*15);
	}
	if(intJsDoFlash == 0) {	
		for(var i = 0; i < intToCount; i++) { // *** Loop, MF, loop!
			if(g("divFrontData" + arrFrontDivs[i])) { // *** if infobox exists
				var obj = g("divFrontData" + arrFrontDivs[i]);
				// *** set the info box width, zIndex, top, left and visibility
				obj.style.width = intDivWidth + "px";
				obj.style.zIndex = 900;
				obj.style.top = rypos("divWhiteBackground") + p(crf*50) + "px";
				obj.style.left = intStartX + p(intDivWidth * i) + p(crf*30*i) + "px";
				obj.style.visibility = "visible";
				
				// *** Set the style values of the semi-transparent div to match those of the infobox
				var objBg = g("divFrontData" + arrFrontDivs[i] + "bg");
				objBg.style.zIndex = 199;
				objBg.style.top = obj.style.top;
				objBg.style.left = obj.style.left;
				objBg.style.width = obj.offsetWidth + "px";
				objBg.style.height = obj.offsetHeight + "px";
				
				// *** set the text color of the tab belonging to the current infobox to red (both text-lines)
				g("divTab" + arrFrontDivs[i]).style.color = "#f00";
				g("divTab" + arrFrontDivs[i]).childNodes[0].style.color = "#f00";
				
				if(ns6) {
					g("divTab" + arrFrontDivs[i]).childNodes[0].childNodes[2].style.color = "#f00";
				} else {
					g("divTab" + arrFrontDivs[i]).childNodes[0].childNodes[2].style.color = "#f00";	
				}
				
				// *** get the div object containing the gray line. Set zIndex and top values
				var objLine = g("divFrontData" + arrFrontDivs[i] + "line");
				objLine.style.zIndex = 199;
				objLine.style.top = rypos("imgRedLineTop1") + g("imgRedLineTop1").offsetHeight + "px";
				
				// *** if center of the current infobox is to the left of the corrosponding tab center then 
				if((rxpos("tab" + arrFrontDivs[i]) + p(g("tab" + arrFrontDivs[i]).offsetWidth / 2)) < rxposObj(obj) + p(obj.offsetWidth / 2)) {
					objLine.innerHTML = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" height=\"" + (ryposObj(obj) - (rypos("imgRedLineTop1") + g("imgRedLineTop1").offsetHeight)) + "px\"><tr style=\"height:" + 100/(i+2)+ "%\"><td style=\"border:#888 solid;border-width:0px 0px 1px 1px;\">&nbsp;</td></tr><tr><td style=\"border-right:#888 1px solid;\">&nbsp;</td></tr></table>";
					objLine.style.left = rxpos("tab" + arrFrontDivs[i]) + p(g("tab" + arrFrontDivs[i]).offsetWidth / 2) + "px";
					objLine.style.width = rxposObj(obj) + p(obj.offsetWidth / 2) - p(objLine.style.left) + "px";
				} else {
					// *** else (the infobox center is to the right of corrosponding tab center)
					objLine.innerHTML = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" height=\"" + (ryposObj(obj) - (rypos("imgRedLineTop1") + g("imgRedLineTop1").offsetHeight)) + "px\"><tr style=\"height:" + 100/(i+2)+ "%\"><td style=\"border:#888 solid;border-width:0px 1px 1px 0px;\">&nbsp;</td></tr><tr><td style=\"border-left:#888 1px solid;\">&nbsp;</td></tr></table>";
					objLine.style.left = rxposObj(obj) + p(obj.offsetWidth / 2) + "px";
					objLine.style.width = rxpos("tab" + arrFrontDivs[i]) + p(g("tab" + arrFrontDivs[i]).offsetWidth / 2) - p(objLine.style.left) + "px";
				}
			}
		}
	}//
}
function ap(v) {
	alert(v + ": width (" + g(v).style.width + "), height (" + g(v).style.height + ")\nx: " + rxpos(v) + ", y: " + rypos(v) );
}

function positionTabs() {
	var startX = rxpos("divMain") + p(crf*43);
	var startY = rypos("divMain") + p(crf*36);

	for(var i = 0; i < 9; i++) {
		if(g("tab" + i)) {
			g("tab" + i).style.left = startX + (i * p(crf*102)) + "px";
			g("tab" + i).style.top = startY + "px";
			g("divTab" + i).style.left = g("tab" + i).style.left;
			g("divTab" + i).style.top = rypos("tab" + i) + p((g("tab" + i).offsetHeight - g("divTab" + i).offsetHeight) / 2) + "px";
		}
	}
	g("imgTopTabRight").style.left = rxpos(strLastTab) + g(strLastTab).offsetWidth - 2 + "px";
	g("imgTopTabRight").style.top = g(strLastTab).style.top;
}

function colorizeTab(cid) {
	if(!g("divTab" + cid)) { return; }
	var obj = g("divTab" + cid);
	g("tab" + cid).src = "img/top_tab_trans_" + jsres + ".png";
	obj.style.color = "#EC2428";
	for(var i = 0; i < obj.childNodes.length; i++) {
		if(obj.childNodes[i].tagName) {
			if(obj.childNodes[i].tagName.toString().toLowerCase() == "div") {
				obj.childNodes[i].style.color = "#EC2428";
			}
		}
	}
	if(cid==8) {
		g("imgTopTabRight").src = "img/top_tab_right_trans_" + jsres + ".png";
	}
}

function addPngFix() {
	var arr = document.getElementsByTagName("img");
	for(var i = 0; i < arr.length; i++) {
		if(arr[i].src) {
			if(arr[i].src.toLowerCase().indexOf("png") > 0) {
				if(arr[i].className == "") {
					arr[i].className = "overlay";
				} else {
					if(arr[i].className != "overlay" || arr[i].className != "overlaystay") {
						arr[i].className += " overlay";
					}
				}
			}
		}
	}
}

function toggleInfo() {
	if(g('masterContainer1').style.display=="block") {
		g('masterContainer1').style.display = "none";
		g('documentContainer1').style.display = "none";
		g('arrowContainer1').style.display = "none";
		g('imgTextArea').style.display = "none";
		g('lukknap').style.display = "none";
	}
	else {
		g('masterContainer1').style.display = "block";
		g('documentContainer1').style.display = "block";
		g('arrowContainer1').style.display = "block";
		g('imgTextArea').style.display = "block";
		g('lukknap').style.display = "block";
	}
}

var intCurrImg = -1;
function nextImage() {
	if(typeof(arrPageImages)!="undefined") {
		if(arrPageImages.length==0) return;
		intCurrImg += 1;
		if(intCurrImg>=arrPageImages.length) {
			intCurrImg = 0;
		}
		g('imgContentsBackground').src = arrPageImages[intCurrImg];
	}
}

function prevImage() {
	if(typeof(arrPageImages)!="undefined") {
		if(arrPageImages.length==0) return;
		intCurrImg -= 1;
		if(intCurrImg<0) {
			intCurrImg = arrPageImages.length - 1;
		}
		g('imgContentsBackground').src = arrPageImages[intCurrImg];
	}
}

function printThis(v)
{ 
	if(v!=0) {
		document.forms.printform.printboat.value = v;
	}
	document.forms.printform.printwhat.value = document.getElementById("documentContainer").innerHTML;
	document.forms.printform.submit();
}

function printerfocus()
{
	printframe.focus();
	printframe.print();
}
