
	var D                   = document;
	var excludeIdArr	      = new Array( 'bioId' );
	var divEmptyHeight;
	var closedTabHeight     = 0;
	var tabData 						= new Object();
	var initialHeightObject = new Object();
	var imageRoot						= '/fab2007/landingpage/artist';

	function preload() {
		var args = preload.arguments;
		for (var x = 0; x < args.length; x += 2) {
			eval( args[x]+' = new Image()' );
			eval( args[x]+'.src = "'+args[x+1]+'"' );
		}
	}

	preload(
		'bt_home', imageRoot + '/pics/home_grey.gif',
		'bt_home_over',imageRoot + '/pics/home_orange.gif',
		'bt_concerts',imageRoot + '/pics/concerts_grey.gif',
		'bt_concerts_over',imageRoot + '/pics/concerts_orange.gif',
		'bt_playlist',imageRoot + '/pics/playlist_grey.gif',
		'bt_playlist_over',imageRoot + '/pics/playlist_orange.gif',
		'bt_channels',imageRoot + '/pics/channels_grey.gif',
		'bt_channels_over',imageRoot + '/pics/channels_orange.gif',
		'bt_charts',imageRoot + '/pics/charts_grey.gif',
		'bt_charts_over',imageRoot + '/pics/charts_orange.gif',
		'bt_arrow',imageRoot + '/pics/' + tabArrowUp,
		'bt_arrow_down',imageRoot + '/pics/' + tabArrowRight,
		'bt_archive',imageRoot + '/pics/archive_grey.gif',
		'bt_archive_over',imageRoot + '/pics/archive_dark.gif',
		'bt_comingup',imageRoot + '/pics/comingup_grey.gif',
		'bt_comingup_over',imageRoot + '/pics/comingup_dark.gif',
		'bt_pending',imageRoot + '/pics/pending_grey.gif',
		'bt_pending_over',imageRoot + '/pics/pending_dark.gif',
		'bt_offline',imageRoot + '/pics/offline_grey.gif',
		'bt_offline_over',imageRoot + '/pics/offline_dark.gif'
	);

	function swapOver( imgName )	{
		if ( D.images ) {
			D.images[imgName].src = eval( imgName+'_over.src' );
		}
	}

	function swapOut( imgName )	{
	  if ( imgName != 'bt_archive' ) {
  		if ( D.images ) {
  			D.images[imgName].src = eval( imgName+'.src' );
  		}
		}
	}

	function swapTabArrow( ref ) {
		if( ref.name != '' ) {
			if( ref.src == eval( ref.name+'.src' ) ) {
			 	ref.src = eval( ref.name+'_down.src' );
			}
			else {
				ref.src = eval( ref.name+'.src' );
			}
		}
 	}

 	function setArrowRight(ref) {
 		if( ref.name != '') {
 			if( ref.src = eval( ref.name+'_down.src' ) ) {
	 			ref.src = eval( ref.name+'.src' );
    	}
 		}
 	}

	function onTabClick( el ) {
		if( el ) {
	    var imgs = el.getElementsByTagName( 'img' );
			if( imgs && imgs.length > 0 ) {
					swapTabArrow( imgs[0] );
			}
			var n = findNextDiv( el );
			if( n ) {
				toggleNextDiv( n );
			}
		}
	}

	function findNextDiv( el ) {
		var n = el;
		do  n = n.nextSibling;
		while ( n && n.nodeType != 1 && n.tagName != 'DIV' );
		return n;
	}

	function toggleNextDiv( el ) {
		if( el ) {
			if( el.style.display == 'block' ) {
				el.style.display = 'none';
			} else {
				el.style.display = 'block';
				if( initialHeightObject[el.id] == undefined ) {
					initialHeightObject[el.id] = getTotalHeight( el );
				}
			}
			setTabHeight();
		}
	}

	// [NvG] +1 prevents useless Firefox scrollbar
	function getTotalHeight( el ) {
		var margin 	= getMarginSize( el );
		var theight = margin + el.offsetHeight;
		return Math.ceil(theight) + 1;
	}

	function getMarginSize( el ) {
		//IE
		if( el.currentStyle ) {
			var tMarginBottom = el.currentStyle['marginBottom'];
			var tMarginTop = el.currentStyle['marginTop'];
		}
		//Mozilla
	  else if( window.getComputedStyle ) {
			var tMarginTop = D.defaultView.getComputedStyle( el, null ).getPropertyValue( 'margin-top' );
			var tMarginBottom = D.defaultView.getComputedStyle( el, null ).getPropertyValue( 'margin-bottom' );
		}
		var total = parseInt( tMarginBottom )+ parseInt( tMarginTop );
		return isNaN( total ) ? 0 : total;
	}

	function initTab() {
		var el									= D.getElementById( 'rightSub');
		var divs								= el.getElementsByTagName( 'DIV' );
		var tabHeight;
		var totalTabHeight			= 0;

		if( divs ) {
			var y = 0;
	    for ( var i = 0; i < divs.length; i++ ) {
	      if( divs[i].className == 'rtabHeader') {
	        totalTabHeight 						+= getTotalHeight( divs[i] );
	        if( y == 0 ) {
	        	tabHeight = totalTabHeight;
	        }
	        y++;
	      }
	    }
		}
		var excludeHeight				= 0;
		if( excludeIdArr && excludeIdArr.length > 0 ) {
			for( var i =0; i < excludeIdArr.length; i++ ) {
				excludeHeight += getTotalHeight( D.getElementById( excludeIdArr[i] ) );
			}
		}

		tabData.divFields	 			= divs;
		tabData.tabHeight				= tabHeight;
		tabData.totalHeight 		= getTotalHeight( el );
		tabData.totalTabHeight	= totalTabHeight;
		tabData.availableHeight	= tabData.totalHeight - totalTabHeight - excludeHeight;
	}

	function setTabHeight() {
		var tabHeightAvg 	= tabData.tabHeight;
		var tabHeightAll 	= tabData.totalTabHeight;
		var totalHeight 	= tabData.totalHeight;
    var blockDiv 			= new Array;	// openstaande divs
    var blockDivAll 	= 0;					// hoogte alle openstaande divs
		var divs					= tabData.divFields;

  	if( divs ) {
	    for(var i = 0; i < divs.length; i++) {
	      if( divs[i].className == 'switchgroup1') {
	        if( divs[i].style.display == 'block') {
	          blockDiv[blockDiv.length] = divs[i];
	          blockDivAll += divs[i].offsetHeight;
	        }
	      }
	    }
		}

		var availableHeight = tabData.availableHeight;
		var avDiv 					= availableHeight / blockDiv.length;
		var restHeight			= 0;

		if( blockDiv.length == 1 ) {
			var openDiv = blockDiv[0];
			var startSize = initialHeightObject[openDiv.id];
      if( startSize < availableHeight ) {
				openDiv.style.height = startSize + 'px';
      }else if( startSize > availableHeight ){
				openDiv.style.height = availableHeight + 'px';
      }
		}else if( blockDiv.length > 1 ) {
			var avgCount = 0;
	    for( var i = 0; i < blockDiv.length; i++ ) {
				var startSize = initialHeightObject[blockDiv[i].id];
				if( startSize < avDiv ) {
          blockDiv[i].style.height =  startSize + 'px';
					restHeight = avDiv - startSize;
				}else if( startSize > avDiv ) {
          blockDiv[i].style.height =  avDiv + 'px';
					avgCount++;
				}
	    }
	    if( restHeight > 0 ) {
		    for( var i = 0; i < blockDiv.length; i++ ) {
					var startSize = initialHeightObject[blockDiv[i].id];
					if( startSize > avDiv ) {
						var h = avDiv + Math.round( restHeight/avgCount );
						h = h > startSize ? startSize : h;
						blockDiv[i].style.height =  h + 'px';
					}
		    }
	    }
		}
  }

  function highlight( el ) {
    if( el.className != 'cSelected' ) {
	  	el.style.borderTop 		= '1px solid #a2a2a2';
	  	el.style.borderBottom = '1px solid #a2a2a2';
  	} else{
	    el.style.borderTop 		= '1px solid #bd7513';
	  	el.style.borderBottom = '1px solid #bd7513';
    }
  }

  function dehighlight( el ) {
  	el.style.borderTop 		= '1px solid #ffffff';
  	el.style.borderBottom = '1px solid #ffffff';
  }

  function buyLight( el ) {
  	el.style.color    = '#bd7513';
  }

  function deBuyLight( el ) {
  	el.style.color 		= '#7a7a7a';
  }

  function Buytrack( inTrack, inName, inPic, inId, inAlbum, inUrl ) {
  	this.track 	= inTrack;
	  this.name 	= inName;
	  this.pic 		= inPic;
	  this.id 		= inId;
	  this.album 	= inAlbum;
	  this.url 		= inUrl;
  }

  function onChapter( inId ) {
    var setlist = D.getElementById( 'setList' );

    if( setlist ) {
	    var spans 	= setlist.getElementsByTagName( 'span' );
	    drawBuyInfo( inId );

	    for( var i = 0; i < spans.length; i++) {
	      if( spans[i].id == 'c_' + inId ) {
	        spans[i].className = 'cSelected';
	      }else{
	        spans[i].className = 'cDeSelected';
	      }
	    }
	   }
  }

  function drawBuyInfo ( inId ) {
 		var html = '';
 		var invalid = true;

  	for( var i = 0; i < buytrack.length; i++ )	{
       if( inId != undefined && inId > 0 ) {
         if( buytrack[i].id == inId && buytrack[i].album != '') {
	          html += '<div class="buyAll" onClick="window.open(\'' + buytrack[i].url +  '\')">';
	          html += '<div id="buyPic"><img src="' + buytrack[i].pic + '" width="45" height="45" alt="" /></div>';
	          html += '<div class="buyTrack"><span onmouseover="buyLight(this)" onmouseout="deBuyLight(this)" onClick="window.open(\'' + buytrack[i].url +  '\')" style="color:#7a7a7a">BUY TRACK</span></div>';
	          html += '<div class="buyName"><span>'+ buytrack[i].name.toUpperCase(); + '</span></div>';
	    	    html += '<div class="buyFrom"><span>from album:</span></div>';
	          html += '<div class="buyAlbum"><span>'+ buytrack[i].album.toUpperCase(); + '</span></div>';
  	        html += '</div>'
            invalid = false;
   	     }
 	     }
 	  }
		if( invalid ) {
			html = '<div class="buyTrack" style="margin-top:5px"><span style="color:#c3c3c3">BUY TRACK</span></div>';
		}
	 	D.getElementById( 'buyThis' ).innerHTML = html;
 	}

	function disableBody() {
		D.body.ondragstart = function() {
			return false;
		}

		//FF
		if(typeof D.body.style.MozUserSelect != 'undefined') {
      D.body.style.MozUserSelect = 'none';
    }
    //Internet Explorer
    else if (typeof D.body.onselectstart != 'undefined') {
      D.body.onselectstart = function() {
				return false;
			}
		}
		//Rest(Opera)
		else {
			D.body.onmousedown = function() {
				return false;
			}
			D.body.style.cursor = 'default';
		}
	}

  function goToChapter( inSetNr ) {
    var el = D.getElementById( 'i_test' );
    el.goToChapter( inSetNr );
  }

	function init() {
		initTab();
		var el = D.getElementById( openDefault + '-title' );
		onTabClick( el );
    disableBody();
	  onChapter( 0 );
  }