//----------------------------------------------------------------------------------
// Function: 	Function pack
// Author: 	Lars Nielsen - 10.12.2000 
//----------------------------------------------------------------------------------

var edsetlink = "mlinkdoc";

var currActive = null;
function none(){}

function setBGon(o){if(currActive != o){o.className = 'MenuItemRollover';}}
function setBGoff(o){if(currActive != o){o.className = 'MenuItem';}}
function setPopon(o){if(currActive != o){o.className = 'popItemRollover';}}
function setPopoff(o){if(currActive != o){o.className = 'popItem';}}
function setDocon(o){if(currActive != o){o.className = 'DocItemRollover';}}
function setDocoff(o){if(currActive != o){o.className = 'DocItem';}}
function setSubon(o){if(currActive != o){o.className = 'SubItemRollover';}}
function setSuboff(o){if(currActive != o){o.className = 'SubItem';}}
function setTopMon(o){if(currActive != o){o.className = 'topm_s';}}
function setTopMoff(o){if(currActive != o){o.className = 'topm';}}

//function swapImg(imgDocID,imgObjName) {document.images[imgDocID].src = eval(imgObjName + ".src");}
//function newImage(arg){if (document.images) {rslt = new Image();rslt.src = arg;return rslt;}}



function validateNr(formin,fieldin) {
var field = eval('document.'+formin+'.'+fieldin+'.value');
var valid = "0123456789";

if (field == ''){return false;}
else{
	for (var i=0; i < field.length; i++) {
		temp = "" + field.substring(i, i+1);
		if (valid.indexOf(temp) == "-1"){eval('document.'+formin+'.'+fieldin+'.value = ""');return false;}
	}
	return true;
	}
}

function popUpAll(cUrl,width,height,x,y,scrollbars,toolbar){

	if (x == 0){x = ((window.screen.width - width)/2);}
	if (y == 0){y = ((window.screen.height - height)/2);}
	if (scrollbars == ''){scrollbars = 'yes';}
	if (toolbar == ''){toolbar= 'yes';}

	var popUpA = window.open(cUrl, 'popupA', 'width='+width+',height='+height+',left='+x+',top='+y+',toolbar='+toolbar+',location=no,status=no,scrollbars='+scrollbars+',noresize,menubar=no');
	popUpA.focus();
}

function popUpDoc(cUrl,width,height,x,y,scrollbars,toolbar){

	if (x == 0){x = ((window.screen.width - width)/2);}
	if (y == 0){y = ((window.screen.height - height)/2);}
	if (scrollbars == ''){scrollbars = 'yes';}
	if (toolbar == ''){toolbar= 'yes';}

	var popUpDoc = window.open(cUrl, 'popupA', 'width='+width+',height='+height+',left='+x+',top='+y+',toolbar='+toolbar+',location=no,status=no,scrollbars='+scrollbars+',noresize,menubar=no');
	popUpDoc.focus();
}

function popPreview(cUrl,width,height,x,y){

	if (x == 0){x = ((window.screen.width - width)/2);}
	if (y == 0){y = ((window.screen.height - height)/2);}

	var popUpB = window.open(cUrl, 'popupB', 'width='+width+',height='+height+',left='+x+',top='+y+',toolbar=no,location=no,status=yes,scrollbars=yes,resizable,menubar=no');
	popUpB.focus();
}

function popFunction(cUrl,width,height,x,y){

	if (x == 0){x = ((window.screen.width - width)/2);}
	if (y == 0){y = ((window.screen.height - height)/2);}

	var popUpF = window.open(cUrl, 'popupF', 'width='+width+',height='+height+',left='+x+',top='+y+',toolbar=no,location=no,status=no,scrollbars=yes,resizable,menubar=no'); 
	popUpF.focus();
}


function popUpTxt(cUrl){
	x = ((window.screen.width - 970)/2);
	y = ((window.screen.height - 500)/2);

	var popUptxt = window.open(cUrl, 'popup3', 'width=970,height=500,left='+x+',top='+y+',toolbar=no,location=no,status=no,scrollbars=no,resizable=yes,menubar=no');
	popUptxt.focus();
}

var flipper = 0;
function flipflap(o){
	if(flipper == 1){o.className = 'flapnorm';flipper = 0;}
	else{o.className = 'flaphtml';flipper = 1;}
}


//---------------------------------------------------------------------
//----------------------- ColorPicker function ------------------------
//---------------------------------------------------------------------

function toHex(decimal_number){			//returns 2 digit hex number
   var prefix = (decimal_number < 16) ? '0' : '';
   hex_number = decimal_number.toString(16);
   hex_number = hex_number.toUpperCase();
   return prefix + hex_number;
}

function div_hide(str1){eval(str1+".style.display='none'");eval(str1+".style.visibiliy='hidden'");}
function div_show(str1){eval(str1+".style.display='block'");eval(str1+".style.visibiliy='visible'");}

function colDo(ColorID,OutputID,colour){colour = colour.substring(1);ColorID.style.background='#'+colour;OutputID.value=colour;}

function writeColorPicker(Name,Command,Type,hidename){
	
	var colorTmp = 0;
	var OutputID = Name
	var ColorID = Name + "_2"
	var c3 = new Array("#FFFFFF", "#FFCCCC", "#FFCC99", "#FFFF99", "#FFFFCC", "#99FF99", "#99FFFF", "#CCFFFF", "#CCCCFF", "#FFCCFF", "#CCCCCC", "#FF6666", "#FF9966", "#FFFF66", "#FFFF33", "#66FF99", "#33FFFF", "#66FFFF", "#9999FF", "#FF99FF", "#C0C0C0", "#FF0000", "#FF9900", "#FFCC66", "#FFFF00", "#33FF33", "#66CCCC", "#33CCFF", "#6666CC", "#CC66CC", "#999999", "#CC0000", "#FF6600", "#FFCC33", "#FFCC00", "#33CC00", "#00CCCC", "#3366FF", "#6633FF", "#CC33CC", "#666666", "#990000", "#CC6600", "#CC9933", "#999900", "#009900", "#339999", "#3333FF", "#6600CC", "#993399", "#333333", "#660000", "#993300", "#996633", "#666600", "#006600", "#336666", "#000099", "#333399", "#663366", "#000000", "#330000", "#663300", "#663333", "#333300", "#003300", "#003333", "#000066", "#330099", "#330033"); 
	
	var sHTML = "";
	sHTML += ("<table border=0 cellpadding=0 cellspacing=0><tr class=bckBrowndark onClick=\"javascript:div_hide('"+hidename+"');\" style='cursor: hand;'><td  height=22 align=right><font color=white><b>[X]</b>&nbsp;&nbsp;</font></td></tr><tr><td>")
	//sHTML += ("<table border=0 width=280 align=center cellpadding=0 cellspacing=0><tr><td width=45><table border=1 cellpadding=0 cellspacing=0><tr><td id='"+ColorID+"' width=40 height=25></td></tr></table><div id='"+TextID+"'><font size=1>&nbsp;</font></div></td><td>&nbsp;&nbsp;</td><td>")
	sHTML += ("<table cellpadding=0 cellspacing=1 bgcolor=black>")

			sHTML += ("<tr>");
			var i = 0;
			for(var r=0; r < c3.length; r++){
				var colour = c3[r];
				sHTML += ("<td onclick=\"colDo("+ColorID+","+OutputID+",'"+colour+"');"+Command+"\" style=\"cursor:pointer;background-color:"+colour+";\" width=18 height=11></td>")
		
				i++;
				if(i==10 && r < 69){sHTML += ("</tr><tr>");i=0;}
			}
			sHTML += ("</tr>");


		
	sHTML += ("</table>")
	sHTML += ("<input type=hidden id='"+OutputID+"'>")
	sHTML += ("</td></tr></table>")	
	return sHTML;		
	
}

//---------------------------------------------------------------------
//----------------------- FolderTree function -------------------------
//---------------------------------------------------------------------
var openImg = new Image();
openImg.src = "images/fld_open.gif";
var closedImg = new Image();
closedImg.src = "images/fld_closed.gif";

function showBranch(branch){
	var objBranch = document.getElementById(branch).style;
	if(objBranch.display=="block")
		objBranch.display="none";
	else
		objBranch.display="block";
}

function swapFolder(img){
	objImg = document.getElementById(img);
	if(objImg.src.indexOf('closed.gif')>-1)
		objImg.src = openImg.src;
	else
		objImg.src = closedImg.src;
}
