/* **********************************************************************
Site:						hamlet-berlin.de
URL:						www.hamlet-berlin.de (info@hamlet-berlin.de)
Filename:				general.js
Description:		misc JS functions
Author:					© 2006 Sebastian Becker (sebastian.becker@berlin.de)
********************************************************************** */

if(!d)var d=document;
if(!w)var w=window;

// normalize href
var URI=w.location.href.toString();
URI=URI.toLowerCase();
var file_name=URI.substring(URI.lastIndexOf('/')+1);
var lang_array=URI.split("/");
var lang=lang_array[3];

d.write('<style type="text/css">.badbrowser{display:none;color:#CAB99D;}</style>');

// browser check
var ie_dom=(document.all&&document.getElementById)?1:0;

// default status message
status_msg = d.title.replace("- Home","");
defaultStatus = status_msg;

// IE CSS menu compatibility
// www.alistapart.com/articles/dropdowns
startList = function() {
if(ie_dom) {
navRoot=d.getElementById("nav");
for(i=0;i<navRoot.childNodes.length;i++) {
node=navRoot.childNodes[i];
if(node.nodeName=="LI") {
node.onmouseover=function(){this.className+=" over";}
node.onmouseout=function(){this.className=this.className.replace(" over", "");}
}}}}


// preload images
function preload()
{
var theImages = new Array();
theImages[0] = 'img/bg_nav_hover.gif';
theImages[1] = 'img/bg_subnav_hover.gif';
}

// set language variable
if(!lang)var lang=URI.indexOf("/de")!=-1?"de":"en";

function filterSupported(img)
{
var temp=0;
if(navigator.appName=='Microsoft Internet Explorer') {
if(navigator.userAgent.indexOf('Mac')==-1) {
if(img.filters) {
temp=1;
}}}
return temp;
}

function fadeImage(img,time)
{
if(filterSupported(img)==1) {
img.style.visibility='hidden';
img.style.filter='blendTrans(duration='+time+')';
img.filters.blendTrans.Apply();
img.filters.blendTrans.Play();
img.style.visibility='visible';
}
}


function positionFooter()
{
if(!d.getElementById||!d.body.offsetHeight)return;

var dE = d.documentElement; // Retrieves a reference to the root node of the document
var dB = d.body;

// Reset footer's margin-top...
var footer=d.getElementById('footer');
var footer_top=(footer.style.marginTop)?parseInt(footer.style.marginTop):0; // 64

var window_height = (typeof(w.innerHeight)=='number')?w.innerHeight:(dE&&dE.clientHeight)?dE.clientHeight:(dB&&dB.clientHeight)?dB.clientHeight:0;
var content_height = d.getElementById('container').offsetHeight - footer_top;

var footerMT=window_height-content_height;
if(navigator.userAgent&&navigator.userAgent.indexOf("MSIE")>=0)footer.style.marginTop=footerMT+'px';
}


function init()
{
startList();
positionFooter();
preload();
if(document.all)replaceAnchorLinks(); // Mozilla is buggy
if(window.ActiveXObject) document.execCommand("BackgroundImageCache", false, true);
}

window.onresize = positionFooter;