// 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", "25.JPG", "26.JPG", "27.JPG", "28.JPG", "29.JPG", "30.JPG", "31.JPG", "32.JPG", "33.JPG", "34.JPG", "35.JPG"  ],
//images: ["1.JPG", "2.JPG", "3.JPG" ],

	//Just type the name of the picture in this list 
	alt: ["17 year old disabled girl Hanh, who has Cerebral Palsy, is cared for by British charity the Kianh Foundation at Hoi An Orphanage, Vietnam.", "3 year old disabled boy Duy, who has Downs Syndrome, pictured in Hoi An Orphanage, Vietnam. He has now been returned to his family. (2)", "Inside the Kianh Foundation’s Physiotherapy room at Hoi An Orphanage, Vietnam: Kianh Foundation’s physiotherapist Hoa works with 10 year old Thuong who has Cerebral Palsy. (3)","Be Hong is 5 years old and has hydrocephalus. The Kianh Foundation arranged shunt surgery for her in 2005 and she is making great progress.(4)", "3 year old Duyen has Downs Syndrome and 5 year old Bin has hydrocephalus. They are cared for by the Kianh Foundation at Hoi An Orphanage, Vietnam.(5)", "5 year old Bin has Hydrocephalus and attends the Kianh Foundation’s education and therapy programmes at Hoi An Orphanage, Vietnam. (6)", "3 year old Duyen, has Downs Syndrome and is cared for by the Kianh Foundation in Vietnam.(7)", "Good friends, 11 year old Hau, who has Downs Syndrome, and 8 year old Bao, who has no disability, studying together in the Kianh Foundation’s classroom at Hoi An Orphanage, Vietnam.(8)", "Phuc painting in the Kianh Foundation’s special education classroom. She has no disability but spent a year catching up in the class after having little stimulus in her previous environment.(9)", "Hau A and Hau B on a trip to the amusement park organised by the Kianh Foundation in Hoi An, Vietnam.(10)", "18 year old Phuc gives a guiding hand to 12 year old Phuoc inside the Kianh Foundation's physiotherapy room. Both boys have Cerebral Palsy. (11)", "Children, cared for by the Kianh Foundation at Hoi An Orphanage, receive dental treatment at the East Meets West clinic in Danang City. (12)","8 year old Hien enjoying a party organised by the Kianh Foundation in Hoi An. The Foundation arranged for him to have cleft palette surgery. (13)", "Tuan and Phuoc, who both have Cerebral Palsy, in one of the Kianh Foundation’s special education classrooms at Hoi An Orphanage with teacher, Mrs Lai, and Roe Schroeder, the Kianh Foundation’s Director of Special Education. (14)", "5 year old Bin has Hydrocephalus and attends the Kianh Foundation’s education and therapy programmes at Hoi An Orphanage, Vietnam. (15)", "Minh Hien, who has physical and learning difficulties, with Tam, who has no disability, studying together in the Kianh Foundation’s special education classroom at Hoi An Orphanage. (16)", "Phuoc and Minh Hien in the ball pond in the Kianh Foundation’s special education classroom At Hoi An Orphanage, Vietnam. (17)", "Birthday party for Hau, who has Downs Syndrome, at Red Bridge Restaurant, Hoi An. The Kianh Foundation organises parties and social trips for the disabled children living at Hoi An Orphanage.(18)", "5 year old girl Hong. The Kianh Foundation arranged for her to have 2 shunt surgeries for her Hydrocephalus and she is making great progress.(19)", "Deaf blind, and possibly autistic, boy Anh is cared for by the Kianh Foundation at Hoi An Orphanage, Vietnam.(20)", "Pupils from the Kianh Foundation’s Special Education Classroom 1 queue up for a social outing. (21)", "Kianh Foundation physiotherapist Hoa works with 16 year old Van May at Hoi An Orphanage, Vietnam. Van May has Cerebral Palsy. (22)", "Kianh Foundation’s Special Education Classroom 1 at Hoi An Orphanage, Vietnam. (23)", "17 year old Vietnamese girl Ly, who has Cerebral Palsy. She attends the Kianh Foundation’s special education classes at Hoi An Orphanage.(24)", "Van May, who has Cerebral Palsy, helps Bin, who has hydrocephalus. They are pictured in the Kianh Foundation’s special education classroom at Hoi An Orphanage, Vietnam.(25)", "Kianh Foundation’s Special Education Teacher Loan, on a trip to the local park, with Tuan, who has Cerebral Palsy, and Hien who has cleft palette problems.(26)", "5 year old Khoa Em, who has Cerebral Palsy, pictured in the Kianh Foundation’s physiotherapy room at Hoi An Orphanage, Vietnam. (27)", "Special Education Teacher Lai reads a story to Vietnamese disabled children Phuoc, Yen and Khoa Anh in the Kianh Foundation’s classroom at Hoi An Orphanage. All the children have Cerebral Palsy.(28)", "Disabled children Lup, Ly and Tri pictured outside the Kianh Foundation’s special education classroom at Hoi An Orphanage. Ly has Cerebral Palsy and Tri has polio.(29)", "Vietnamese girl Minh Hien, who has physical and learning difficulties, enjoying a day out in Hoi An, organised by the Kianh Foundation. (30)", "Disabled Vietnamese boys Tien and Phuoc enjoying a day out in Hoi An, organised by the Kianh Foundation. Phuoc has Cerebral Palsy.(31)", "Disabled Vietnamese boy Thuong gives a lift to his friend, Phuoc, on his walker. Both boys have Cerebral Palsy and are cared for by the Kianh Foundation at Hoi An Orphanage. (32)", "Hien with his good friend, Khoa Anh at Hoi An Orphanage, Vietnam. Hien has cleft palette problems and Khoa Anh has Cerebral Palsy. Both have had surgeries arranged by the Kianh Foundation. (33)", "11 year old Tuan, who has Cerebral Palsy, painting a house in the Kianh Foundation’s Special Education Classroom at Hoi An Orphanage. (34)", "Special Education Teacher Lai, Bin and Phuoc in the Kianh Foundation Special Education Classroom 2 at Hoi An Orphanage. Bin has hydrocephalus and Phuoc has Cerebral Palsy. (35)" ],
	//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: ["17 year old disabled girl Hanh, who has Cerebral Palsy, is cared for by British charity the Kianh Foundation at Hoi An Orphanage, Vietnam.", "3 year old disabled boy Duy, who has Downs Syndrome, pictured in Hoi An Orphanage, Vietnam. He has now been returned to his family. (2)", "Inside the Kianh Foundation’s Physiotherapy room at Hoi An Orphanage, Vietnam: Kianh Foundation’s physiotherapist Hoa works with 10 year old Thuong who has Cerebral Palsy. (3)","Be Hong is 5 years old and has hydrocephalus. The Kianh Foundation arranged shunt surgery for her in 2005 and she is making great progress.(4)", "3 year old Duyen has Downs Syndrome and 5 year old Bin has hydrocephalus. They are cared for by the Kianh Foundation at Hoi An Orphanage, Vietnam.(5)", "5 year old Bin has Hydrocephalus and attends the Kianh Foundation’s education and therapy programmes at Hoi An Orphanage, Vietnam. (6)", "3 year old Duyen, has Downs Syndrome and is cared for by the Kianh Foundation in Vietnam.(7)", "Good friends, 11 year old Hau, who has Downs Syndrome, and 8 year old Bao, who has no disability, studying together in the Kianh Foundation’s classroom at Hoi An Orphanage, Vietnam.(8)", "Phuc painting in the Kianh Foundation’s special education classroom. She has no disability but spent a year catching up in the class after having little stimulus in her previous environment.(9)", "Hau A and Hau B on a trip to the amusement park organised by the Kianh Foundation in Hoi An, Vietnam.(10)", "18 year old Phuc gives a guiding hand to 12 year old Phuoc inside the Kianh Foundation's physiotherapy room. Both boys have Cerebral Palsy. (11)", "Children, cared for by the Kianh Foundation at Hoi An Orphanage, receive dental treatment at the East Meets West clinic in Danang City. (12)","8 year old Hien enjoying a party organised by the Kianh Foundation in Hoi An. The Foundation arranged for him to have cleft palette surgery. (13)", "Tuan and Phuoc, who both have Cerebral Palsy, in one of the Kianh Foundation’s special education classrooms at Hoi An Orphanage with teacher, Mrs Lai, and Roe Schroeder, the Kianh Foundation’s Director of Special Education. (14)", "5 year old Bin has Hydrocephalus and attends the Kianh Foundation’s education and therapy programmes at Hoi An Orphanage, Vietnam. (15)", "Minh Hien, who has physical and learning difficulties, with Tam, who has no disability, studying together in the Kianh Foundation’s special education classroom at Hoi An Orphanage. (16)", "Phuoc and Minh Hien in the ball pond in the Kianh Foundation’s special education classroom At Hoi An Orphanage, Vietnam. (17)", "Birthday party for Hau, who has Downs Syndrome, at Red Bridge Restaurant, Hoi An. The Kianh Foundation organises parties and social trips for the disabled children living at Hoi An Orphanage.(18)", "5 year old girl Hong. The Kianh Foundation arranged for her to have 2 shunt surgeries for her Hydrocephalus and she is making great progress.(19)", "Deaf blind, and possibly autistic, boy Anh is cared for by the Kianh Foundation at Hoi An Orphanage, Vietnam.(20)", "Pupils from the Kianh Foundation’s Special Education Classroom 1 queue up for a social outing. (21)", "Kianh Foundation physiotherapist Hoa works with 16 year old Van May at Hoi An Orphanage, Vietnam. Van May has Cerebral Palsy. (22)", "Kianh Foundation’s Special Education Classroom 1 at Hoi An Orphanage, Vietnam. (23)", "17 year old Vietnamese girl Ly, who has Cerebral Palsy. She attends the Kianh Foundation’s special education classes at Hoi An Orphanage.(24)", "Van May, who has Cerebral Palsy, helps Bin, who has hydrocephalus. They are pictured in the Kianh Foundation’s special education classroom at Hoi An Orphanage, Vietnam.(25)", "Kianh Foundation’s Special Education Teacher Loan, on a trip to the local park, with Tuan, who has Cerebral Palsy, and Hien who has cleft palette problems.(26)", "5 year old Khoa Em, who has Cerebral Palsy, pictured in the Kianh Foundation’s physiotherapy room at Hoi An Orphanage, Vietnam. (27)", "Special Education Teacher Lai reads a story to Vietnamese disabled children Phuoc, Yen and Khoa Anh in the Kianh Foundation’s classroom at Hoi An Orphanage. All the children have Cerebral Palsy.(28)", "Disabled children Lup, Ly and Tri pictured outside the Kianh Foundation’s special education classroom at Hoi An Orphanage. Ly has Cerebral Palsy and Tri has polio.(29)", "Vietnamese girl Minh Hien, who has physical and learning difficulties, enjoying a day out in Hoi An, organised by the Kianh Foundation. (30)", "Disabled Vietnamese boys Tien and Phuoc enjoying a day out in Hoi An, organised by the Kianh Foundation. Phuoc has Cerebral Palsy.(31)", "Disabled Vietnamese boy Thuong gives a lift to his friend, Phuoc, on his walker. Both boys have Cerebral Palsy and are cared for by the Kianh Foundation at Hoi An Orphanage. (32)", "Hien with his good friend, Khoa Anh at Hoi An Orphanage, Vietnam. Hien has cleft palette problems and Khoa Anh has Cerebral Palsy. Both have had surgeries arranged by the Kianh Foundation. (33)", "11 year old Tuan, who has Cerebral Palsy, painting a house in the Kianh Foundation’s Special Education Classroom at Hoi An Orphanage. (34)", "Special Education Teacher Lai, Bin and Phuoc in the Kianh Foundation Special Education Classroom 2 at Hoi An Orphanage. Bin has hydrocephalus and Phuoc has Cerebral Palsy. (35)"]
	//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;
}
