

initBrowser();

// initBrowser function - is called automatically when this library is included
function initBrowser()
{
dom = (document.getElementById)? true:false;
ie4 = (document.all && !dom)? true:false;
ie5 = (dom && navigator.appVersion.indexOf("MSIE 5")>-1)? true:false;
ie6 = (dom && navigator.appVersion.indexOf("MSIE 6")>-1)? true:false;
ns4 = (document.layers)? true:false;
ns6 = (document.createRange)? true:false;
}


// getStyle returns the css style of an element
function getStyle(divId)
{
if (dom) return document.getElementById(divId).style;
else if (ie4) return document.all[divId].style;
else if (ns4) return document.layers[divId];
}

// getElement returns the element itself
function getElm(divId)
{
if (dom) return document.getElementById(divId);
else if (ie4) return document.all[divId];
else if (ns4) return document.layers[divId];
}


/*
---------------------------------
css property get and set function
---------------------------------
*/

// gets any CSS property value
function getProp(divId, prop)
{
style=getStyle(divId);
str="value=style."+prop;
eval(str);
return value;
}

// sets any CSS property value
function setProp(divId, prop, value)
{
style=getStyle(divId);
str="style."+prop+"='"+value+"'";
eval(str);
}


/*
--------------------
visibility functions
--------------------
*/

// If the div is visible, shows it, otherwise hides it
function showHide(divId)
{
if (isVisible(divId)) hide(divId);
else show(divId);
}

function show(divId)
{
objStyle=getStyle(divId);
if (ns4) objStyle.visibility="show";
else objStyle.visibility="visible";
}

function hide(divId) 
{
objStyle=getStyle(divId);
if (ns4) objStyle.visibility="hide";
else objStyle.visibility="hidden";
}

// Returns TRUE if the div is visible. Otherwise return FALSE
function isVisible(divId)
{
objStyle=getStyle(divId);
if (objStyle.visibility=="visible" || objStyle.visibility=="show") return true;
else return false;
}


/*
----------------------
Move / slide functions
----------------------
*/

// Moves the div to the absolute coordinates (x, y)
function moveTo(divId, x, y)
{
objStyle=getStyle(divId);
objStyle.xpos=x;
objStyle.ypos=y;
objStyle.left=objStyle.xpos;
objStyle.top=objStyle.ypos;
}

// Shifts the div by the specified amount
function moveBy(divId, x, y)
{
objStyle=getStyle(divId);
if (!objStyle.xpos)
	{
	objStyle.xpos=parseInt(objStyle.left);
	objStyle.ypos=parseInt(objStyle.top);
	}
objStyle.xpos+=x;
objStyle.ypos+=y;
objStyle.left=objStyle.xpos;
objStyle.top=objStyle.ypos;
}

// Slides (moves continuously) the div to the absolute coordinates (x, y)
function slideTo(divId, x, y, inc, onEnd)
{
objStyle=getStyle(divId);
if (!onEnd) onEnd=null;
objStyle.xpos=parseInt(objStyle.left);
objStyle.ypos=parseInt(objStyle.top);
var distx=x-objStyle.xpos;
var disty=y-objStyle.ypos;
var dist=Math.sqrt(Math.pow(distx,2)+Math.pow(disty,2))/inc;
if (dist==0) return;
var dx=distx/dist;
var dy=disty/dist;
var iterLeft=Math.round(dist);
slideTo1(divId, x, y, dx, dy, iterLeft, onEnd);
}

// function used by slideTo()
function slideTo1(divId, x, y, dx, dy, iterLeft, onEnd)
{
iterLeft--;
if (iterLeft>=0)
	{
	moveBy(divId, dx, dy);
	setTimeout('slideTo1("'+divId+'",'+x+','+y+','+dx+','+dy+','+iterLeft+','+onEnd+')', 10);
	}
else
	{
	moveTo(divId, x, y);
	eval(onEnd);
	}
}




/*
--------------
clip functions
clip values must be initialised (in the CSS) before using those functions
--------------
*/

// Returns the clip value in the given direction
function clipValue(divId, direction) 
{
objStyle=getStyle(divId);
if (ie4 || dom) var clipv = objStyle.clip.split("rect(")[1].split(")")[0].split("px");
if (direction=="t") return (ns4)? objStyle.clip.top : Number(clipv[0]);
if (direction=="r") return (ns4)? objStyle.clip.right : Number(clipv[1]);
if (direction=="b") return (ns4)? objStyle.clip.bottom : Number(clipv[2]);
if (direction=="l") return (ns4)? objStyle.clip.left : Number(clipv[3]);
}

// set the clip values
function clipTo(divId, t, r, b, l)
{
objStyle=getStyle(divId);
if (ns4)
	{
	objStyle.clip.top=t;
	objStyle.clip.right=r;
	objStyle.clip.bottom=b;
	objStyle.clip.left=l;
	}
else
	objStyle.clip="rect("+t+"px "+r+"px "+b+"px "+l+"px)";
status=t+","+r+","+b+","+l;
}	

// Changes the clip value in the given direction
function clipBy(divId, direction, amount)
{
clipT=clipValue(divId, "t");
clipR=clipValue(divId, "r");
clipB=clipValue(divId, "b");
clipL=clipValue(divId, "l");
switch(direction)
	{
	case "t" : clipTo(divId, clipT+amount, clipR, clipB, clipL);break;
	case "r" : clipTo(divId, clipT, clipR+amount, clipB, clipL);break;
	case "b" : clipTo(divId, clipT, clipR, clipB+amount, clipL);break;
	case "l" : clipTo(divId, clipT, clipR, clipB, clipL+amount);break;
	}
}

// wipes (clip continuously) in the given direction, with the given amount of pixels
function wipe(divId, direction, amount, inc, onEnd)
{
if (!onEnd) onEnd=null;
if (amount!=0 && clipValue(divId, direction)>=0)
	{
	if (amount>0) 
		{
		clipBy(divId, direction, inc);
		amount-=inc;
		}
	else 
		{
		clipBy(divId, direction, -inc);
		amount+=inc;
		}
	setTimeout("wipe('"+divId+"','"+direction+"',"+amount+","+inc+",\""+onEnd+"\")", 20);
	}
}




// ReplaceContent function
// replaces the content of the div
function replaceContent(divId, content)
{
objElm=getElm(divId);
if (ns4)
	{
	objElm.document.write(content);
	objElm.document.close();
	}
else
	objElm.innerHTML=content;
}




/*
------------
Mouse events
------------
*/

function initMouseEvents()
{
document.onmousemove = mouseMove;
if (ns4) document.captureEvents(Event.MOUSEMOVE);
}

function mouseMove(e) 
{
document.mouseX = (ns4||ns6)? e.pageX : event.x+document.body.scrollLeft;
document.mouseY = (ns4||ns6)? e.pageY : event.y+document.body.scrollTop;
status=document.mouseX+","+document.mouseY;
return true;
}


// ####################
// ####  The following code
// ####  resizes id'entified
// ####  iframes to get rid of verticla scroll bars
// ####################

function dbg()
{
//document.all.contentIFrame.style.display='block'
//document.all.contentIFrame.style.scrolling = 'auto'
ResizeIFrames()
}

/***********************************************
* IFrame SSI script- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/

function ResizeIFrames()
{

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["contentIFrame","newsFrame"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers
var FFextraWidth=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra width in px to add to iframe in FireFox 1.0+ browsers


function dyniframesize() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){

if (document.getElementById){ //begin resizing iframe procedure
dyniframe[dyniframe.length] = document.getElementById(iframeids[i]);
if (dyniframe[i] && !window.opera)
{
	dyniframe[i].style.display="block"
	if (dyniframe[i].contentDocument && dyniframe[i].contentDocument.body.offsetHeight) //ns6 syntax
	dyniframe[i].height = dyniframe[i].contentDocument.body.offsetHeight+FFextraHeight; 
	else if (dyniframe[i].Document && dyniframe[i].Document.body.scrollHeight) //ie5+ syntax
	dyniframe[i].height = dyniframe[i].Document.body.scrollHeight;
/*
	if (dyniframe[i].contentDocument && dyniframe[i].contentDocument.body.offsetWidth) //ns6 syntax
	dyniframe[i].width = dyniframe[i].contentDocument.body.offsetWidth+FFextraWidth; 
	else if (dyniframe[i].Document && dyniframe[i].Document.body.scrollWidth) //ie5+ syntax
	dyniframe[i].width = dyniframe[i].Document.body.scrollWidth;
*/

}

}
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}

if (window.addEventListener)
window.addEventListener("load", dyniframesize, false)
else if (window.attachEvent)
window.attachEvent("onload", dyniframesize)
else
window.onload=dyniframesize

}

