var NS4 = (document.layers) ? 1 : 0;
var IE4 = (document.all) ? 1 : 0;

var starter = "<table cellspacing = 1 cellpadding = 1><tr><td width = 55 align = 'right'><img src = '../img2/";
var ender = "</font></td></td></tr></table>";
var mider = " height = 60></a></td><td width = 155><a class = under target = _blank href = 'http://www.amazon.co.uk/exec/obidos/ASIN/";
var rhsStatAd = new Array()

rhsStatAd[0] = starter + "0140145818.gif' width = 38" + mider + "0140145818/theowlnet-21'>A History of Wales</a><br>John Davies<br><font color = '#ba0501'><b>£10.39 (20%)" + ender;

rhsStatAd[1] =  starter + "1902007735.jpg' width = 43" + mider + "1902007735/theowlnet-21'>Country Living Guide to Rural Wales</a><br>Moira McCrossan<br><font color = '#ba0501'><b>£10.99" + ender;

rhsStatAd[2] =  starter + "067101580X.jpg' width = 39" + mider + "067101580X/theowlnet-21'>Urban Dreams and Rural Realities: One Couple's Pursuit of the Good Life  </a><br>Bel Crewe, Daniel Butler<br><font color = '#ba0501'><b>£6.39 (20% off)" + ender;

rhsStatAd[3] =  starter + "1843531208.jpg' width = 39" + mider + "1843531208/theowlnet-21'>The Rough Guide to Wales</a><br>Mike Parker, Paul Whitfield<br><font color = '#ba0501'><b>£8.79 (20% off)" + ender;

rhsStatAd[4] =  starter + "186450126X.jpg' width = 42" + mider + "186450126X/theowlnet-21'>Lonely Planet: Wales</a><br>John King<br><font color = '#ba0501'><b>£7.99 (20% off)</b>" + ender;

function start(nameOfElement) 
{
    eval("setInterval('update(" + '"' + nameOfElement + '"' + ")', 4000)");
}

function update(nameOfElement) 
{
   if (num == ar.length) num = 0;
   eval("display(" + '"' +  nameOfElement + '"' + ", ar[num])")
   num++;
}

function getRandNotX(x)
{
    if (rhsStatAd.length == 1) return 0

    var num = x
    while(num == x)
        num = Math.floor(Math.random()*rhsStatAd.length);
    return num
}

// Change text element
function display(id, str) {
  if (NS4) {
    with (document[id].document) {
      open();
      write(str);
      close();
    }
  } else {
    document.all[id].innerHTML = str;
  }
}

function getPhotoList()
{ 
   var p = places;
   var s = "";
   var s = s + "<font class = smltit>";
  
  for(var i = 0; i < p.length; ++i)
  {
       s = s + p[i][0] + "<br>" + getPhotosForI(i);
   }
   s = s + "</font>";
   return s;
}

function blankstatus()
{
    status = " "
}

function getNumOfPics()
{
   var total = 0
   for(var i = 0; i < places.length; ++i)
       total = total + places[i][1];
  return total
}

function getPhotosForI(i)
{
    var p = places
    var s = ""
    var s = s + "<table cellspacing = 7><tr>"

    var j = 0
    var counter = -1
    for(j = 0; j < p[i][1]; ++j)
   {
          counter++
          if(counter == 5)
          {
               s = s +"</tr><tr>"
               counter = 0
          }
          s = s + "<td width = 80 align = 'center'><a onmouseover = 'blankstatus(); return true;' href = 'javascript:displayFullSizeImage(" + i + ", " + j + ")'>";
          s = s + "<img src = 'img/tn_" + (p[i][0].replace(/ /gi, "") + (j+1)) + ".jpg' border = 0></a></td>";
   }
   s = s + "</tr></table>";
   return s;
}

function displayFullSizeImage(i, j)
{

    blankstatus();
    var p = places
    var filename = "img/" + (p[i][0].replace(/ /gi, "") + (j+1)) + ".jpg";
    var picname = placeName + " - " + p[i][0] + " Picture " + (j+1);
    var thumbnail = "img/tn_" + (p[i][0].replace(/ /gi, "") + (j+1)) + ".jpg";

    var w = window.open("", "", "width=790, height=525, scrollbars")
    w.moveTo(0,0)

    var BS = ""
    BS = "<html><head><title>" + picname + " - Copyright 2003 Carm1.co.uk, All Rights Reserved</title>"
    BS = BS + "<link rel = 'stylesheet' type = 'text/css' href = '../../codes/carm1.css'>"

    BS = BS + "<script language = 'JavaScript1.2'>var NS4 = (document.layers) ? 1 : 0;var IE4 = (document.all) ? 1 : 0;function display(id, str) {if (NS4) {with (document[id].document) {open();write(str);close();}}else {document.all[id].innerHTML = str;}}status = ' ';</script></head>"

    BS = BS + "<body>"
    BS = BS + getTopOfZoomedPage()
    BS = BS + "<table width = 753><tr><td width = 530 align = 'center' valign = 'top'>"
    BS = BS + "<table cellspacing = 0 cellpadding = 0><tr><td align = 'center'>"
    BS = BS + getAmazonBanner();
    BS = BS + "<br><font color = '#555555'>Click here to <a class = under href = 'javascript:close()'>Close </a> this window and return<br>to view more photographs of <b>" + placeName + "</b>.</font><br>"

    quot = '"'
    changePic = "imgMain.src = " + quot + filename + quot
    fullCmd = "display(" +  quot + "largePic" + quot + ", " + quot + "" + quot + ");" + changePic

    BS = BS + "<span id = largePic><br><br><b>Full size image is loading. Please Wait....</b><br><i>Image should be displayed within 30 seconds.</i><br><br><img src = " + "'" + filename + "'" + " width = 1 height = 1 onload = '" + fullCmd + "'></span></br>"
    BS = BS + "<img name = imgMain border = 1 src = '" + thumbnail + "' ></td></tr>"

    // Add 2px padding
    BS = BS + "<tr height = 2><td><img src = '../../img/pixel.gif' height = 2></td></tr>"
    BS = BS + "<tr><td align = 'center'><b style = 'color:#ba0501'>" + picname +"</b></td></tr></table>"
    BS = BS + "</td>"

    BS = BS + getRightColumn()
    BS = BS + "</tr></table>"
    BS = BS + "</body></html>"

    // Output HTML code
    var d = w.document.write
    d(BS);
}

function getTopOfZoomedPage()
{
    var s = ""
    var s = s + "<table><tr height = 60>" + getLogoInTD(); 
    s = s + "<td width = 5><img src = '../img/pixel.gif' width = 5 height = 1></td>"
    s = s + "<td width = 468><A HREF='http://www.amazon.co.uk/exec/obidos/redirect-home?tag=theowlnet-21&site=books'><IMG SRC='../img/fixedad.gif' alt='In Association with Amazon.co.uk' border='0' width = 468 height = 60></A></td>"
    s = s + "</tr></table><br>"
    return s;
}

function getTopOfPage()
{
   var s = ""
   s = "<table cellpadding = 0 cellspacing = 0><tr height = 60>" + getLogoInTD()
   s = s + "<td width = 10><img src = '../img/pixel.gif' width = 10 height = 1></td>"
   s = s + "<td value = 'center'>" + getDynamicAdvert()
   s = s + "</td></tr><tr><td colspan = 3 align = 'right'><font style = 'color:red;font-size:7pt'> <a href = '../advertise.htm' style = 'color:red;text-decoration:underline'>Advertise</a> your business here.</font></td></tr></table><br>"
   return s;
}

function getLogoInTD()
{
    var s = "<td width = 120 bgcolor = '#ba0501' valign = 'center' align = 'center' style = 'color:white; font-size:12pt'><b>Kidwelly.info</b><br><font class = sml>Free Photographic Guide to Kidwelly</font></td>"
    return s
}

function getMainBody()
{
   var p = places
   var s = ""
   s = s + "<font style = 'color:#777777; font-size:8pt'>Click here to return to the <b>Kidwelly.info</b> <a href = '../index.htm' class = under>home</a> page</font><br>"
   s = s + "Here are a selection of " + getNumOfPics() + " photographs of <b>" + placeName + "</b>. When they are all displayed, click on a photograph you would like to see in greater detail and it will be loaded automatically into a new window. Useful " + placeName + " links and information are listed at the bottom of this page.<br>"
   s = s + "</table>" + getPhotoList();
   return s
}

function getDynamicAdvert()
{
   var s = "<table width = 468 cellpadding = 0 cellspacing = 0><tr><td align = 'center' bgcolor = '#ffffaa'><SPAN ID='banner'><I>Loading Local Adverts...</I></SPAN></td><td width =1><img src = '../img/pixel.gif' height = 60 width = 1></td></tr></table>"
    return s
}

function getRightColumn()
{
   var p = places
  
   var s = ""

   // Pad Rows
   var s = s + "<td width = 2><img src = '../img/pixel.gif' width = 2></td>"

   var s = s + "<td width = 220 valign = 'top'>"

   s = s + "<table cellspacing = 1 cellpadding = 1 bgcolor = '#f0ffff'><tr><td align = 'center'>"
   if (statAd.length > 0)
   {
         s = s + statAd
         s = s + "</td></tr></table>"
         s = s + "<div align = 'right'><font style = 'color:red;font-size:7pt'>..." + placeName + " page <a href = '../Advertise.htm' style = 'color:red;text-decoration:underline'>Sponsor</a></font></div><br>"
   }
   else
   {

    s = s + "This photograph album page is available for <a href = '../Advertise.htm' class = under>Sponsorship</a>. Prices start from as low as £5.00 per year so please click here to find out more."
    s = s + "</td></tr></table><br>"
   }

   // Display 2 random ads
   s = s + "<table cellpadding = 0 cellspacing = 0><tr><td>"
   var num1 = getRandNotX(999)
   var num2 = getRandNotX(num1)
   s = s + rhsStatAd[num1];
   s = s + rhsStatAd[num2];
   s = s + "</td></tr><tr>"
   s = s + "<td align = 'right'><font style = 'color:red;font-size:7pt'>...in Association with <a href='http://www.amazon.co.uk/exec/obidos/redirect-home?tag=theowlnet-21&site=books' style = 'color:red;text-decoration:underline'>Amazon.co.uk</a>.</font>"
   s = s + "</td></tr></table>"

   s = s + "<br>"
   s = s + "All photographs on this website are copyright Carm1.co.uk, but may be reproduced online free of charge if you follow our <a href = '../UsageGuidelines.htm' class = under>Usage Guidelines</a>."

   s = s + "</td>"
   return s;
}

function getCopyright()
{
   var s = "<table><tr><td width = 120><img src = '../img/pixel.gif' width = 120 height = 1></td><td align = center><font style = 'font-size:8pt'>© 2003 Carm1.co.uk - All rights reserved<br>Web design by <a href = 'http://www.carm1.co.uk'><b><font color = 'blue'>Carm1.co.uk</font></b></a> - Quality Web Services for the Businesses of Carmarthenshire</font></td></tr></table>"

   var s = "<br><font style = 'font-size:8pt'>© 2003 Carm1.co.uk - All rights reserved<br>Web design by <a href = 'http://www.carm1.co.uk'><b><font color = 'blue'>Carm1.co.uk</font></b></a> - Quality Web Services for the Businesses of Carmarthenshire</font><br>"

   s =s + getCounter()

   return s
}

function getCounter()
{
   var s = "<script type='text/javascript' language='JavaScript'>var site='s16kidwelly'</script><script type='text/javascript' language='JavaScript1.2' src='http://s16.sitemeter.com/js/counter.js?site=s16kidwelly'></script><noscript><a href='http://s16.sitemeter.com/stats.asp?site=s16kidwelly' target='_top'><img src='http://s16.sitemeter.com/meter.asp?site=s16kidwelly' alt='Site Meter' border=0></a></noscript>"
   return s
}

function getAmazonBanner()
{ 
     var BS = "";
     var s1 = "<td><A HREF='http://www.amazon.co.uk/exec/obidos/redirect?tag=theowlnet-21&path="
     var s2 = " height = 26 border = 0></a></td>"
 
     BS = BS + "<table cellpadding = 0 cellspacing = 0><tr><td><table cellpadding = 0 cellspacing = 0><tr>"
     BS = BS + "<td><A HREF='http://www.amazon.co.uk/exec/obidos/redirect-home?tag=theowlnet-21&site=amazon'><img src = '../../img/Am_Home.gif' width = 60" + s2
     BS = BS + s1 + "subst/home/books.html'><img src = '../../img/Am_Books.gif' width = 39" + s2
     BS = BS + s1 + "tg/stores/browse/-/electronics/560798'><img src = '../../img/Am_Electronics.gif' width = 74" + s2
     BS = BS + s1 + "tg/stores/browse/-/music/229816'><img src = '../../img/Am_Music.gif' width = 39" + s2
     BS = BS + s1 + "tg/stores/browse/-/dvd/283926'><img src = '../../img/Am_DVD.gif' width = 35" + s2
     BS = BS + s1 + "tg/stores/browse/-/video/283920'><img src = '../../img/Am_Video.gif' width = 43" + s2
     BS = BS + s1 + "tg/stores/browse/-/software/300435'><img src = '../../img/Am_Software.gif' width = 58" + s2
     BS = BS + s1 + "tg/stores/browse/-/videogames/300703'><img src = '../../img/Am_PCGames.gif' width = 59" + s2
     BS = BS + s1 + "tg/browse/-/3146281'><img src = '../../img/Am_Kitchen.gif' width = 58" + s2
     BS = BS + s1 + "tg/browse/-/kids/468292'><img src = '../../img/Am_Kids.gif' width = 47" + s2
     BS = BS + "</tr><tr><td colspan = 10 bgcolor = 'black'><img src = 'img/pixel.gif' height = 1></td></tr></table>"

     BS = BS + "</td><tr>"
     BS = BS + "<tr><td align = 'right' valign = 'top'><font style = 'font-size:7pt'>In Association with <A HREF='http://www.amazon.co.uk/exec/obidos/redirect-home?tag=theowlnet-21&site=amazon'>Amazon.co.uk</a></font><br></td></tr></table>"

     return BS;
}

function displayPart1()
{
     var BS = ""
     BS = BS + getTopOfPage()
     BS = BS + "<table width = 763><tr><td width = 540 valign = 'top'><table align = 'center'><tr><td>"
    
     BS = BS + getAmazonBanner();
     document.write(BS)
}

function displayPart2()
{
     var BS = ""
     BS = BS + getMainBody()
     document.write(BS)

     if(arguments.length == 0)
     {
        document.write("<font style = 'color:#777777; font-size:8pt'>So far we have been unable to find any good <i>" + placeName + "</i> related web sites. If you know of any useful links or information which you think will help the visitors of this <b>Kidwelly.info</b> web page, please email them to us at <a href = 'mailto:suggestions@kidwelly.info' class = under>suggestions@Kidwelly.info</a>.</font><br><br>")
        displayPart3();
     }
     else
     {
        document.write("<br><font class = smltit>Useful "+ placeName + " Links</font><BR>")
        document.write("<font style = 'color:#777777; font-size:8pt'>Please click here if you can suggest any good <i>" + placeName + "</i> related <a href = 'mailto:suggestions@kidwelly.info' class = under>links</a> or other information we should add to this <b>Kidwelly.info</b> web page.</font><br>")
     }    
}

function displayPart3()
{
     var BS = "";
     BS = BS + "</td>"
     BS = BS + getRightColumn()
     start('banner')
     BS = BS + "</tr></table>"
     BS = BS + getCopyright()

     document.write(BS)
}

function displayPhotoPage2(name)
{
     var BS = ""
     BS = BS + getTopOfPage()
     BS = BS + "<table><tr>"
     BS = BS + getMainBody()
     BS = BS + getRightColumn()
     start('banner')
     BS = BS + "</tr></table>"
     BS = BS + getCopyright()

     document.write(BS)   
}




var i = 0
var ar = new Array();
var places = new Array();
var statAd = new String;
statAd = ""
var placeName = new String;

// General banner ads shown on all pages.
ar[i] = "<A HREF='http://www.theowl.net' class = under>TheOwl.net</A> <b>Free Online Antiques and Collectables Guide</b><br>Read the latest antiques and collectables news and get amazing discounts on antiques and collectables reference books.";i++;
ar[i] = "<A HREF='../Advertise.htm' class = under>Advertise</A> your local business here for FREE.<br>Click to find out more.";i++;

// Start banner advert with locals.
var num = i;