// JavaScript Document
var aJS = new Array();


aJS[aJS.length] = new Array('images/cats/kittens.jpg', 
				   'Kittens',
				   'Note this is not a picture of any kittens we have in at the moment.',
				   'All the kittens are 9 weeks or older. When taking on a kitten please remember that they can live for more than 20 years. All kittens MUST be neutered and we are willing to help pay toward these costs. For details ring 0845 371 2717.  Remember a kitten takes a lot of looking after.'); 


aJS[aJS.length] = new Array('images/cats/Stripey.jpg',
				   'Stripey',
				   '1 year-old tabby male',
				   'Stripey is quite a live wire very playful and although affectionate not a lap cat.  He could be part Bengal.');


aJS[aJS.length] = new Array('images/cats/Essie.jpg',
				   'Essie',
				   '1-2 year-old black short-hair female',
				   'Essie is a very cuddly and affectionate young cat. She has recently had kittens but has now been spayed. Please give her a loving home.');

aJS[aJS.length] = new Array('images/cats/charlie.jpg',
				   'Charlie',
				   '2-4 year-old black short-hair male',
				   'Charlie hates being in a pen - he is nervous with strangers but will make a wonderful pet.');

aJS[aJS.length] = new Array('images/cats/bracken.jpg',
				   'Bracken',
				   '2 year-old tortoiseshell/tabby short-hair female',
				   'Bracken would love a home with sister Willow.');

aJS[aJS.length] = new Array('images/cats/willow.jpg',
				   'Willow',
				   '2 year-old tortoiseshell/tabby short-hair female',
				   'Willow and her sister Bracken are both adorable cats. Please give them a home.');

aJS[aJS.length] = new Array('images/cats/Esme.jpg',
				   'Esme',
				   'Tortoiseshell and white female, about 1 year old',
				   'Esme is a pretty cat who enjoys being stroked and made a fuss of.');

aJS[aJS.length] = new Array('images/cats/farmcats-2007-07-12-160x120.jpg',
				   'Farm Cats',
				   'These are not ferals, they just prefer the outdoor life.',
				   'These cats could be rehomed to farms, stables or smallholdings or anyone looking for an outdoor cat. Maybe you live in the country and have space for a cat to roam.');

/*aJS[aJS.length] = new Array('images/cats/farm-kittens-080827.jpg', 
				   'Kittens',
				   'A number of kittens rescued from farms, both sexes, mix of colours including tabby, black and white, and calico.',
				   'We have a number of kittens who were rescued from farms at 5 or 6 weeks. They are now 12 weeks old, vaccinated, micro chipped, wormed and treated for fleas. Although still slightly nervous of new things and sudden movements they are very playful and gaining in confidence each day. They need a rural home with a large garden away from roads.  They are ok with other cats and dogs but would not be suitable for a home with young children.');*/


var numPages = Math.ceil(aJS.length / 6);  /* 6 is max no cats per page */
var catsPerPage = Math.ceil(aJS.length / numPages);

function showCatsPage(page) {

	minCat = catsPerPage * (page-1);
	if (page < numPages) 
	    maxCat = (page * catsPerPage) -1;
	else
		maxCat = aJS.length -1;
	showCats (minCat, maxCat);
}

function showCats(minCat, maxCat)	{
    x = minCat;
	i=0;
	while (x < aJS.length && x < maxCat+1) {
		img = aJS[x][0];
		catName = aJS[x][1];
		catDesc = aJS[x][2];

		document.getElementById('divCatImg'+i).innerHTML = '<a href="javascript:showCat('+x+');"><img src="' + img + '" alt="'+catName+'" style="width:96px;height:72px;"><a>';
		
		document.getElementById('divCatName'+i).innerHTML = catName;
		document.getElementById('divCatDesc'+i).innerHTML = catDesc;
		i++; x++;
	}
}

function showFirstCat (page) {
	showCat (catsPerPage * (page-1));
}

function showCat(cat)	{
	if (aJS.length > 0)	{
		img = aJS[cat][0];
		catName = aJS[cat][1];
		catDesc = aJS[cat][2];
		catText = aJS[cat][3];

		document.getElementById('divCatImg').innerHTML = '<img src="' + img + '" alt="'+catName+'" style="width:254px;height:192px;">'	
		document.getElementById('divCatName').innerHTML = catName;
/*		document.getElementById('divCatDesc').innerHTML = catDesc; */
		document.getElementById('divCatText').innerHTML = catText;
	}
}

function showRandomCat(){
	if (aJS.length > 0)	{
		argID = Math.floor(Math.random() * aJS.length);
		img = aJS[argID][0];
		catName = aJS[argID][1];
		catDesc = aJS[argID][2];
		catText = aJS[argID][3];
		document.getElementById('divCatImg').innerHTML = '<img src="' + img + '" alt="'+catName+'" style="width:200px;height:150px;">'	
		document.getElementById('divCatText').innerHTML = catText;
		document.getElementById('divCatName').innerHTML = 'Can you give ' + catName + ' a home?';
	}
}

function doLinks (page) {
	if (page < numPages) {
		document.getElementById('divLinkRight').innerHTML = '<a href="homeACatGallery.html?p='+ (parseInt(page)+1) +'">More Cats >></a>';
	}
	if (page > 1) {
		document.getElementById('divLinkLeft').innerHTML = '<a href="homeACatGallery.html?p=' + (parseInt(page)-1) +'"><< More Cats</a>';
	}
	document.getElementById('divPageNum').innerHTML = 'Page ' + page + ' of ' + numPages; 
}




