var bookmarkurl   = "http://www.kijktvonline.nl/";
var bookmarktitel = "Kijk TV Online.nl";
var Width_
var contents = 0;
var TV = 0;
var TV2 = false;
var wait_now = 0;
var ScreenRatio = 270/320;
var StandardVideoHeight = 270;

function favorieten()
{
	if( window.sidebar ) {
		// Mozilla Firefox Bookmark
		window.sidebar.addPanel(bookmarktitel, bookmarkurl,"");
	}else if( window.external ) {
		// IE Favorite
		window.external.AddFavorite( bookmarkurl, bookmarktitel);
	}else if(window.opera && window.print) {	// Opera Hotlist
		return true;
	}
}

function setHomepage()
{
	if (document.all)
	{
		document.body.style.behavior='url(#default#homepage)';
		document.body.setHomePage( absLINK );
	}else if (window.sidebar) {
		if(window.netscape) {
			try
			{
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
			}catch(e) {
				alert("We kunnen uw home pagine niet aanpassen.\r\nDit zult u helaas handmatig moeten doen in de configuratie van uw browser.");
		}	}
		var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
		prefs.setCharPref( 'browser.startup.homepage', absLINK );
}	}

function resizeTV( s )
{
	// Get the current ScreenRatio.
	TVRatio = ScreenRatio;
	if( TVRatio == 0 ) { TVRatio = (270/320); }

	if (s == null){
		s = -1;
	}

	// No resizing while watching ads!
	if( RunningTV != 1 && s == -1)
		return false;

	if( horizontalSlider && s == -1 ) {
		var slider = horizontalSlider.getValue();
	}else{
		// Add is being played: dont change the screen size.
		var slider = 0;
		TVRatio = (270/320)
	}

	if(slider < 0) {
		y = Math.floor( StandardVideoHeight  + (slider * (StandardVideoHeight/100) ) );
	}else{
		y = Math.floor( StandardVideoHeight  + (slider * 3 * (StandardVideoHeight/100) ) );
	}
	x = (y / TVRatio);

	XX = Math.ceil( $(document).width() * 0.9 );
	if(XX < MinWidth) {
		XX = MinWidth;
	}else if(XX > MaxWidth) {
		XX = MaxWidth;
	}

	if(x > (XX - 320)) { x = (XX - 320); }
	$('#TV').width( x );
	$('#TV').height( Math.round(TVRatio * x) );
	$('#VideoStrip').width( x );
	$('#VideoStrip').height( Math.round(TVRatio * x) );
	$('#TV_comment').width( x );

	if( $('#FlashPlayer1') ) {
		$('#FlashPlayer1').width( x );
		$('#FlashPlayer1').height( Math.round(TVRatio * x) );
	}
	if( $('#FlashPlayer2') ) {
		$('#FlashPlayer2').width( x );
		$('#FlashPlayer2').height( Math.round(TVRatio * x) );
	}
};

function Wait_time( id )
{
	if( wait_now > $(window).width() || wait_now < $(window).width() )
	{
		div_maxwidth( id );
		wait_now = $(window).width();
	}
	setTimeout('Wait_time("'+ id +'")', PageResizeTime);
}

function div_maxwidth( id1 )
{
	$('#Row1').width( 0 );	$('#Row2').width( 0 );	$('#Row3').width( 0 );	$('#Row4').width( 0 );	$('#Row5').width( 0 );
	$('#Spacer_1').html('');	$('#Spacer_2').html('');	$('#Spacer_3').html('');	$('#Spacer_4').html('');
	$('#Spacer_1').width( 0 );	$('#Spacer_2').width( 0 );	$('#Spacer_3').width( 0 );	$('#Spacer_4').width( 0 );
	Width_ = Math.ceil( $(window).width() * 0.9 );
	if(Width_ < MinWidth) {
		Width_ = MinWidth;
	}else if(Width_ > MaxWidth)	{
		Width_ = MaxWidth;
	}
	$( '#'+id1 ).width( Width_ );

// De header goed maken
	BolletjesBreed = Math.floor( ( ($(document).width() - Width_) / 2 ) * (ProcentBolletjes / 100) );
	if( BolletjesBreed <= 0 ) { BolletjesBreed = 1; }

	$('#headLeft').width( BolletjesBreed );
	$('#headRight').width( BolletjesBreed );

// De content goed maken...
	ContentWidth = $('#ContentDiv').width();
	rows = Math.floor( ContentWidth / ContentMinWidth );

// Tabel breedtes instellen
	if( contents > 0 )
	{
		if(rows == 1) { m = 0 }
		else if(rows == 2) { m = 6 }
		else if(rows == 3) { m = 8 }
		else if(rows == 4) { m = 9 }
		else if(rows == 5) { m = 10 }
		else{ rows = 2; m = 6 }
		w = Math.floor( ContentWidth / rows ) - m;
		$('#Row1').width( w );
		if(rows > 1) {
			$('#Row2').width( w );
			$('#Spacer_1').width( 12 );
			if(rows > 2) {
				$('#Row3').width( w );
				$('#Spacer_2').width( 12 );
				if(rows > 3) {
					$('#Row4').width( w );
					$('#Spacer_3').width( 12 );
					if(rows > 4) {
						$('#Row5').width( w + 2 );
						$('#Spacer_4').width( 12 );
		}	}	}	}
		$('#contentdiv').width( (w + m) * rows );
		$('#Row1').html(''); $('#Row2').html(''); $('#Row3').html(''); $('#Row4').html(''); $('#Row5').html('');
		var z = 1;
		for (var i = 1; contents >= i; i++)
		{
			source = '<br />' + $('#container_'+i).html();
			if(z == 1) { $('#Row1').html( $('#Row1').html() + source); }
			if(z == 2) { $('#Row2').html( $('#Row2').html() + source); }
			if(z == 3) { $('#Row3').html( $('#Row3').html() + source); }
			if(z == 4) { $('#Row4').html( $('#Row4').html() + source); }
			if(z == 5) { $('#Row5').html( $('#Row5').html() + source); }
			z++;
			if( z > rows ) { z = 1; }
		}
	}else if( $('#contentWidth') ) {
		if(ContentWidth > ContentMaxWidth)
		{
			$('#contentWidth').width( ContentMaxWidth );
		}else{
			$('#contentWidth').width( ContentWidth );
}	}	}

function SetHeaderImage( img ) { $('#Afbeelding').rows = '<img src="'+ AbsLINK +'images/'+ img +'.gif" alt="" border="0" />'; }

function SelectAll( id )
{
	document.getElementById( id ).select();
}
