//********************************************************************************************************
//Checkm8 Ad Coding
//********************************************************************************************************
function DisplayAds(cat, position, width, height)
{

	var CM8url = 'http://ads.checkm8.co.za/adam/detect?';
	//var CM8cat = '&cat=st.testing';
	var CM8cat = '&cat=st.';
	if ( cat != "" )
		CM8cat = CM8cat + cat;
	else
		CM8cat = CM8cat + ProcessCookie( "adstring" );
	
	//document.write ( "Add: " + position + ":" + CM8cat + "(" + height + "," + width + ")");
	//return;
	CM8ShowAd(CM8url +'req=bo'+'&pos=' + position + '&sz=' +  width + 'x' + height + CM8cat);
}

function DisplayRMAds( cat )
{

	var CM8url = 'http://ads.checkm8.co.za/adam/detect?';
	//var CM8cat = '&cat=st.testing';
	var CM8cat = '&cat=st.';
	if ( cat != "" )
		CM8cat = CM8cat + cat;
	else
		CM8cat = CM8cat + ProcessCookie( "adstring" );
	
	//document.write ( "Add: " + position + ":" + CM8cat + "(" + height + "," + width + ")");
	//return;
	CM8ShowAd(CM8url +'req=r'+ CM8cat);
}

//********************************************************************************************************

//********************************************************************************************************
//Sundaytimes Popup Windows
//********************************************************************************************************
	function viewPop(filetoview)
	{
		
		var fwidth = screen.width;
		var fheight = screen.height;

		var fleft = (fwidth - 500)/2;
		var ftop = (fheight - 400)/2;

		var desktop=window.open(filetoview,"floating","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable,width=500,height=400,left=" + fleft + ",top=" + ftop);
		
	}
//********************************************************************************************************


//********************************************************************************************************
//Go to a given url
//********************************************************************************************************
	function goUrl(Selected) 
	{
		/*	
			change page location to option selected from navigation 
			drop-down 
		*/
		var newURL = Selected.options[Selected.selectedIndex].value ;
		if (newURL!=" ") {
			document.location.href = newURL;
		}
	}
//********************************************************************************************************


//********************************************************************************************************
//Random popups for Adservings - Open per session or per page.
//********************************************************************************************************
	
	var URLS, WinParam, Impressions
			
	URLS = new Array();
			
	URLS[0] = "/home/welcome.html";
	//URLS[1] = "HTMLPopup.htm";
	//URLS[2] = "FlashPopup.htm";
			
	PerSession = 1;	
			
	function Initialise()
	{
		//Disabled for now...
		
		var Width, Height;
		
		Width = "550";
		Height = "550";
		WinParam = "scrollbars=yes,resizable=yes,toolbar=no,menubar=no,status=yes,location=no,left=100,top=30,height=" + Height + ",width=" + Width;
		
		if (PerSession == 0)
			OpenPopup();
		else
		{
			CheckLoad();
		}
		
	}
			
	function ProcessCookie(Name)
	{
		var Search, ReturnVal, offSet, End;	
		Search = Name + "=";
		ReturnVal = "";
		
		if (document.cookie.length > 0)
		{
			offSet = document.cookie.indexOf(Search);
			if (offSet != -1)
			{
				offSet += Search.length;
				End = document.cookie.indexOf(";", offSet);
				if (End == -1)
				{
					End = document.cookie.length;
				}
				ReturnVal = unescape(document.cookie.substring(offSet, End));
			}
		}
		return ReturnVal;
	}
			
	function CheckLoad()
	{
		if (ProcessCookie("Popup") == "")
		{
			OpenPopup();
			document.cookie = "Popup=Yes";
		}
	}
	
	function OpenPopup()
	{
		var RandomNo, objWin;
		RandomNo = Math.floor(Math.random()*(URLS.length))
		
		objWin = window.open(URLS[RandomNo], "Popup", WinParam);
		
		//objWin.blur();
		//window.focus();
	}
//********************************************************************************************************

//********************************************************************************************************
//Relatedlinks - Create and populate relayted links.
//********************************************************************************************************

	function RaletedObject ( Title, URL )	{
		this.Title = Title;
		this.URL = URL;
	}

	function createRalaytedlinks(){
	
		//check for arrays
		//populate string
		//add string to innerHTML of div
		var sContent = "";
		var objDiv;
		

			sContent = '<table border="0" cellpadding="0" cellspacing="0" width=220 bgcolor=#999999><tr><td><table border="0" cellpadding="1" cellspacing="0" width="220" bgcolor="#999999"><tr><td><table width="220" border="0" cellpadding="3" cellspacing="0"><tr><td bgcolor="#cc0000" valign="top"><div class="communitystrap">RELATED LINKS</div></td></tr><tr><td valign="top" bgcolor="white"><div class="frontpageheadline">';
			for (var i = 0; i < arRalatedlinks.length; i++){
				sContent += '<li type="square"><a href="' + arRalatedlinks[i].URL + '">' + arRalatedlinks[i].Title + '</a></li><br>';
			}
			sContent += '</div></td></tr></table></td></tr></table></td></tr></table>';
			objDiv = document.getElementById("divRelatedLinks");
			objDiv.innerHTML = sContent;


	}
//********************************************************************************************************
