<!-- General purpose functions
// (c) 2008 MerrimansPlace.co.uk.  All rights reserved.

var QUERY_STR = "XXX";


function Header()
{
	var html = '';

	html = '<a name="Top"></a><table class=Header><tr>';
	document.write(html);

	// Logo    
	html = '<td class=Left>';
	//html = html + '<a href="index.htm">';
	html = html + '<img src="logo.jpg" class=Logo alt="Merrimans Place"> </img>';
	//html = html + '</a>';
	html = html + '</td>'; 
	document.write(html);  

	// Search form
	html = '<td class=Right>';
	html = html + '<form name="SearchForm" onsubmit="ProcessForm(this); return false;">';           	html = html + 'Find &nbsp;<input type="text" size="20" name="query">';
	html = html + '&nbsp; In &nbsp;<select name="service" size="1">'; 
	document.write(html); 

	// Search sites
 	html = '<option value="http://search.atomz.com/search/?sp-q=XXX&amp;';
	html = html + 'sp-a=sp10029c5d&amp;sp-p=all&amp;sp-f=ISO-885//9-//1">';
	html = html + 'this site...</option>';
	document.write(html); 
             
	html = '<option value="http://www.google.co.uk/search?q=XXX';
	html = html + '&ie=UTF-8&oe=UTF8&hl=en&btnG=Google+Search&meta=">';
	html = html + 'Google</option>';
	document.write(html); 

        html = '<option value="http://search.metacrawler.com/crawler?general=XXX'
	html = html + 
		'&method=0&redirect=&rpp=20&hpe=10&region=0&timeout=0&sort=0&theme=classic">';
	html = html + 'MetaCrawler</option>'; 
	document.write(html); 
                   
	// End of search form
	html = '</select>';
	html = html + '&nbsp;<input type="submit" value="Search">';
	html = html + '</form>';
	html = html + '</td>';
	document.write(html); 

	// Tidy up
	html = '</tr></table>';
	document.write(html); 
}



// Main footer
function Footer()
{
	var html = '';
	var now = new Date();
	var yy = now.getYear();

	// Workaround for Firefox bug (displays 108 instead of 2008)
	if (yy < 1900) 
	{
		yy = yy + 1900;
	}

	html = html + '<p class=Divider></p>';
	//html = '<span align=center class=Divider></span>';
	document.write(html);

	html = '<p class=Footer>MerrimansPlace.co.uk © I. Merriman 1997 - ' + yy + '. ';
	html = html + '&nbsp;All rights reserved.<br><br>';
	html = html + 'Disclaimer: The information offered on MerrimansPlace.co.uk ';
	html = html + 'is provided &quot;as is&quot; without warranty or guarantee of any kind. ';
	html = html + 'I cannot accept any responsibility or liability if there are any problems';
	html = html + ' with the information, service and/or merchandise provided by this web site and/or any external web sites.</p>';
	document.write(html);

	StatCounter();
}


// Links to all Sections, called by SideLinks and FooterLinks
function SectionLinks(bSideLink)
{
	SectionLink('index.htm', 'Front Page', bSideLink, false);
	SectionLink('compute.htm', 'Computing / Internet', bSideLink, false);
	SectionLink('ents.htm', 'Entertainment', bSideLink, false);
	SectionLink('cinema.htm', 'Films / Cinema', bSideLink, false);
	SectionLink('finance.htm', 'Finance', bSideLink, false);
	SectionLink('gadgets.htm', 'Gadgets / Technology', bSideLink, false);
	SectionLink('lifestyle.htm', 'Life Style', bSideLink, false);
	SectionLink('music.htm', 'Music', bSideLink, false);
	SectionLink('news.htm', 'News', bSideLink, false);
	SectionLink('notts.htm', 'Nottingham', bSideLink, false);
	SectionLink('refs.htm', 'Reference', bSideLink, false);
	SectionLink('shops.htm', 'Shops', bSideLink, false);
	SectionLink('sports.htm', 'Sport', bSideLink, false);
	SectionLink('tv.htm', 'Television', bSideLink, false);
	SectionLink('uktravel.htm', 'UK Travel', bSideLink, false);
	SectionLink('travel.htm', 'World Travel / Holidays', bSideLink, true);

}


// Link to a single section, called by SectionLinks
function SectionLink(strURL, strDesc, bSideLink, bLastLink)
{
	var html = '';

	if (bSideLink == true) 
	{	
		// Link on side of screen
		html = '<a class=SectionLink href="' + strURL + '">- ' + strDesc + '</a><br>';
	}
	else
	{	
		// Link in footer
		html = '<a class=SectionLink href="' + strURL + '">' + strDesc + '</a>';

		if (bLastLink == false)
		{
			html = html + ' <b>|</b> ';
		}
	}
	
	document.write(html);	
}


// Side list
function SideLinks()
{
	var html='';

	html = '<p class=Sections><span class=SectionHeading>Sections:</span><br>';
	document.write(html);

	SectionLinks(true);

	html = "</p>";
	document.write(html);
}


// Footer Links
function FooterLinks()
{
	var html='';

	html = '<p>&nbsp;</p>';
	document.write(html);

	html = '<p class=FooterLinks>';
	document.write(html);

	SectionLinks(false);

	html = '</p>';
	document.write(html);
}


// Stat Counter (used by footer)
function StatCounter()
{
	var html = "";
	html = '<!-- Start of StatCounter Code -->';
	html = html + '<script type="text/javascript" language="javascript">';
	html = html + 'var sc_project=318813; ';
	html = html + 'var sc_partition=1;'; 
	html = html + '</script>';
	document.write(html);

	html = '<script type="text/javascript" language="javascript"';
	html = html + 'src="http://www.statcounter.com/counter/counter.js"></script>';
	html = html + '<noscript>';
	html = html + '<a href="http://www.statcounter.com/free_hit_counter.html" target="_blank">';
	html = html + '<img  src="http://c2.statcounter.com/counter.php?sc_project=318813&amp;java=0" ';
	html = html + 'alt="free page hit counter" border="0"></a> </noscript>';
	html = html + '<!-- End of StatCounter Code -->';
	document.write(html);
}



//  Returns posn of "strSub" within "strMain"
function FindSubstring(strSub, strMain) 
{
	var i, nSubLen = strSub.length, nMainLen = strMain.length;
	
	for (i=0; i<=nMainLen-nSubLen; i++) 
	{
    	if (strSub == strMain.substring(i,i+nSubLen))
        	return i;
	}

	return false;
}


// Chop up query into parts before & after, text searched for
function PrepQuery(search) 
{
	var iPos = FindSubstring(QUERY_STR, search);
 
  	this.pre = search.substring(0,iPos);
  	this.post= search.substring(iPos+QUERY_STR.length, search.length);
}


// Build URL and call the search engine
function ProcessForm(form) 
{
  	var i, strNewQry="";
	var strOldQry=form.query.value;

  	for (i=0; i<strOldQry.length; i++) 
	{  // compress [ ]+ into \+
    		var thischar = strOldQry.charAt(i);

    		if (thischar != ' ')
      			strNewQry += thischar;
    		else if (lastchar != ' ')
      			strNewQry += '+';
    		lastchar = thischar;
  	}

	i=form.service.selectedIndex;
  	var eng=new PrepQuery(form.service.options[i].value);

   	window.location.href = eng.pre + strNewQry + eng.post;
}



//  Handle portal/category menus 
function GotoURL() 
{
	i = document.linkform.list.selectedIndex;
	if (i > 0)
		{
		window.location.href = document.linkform.list.options[i].value;
		}
}




//-->