// JavaScript Document

function randomImage(number) {
//All the pictures go in here

//All pictures width are 275... height can be anything.
//So, all images in leftsidepictures folder must be of 275 width.
var allPictures = {
    path:   'LeftSidePictures/',
    images: ["1.JPG", "2.JPG", "3.JPG", "4.JPG", "5.JPG", "6.JPG", "7.JPG", "8.JPG", "9.JPG", "10.JPG", "11.JPG", "12.JPG", "13.JPG", "14.JPG", "15.JPG", "16.JPG", "17.JPG", "18.JPG", "19.JPG", "20.JPG","21.JPG", "22.JPG", "23.JPG", "24.JPG"  ],
//images: ["1.JPG", "2.JPG", "3.JPG" ],

	//Just type the name of the picture in this list 
	alt: ["8 year old disabled boy with Cerebral Palsy and Erb’s Palsy who receives education and physiotherapy at the Kianh Foundation’s centre in Dien Nam Dong, Dien Ban, Central Vietnam.", "15 year old Vietnamese girl who has cerebral palsy. She receives speech therapy and physiotherapy at a centre run by British charity the Kianh Foundation, in Dien Ban, Central Vietnam. (2)", "7 year old Vietnamese girl with Down’s Syndrome. She is being educated by British charity the Kianh Foundation, at their centre in Dien Ban, Central Vietnam. (3)", "9 year old boy with Cerebral Palsy, pictured at home with his grandmother in Dien Ban, Central Vietnam. (4)", "11 year old Vietnamese boy with Down’s Syndrome. He is being educated by British charity the Kianh Foundation, at their centre in Dien Ban, Central Vietnam. (5)", "29 year old Vietnamese woman who has Cerebral Palsy and lives at Hoi An Adult Shelter. (6)", "18 year old boy with Cerebral Palsy who lives at the Hoi An Adult Shelter. (7)", "Kianh Foundation volunteer physiotherapist from the UK, working with 25 year old woman who has Cerebral Palsy and lives at the Hoi An Adult Shelter in Central Vietnam. (8)", "5 year old Vietnamese boy on the Autism spectrum, at home with his younger brother in Dien Ban, Central Vietnam. He is receiving education home visits from the Kianh Foundation, a British charity. (9)", "Typical house of the children who receive education and physiotherapy from the Kianh Foundation in Dien Ban, Central Vietnam. (10)", "Kianh Foundation Special education teacher, Tho, in the classroom with a 5 year old Vietnamese boy who has Cerebral Palsy. (11)", "Kianh Foundation special education teacher, Tho, in the classroom with an 11 year old girl who has developmental delay. (12)", "Two 14 year old Vietnamese children with developmental delay both receive special education at the Kianh Foundation’s centre in Dien Ban, Central Vietnam. (13)", "staff, children and parents pictured at the Kianh Foundation’s centre in Dien Ban, Central Vietnam. (14)", "Kianh Foundation special education teacher Quynh working in the classroom with a child with Downs Syndrome and developmental delay. (15)", "Children with Downs Syndrome and developmental delay in the Kianh Foundation’s special education classroom at Dien Ban, Central Vietnam. (16)", "5 year old child with cerebral palsy receiving physiotherapy in the Kianh Foundation’s Centre in Dien Ban, Central Vietnam. (17)", "11 year old child with developmental delay in the Kianh Foundation’s special education classroom. (18)", "20 year old Vietnamese woman with cerebral palsy at the Hoi An Adult Shelter in Central Vietnam. (19)", "Vietnamese children with Downs Syndrome and developmental delay at the Kianh Foundation’s special education and physiotherapy centre in Dien Ban, Central Vietnam. (20)", "9 year old Vietnamese boy with cerebral palsy at home with his granddad in Dien Ban, Central Vietnam. (21)", "8 year old disabled boy with Cerebral Palsy and Erb’s Palsy who receives education and physiotherapy at the Kianh Foundation’s centre in Dien Nam Dong, Dien Ban, Central Vietnam. (22)", "Kianh Foundation special education teacher and physiotherapist with a child who has Downs Syndrome. (23)", "Children with disability who receive care from the Kianh Foundation, a British charity working in Central Vietnam. (24)" ],
	//Type the alt tag that corresponds with the image (first image listed goes with the first alt tag listed, second image goes with the second alt tag, etc
	

	
	title: ["8 year old disabled boy with Cerebral Palsy and Erb’s Palsy who receives education and physiotherapy at the Kianh Foundation’s centre in Dien Nam Dong, Dien Ban, Central Vietnam.", "15 year old Vietnamese girl who has cerebral palsy. She receives speech therapy and physiotherapy at a centre run by British charity the Kianh Foundation, in Dien Ban, Central Vietnam. (2)", "7 year old Vietnamese girl with Down’s Syndrome. She is being educated by British charity the Kianh Foundation, at their centre in Dien Ban, Central Vietnam. (3)", "9 year old boy with Cerebral Palsy, pictured at home with his grandmother in Dien Ban, Central Vietnam. (4)", "11 year old Vietnamese boy with Down’s Syndrome. He is being educated by British charity the Kianh Foundation, at their centre in Dien Ban, Central Vietnam. (5)", "29 year old Vietnamese woman who has Cerebral Palsy and lives at Hoi An Adult Shelter. (6)", "18 year old boy with Cerebral Palsy who lives at the Hoi An Adult Shelter. (7)", "Kianh Foundation volunteer physiotherapist from the UK, working with 25 year old woman who has Cerebral Palsy and lives at the Hoi An Adult Shelter in Central Vietnam. (8)", "5 year old Vietnamese boy on the Autism spectrum, at home with his younger brother in Dien Ban, Central Vietnam. He is receiving education home visits from the Kianh Foundation, a British charity. (9)", "Typical house of the children who receive education and physiotherapy from the Kianh Foundation in Dien Ban, Central Vietnam. (10)", "Kianh Foundation Special education teacher, Tho, in the classroom with a 5 year old Vietnamese boy who has Cerebral Palsy. (11)", "Kianh Foundation special education teacher, Tho, in the classroom with an 11 year old girl who has developmental delay. (12)", "Two 14 year old Vietnamese children with developmental delay both receive special education at the Kianh Foundation’s centre in Dien Ban, Central Vietnam. (13)", "staff, children and parents pictured at the Kianh Foundation’s centre in Dien Ban, Central Vietnam. (14)", "Kianh Foundation special education teacher Quynh working in the classroom with a child with Downs Syndrome and developmental delay. (15)", "Children with Downs Syndrome and developmental delay in the Kianh Foundation’s special education classroom at Dien Ban, Central Vietnam. (16)", "5 year old child with cerebral palsy receiving physiotherapy in the Kianh Foundation’s Centre in Dien Ban, Central Vietnam. (17)", "11 year old child with developmental delay in the Kianh Foundation’s special education classroom. (18)", "20 year old Vietnamese woman with cerebral palsy at the Hoi An Adult Shelter in Central Vietnam. (19)", "Vietnamese children with Downs Syndrome and developmental delay at the Kianh Foundation’s special education and physiotherapy centre in Dien Ban, Central Vietnam. (20)", "9 year old Vietnamese boy with cerebral palsy at home with his granddad in Dien Ban, Central Vietnam. (21)", "8 year old disabled boy with Cerebral Palsy and Erb’s Palsy who receives education and physiotherapy at the Kianh Foundation’s centre in Dien Nam Dong, Dien Ban, Central Vietnam. (22)", "Kianh Foundation special education teacher and physiotherapist with a child who has Downs Syndrome. (23)", "Children with disability who receive care from the Kianh Foundation, a British charity working in Central Vietnam. (24)" ]
	//Type the title tag that corresponds with the image (first image listed goes with the first title tag listed, second image goes with the second title tag, etc
	
}

var usedIDs = new Array();
if(number > 0)


for(var i = 0; i <	number; i++) {
var k = getRandomImage(allPictures, usedIDs);
usedIDs[i] = k;
}
	
}

Array.prototype.contains = function (element) {
for (var i = 0; i < this.length; i++) {
if (this[i] == element) {
return true;
}
}
return false;
}



function getRandomImage(rObj, usedIDs) {
    var imgAr = rObj.images;  if (!imgAr ) {return;}
    var num = Math.floor( Math.random() * imgAr.length );
	
	if(usedIDs.length > 0 && usedIDs.length != imgAr.length)
	{
	while(usedIDs.contains(num))
	num = Math.floor( Math.random() * imgAr.length );
	}
	
	
    var imgStr = '';   var imgFile = imgAr[ num ];
    
    var path = rObj.path || ''; var id = rObj.name || '';
    var title, alt, url;
    // If there are *any* entries for actions, alt or title include them here 
    if (rObj.alt) {
        alt = rObj.alt[num]? rObj.alt[num]: rObj.alt[0]? rObj.alt[0]: 'Kiahn Foundation Image';
    }
    if (rObj.title) {
        title = rObj.title[num]? rObj.title[num]: rObj.title[0]? rObj.title[0]: '';
    }
    if (rObj.actions) {
        url = rObj.actions[num]? rObj.actions[num]: rObj.actions[0]? rObj.actions[0]: null;
    }
    if (url) {
        imgStr += '<a href="';
        imgStr += typeof url == 'string'? url: 'javascript: void ' + url;
        imgStr += '">';
    }
    
    imgStr += '<img src="' + path + imgFile + '"';
    imgStr += id? ' id="' + id + '" name="' + id + '"': '';
    if (title) {
        imgStr += ' title="' + title + '"';
    }
    imgStr += ' alt="' + alt + '" class="leftImages" />';
    if (url) {
        imgStr += '</a>';
    }
    document.write(imgStr); 
	document.close();
	return num;
}

