// These are the custom settings
// Scrolling type - scroll interval in milliseconds (1000 = 1 second)
var intInterval = 5000;

// Random code addition (in case multiple blocks are on a single page i.e. the config page)
var intRandId = Math.round( 100 * Math.random() );

// Fonts
strHeader1Font 	= 'arial';
strHeader2Font 	= 'arial';
strGeneralFont	= 'arial';

// Fontsizes
strHeader1Size	= '14pt';
strHeader2Size	= '12pt';
strGeneralSize	= '8pt';

// Colors
strBack1Color	= '#FFFFFF';
strBack2Color	= '#FFFFFF';
strBorderColor	= '#FFFFFF';
strHeader1Color	= '#000000';
strHeader2Color	= '#000000';
strGeneralColor = '#000000';
strLinkColor	= '#E0220C';

// Logo or text?
blnUseLogo = true;
strLogo	= 'images/kpn.gif';
strText = '';

// The news items to display
arrItems = new Array( 10 );
arrItems[0] = new Array( 'Nieuws', 'Nieuw: de micro-SIM kaart van KPN', 'cc829/nieuws/319' );
arrItems[1] = new Array( 'Actie', 'Digitale telefonie nu voor iedere bedrijfscentrale', 'cc829/actie/317' );
arrItems[2] = new Array( 'Actie', 'Onbeperkt mobiele data met Pocket Internet Zeker', 'cc829/actie/315' );
arrItems[3] = new Array( 'Nieuws', 'KPN verhoogt snelheden Zakelijk Internet', 'cc829/nieuws/313' );
arrItems[4] = new Array( 'Nieuws', 'Wat gebeurt er als uw server of harddisk crashed?', 'cc829/nieuws/307' );
arrItems[5] = new Array( 'Actie', 'Wilt u onze nieuwsbrief blijven ontvangen?', 'cc829/actie/293' );
arrItems[6] = new Array( 'Nieuws', 'Kom naar ons voor al uw ICT vragen', 'cc829/nieuws/295' );
arrItems[7] = new Array( 'Actie', 'Alle contracten  in één hand..... wel zo makkelijk', 'cc829/actie/297' );
arrItems[8] = new Array( 'Actie', 'Steeds meer ondernemers kiezen Zakelijk Glas', 'cc829/actie/298' );
arrItems[9] = new Array( 'Nieuws', 'Als het gras elders niet zo groen blijkt', 'cc829/nieuws/304' );

// Base link
strBaselink = 'http://www.partnernieuws.nl/';

// syndOpenWindow function
// Opens a popup window without all default browser features
function syndOpenWindow( strTarget ) {
	var strOpts = "";
	strOpts = 'left=50,top=50,screenX=50,screenY=50,width=800,height=600,menubar=no,location=no,resizable=no,scrolling=yes,scrollbars=yes,status=0';
	PopUP = window.open( strTarget, 'eMarketing', strOpts);
	PopUP.focus();
}


var intActiveItem = 0;

// renderBlock()
// This function handles the actual display of the syndication block on the site
function renderBlock() {
	// Output the header
	document.write( '<div id="syn_container" style="background-color: ' + strBack1Color + '; width: 486px; height: 45px; border: 1px solid ' + strBorderColor + '; line-height: 100%;">' );
	document.write( ' <table cellpadding="0" cellspacing="0" border="0" style="height: 45px; width: 100%;">' );
    document.write( '  <tr>' );
	document.write( '   <td id="syn_header" style="font-family: ' + strHeader1Font + '; font-size: ' + strHeader1Size + '; color: ' + strHeader1Color + '; text-align: center; vertical-align: middle; width: 200px;">' );
	
	// Output either the logo or the custom titletext
	if( blnUseLogo ) {
		document.write( '<img src="' + strBaselink + strLogo + '" alt="KPN Business Partner" />' );
	} else {
		document.write( '<h3 style="margin: 3px;">' + strText + '</h3>' );
	}
	
	// End header, start content
	document.write( '</td>' );
	document.write( '   <td style="font-family: ' + strGeneralFont + '; font-size: ' + strGeneralSize + '; background-color: ' + strBack2Color + '; color: ' + strGeneralColor + '; padding: 3px; border-left: 1px solid ' + strBorderColor + '; width: 10px;">&gt;</td>' );
    document.write( '   <td id="syn_content' + intRandId + '" style="font-family: ' + strGeneralFont + '; font-size: ' + strGeneralSize + '; background-color: ' + strBack2Color + '; color: ' + strGeneralColor + '; vertical-align: middle; padding: 3px; padding-left: 8px;">' );

	// Output the newsitems (only first two items!)
	if( arrItems.length == 0 ) {
		document.write( '<span style="text-align: justify;">Op dit moment geven wij er de voorkeur aan om u persoonlijk te informeren over de lopende aanbiedingen van KPN.<br />Voor persoonlijk advies kunt u ons bellen.</span>' );
	} else {
		strDisplayTitle = arrItems[0][1];
				
		if( arrItems[0][2] ) {
			strLink = strBaselink + arrItems[0][2];
		} else {
			strLink = '#';
		}
		
		document.write( '    <a onclick="syndOpenWindow( \'' + strLink + '\' );" title="' + arrItems[0][0] + ': ' + arrItems[0][1] + '" style="color: ' + strLinkColor + '; cursor: hand;">' + strDisplayTitle + '</a><br />' );
	}
		    
	// Output the footer
    document.write( '   </td>' );
    document.write( '  </tr>' );
	document.write( ' </table>' );
	document.write( '</div>' );
	
	window.setTimeout( 'scrollNext()', intInterval );
}

function scrollNext() {
	if( arrItems.length > 0 ) {
		// Goto the next item in the list of items
		intActiveItem++;
		
		// If we reached the last one, reset and go to the first one again
		if( intActiveItem == arrItems.length ) {
			intActiveItem = 0;
		}
		
		// Replace the first item with a new item
		strDisplayTitle = arrItems[intActiveItem][1];
				
		if( arrItems[intActiveItem][2] ) {
			strLink = strBaselink + arrItems[intActiveItem][2];
		} else {
			strLink = '#';
		}
	
		// Show next link		
		var elContentContainer = document.getElementById( 'syn_content' + intRandId );
		var strItems = '<a onclick="syndOpenWindow( \'' + strLink + '\' );" title="' + arrItems[intActiveItem][0] + ': ' + arrItems[intActiveItem][1] + '" style="color: ' + strLinkColor + '; cursor: hand;">' + strDisplayTitle + '</a><br />';
		elContentContainer.innerHTML = strItems;
		
		// Restart the timer
		window.setTimeout( 'scrollNext()', intInterval );
	}
}

// Call renderBlock();
renderBlock();