window.onload = function() {
    initanimation();
    addMattesAndShadows();
    pngFix()
}




var tvdown, tvup, tvicon, audioicon;
var attributes;
var tvisdown = 0;
var audioisdown = 0;
function initanimation() {
	attributes = { top: {from: -435, to: -30} };
	tvdown = new YAHOO.util.Motion('tv', attributes, 1.0, YAHOO.util.Easing.bounceOut);
	
	attributes = { top: {from: -40, to: -435} };
	tvup = new YAHOO.util.Motion('tv', attributes, 0.6, YAHOO.util.Easing.backIn);
	
	
	attributes = { top: {from: -50, to: 140} };
	tvicon = new YAHOO.util.Motion('tvlink', attributes, 0.6, YAHOO.util.Easing.easeOut);
	attributes = { top: {from: -50, to: 125} };
	audioicon = new YAHOO.util.Motion('audiolink', attributes, 0.6, YAHOO.util.Easing.easeOut);
	
	var ran_unrounded=Math.random()*5.0;
	var random=Math.round(ran_unrounded);
	if(random==1 && $('section0')==null){
		//tvicon.animate();
		YAHOO.util.Dom.setY(document.getElementById('tvlink'), "140");
	}
	if(random==2 && $('section0')==null){
		//audioicon.animate();
		YAHOO.util.Dom.setY(document.getElementById('audiolink'), "125");
	}
	
	
	//alert(random);
}

var so;
function tvnaarbeneden() {
	if(tvisdown==1) {
		tvnaarboven();
		return;
	} 
	tvisdown=1;
	tvdown.animate();
	
	so = new SWFObject('http://www.hazewindus.info/assets/flash/flvplayer.swf','jstest','240','180','7');
	so.addParam("allowfullscreen","false");
	so.addVariable("file",videourl);
	so.addVariable("autostart","true");
	so.addVariable("backcolor","0x000000");
	so.addVariable("frontcolor","0xCCCCCC");
	so.addVariable("lightcolor","0x557722");
	starttimer = setTimeout("so.write('player');",200);
	
}
function tvnaarboven() {
	tvisdown=0;
	//so_clearInnerHTML(document.getElementById("player"));
	starttimer = setTimeout('so_clearInnerHTML(document.getElementById("player"));',500);
	tvup.animate();
}

var audiourl, audioisaan;
function audionaarbeneden() {
	//alert('Nog geen audio...');
	if(audioisaan==1) {
		audionaarboven();
		return;
	}
	soundManager.createSound({
		id:'mySound1',
		url:audiourl
	});
	soundManager.play('mySound1');
	audioisaan=1;
}
function audionaarboven() {
	soundManager.stop('mySound1');
	audioisaan=0;
}
function sendEvent(swf,typ,prm) { 
  thisMovie(swf).sendEvent(typ,prm); 
};
function getUpdate(typ,pr1,pr2,swf) {};
function thisMovie(swf) {
  if(navigator.appName.indexOf("Microsoft") != -1) {
    return window[swf];
  } else {
    return document[swf];
  }
};





var tallfilms = {
	src: 'images/sifr_tallfilms.swf'
	,ratios: [6,1.24,7,1.21,8,1.18,10,1.16,11,1.13,12,1.12,13,1.11,15,1.1,17,1.09,19,1.08,22,1.07,26,1.06,32,1.05,41,1.04,58,1.03,97,1.02,1.01]
	,forceSingleLine: true
};


// sIFR.domains = ['hazewindus.info'] // Don't check for domains in this demo
sIFR.useStyleCheck = true;
sIFR.activate(tallfilms);

//sIFR.debug.ratios(tallfilms, {
sIFR.replace(tallfilms, {
selector: 'li.active'
,css: [
  '.sIFR-root { font-weight: bold; letter-spacing: 0.5;  }'
  ,'a { text-decoration: none; }'
  ,'a:link { color: #780014; }'
  ,'a:hover { color: #780014; }'
]
,wmode: 'transparent'
});
sIFR.replace(tallfilms, {
selector: '#navlist li'
,css: [
  '.sIFR-root { font-weight: bold; letter-spacing: 0.5;  }'
  ,'a { text-decoration: none; }'
  ,'a:link { color: #000000; }'
  ,'a:hover { color: #780014; }'
]
,wmode: 'transparent'
});

sIFR.replace(tallfilms, {
selector: '#subnavlist li'
,css: [
  '.sIFR-root { font-weight: bold; letter-spacing: 0.5;  }'
  ,'a { text-decoration: none; }'
  ,'a:link { color: #000000; }'
  ,'a:hover { color: #780014; }'
]
,wmode: 'transparent'
});

sIFR.replace(tallfilms, {
selector: '#navlisth li'
,css: [
  '.sIFR-root { text-align: center; font-weight: bold; letter-spacing: 1.0; width: 220px; }'
  ,'a { text-decoration: none; }'
  ,'a:link { color: #111111; }'
  ,'a:hover { color: #780014; }'
]
,wmode: 'transparent'
});

sIFR.replace(tallfilms, {
selector: '#footer li.footeractive'
,css: [
  '.sIFR-root { font-weight: bold; letter-spacing: 0.5;  }'
  ,'a { text-decoration: none; }'
  ,'a:link { color: #ffffff; }'
  ,'a:hover { color: #ffffff; }'
]
,wmode: 'transparent'
});

sIFR.replace(tallfilms, {
selector: '#footer li'
,css: [
  '.sIFR-root { font-weight: bold; letter-spacing: 0.5;  }'
  ,'a { text-decoration: none; }'
  ,'a:link { color: #bfb894; }'
  ,'a:hover { color: #ffffff; }'
]
,wmode: 'transparent'
});

function addMattesAndShadows() {
  var imgs = document.getElementsByTagName("img");

  for (var i = 0; i < imgs.length; i++) {
    var thisImg = imgs[i];
    var isShadow = true;
    var extraWidth = 0;
    if (thisImg.className) {
      var classTokens = thisImg.className.split(' ');
      for (var j = 0; j < classTokens.length; j++) {
        var thisToken = classTokens[j];
        if (thisToken == "noshadow")
          isShadow = false;
          isShadow = true;
        if (thisToken == "nomatte")
          extraWidth = 0;
      }

      if (isShadow) {
        var shadowDiv = document.createElement('div');
        
        
        shadowDiv.className = 'shadow '+ thisImg.className;
        shadowDiv.style.width = (thisImg.width + extraWidth) + "px";

        shadowDiv.appendChild(thisImg.cloneNode(false));
        var topLeft = document.createElement('div');
        topLeft.className = "topleft";
        shadowDiv.appendChild(topLeft);

        var topRight = document.createElement('div');
        topRight.className = "topright";
        shadowDiv.appendChild(topRight);

        var bottomLeft = document.createElement('div');
        bottomLeft.className = "bottomleft";
        shadowDiv.appendChild(bottomLeft);

        var bottomRight = document.createElement('div');
        bottomRight.className = "bottomright";
        shadowDiv.appendChild(bottomRight);

        thisImg.parentNode.replaceChild(shadowDiv, thisImg);

      }

    }

  }

}

function $(id) {
	return document.getElementById(id);
}
function loadDiv(ObjFrom, ObjTo) {
	if(ObjTo==null) {ObjTo = 'player';}
	if(ObjFrom==null) {
		$(ObjTo).innerHTML = '';
	} else {
		$(ObjTo).innerHTML = $(ObjFrom).innerHTML;
	}
	
}

function so_clearInnerHTML(obj) {
	while(obj.firstChild) obj.removeChild(obj.firstChild);
	
	// perform a shallow clone on obj
	nObj = obj.cloneNode(false);
	// insert the cloned object into the DOM before the original one
	obj.parentNode.insertBefore(nObj,obj);
	// remove the original object
	obj.parentNode.removeChild(obj);
}

function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
function getWindowWidth() {
	var windowWidth = 0;
	if (typeof(window.innerWidth) == 'number') {
		windowWidth = window.innerWidth;
	}
	else {
		if (document.documentElement && document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		}
		else {
			if (document.body && document.body.clientWidth) {
				windowWidth = document.body.clientWidth;
			}
		}
	}
	return windowWidth;
}

// make png-files tranparent
function pngFix()
{
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])

	if ((version >= 5.5) && (document.body.filters)) 
	{
	   for(var i=0; i<document.images.length; i++)
	   {
		  var img = document.images[i]
		  var imgName = img.src.toUpperCase()
		  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
		  {
			 var imgID = (img.id) ? "id='" + img.id + "' " : ""
			 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
			 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			 var imgStyle = "display:inline-block;" + img.style.cssText 
			 if (img.align == "left") imgStyle = "float:left;" + imgStyle
			 if (img.align == "right") imgStyle = "float:right;" + imgStyle
			 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
			 var strNewHTML = "<span " + imgID + imgClass + imgTitle
			 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			 + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
			 img.outerHTML = strNewHTML
			 i = i-1
		  }
	   }
	}
}

