var picarray =
[[],
// bats_01 which category?
// bats_02
// bats_03
// red_tail_pit_wiper_01
// red_tail_pit_wiper_02

["nature_01_01", "nature", "forest ", "h", "view from Gunung Brinchang"],
["mossy_forest_01", "nature", "mossy forest", "h", "mossy forest"],
["mossy_forest_02", "nature", "mossy forest", "h", "mossy forest"],
["mossy_forest_03", "nature", "mossy forest", "h", "mossy forest"],
["mossy_forest_04", "nature", "mossy forest", "h", "mossy forest"],
["mossy_forest_05", "nature", "mossy forest", "h", "mossy forest"],
["mossy_forest_06", "nature", "mossy forest", "h", "mossy forest"],
["mossy_forest_07", "nature", "mossy forest", "h", "mossy forest"],
["mossy_forest_08", "nature", "mossy forest", "h", "mossy forest"],
["mossy_forest_09", "nature", "mossy forest", "h", "mossy forest"],
["mossy_forest_10", "nature", "mossy forest", "h", "mossy forest"],
["mossy_forest_11", "nature", "mossy forest", "h", "mossy forest"],
["mossy_forest_12", "nature", "forest ", "h", "mossy forest"],
["pitcher_plant_red_01", "nature", "forest-flora", "h", "red pitcher plant"],
["pitcher_plant_black_01", "nature", "forest-flora", "v", "a black pitcher plant among the shrubs"],
["pitcher_plant_black_02", "nature", "forest-flora", "v", "its vivid and contrasting colour distincts the pitcher plant among its green surroundings"],
["pitcher_plant_black_03", "nature", "forest-flora", "v", "side view of the black pitcher plant"],
["pitcher_plant_white_01", "nature", "forest-flora", "v", "flies attracted into the pitcher plant"],
["nature_01_04", "nature", "forest-flora", "h", "an endangered green pitcher plant, the <i>barrocalis</i>"],
["nature_01_05", "nature", "forest-flora", "h", "green pitcher plant"],
["nature_01_07", "nature", "forest-flora", "h", "a bunch of wild bananas"],
["nature_01_08", "nature", "waterfall", "h", "waterfall & a resthouse"],
["nature_01_09", "nature", "waterfall", "h", "waterfall"],
["nature_01_10", "nature", "waterfall", "h", "waterfall"],
["nature_01_11", "nature", "waterfall", "v", "a natural jacuzzi under the gushing waterfall"],
["nature_01_12", "nature", "forest-flora", "h", "seed"],
["nature_01_13", "nature", "forest-flora", "h", "wild flower"],
["flower_dancing_flower_01", "nature", "forest-flora", "h", "wild dancing flower"],
["flower_gingeria_01", "nature", "forest-flora", "v", "red gingeria flower"],
["flower_helmet_orchid_01", "nature", "forest-flora", "h", "looks like an insect? it's a <i>helmet orchid</i>, the smallest orchid in the world"],
["flower_corba_lily_01", "nature", "forest-flora", "h", "the cobra lily flower"],
["flower_corba_lily_02", "nature", "forest-flora", "h", "the side view of the cobra lily flower"],
["flower_corba_lily_03", "nature", "forest-flora", "h", "a close-up of the cobra lily flower"],
["flower_wild_01", "nature", "forest-flora", "h", "a bunch of wild flowers"],
["flower_wild_02", "nature", "forest-flora", "h", "another bunch of wild flowers"],
["flower_wild_03", "nature", "forest-flora", "h", "wild flowers"],
["flower_wild_04", "nature", "forest-flora", "h", "white wild flowers"],
["flower_wild_05", "nature", "forest-flora", "h", "white wild flowers"],
["flower_wild_orchid_01", "nature", "forest-flora", "v", "wild orchids"],
["flower_wild_orchid_02", "nature", "forest-flora", "v", "purple wild orchids"],
["flower_wild_orchid_03", "nature", "forest-flora", "h", "tiny orange wild orchids"],
["golden_needle_leaf_01", "nature", "forest-flora", "h", "golden needle leaf is a herb"],
["wild_mushroom_01", "nature", "forest-flora", "h", "did a child left a spikeball behind? you've been tricked, it's actually a wild mushroom"],
["wild_mushroom_02", "nature", "forest-flora", "h", "a white wild mushroom"],
["wild_mushroom_03", "nature", "forest-flora", "h", "what are these, you may ask. it's just another kind of wild mushrooms that resemble small cups - minus the handlem"],
["fern_01", "nature", "forest-flora", "v", "the size of this drying fern leaf is extensive it can cover your head"],
["monkey_01", "nature", "forest-fauna", "h", "monkeys"],
["monkey_02", "nature", "forest-fauna", "h", "monkeys"],
["moth_long_tailed_01", "nature", "forest-fauna", "h", "it is not a leaf, it's a long-tailed moth"],
["nature_02_01", "nature", "tea plantation", "h", "''Giant Green Carpet of Malaysia'' - tea plantation"],
["nature_02_02", "nature", "tea plantation", "h", "workers collecting tea leaves"],
["nature_02_03", "nature", "tea plantation", "h", "the rolling green hills"],
["nature_02_04", "nature", "tea plantation", "h", "tea plantation"],
["nature_02_05", "nature", "tea plantation", "h", "workers' quarters amid the green lushes of tea plantation"],
["nature_02_06", "nature", "tea plantation", "h", "the hilly slopes of Cameronian tea plantation"],
["nature_02_07", "nature", "tea plantation", "h", "waves of tea plantation"],
["nature_02_08", "nature", "tea plantation", "h", "the BOH Tea Factory"],
["nature_02_09", "nature", "tea plantation", "h", "the BOH Tea Factory"],
["nature_02_10", "nature", "tea plantation", "h", "the BOH Tea Factory"],
["orang_asli_02", "nature", "orang asli", "h", "a settlement of the 'orang asli' native community"],
["orang_asli_03", "nature", "orang asli", "h", "the traditional house (rumah orang asli) has stilts separating the floor from the ground"],

["agro_01_01", "agro", "cactus", "h", "a variety of cacti"],
["agro_01_02", "agro", "cactus", "h", "the thorny cactus"],
["agro_01_03", "agro", "fruit", "h", "giant lemons"],
["agro_01_04", "agro", "fruit", "h", "dripping tomatoes"],
["agro_01_05", "agro", "fruit", "h", "capsicuum"],
["agro_01_06", "agro", "fruit", "h", "lover's fruits"],
["strawberries_01", "agro", "strawberries", "h", "strawberry farm"],
["strawberries_02", "agro", "strawberries", "h", "fresh strawberries"],
["agro_03_01", "agro", "flower nursery", "h", "crysanthemum nursery"],
["agro_03_02", "agro", "flower nursery", "h", "blooming yellow crysanthemums"],
["agro_03_03", "agro", "flower nursery", "h", "white crysanthemums"],
["agro_03_04", "agro", "flower nursery", "h", "a sea of colourful crysanthemums"],
["agro_03_05", "agro", "flower nursery", "h", "bright yellow crysanthemums"],
["agro_03_06", "agro", "flower nursery", "h", "palilia flowers"],
["agro_03_07", "agro", "flower nursery", "h", "packed crysanthemums ready for sale"],
["agro_03_08", "agro", "flower nursery", "h", "Cameron Highlands is the main producer of fresh crysanthemums throughout Malaysia"],
["agro_04_01", "agro", "vegetable farming", "h", "water-cress farm"],
["agro_04_02", "agro", "vegetable farming", "h", "cabbage farm beside the water-cress farm"],
["agro_04_03", "agro", "vegetable farming", "h", "rolls of cabbages"],
["agro_04_04", "agro", "vegetable farming", "h", "cabbages up-close"],
["agro_04_05", "agro", "vegetable farming", "h", "young cabbages sprouting"],
["agro_05_01", "agro", "organic farming", "h", "hydrophonic farming"],
["agro_05_02", "agro", "organic farming", "h", "organic cabbages"],
["agro_06_01", "agro", "lettuce delight", "h", "lettuce farming"],

["leisure_01_01", "leisure", "tea plantation", "h", "an overview of the tea plantation"],
["leisure_01_02", "leisure", "tea plantation", "h", "tea plantation along the road"],
["leisure_01_03", "leisure", "vegetable farming", "h", "an overview of the vegetable terraces"],
["leisure_02_01", "leisure", "market square", "h", "a variety of greens for sale"],
["leisure_02_02", "leisure", "market square", "h", "other than fruits and vegetables, souvenirs can also be found"],
["leisure_02_03", "leisure", "market square", "v", "town dwellers and tourists shopping for fresh goods"],
["strawberries_03", "leisure", "strawberries", "v", "packing strawberries for sale"],
["leisure_04_01", "leisure", "honey bee centre", "h", "the admission into Honey Bee Farm is free"],
["leisure_04_02", "leisure", "honey bee centre", "h", "bees ar work"],
["leisure_05_01", "leisure", "rose centre", "h", "the colourful Rose Centre houses many flowers other than roses"],
["leisure_05_02", "leisure", "rose centre", "h", "pink rosy rose"],
["leisure_05_03", "leisure", "rose centre", "h", "the green rose"],
["leisure_05_04", "leisure", "rose centre", "h", "pots of purple flowers"],
["leisure_05_05", "leisure", "rose centre", "h", "white flower"],
["leisure_05_06", "leisure", "rose centre", "h", "bright red lily 4-faced flower"],
["leisure_05_07", "leisure", "rose centre", "h", "white orchids"],
["leisure_05_08", "leisure", "rose centre", "h", "purple orchids"],
["leisure_05_09", "leisure", "rose centre", "h", "blue flowers"],
["leisure_05_10", "leisure", "rose centre", "h", "red flowers"],
["leisure_05_11", "leisure", "rose centre", "v", "exotic heliconia"],
["leisure_05_12", "leisure", "rose centre", "h", "Malaysia's national flower, the hibiscus"],
["leisure_05_13", "leisure", "rose centre", "h", "wild flowers"],
["leisure_05_14", "leisure", "rose centre", "h", "red anthuriums"],
["leisure_05_15", "leisure", "rose centre", "h", "a girl amid fully-bloomed yellow orchids"],
["leisure_05_16", "leisure", "rose centre", "h", "violet orchids with pruple blooms"],
["leisure_05_17", "leisure", "rose centre", "h", "exotic plant"],
["leisure_06_01", "leisure", "butterfly garden", "h", "an orange butterfly at work"],
["leisure_06_02", "leisure", "butterfly garden", "h", "atlas moths resting"],
["leisure_06_03", "leisure", "butterfly garden", "h", "a camellian"],
["leisure_06_04", "leisure", "butterfly garden", "h", "a stag beetle"],
["leisure_06_05", "leisure", "butterfly garden", "h", "What do you see here? It's a stick insect appearing like branches"],
["leisure_06_06", "leisure", "butterfly garden", "v", "Do you spot anything unusual here? A leaf insect camouflaging among the green leaves"],
["leisure_06_07", "leisure", "butterfly garden", "h", "a stag beetle at work"],
["leisure_06_08", "leisure", "butterfly garden", "h", "another butterfly at work"],
["leisure_07_01", "leisure", "sam poh temple", "h", "frontal view of Sam Poh Temple"],
["leisure_07_02", "leisure", "sam poh temple", "h", "the back of Sam Poh Temple"],

["sunrise_01_01", "sunrise", "sunrise", "h", "sunlight seeping through the clouds"],
["sunrise_01_02", "sunrise", "sunrise", "h", "the sunlight giving colours to the cloudy sky"],
["sunrise_01_03", "sunrise", "sunrise", "h", "beautiful view from the mountain"],
["sunrise_01_04", "sunrise", "sunrise", "h", "the sun rising higher"],
["sunrise_01_05", "sunrise", "sunrise", "h", "illumination from the sun"],
["sunrise_01_06", "sunrise", "sunrise", "h", "here comes the mighty sun from behind the mountain"],
["sunrise_01_07", "sunrise", "sunrise", "h", "the sun beam lighting up the altocumulus mackerel sky"],
["sunrise_01_08", "sunrise", "sunrise", "h", ""],
["sunrise_01_09", "sunrise", "sunrise", "h", ""],
["sunrise_01_10", "sunrise", "sunrise", "h", ""],
["sunrise_01_11", "sunrise", "sunrise", "h", ""],
["sunrise_01_12", "sunrise", "sunrise", "h", ""],
["sunrise_01_13", "sunrise", "sunrise", "h", ""],
["sunrise_01_14", "sunrise", "sunrise", "h", ""],
["sunrise_01_15", "sunrise", "sunrise", "h", ""],
["sunrise_01_16", "sunrise", "sunrise", "h", ""],
["sunrise_01_17", "sunrise", "sunrise", "h", ""],
["sunrise_01_18", "sunrise", "sunrise", "h", ""],
["sunrise_01_19", "sunrise", "sunrise", "h", ""],
["sunrise_01_20", "sunrise", "sunrise", "h", ""],
["sunrise_01_21", "sunrise", "sunrise", "h", ""],
["sunrise_01_22", "sunrise", "sunrise", "h", ""],
["sunrise_01_23", "sunrise", "sunrise", "h", ""],
["sunrise_01_24", "sunrise", "sunrise", "h", ""],
["sunrise_01_25", "sunrise", "sunrise", "h", ""],
["sunrise_01_26", "sunrise", "sunrise", "h", ""],
["sunrise_01_27", "sunrise", "sunrise", "h", ""],
["sunrise_01_28", "sunrise", "sunrise", "h", ""],
["sunrise_01_29", "sunrise", "sunrise", "h", ""],
["sunrise_01_30", "sunrise", "sunrise", "h", ""],
["sunrise_01_31", "sunrise", "sunrise", "h", ""],
["sunrise_01_32", "sunrise", "sunrise", "h", ""],
["sunrise_01_33", "sunrise", "sunrise", "h", ""],
["sunrise_01_34", "sunrise", "sunrise", "h", ""],
["sunrise_01_35", "sunrise", "sunrise", "h", ""],
["sunrise_01_36", "sunrise", "sunrise", "h", ""],
["sunrise_01_37", "sunrise", "sunrise", "h", ""],
["sunrise_01_38", "sunrise", "sunrise", "h", ""],
["sunrise_01_39", "sunrise", "sunrise", "h", ""],
["sunrise_01_40", "sunrise", "sunrise", "h", ""],
["sunrise_01_41", "sunrise", "sunrise", "h", ""],
["sunrise_01_42", "sunrise", "sunrise", "h", ""],
["sunrise_01_43", "sunrise", "sunrise", "h", ""],
["sunrise_01_44", "sunrise", "sunrise", "h", ""],
["sunrise_01_45", "sunrise", "sunrise", "h", ""],
["sunrise_01_46", "sunrise", "sunrise", "h", ""],
["sunrise_01_47", "sunrise", "sunrise", "h", ""],
["sunrise_01_48", "sunrise", "sunrise", "h", ""],
["sunrise_01_49", "sunrise", "sunrise", "h", ""],
["sunrise_01_50", "sunrise", "sunrise", "h", ""],
["sunrise_01_51", "sunrise", "sunrise", "h", ""],
["sunrise_01_52", "sunrise", "sunrise", "h", ""],
["sunrise_01_53", "sunrise", "sunrise", "h", ""],
["sunrise_01_54", "sunrise", "sunrise", "h", ""],
["sunrise_01_55", "sunrise", "sunrise", "h", ""],
["sunrise_01_56", "sunrise", "sunrise", "h", ""],
["sunrise_01_57", "sunrise", "sunrise", "h", ""],
["sunrise_01_58", "sunrise", "sunrise", "h", ""],
["sunrise_01_59", "sunrise", "sunrise", "h", ""],
["sunrise_01_60", "sunrise", "sunrise", "h", ""],
["sunrise_01_61", "sunrise", "sunrise", "h", ""],
["sunrise_01_62", "sunrise", "sunrise", "h", ""],
["sunrise_01_63", "sunrise", "sunrise", "h", ""],
["sunrise_01_64", "sunrise", "sunrise", "h", ""],
["sunrise_01_65", "sunrise", "sunrise", "h", ""],
["sunrise_01_66", "sunrise", "sunrise", "h", ""],
["sunrise_01_67", "sunrise", "sunrise", "h", ""],
["sunrise_01_68", "sunrise", "sunrise", "h", ""],
["sunrise_01_69", "sunrise", "sunrise", "h", ""],
["sunrise_01_70", "sunrise", "sunrise", "h", ""],
["sunrise_01_71", "sunrise", "sunrise", "h", ""],
["sunrise_01_72", "sunrise", "sunrise", "h", ""],
["sunrise_01_73", "sunrise", "sunrise", "h", ""],
["sunrise_01_74", "sunrise", "sunrise", "h", ""],
["sunrise_01_75", "sunrise", "sunrise", "h", ""],
["sunrise_01_76", "sunrise", "sunrise", "h", ""],
["sunrise_01_77", "sunrise", "sunrise", "h", ""],
["sunrise_01_78", "sunrise", "sunrise", "h", ""],
["sunrise_01_79", "sunrise", "sunrise", "h", ""],
["sunrise_01_80", "sunrise", "sunrise", "h", ""],
["sunrise_03_01", "sunrise", "forest ", "h", "mist floating close to the tropical forest"],
["sunrise_03_02", "sunrise", "forest ", "h", "foggy mist blanketing the mountains"],
["sunrise_03_03", "sunrise", "forest ", "h", "mild mist enveloping the mountains in a clear morning"],
["sunrise_03_04", "sunrise", "forest ", "h", "the cooling mist gives a soft and comforting look to the thick forest"],

["jungle_01_01", "jungle", "forest ", "h", "tourists participating in jungle trekking"],
["jungle_01_02", "jungle", "forest ", "h", "bundles of ferns inhibiting on trees"],
["jungle_01_03", "jungle", "forest ", "h", "Cameron Highlands is part of the Titiwangsa Mountains, the backbone of the Peninsula Malaysia"],
["jungle_02_01", "jungle", "rafflesia", "h", "tourists snapping photos of the rafflesia"],
["jungle_02_02", "jungle", "rafflesia", "h", "this parasitic flower is the largest flower in its category"],
["orang_asli_01", "jungle", "orang asli", "h", "a chart of the native communities in Peninsula Malaysia"],
["orang_asli_04", "jungle", "orang asli", "h", "around it is their garden where they grow fruit trees and vegetables"],
["orang_asli_05", "jungle", "orang asli", "h", "a 'store house'"],
["orang_asli_06", "jungle", "orang asli", "h", "the kampung's roof is made of bamboo leaves weaved together"],
["orang_asli_07", "jungle", "orang asli", "h", "children playing around"],
["orang_asli_08", "jungle", "orang asli", "h", "the kampung from far"],
["orang_asli_09", "jungle", "orang asli", "h", "another view of the kampung"],
["orang_asli_10", "jungle", "orang asli", "h", "a structure built with bamboo and ropes"],
["orang_asli_11", "jungle", "orang asli", "h", "a villager making a bon fire"],
["orang_asli_12", "jungle", "orang asli", "h", "the interior of the kampung"],
["orang_asli_13", "jungle", "orang asli", "h", "making a blow-pipe"],
["orang_asli_14", "jungle", "orang asli", "h", "a villager demonstrating on the blow-pipe"],
["orang_asli_15", "jungle", "orang asli", "h", "a tourist tries out the blow-pipe"],
["orang_asli_16", "jungle", "orang asli", "h", "the women weaving with mengkuang leaves"],
["orang_asli_17", "jungle", "orang asli", "h", "the finished products of weaving"],
["orang_asli_18", "jungle", "orang asli", "h", "weaved baskets to store their stocks"],
["orang_asli_19", "jungle", "orang asli", "h", "bamboo flutes along with a weaved tray, bangles and mats"],
["orang_asli_20", "jungle", "orang asli", "h", "a close-up on the weaving and the straws of coloured leaves"],
["orang_asli_21", "jungle", "orang asli", "h", "a poisonous stem with thorns used as weapon"],
["orang_asli_22", "jungle", "orang asli", "v", "a 'bubu' fish trap made of rattan"],
["orang_asli_23", "jungle", "orang asli", "h", "children looking out through the broken wall"],
["orang_asli_24", "jungle", "orang asli", "v", "a child overlooking the compound"],
["orang_asli_25", "jungle", "orang asli", "h", "a tourist witnessing the weaving"],
["orang_asli_26", "jungle", "orang asli", "h", "a villager blowing the nose flute"],
["orang_asli_27", "jungle", "orang asli", "h", "the tourist gives a try on the nose flute"],
["orang_asli_28", "jungle", "orang asli", "h", "flute blowing without using the mouth"],
["orang_asli_29", "jungle", "orang asli", "h", "children playing in the river"],
["orang_asli_30", "jungle", "orang asli", "v", "tourists experiencing the blow-pipe"],

["special_01_01", "special", "van", "h", "the Titiwangsa tour van"],
["special_01_02", "special", "van", "h", "the other side of it"],
["special_02_01", "special", "unititi express", "h", "a coach for passengers from Kuala Lumpur to Cameron Highlands"],
["special_02_02", "special", "unititi express", "h", "the other side of it"]

];

var categoriesarray = 
["Nature Discovery Tour", "Agro Delight Tour", "Leisure Tour", "Sunrise Spectacular", "Jungle Trekking", "Special Services"];
var tagsarray = new Array();

function load_categories() {	// to list all categories available
  document.getElementById('categoriesdiv').innerHTML = "";
  var currentitem = "", currentlink = "", codes = "";
  for (var row=0; row<categoriesarray.length; ++row) {
    currentitem = categoriesarray[row].toLowerCase();
    currentitem = currentitem.substring(0,currentitem.indexOf(" "));
    codes += "<div><a href=\"javascript:write_category_thumbnail('"+ currentitem +"');\">"+ categoriesarray[row] +"</a></div>";
  }
  document.getElementById('categoriesdiv').innerHTML = codes;
}

function load_tags() {	// to list all tags (full names) available
  document.getElementById('tagsdiv').innerHTML += "";
  var presenttag="", previoustag="", presenttagarray="";
  var counter = 0, duplicate = "";
  for (var row=1; row<picarray.length; ++row) {
    presenttag = picarray[row][2];
    previoustag = picarray[row-1][2];
    duplicate = "no";	// default is "no". -duplicate- is to catch if there's duplicated tags in -tagsarray[]- so that there's only 1 of each tag.
    if (presenttag != previoustag) {		// if !=, means there's possibility it's new tag to be added into tagsarray[]. Need to test if it already existed in -tagsarray[]-.
      for (var row2=0; row2<tagsarray.length; ++row2) {
        if (tagsarray[row2] == presenttag)  // if ==, means the -presenttag- already existed in -tagsarray[]-.
          duplicate = "yes";				// "yes" so that this -presenttag- will be ignored to avoid duplication in -tagsarray[]-.
      }
      if (duplicate == "no") {				// "no" (default value), means -presenttag- is a new tag and wil be added into -tagsarray[]-.
        tagsarray[counter] = presenttag;
        ++counter;
      }
    }
  }
  tagsarray.sort(sorttags);	// passes the tagarray[] to function sorttags() for sorting.
  var codes="";
  for (var row3=0; row3<tagsarray.length; ++row3) { // list all tags
    codes += "<div><a href=\"javascript:write_tag_thumbnail('"+ tagsarray[row3] +"');\">"+ tagsarray[row3] +"</a></div>";
  }
  document.getElementById('tagsdiv').innerHTML = codes;
}

// used by load_tags().
// this function sorts the items in the tagsarray[] in ascending order.
function sorttags(item1,item2) {
  var index=0, charcode1=0, charcode2=0;
  do {
    charcode1 = item1.charCodeAt(index);
    charcode2 = item2.charCodeAt(index);
    ++index;
  } while ((charcode1 == charcode2));
  return charcode1 - charcode2;
}
//=========================================================

function write_category_thumbnail(cate) {
  document.getElementById('chosen_thumbnail').innerHTML = "";			// clear -chosen_thumbnail- to enter new codes
  var category="", firstphoto="", title="", codes="";
  for (var row=0; row<categoriesarray.length; ++row) {				// loop through -categoriesarray[]-...
    category = categoriesarray[row].toLowerCase();			 	// ...to get -category-
    category = category.substring(0,category.indexOf(" "));
    if (cate == category) {							// ...to match with -cate-, to get -title-.
      title = "<b>Category : </b>"+ categoriesarray[row];
    }
  }
  var currentcate="", photodesc="", photoname="";
  for (var row=1; row<picarray.length; ++row) {		// loop through -picarray[][]-
    photoname = picarray[row][0];
    currentcate = picarray[row][1];			// ...to get first 4 characters
    if (cate == currentcate) {						// ...to match with -cate-, to write thumbnail codes.
      if (codes == "")	firstphoto = photoname;
      photodesc = picarray[row][4];
      codes += "<div width=\"75px\" height=\"75px\" style=\"background: url(images/photogallery_thumbnail/"+ photoname +".jpg) no-repeat center;\"><a href=\"javascript:write_photo('"+ photoname +"');\"><img src=\"images/photogallery_thumbnail/thumbnail_skeleton.gif\" alt=\""+ photoname +" - "+ photodesc +"\"/></a></div>";
    }
  }
  document.getElementById('chosen_title').innerHTML = title;
  document.getElementById('chosen_thumbnail').innerHTML = codes;
  write_photo(firstphoto);
}

function write_tag_thumbnail(tag) {
  document.getElementById('chosen_thumbnail').innerHTML = "";			// clear -chosen_thumbnail- to enter new codes
  var currenttag="", firstphoto="", photoname="", photodesc="", title="", codes="";
  for (var row=1; row<picarray.length; ++row) {							// loop through -picarray[][]-
    currenttag = picarray[row][2];										// ...to get -currenttag- in the -picarray[][]-
    if (tag == currenttag) {											// ...to match with -tag-, to get -folder-, -title- & write thumbnail codes.
      photoname = picarray[row][0];
      photodesc = picarray[row][4];
      if (codes == "")	firstphoto = photoname;
      title = "<b>Tag : </b>"+ tag;
      codes += "<div width=\"75px\" height=\"75px\" style=\"background: url(images/photogallery_thumbnail/"+ photoname +".jpg) no-repeat center;\"><a href=\"javascript:write_photo('"+ photoname +"');\"><img src=\"images/photogallery_thumbnail/thumbnail_skeleton.gif\" alt=\""+ photoname +" - "+ photodesc +"\"/></a></div>";
    }
  }
  document.getElementById('chosen_title').innerHTML = title;
  document.getElementById('chosen_thumbnail').innerHTML = codes;
  write_photo(firstphoto);
}
//=========================================================

function write_photo(item) {
  document.getElementById('photo').innerHTML = "";
  var photoname="", photodesc="", photocodes="", desccodes="";
  for (var row=1; row<picarray.length; ++row) {
    photoname = picarray[row][0];
    if (item == photoname) {
      photodesc = picarray[row][4];
      photocodes = "<img style='border: solid 10px #ebe4f1;' src=\"images/photogallery/"+ photoname +".jpg\" alt=\""+ photoname +"\"/>";
      desccodes = photodesc;
    }
  }
  document.getElementById('photo').innerHTML = photocodes;
  document.getElementById('description').innerHTML = desccodes;
}
//=========================================================

function toggle(targetId){ 
  if (document.getElementById(targetId).style.display == "none")
    document.getElementById(targetId).style.display = ""; 
  else
    document.getElementById(targetId).style.display = "none"; 
}
//=========================================================

function randomphoto() {
  var row = Math.round(1 + Math.random()*(picarray.length-1));
  var photoname = picarray[row][0];
  var photodesc = picarray[row][4];
  var dimension = picarray[row][3];
  var height = "150", bgphoto="", paddingbottom="";
  switch (dimension) {
  case "h": bgphoto = "randomphoto_pic_h"; paddingbottom = "35"; break;
  case "v": bgphoto = "randomphoto_pic_v"; paddingbottom = "10"; break;
  }
  var codes = "<div height=\""+ height +"px\" align=\"center\" style=\"background: url(images/"+ bgphoto +".jpg) no-repeat top center; padding: 40px 0 "+ paddingbottom +"px 0;\"><img src=\"images/photogallery_thumbnail/"+ photoname +".jpg\" alt=\"\" title=\""+ photodesc +"\"/></div>";
  document.getElementById('photogallery_a').innerHTML += codes;
  document.getElementById('photogallery_b').innerHTML += codes;
}