var bG = {
  // initialisation function, call with load
  init: function() {
    if (!document.getElementById) return;  
      
    bG.mac = (navigator.appVersion.indexOf("Mac")!=-1)? true:false;    
		if (bG.mac) {
			return;
		}
    
		bG.togglelink = document.getElementById('togglelink');		
    bG.divh = document.getElementById('inner_wrapper').offsetHeight;
    
    //alert(bG.divh);
    
		swfobject.embedSWF('/site/images/flash/bg.swf', 'flashcontent', '100%', bG.divh, '9.0.0','', flashvars, params, attributes);
		
		
		bG.flashcontent = document.getElementById('flashcontent');		
		bG.flashcontent.style.height = bG.divh;
		
		setTimeout("bG.checkheight()", 500);
		setTimeout("bG.innerBgColour()", 100);
    
    if (!document.getElementById('togglearea')) return;
    
		bG.divht = document.getElementById('togglearea').offsetHeight;
		bG.closedHeight = bG.divh;
		bG.openHeight = bG.divh+bG.divht;	    
    bG.addEvent(bG.togglelink, 'click', bG.changeHeight, false);
    bG.addEvent(bG.togglelink, 'keypress', bG.changeHeight, false);
	    
		
		
  },
  
  innerBgColour: function() {
  
  	document.getElementById('inner_wrapper').style.backgroundColor = "transparent";
  },
  
  checkheight: function() {
  
  	//alert(document.getElementById('inner_wrapper').offsetHeight);
  	bG.flashcontent.style.height = document.getElementById('inner_wrapper').offsetHeight;
  },
  
  changeHeight: function() {
  
  	//alert('flashheight='+bG.flashcontent.offsetHeight+' - closed='+bG.closedHeight+' - open='+bG.openHeight);
  
  	if (bG.flashcontent.offsetHeight == bG.closedHeight) {
			if (document.getElementById('flashcontent').effect) {
	  	  var myEffect2 = document.getElementById('flashcontent').effect('height', {duration: 500, transition: Fx.Transitions.linear});
			  myEffect2.start(bG.openHeight); 
			} else {
			  bG.flashcontent.style.height = bG.openHeight;
			}
			
			
		} else {			
			if (document.getElementById('flashcontent').effect) {
		  	var myEffect3 = document.getElementById('flashcontent').effect('height', {duration: 500, transition: Fx.Transitions.linear}); 
				myEffect3.start(bG.closedHeight); 
			} else {
				setTimeout("bG.flashcontent.style.height = bG.closedHeight", 300);
			}
				 
		} 	
  
  },
  
  
	
	// function to add event listener, also caches events so they can be removed when the
	// page unloads to avoid memory leaks in IE
  addEvent: function(elm, evType, fn, useCapture) {
		// for W3C DOM complience
    if (elm.addEventListener) {
      elm.addEventListener(evType, fn, useCapture);
      return true;
    } 
		// for IE...
		else if (elm.attachEvent) {
      var r = elm.attachEvent('on' + evType, fn);
      //EventCache.add(elm, evType, fn);
      return r;
    } else {
			// for anyone else not IE or Moz... Safari etc
      elm['on' + evType] = fn;
    }
  }
	
}

bG.addEvent(window, 'load', bG.init, false);