/*
file: misctools.js 
Author: TG
Date: 2001/08/08
*/
var gs_browserName = navigator.appName
if (gs_browserName=="Netscape") gs_browserName = "ns"
else if (gs_browserName=="Microsoft Internet Explorer") gs_browserName = "ie"
/**************************************
**	Name	saveFaceSize
**	Desc	Save Font size in a cookie
**	Para	fz	font size in pixels
***************************************/
function saveFaceSize(fz)
{
   	//expire.setTime (expire.getTime() + (6000 * 24 * 3600000)); //expires in 6 days from users clock
   	//expire = expire.toGMTString();
	document.cookie = "fontSize=" + fz //+ "; expires=" + expire;
}

/**************************************
**	Name	loadFontSize
**	Desc	Get font from the cookie
**	Para	return the font size in pixels
***************************************/
function loadFontSize()
	//get font size from a cookie
{
	var fonzee = 0
	tempArray = document.cookie.split(";");		
	for (tA = 0; tA < tempArray.length; tA++)
	{
		if (tempArray[tA].indexOf('fontSize') > -1) //found the font section in cookie
		{
			fontValue = tempArray[tA].split("=")
			fonzee = parseInt(fontValue[1]);
			//lineHeight = fontSize+Math.round(.3*fontSize);
		}
	}
	return fonzee;
}

/**************************************
**	Name	addToArray
**	Desc	Add a value at the end of an array
**	Para	arrBase		current array
**			strToAdd	Value to add
**			return		the new array
***************************************/
function addToArray(arrBase, strToAdd)
{
	tmp = new Array(arrBase.length + 1)
	for (i = 0 ; i < arrBase.length ; i++) 
	{
		tmp[i] = arrBase[i]
	}
	tmp[i] = strToAdd;
	return tmp;
}

/**************************************
**	Name	getParameter
**	Desc	Get a parameter from an url
**	Para	paramName	Name of the parameter
**			return		Parameter's value
***************************************/
function getParameter(paramName)
{
	para = myUrl.indexOf(paramName + "=")
	if (para > 0) 
	{ 
		var paramValue = myUrl.substring(para);
		if (paramValue.indexOf("&") > 0) 
		{
			paramValue = paramValue.substring((paramName.length + 1),paramValue.indexOf("&"))
		}
		else
		{
			paramValue = paramValue.substring(paramName.length + 1)
		}
	}
	return paramValue;
}

/**************************************
**	Name	openPopup
**	Desc	Open a window in the center of screen
**	Para	url			url of the new window
**			name		Parameter's value
**			h
**			v
***************************************/	
function openPopup(url, name, h, v) 
{

        if (gs_browserName == "ie"){
        	var newwin = window.open(url, name, "width=" + h + ", height=" + v + ", resizable=0, scrollbars=0, menubar=0, titlebar=0, left=" + ((screen.width - h) /2) + ",top=" + ((screen.height - v) /2));
        }
        else
        {
        	var newwin = window.open(url,name,'width=' + h + ',height=' + v + ',scrollbars=0,menubar=0,titlebar=0,top=120,left=120');
        }
}

function openPrintWin(strUrl, idFav)
{
	window.open(strUrl + "?id=" + idFav, "PrintWindow", "resizable=no, scrollbars=yes, width=" + 600 + ", height=" + (screen.height - (screen.height/5)) + ", left=" + ((screen.width - 600) /2) + ",top=" + ((screen.height - (screen.height - (screen.height/5))) /2));
}
function openPrintWin2(strUrl, cdo_id,rub_id)
{
	
	window.open("../include/"+strUrl + "?cdo_id=" + cdo_id+"&rub_id="+rub_id, "PrintWindow", "resizable=no, scrollbars=yes, width=" + 600 + ", height=" + (screen.height - (screen.height/5)) + ", left=" + ((screen.width - 600) /2) + ",top=" + ((screen.height - (screen.height - (screen.height/5))) /2));
}
function openPrintWinInside(strUrl, rub_id)
{
	
	window.open(strUrl + "?rub_id="+rub_id, "PrintWindow", "resizable=no, scrollbars=yes, width=" + 600 + ", height=" + (screen.height - (screen.height/5)) + ", left=" + ((screen.width - 600) /2) + ",top=" + ((screen.height - (screen.height - (screen.height/5))) /2));
}

function openPrint(strUrl, rub_id)
{
	window.open(strUrl + "?rubId="+rub_id+"&print=1", "PrintWindow", "resizable=no , scrollbars=yes, width=" + 600 + ", height=" + (screen.height - (screen.height/5)) + ", left=" + ((screen.width - 600) /2) + ",top=" + ((screen.height - (screen.height - (screen.height/5))) /2));
	
}

function getFontSize(obj) {
	fSize = obj.style.fontSize
	return fSize
}

function setFontSize(docLayer,sz) 
{
	lineHeight = fSize+Math.round(.3 * fSize);
	for (var i = 0 ; i < docLayer.length ; i++) 
	{
		
		if (document.getElementById(docLayer[i])) 
		{
			obj = document.getElementById(docLayer[i]);			
			obj.style.backgroundcolor = "#CCFFFF"
			obj.style.fontSize = sz + "px";
			obj.style.lineHeight = lineHeight + "px";
		}
	}
	saveFaceSize(sz)
}

function eventFontLarger(docLayer) 
{
	if (docLayer.length > 0)	
	{
		fSize = fSize + 1
		if (fSize > 16) {
			fSize = 16;
		}
		setFontSize(docLayer,fSize);
	}
}

function eventFontSmaller(docLayer) 
{
	if (docLayer.length > 0)	
	{
		fSize = fSize - 1
		if (fSize < 9) 
		{
			fSize = 9;
		}
		setFontSize(docLayer,fSize);
	}
}

function addFav(strUrl,idFav) {
	if (gs_browserName == "ie")
	{
		window.open(strUrl + "?id=" + idFav, "favorite", "resizable=no, scrollbars=no, width=412, height=330, left=" + ((screen.width - 412) /2) + ",top=" + ((screen.height - 330) /2));
	}	
	else
	{
		window.open(strUrl + '?id=' + idFav,'favorite','width=412,height=330,scrollbars=0,menubar=0,titlebar=0,top=120,left=120');
	}
}

var fSize = 10

if (loadFontSize() > 0) {
	fSize = loadFontSize()
}
