window.thumbnails = {};
thumbnails[8045049] = clik.newPhoto({"link":"#","caption":"","height":73,"id":8045049,"server_id":31,"src":"blank_business_card_thumb.jpg","galleries_id":"","width":130});
thumbnails[8045140] = clik.newPhoto({"link":"#","caption":"Booja-Booja","height":83,"id":8045140,"server_id":31,"src":"BB_Flamed_Bananas_thumb.jpg","galleries_id":"","width":130});
thumbnails[8111756] = clik.newPhoto({"link":"#","caption":"Prestat truffles","height":130,"id":8111756,"server_id":31,"src":"PR_truffles_thumb.jpg","galleries_id":"","width":85});
thumbnails[8051839] = clik.newPhoto({"link":"photo_8051839.html","caption":"Botanical Caraques","height":125,"id":8051839,"server_id":31,"src":"botanical-caraques-kc_thumb.jpg","galleries_id":431571,"width":130});
thumbnails[8051848] = clik.newPhoto({"link":"photo_8051848.html","caption":"After Dinner Mint Caraques","height":126,"id":8051848,"server_id":31,"src":"mint-caraques-kc_thumb.jpg","galleries_id":431571,"width":130});
thumbnails[8051857] = clik.newPhoto({"link":"photo_8051857.html","caption":"Kernow Chocolate Boxes","height":80,"id":8051857,"server_id":31,"src":"pinkgreenchocboxes-kc_thumb.jpg","galleries_id":431571,"width":130});
thumbnails[8051881] = clik.newPhoto({"link":"photo_8051881.html","caption":"Chunky Chocolate","height":130,"id":8051881,"server_id":31,"src":"DSCN0711_thumb.JPG","galleries_id":431759,"width":118});
thumbnails[8051888] = clik.newPhoto({"link":"photo_8051888.html","caption":"Chocolate Shapes","height":93,"id":8051888,"server_id":31,"src":"DSCN0704_thumb.JPG","galleries_id":431759,"width":130});
thumbnails[8103841] = clik.newPhoto({"link":"photo_8103841.html","caption":"Gnaw","height":92,"id":8103841,"server_id":31,"src":"227474_224011557609611_224010817609685_986414_1824318_n_thumb.jpg","galleries_id":431570,"width":130});
thumbnails[8111750] = clik.newPhoto({"link":"photo_8111750.html","caption":"Prestat Jewel Box","height":96,"id":8111750,"server_id":31,"src":"PR010-big_thumb.jpg","galleries_id":431571,"width":130});
thumbnails[8111754] = clik.newPhoto({"link":"photo_8111754.html","caption":"Prestat wafers","height":96,"id":8111754,"server_id":31,"src":"PR_wafers1_thumb.jpg","galleries_id":431571,"width":130});
thumbnails[8776088] = clik.newPhoto({"link":"photo_8776088.html","caption":"Gold Stars","height":98,"id":8776088,"server_id":31,"src":"302270_580270858118_272700376_2792376_1804378977_n_thumb.jpg","galleries_id":431759,"width":130});
thumbnails[8776124] = clik.newPhoto({"link":"photo_8776124.html","caption":"Large Party Bags","height":98,"id":8776124,"server_id":31,"src":"302900_580270478878_272700376_2792372_1467820426_n_thumb.jpg","galleries_id":431571,"width":130});
thumbnails[8776204] = clik.newPhoto({"link":"photo_8776204.html","caption":"Mixed Bag","height":130,"id":8776204,"server_id":31,"src":"378871_580271147538_272700376_2792379_773439737_n_thumb.jpg","galleries_id":431759,"width":97});
thumbnails[8776278] = clik.newPhoto({"link":"photo_8776278.html","caption":"Small Party bags","height":98,"id":8776278,"server_id":31,"src":"385902_580270588658_272700376_2792374_840254025_n1_thumb.jpg","galleries_id":431571,"width":130});
thumbnails[8776287] = clik.newPhoto({"link":"photo_8776287.html","caption":"Chocolate Reindeer","height":74,"id":8776287,"server_id":31,"src":"392211_580270723388_272700376_2792375_564806174_n1_thumb.jpg","galleries_id":431759,"width":130});
thumbnails[8812393] = clik.newPhoto({"link":"photo_8812393.html","caption":"Large gift set","height":97,"id":8812393,"server_id":31,"src":"313595_582362506438_272700376_2801711_1925776939_n_thumb.jpg","galleries_id":431571,"width":130});
thumbnails[8812434] = clik.newPhoto({"link":"photo_8812434.html","caption":"Chocolate jar","height":130,"id":8812434,"server_id":31,"src":"373914_582362820808_272700376_2801716_56997840_n_thumb.jpg","galleries_id":431571,"width":126});
thumbnails[8812450] = clik.newPhoto({"link":"photo_8812450.html","caption":"Turkish Delight","height":130,"id":8812450,"server_id":31,"src":"373970_582362676098_272700376_2801714_1975775972_n_thumb.jpg","galleries_id":431571,"width":97});
thumbnails[8812466] = clik.newPhoto({"link":"photo_8812466.html","caption":"Large sweets jar","height":130,"id":8812466,"server_id":31,"src":"385075_582362596258_272700376_2801712_1829035786_n_thumb.jpg","galleries_id":431571,"width":114});
thumbnails[8812519] = clik.newPhoto({"link":"photo_8812519.html","caption":"Small sweet jar","height":106,"id":8812519,"server_id":31,"src":"388386_582362621208_272700376_2801713_1440555604_n_thumb.jpg","galleries_id":431571,"width":130});
thumbnails[8812568] = clik.newPhoto({"link":"photo_8812568.html","caption":"Small variety gift set","height":130,"id":8812568,"server_id":31,"src":"393441_582362301848_272700376_2801707_658257814_n_thumb.jpg","galleries_id":431571,"width":108});
thumbnails[8812587] = clik.newPhoto({"link":"photo_8812587.html","caption":"Small chunky chocolate gift set","height":130,"id":8812587,"server_id":31,"src":"392130_582362421608_272700376_2801709_755792160_n_thumb.jpg","galleries_id":431571,"width":104});
thumbnails[8050613] = clik.newPhoto({"link":"photo_8050613.html","caption":"For The Love of Chocolate","height":73,"id":8050613,"server_id":31,"src":"blank_business_card1_thumb.jpg","galleries_id":431570,"width":130});
thumbnails[8050525] = clik.newPhoto({"link":"photo_8050525.html","caption":"Montezuma's","height":98,"id":8050525,"server_id":31,"src":"DSCN0722_thumb.JPG","galleries_id":431570,"width":130});
thumbnails[8050085] = clik.newPhoto({"link":"photo_8050085.html","caption":"Sweet Boutique Slabs","height":102,"id":8050085,"server_id":31,"src":"SB_Slabs_thumb.jpg","galleries_id":431570,"width":130});
thumbnails[8103796] = clik.newPhoto({"link":"photo_8103796.html","caption":"","height":130,"id":8103796,"server_id":31,"src":"246870_224789674198466_224010817609685_992854_1980211_n_thumb.jpg","galleries_id":433870,"width":103});
thumbnails[8103835] = clik.newPhoto({"link":"photo_8103835.html","caption":"","height":73,"id":8103835,"server_id":31,"src":"blank_business_card_-_Version_3_thumb.jpg","galleries_id":431829,"width":130});
thumbnails[8103884] = clik.newPhoto({"link":"photo_8103884.html","caption":"","height":130,"id":8103884,"server_id":31,"src":"booja_booja_thumb.jpg","galleries_id":433867,"width":130});
thumbnails[8103933] = clik.newPhoto({"link":"photo_8103933.html","caption":"","height":45,"id":8103933,"server_id":31,"src":"logo_montezuma_thumb.gif","galleries_id":431830,"width":130});
thumbnails[8103934] = clik.newPhoto({"link":"photo_8103934.html","caption":"","height":38,"id":8103934,"server_id":31,"src":"header_Kernow_thumb.gif","galleries_id":433878,"width":130});
thumbnails[8103935] = clik.newPhoto({"link":"photo_8103935.html","caption":"","height":60,"id":8103935,"server_id":31,"src":"logo_Prestat_thumb.png","galleries_id":433874,"width":130});
thumbnails[8103940] = clik.newPhoto({"link":"photo_8103940.html","caption":"","height":130,"id":8103940,"server_id":31,"src":"254954_171793456214851_120088108052053_433510_5253200_n_thumb.jpg","galleries_id":433880,"width":130});
thumbnails[8103942] = clik.newPhoto({"link":"photo_8103942.html","caption":"","height":122,"id":8103942,"server_id":31,"src":"Sweet_Boutique_thumb.jpg","galleries_id":433873,"width":130});
thumbnails[8111747] = clik.newPhoto({"link":"photo_8111747.html","caption":"Gnaw Bars","height":92,"id":8111747,"server_id":31,"src":"227474_224011557609611_224010817609685_986414_1824318_n_131BFB57-1E4F-37DC-714E3D72FF819C7E_thumb.jpg","galleries_id":433870,"width":130});
thumbnails[8111752] = clik.newPhoto({"link":"photo_8111752.html","caption":"Jewel Box","height":96,"id":8111752,"server_id":31,"src":"PR010-big1_thumb.jpg","galleries_id":433874,"width":130});
thumbnails[8111753] = clik.newPhoto({"link":"photo_8111753.html","caption":"Wafers","height":96,"id":8111753,"server_id":31,"src":"PR_wafers_thumb.jpg","galleries_id":433874,"width":130});
thumbnails[8111758] = clik.newPhoto({"link":"photo_8111758.html","caption":"Truffles","height":130,"id":8111758,"server_id":31,"src":"PR_truffles1_thumb.jpg","galleries_id":433874,"width":85});
thumbnails[8281821] = clik.newPhoto({"link":"photo_8281821.html","caption":"","height":102,"id":8281821,"server_id":31,"src":"SB_Slabs_17F82D5F-1EC9-DFB6-0903B3D2473A2770_thumb.jpg","galleries_id":433873,"width":130});
thumbnails[8341904] = clik.newPhoto({"link":"photo_8341904.html","caption":"White chocolate buttons","height":130,"id":8341904,"server_id":31,"src":"White_buttons_2_thumb.jpg","galleries_id":442245,"width":130});
thumbnails[8342074] = clik.newPhoto({"link":"photo_8342074.html","caption":"Milk chocolate buttons","height":130,"id":8342074,"server_id":31,"src":"310AZB7NJYL._SL500_AA300__thumb.jpg","galleries_id":442245,"width":130});
thumbnails[8342403] = clik.newPhoto({"link":"photo_8342403.html","caption":"Squares and diamonds","height":86,"id":8342403,"server_id":31,"src":"321614_573935000228_272700376_2719820_2027866_n_thumb.jpg","galleries_id":442246,"width":130});
thumbnails[8342476] = clik.newPhoto({"link":"photo_8342476.html","caption":"Circles and Ovals","height":98,"id":8342476,"server_id":31,"src":"303581_573935020188_272700376_2719821_911983_n_thumb.jpg","galleries_id":442246,"width":130});
thumbnails[8342500] = clik.newPhoto({"link":"photo_8342500.html","caption":"Hearts and Stars","height":98,"id":8342500,"server_id":31,"src":"305074_573935030168_272700376_2719822_6192201_n_thumb.jpg","galleries_id":442246,"width":130});
thumbnails[8342725] = clik.newPhoto({"link":"photo_8342725.html","caption":"Chocolate Brownies","height":127,"id":8342725,"server_id":31,"src":"title_A7233517-1EC9-DFB6-092584E69ABE5E22_thumb.jpg","galleries_id":442247,"width":130});
thumbnails[8400855] = clik.newPhoto({"link":"photo_8400855.html","caption":"Dark Chocolate Buttons","height":102,"id":8400855,"server_id":31,"src":"680987_T_thumb.jpg","galleries_id":442245,"width":130});
thumbnails[8401096] = clik.newPhoto({"link":"photo_8401096.html","caption":"Chewy chocolate chip cookies","height":130,"id":8401096,"server_id":31,"src":"305844_573935050128_272700376_2719823_5958822_n_thumb.jpg","galleries_id":442247,"width":96});
thumbnails[8406196] = clik.newPhoto({"link":"photo_8406196.html","caption":"Contemporary flowers","height":130,"id":8406196,"server_id":31,"src":"291879_574002674608_272700376_2721311_2609409_n_thumb.jpg","galleries_id":442246,"width":97});
thumbnails[8406227] = clik.newPhoto({"link":"photo_8406227.html","caption":"Contemporary balls","height":130,"id":8406227,"server_id":31,"src":"294179_574002699558_272700376_2721313_1181754_n_thumb.jpg","galleries_id":442246,"width":97});
thumbnails[8406228] = clik.newPhoto({"link":"photo_8406228.html","caption":"Gifts and stars","height":130,"id":8406228,"server_id":31,"src":"296966_574002534888_272700376_2721301_7942061_n_thumb.jpg","galleries_id":442246,"width":97});
thumbnails[8406232] = clik.newPhoto({"link":"photo_8406232.html","caption":"Dolphin","height":130,"id":8406232,"server_id":31,"src":"299371_574002619718_272700376_2721307_1355837_n_thumb.jpg","galleries_id":442246,"width":97});
thumbnails[8406236] = clik.newPhoto({"link":"photo_8406236.html","caption":"Apples","height":130,"id":8406236,"server_id":31,"src":"304293_574002639678_272700376_2721308_5954875_n_thumb.jpg","galleries_id":442246,"width":97});
thumbnails[8406243] = clik.newPhoto({"link":"photo_8406243.html","caption":"Leaves","height":130,"id":8406243,"server_id":31,"src":"308623_574002574808_272700376_2721303_4959734_n_thumb.jpg","galleries_id":442246,"width":97});
thumbnails[8406249] = clik.newPhoto({"link":"photo_8406249.html","caption":"Penguins","height":130,"id":8406249,"server_id":31,"src":"310539_574002599758_272700376_2721305_3223238_n_thumb.jpg","galleries_id":442246,"width":97});
thumbnails[8776147] = clik.newPhoto({"link":"photo_8776147.html","caption":"Ballotin Box Favour","height":98,"id":8776147,"server_id":31,"src":"317572_580271017798_272700376_2792378_573132435_n_thumb.jpg","galleries_id":462088,"width":130});
thumbnails[8776223] = clik.newPhoto({"link":"photo_8776223.html","caption":"Mixed Bag","height":130,"id":8776223,"server_id":31,"src":"378871_580271147538_272700376_2792379_773439737_n1_thumb.jpg","galleries_id":462092,"width":97});
thumbnails[8776228] = clik.newPhoto({"link":"photo_8776228.html","caption":"Large Party Bags","height":98,"id":8776228,"server_id":31,"src":"302900_580270478878_272700376_2792372_1467820426_n1_thumb.jpg","galleries_id":462092,"width":130});
thumbnails[8776231] = clik.newPhoto({"link":"photo_8776231.html","caption":"","height":97,"id":8776231,"server_id":31,"src":"385362_580271237358_272700376_2792380_1964533598_n_thumb.jpg","galleries_id":462098,"width":130});
thumbnails[8776246] = clik.newPhoto({"link":"photo_8776246.html","caption":"Small Party Bags","height":98,"id":8776246,"server_id":31,"src":"385902_580270588658_272700376_2792374_840254025_n_thumb.jpg","galleries_id":462092,"width":130});

/***************************************************************************
* Create the array of Gallery objects                                      *
***************************************************************************/
var galleries = new Object();
galleries[433867] = clik.newGallery({"photoIDs":[8103884],"link":"section518937_433867.html","skipIndex":0,"section_code":"section518937","id":433867,"parentGallery":"","featured_images":8103884,"maxRecords":0,"usePopups":false,"singleSection":false,"title":"Booja-Booja"});galleries[433880] = clik.newGallery({"photoIDs":[8103940],"link":"section518937_433880.html","skipIndex":0,"section_code":"section518937","id":433880,"parentGallery":"","featured_images":8103940,"maxRecords":0,"usePopups":false,"singleSection":false,"title":"Danucci"});galleries[462088] = clik.newGallery({"photoIDs":[8776147],"link":"section559596_462088.html","skipIndex":0,"section_code":"section559596","id":462088,"parentGallery":"","featured_images":8776147,"maxRecords":0,"usePopups":false,"singleSection":false,"title":"Favours"});galleries[433870] = clik.newGallery({"photoIDs":[8103796,8111747],"link":"section518937_433870.html","skipIndex":0,"section_code":"section518937","id":433870,"parentGallery":"","featured_images":8103796,"maxRecords":0,"usePopups":false,"singleSection":false,"title":"Gnaw"});galleries[433878] = clik.newGallery({"photoIDs":[8103934],"link":"section518937_433878.html","skipIndex":0,"section_code":"section518937","id":433878,"parentGallery":"","featured_images":8103934,"maxRecords":0,"usePopups":false,"singleSection":false,"title":"Kernow Chocolates"});galleries[431830] = clik.newGallery({"photoIDs":[8103933],"link":"section518937_431830.html","skipIndex":0,"section_code":"section518937","id":431830,"parentGallery":"","featured_images":8103933,"maxRecords":0,"usePopups":false,"singleSection":false,"title":"Montezuma's"});galleries[462092] = clik.newGallery({"photoIDs":[8776223,8776228,8776246],"link":"section559596_462092.html","skipIndex":0,"section_code":"section559596","id":462092,"parentGallery":"","featured_images":"8776246,8776228,8776223","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Parties"});galleries[433874] = clik.newGallery({"photoIDs":[8103935,8111752,8111753,8111758],"link":"section518937_433874.html","skipIndex":0,"section_code":"section518937","id":433874,"parentGallery":"","featured_images":8103935,"maxRecords":0,"usePopups":false,"singleSection":false,"title":"Prestat"});galleries[433873] = clik.newGallery({"photoIDs":[8103942,8281821],"link":"section518937_433873.html","skipIndex":0,"section_code":"section518937","id":433873,"parentGallery":"","featured_images":8103942,"maxRecords":0,"usePopups":false,"singleSection":false,"title":"Sweet Boutique"});galleries[462098] = clik.newGallery({"photoIDs":[8776231],"link":"section559596_462098.html","skipIndex":0,"section_code":"section559596","id":462098,"parentGallery":"","featured_images":8776231,"maxRecords":0,"usePopups":false,"singleSection":false,"title":"Table decorations and centre pieces"});galleries[431570] = clik.newGallery({"photoIDs":[8103841,8050613,8050525,8050085],"link":"gallery_431570.html","skipIndex":0,"section_code":"gallery","id":431570,"parentGallery":"","featured_images":"8103841,8050613,8050525,8050085","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Chocolate Bars"});galleries[431829] = clik.newGallery({"photoIDs":[8103835],"link":"section518937_431829.html","skipIndex":0,"section_code":"section518937","id":431829,"parentGallery":"","featured_images":8103835,"maxRecords":0,"usePopups":false,"singleSection":false,"title":"For The Love Of Chocolate"});galleries[442246] = clik.newGallery({"photoIDs":[8342403,8342476,8342500,8406196,8406227,8406228,8406232,8406236,8406243,8406249],"link":"section530868_442246.html","skipIndex":0,"section_code":"section530868","id":442246,"parentGallery":"","featured_images":"8406249,8406243,8406236,8406232,8406228,8406227,8406196,8342500,8342476,8342403","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Moulds"});galleries[431571] = clik.newGallery({"photoIDs":[8051839,8051848,8051857,8111750,8111754,8776124,8776278,8812393,8812434,8812450,8812466,8812519,8812568,8812587],"link":"gallery_431571.html","skipIndex":0,"section_code":"gallery","id":431571,"parentGallery":"","featured_images":"8812587,8812568,8812519,8812466,8812450,8812434,8812393,8776278,8776124,8111754","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Chocolates, Boxes and Gifts"});galleries[442247] = clik.newGallery({"photoIDs":[8342725,8401096],"link":"section530868_442247.html","skipIndex":0,"section_code":"section530868","id":442247,"parentGallery":"","featured_images":"8401096,8342725","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Recipes"});galleries[442245] = clik.newGallery({"photoIDs":[8341904,8342074,8400855],"link":"section530868_442245.html","skipIndex":0,"section_code":"section530868","id":442245,"parentGallery":"","featured_images":"8400855,8342074,8341904","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Buttons"});galleries[431759] = clik.newGallery({"photoIDs":[8051881,8051888,8776088,8776204,8776287],"link":"gallery_431759.html","skipIndex":0,"section_code":"gallery","id":431759,"parentGallery":"","featured_images":"8776287,8776204,8776088,8051888,8051881","maxRecords":0,"usePopups":false,"singleSection":false,"title":"Chocolate Bags"});/***************************************************************************
* Create the array of image sets                                           *
***************************************************************************/
var imageSets = {};
imageSets[3] = '8812587,8812568,8812519,8812466,8812450,8812434,8812393,8776287,8776278,8776246,8776231,8776228,8776223,8776204,8776147,8776124,8776088,8406249,8406243,8406236,8406232,8406228,8406227,8406196,8401096,8400855,8342725,8342500,8342476,8342403,8342074,8341904,8281821,8111758,8111756,8111754,8111753,8111752,8111750,8111747,8103942,8103940,8103935,8103934,8103933,8103884,8103841,8103835,8103796,8051888';
imageSets[2] = '8103942,8103940,8103935,8103934,8103933,8103884,8103835,8103796';
imageSets[1] = '8045049';
 /***************************************************************************
* Get a server path given an ID                                            *
***************************************************************************/
function getServerPath(server_id) {
	var val = -1;
		switch (server_id) {
		case 19:
		val = 'http://www5.clikpic.com/Mellie87/images';
		break;
	}
		switch (server_id) {
		case 35:
		val = 'http://admin3.clikpic.com/Mellie87/images';
		break;
	}
		switch (server_id) {
		case 18:
		val = 'http://www4.clikpic.com/Mellie87/images';
		break;
	}
		switch (server_id) {
		case 15:
		val = 'http://www3.clikpic.com/Mellie87/images';
		break;
	}
		switch (server_id) {
		case 34:
		val = 'http://www9.clikpic.com/Mellie87/images';
		break;
	}
		switch (server_id) {
		case 39:
		val = 'http://www10.clikpic.com/Mellie87/images';
		break;
	}
		switch (server_id) {
		case 37:
		val = 'http://admin4.clikpic.com/Mellie87/images';
		break;
	}
		switch (server_id) {
		case 38:
		val = 'http://admin5.clikpic.com/Mellie87/images';
		break;
	}
		switch (server_id) {
		case 21:
		val = 'http://www6.clikpic.com/Mellie87/images';
		break;
	}
		switch (server_id) {
		case 42:
		val = 'db2.clikpic.com/Mellie87/images';
		break;
	}
		switch (server_id) {
		case 40:
		val = 'http://www11.clikpic.com/Mellie87/images';
		break;
	}
		switch (server_id) {
		case 22:
		val = 'http://tpc5/clikpic/Mellie87/images';
		break;
	}
		switch (server_id) {
		case 23:
		val = 'http://tpc10/clikpic/Mellie87/images';
		break;
	}
		switch (server_id) {
		case 24:
		val = 'http://tpc15/clikpic/Mellie87/images';
		break;
	}
		switch (server_id) {
		case 25:
		val = 'http://tpc16/clikpic/Mellie87/images';
		break;
	}
		switch (server_id) {
		case 26:
		val = 'http://tpc20/clikpic/Mellie87/images';
		break;
	}
		switch (server_id) {
		case 2:
		val = 'http://admin.clikpic.com/Mellie87/images';
		break;
	}
		switch (server_id) {
		case 1:
		val = 'http://www1.clikpic.com/Mellie87/images';
		break;
	}
		switch (server_id) {
		case 0:
		val = 'http://www.clikpic.com/Mellie87/images';
		break;
	}
		switch (server_id) {
		case 5:
		val = 'http://www2.clikpic.com/Mellie87/images';
		break;
	}
		switch (server_id) {
		case 32:
		val = 'http://www8.clikpic.com/Mellie87/images';
		break;
	}
		switch (server_id) {
		case 4:
		val = 'http://clikchurch.clikpic.com/Mellie87/images';
		break;
	}
		switch (server_id) {
		case 31:
		val = 'http://www7.clikpic.com/Mellie87/images';
		break;
	}
		switch (server_id) {
		case 51:
		val = 'www12.clikpic.com/Mellie87/images';
		break;
	}
		switch (server_id) {
		case 50:
		val = '[cliktext value=article.servers_id type=servers_id]/Mellie87/images';
		break;
	}
		return val;
}

/***************************************************************************
* img = reference to image object in which to show image                   *
***************************************************************************/
function showHomeImage(img) {
	imageID = randomListVal('');
	if (!basic) {
		img.src = photos[imageID].src;
		img.width = photos[imageID].width;
		img.height = photos[imageID].height;
		img.parentNode.title = img.alt = photos[imageID].caption;
	} else {
		newImage = new Image(photos[imageID].width,photos[imageID].height);
		newImage.src = photos[imageID].src;
		document.images[img.name] = newImage;
		
	}
}

function getHomeImageLink(imageID) {
  	var href='', photo = backgrounds && backgrounds[imageID];
	if(photo){
		if (photo && photo.galleries_id != '') {
  			href = photo.fnGalleryLink();
  		}
  		  		else {
  				href += 'gallery.html';
  	  		}
	}
    return href;
}

/***************************************************************************
* Show a random image on home page from featured images                    *
***************************************************************************/
function showHomeImageInline(el, image_sets_id, href) {
	
	var css = {}, imageID,
	    imageSetsId = 1;
	if(image_sets_id){
		imageSetsId = image_sets_id;
	}
	imageID = randomListVal(imageSets[imageSetsId]);
	if (href == null && 'gallery' != '') {
					href = getHomeImageLink(imageID);
	}
	
	updateImage({nextPhoto: backgrounds[imageID], img:el.find('img')[0],
                $photo:el, $title:$('#homeimageTitleContainer'), $detail:$('#homeimageDetailsContainer'),                speed:0, href:href, css:css, onAfter: function(){                  this.closest('.contentsection').doManualAlign({				    inner: 'img',				    crop: 'a'				  });                }              });
}

/***************************************************************************
* Set 'img' to be a new image given its photo() object                     *
***************************************************************************/
function updateImage (options) {
	var defaults = {nextPhoto:'',field:'',img:'',$photo:'',$title:'',$detail:'',$detailContainer:'',
                    updateDocumentTitle:false,speed:0,href:false,css:false,updateHash:false,onAfter:null,onBefore:null},
		op = $.extend({},defaults,options),
		html = '', temp = '',
		photoId = op.nextPhoto.id,
		photoCaption = ''+op.nextPhoto.caption,
		photoSrc = op.nextPhoto.src;
	
	if (op.updateHash && clik.getIDInUrl(location.href,'photo') != op.nextPhoto.id) {
		clik.changeHash('photos_id=' + op.nextPhoto.id, true);
	}
		
	    if (op.$title.length > 0) {
  		op.$title.fadeGalleryDetails(photoCaption, op.speed);
    }
        if (op.updateDocumentTitle) {
				  document.title = 'For The Love Of Chocolate: ' + photoCaption;
			    }
        if (op.$detail.length > 0) {
      	temp = op.nextPhoto.fnGetImageDetails();
	    op.$detail.fadeGalleryDetails(temp, op.speed, function(){
			if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
				toggleAddToCartConfirm(backgrounds, op.$detail);
			} else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
				toggleAddToCartConfirm(photos, op.$detail);
			}
			$('body').trigger('clikUpdate.popup');
	    });
    }
        $(op.$detailContainer).find('.replaceable[class*=replaceable_photo-]').each(function(){
    	var field = clik.getPrefixedClass(this.className, 'replaceable_photo-');
    	if (field in op.nextPhoto) {
    		$(this).fadeGalleryDetails(op.nextPhoto[field], op.speed);
    	}
    }).end().find('.replaceable.photoPayment').fadeGalleryDetails(op.nextPhoto.fnGetPaymentInfo(), op.speed, function(){
		if (typeof(backgrounds) != 'undefined' && op.nextPhoto == backgrounds[op.nextPhoto.id]) {
			toggleAddToCartConfirm(backgrounds, op.$detailContainer);
		} else if (typeof(photos) != 'undefined' && op.nextPhoto == photos[op.nextPhoto.id]) {
			toggleAddToCartConfirm(photos, op.$detailContainer);
		}
		$('body').trigger('clikUpdate.popup');
	});
		if (op.$photo.length > 0) {
		html = $('<img/>',{
			'class': 'mainphoto photo',
			src: photoSrc,
			id: 'mainPic',
			name: 'mainPic',
			width: op.nextPhoto.width,
			height: op.nextPhoto.height,
			alt: photoCaption,
			css: op.css || {}
		});
		if (op.href) {
			if (op.href.match(/<a/)) {
				html = $(op.href).append(html);
			} else {
				html = $('<a/>', {
					href: op.href,
					title: photoCaption
				}).append(html);
			}
		} else {
			html = $('<a/>', {
				title: photoCaption
			}).append(html);
		}
		if (op.speed == 0) {			op.$photo.html(html);			if (op.onBefore) {			  	op.onBefore.apply(op.$photo);			}			if (op.onAfter) {			  	op.onAfter.apply(op.$photo);			}		} else {			op.$photo.stop(true,true).fadeReplaceWith(html,op.speed,'',function(){  				if (op.onAfter) {				  	op.onAfter.apply(this);				}				clik.doColumnResize(false, $(this).add(op.$detail).add(op.$title));			}, op.onBefore);
		}	}
    if (op.field) {
		op.field.value = photoId;
	} else {
		op.$photo.data('image_id', photoId);
    }
        if (!op.speed) {
      	clik.doColumnResize(false, op.$photo.add(op.$detail).add(op.$title));
    }
        
    return html;
	}

/***************************************************************************
* Toggle add to cart confirmation element and set up the click event for   *
* the 'Add to cart' button.                                                *
***************************************************************************/
function toggleAddToCartConfirm(array, root){
	if (typeof(array) !== 'object' || array === null) {
	  	array = photos;
	}
	if (!$(root).length) {		root = $('body');	}	if($('#paymentConfirm', root).length > 0){
		$('#paymentConfirm', root).hide();
		$('#paymentAddButton', root)
		.unbind()
		.click(function(){
						form = $('#paymentForm', root)[0];
			option_id = 0;
			if(form.item_option.value){
				option_id = form.item_option.value;
			}
			if(addItemToBasket(form.item_number.value,array,form.site.value,parseInt(form.quantity.value, 10),option_id)){
				if($.browser.msie){$('#paymentConfirm', root).text('Item added to cart').show();}
				else{
					$('#paymentConfirm', root).text('Item added to cart').fadeIn();
					dspOrderDetails(form.site.value);
				}
			}
			else{
				$('#paymentConfirm', root).text('Item not added - check cookies are enabled in your browser.').fadeIn();
			}
		});
	}
}

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
clik.photo.fnGetImageDetails = function(){
	var temp = '';
	if (this.description != '') {
		temp +=  '<div id="imageDescription">' + this.description + '</div>';
	}
		if (this.photo_ref != '') {
		temp += '<div class="imageinfo" id="imageRef"><strong>Ref: </strong>' + this.photo_ref + '</div>';
	}
		if (this.takendate != '') {
		
		temp += '<div class="imageinfo" id="imageDate"><strong>Date: </strong>' + this.takendate + '</div>';
	}
	
	if (this.location != '') {
		
		temp += '<div class="imageinfo" id="imageLocation"><strong>Location: </strong>' +  this.location + '</div>';
	}
	
	if (this.photographer != '') {
		
		temp += '<div class="imageinfo" id="imagePhotographer"><strong>Photographer: </strong>' + this.photographer + '</div>';
	}
			
	temp += this.fnGetPaymentInfo();
				if (temp != '') {
		temp += '<div class="spacer"></div>';
	}
	return temp;
};

/***************************************************************************
* Get payment info for image - add as 'method' to photo object             *
***************************************************************************/
clik.photo.fnGetPaymentInfo = function(){
	var temp = '';
	if (this.item_price !== '') {
				temp += '<p>Buy now using PayPal:</p>';
				temp += '<div class="imageinfo" id="imagePrice"><strong>' + this.purchase_instruction + '</strong> &pound;' + (this.item_price).toFixed(2) + '</div>';
		var item_name  = this.purchase_instruction;
		var amount = (this.item_price).toFixed(2);
		var item_option  = 0;
	}
		else if (this.payment_groups_id !== '') {
		temp += '<p>Buy this print online:</p>';
				temp += '<form id="paymentOptions" style="margin:0px;border:0px;" name="paymentOptions">';
						temp += '<select class="paymentlink" name="payment_options_id" onchange="updateCartValue($(this.form).next(\'#paymentForm\')[0],this.form.payment_options_id.options[this.form.payment_options_id.options.selectedIndex].value); if(divShowing(\'paymentConfirm\')){fadeOut(\'paymentConfirm\', 3)};">';
		
		temp += getPaymentOptions(this.payment_groups_id);
		temp += '</select>';
		temp += '</form>';
				var item_option  = paymentGroups[this.payment_groups_id].options[0];
		if(paymentOptions[item_option]){
			var item_name  = paymentOptions[item_option].payment_option;
			var amount =  paymentOptions[item_option].price;
		}
			}
		else {
		
	}
	if (this.item_price !== '' || this.payment_groups_id !== '') {
					temp += '<form id="paymentForm" style="margin:0px;border:0px;" name="paymentForm">';
			temp += '	<input type="hidden" name="item_option" value="' + item_option + '">';
			temp += '	<input type="hidden" name="site" value="MELLIE87">';
			temp += '	<input type="hidden" name="item_number" value="'+ this.id +'">';
			temp += '	<input type="hidden" name="quantity" value="1">';
						temp += '	<input value="Add to cart" id="paymentAddButton" class="button" onmouseover="this.className=\'buttonHi\'\;" onmouseout="this.className=\'button\'\;" type="Button">';
							temp += '	<input value="View cart" id="paymentViewButton" class="button" onmouseover="this.className=\'buttonHi\';" onmouseout="this.className=\'button\';" type="Button" onclick="javascript:window.location=\'cart.html\'">';
			temp += '</form>';
						temp += '<div class="clearing">&nbsp;</div>';
			temp += '<div id="confirmContainer">';
			temp += '<div id="paymentConfirm">Item added to cart</div>';
			temp += '</div>';
			temp += '<div class="clearing">&nbsp;</div>';
	}
	return temp;};

/***************************************************************************
* Pick a photo at random from the featured images of a gallery.            *
* Gallery_id = id of gallery to choose,                                    *
* img = reference to html image in                                         *
* which to show image                                                      *
***************************************************************************/
function showGalleryImage(gallery_id, img, updateLink) {
	
	if(img){
		if (location.hash.match('galleries_id=' + gallery_id) && (imageID = location.hash.match('.*photos_id=(.+)$'))) {
		  	imageID = imageID[1];
		} else {
		  	imageID = randomListVal(galleries[gallery_id].featured_images);
		}
		
		if (imageID != 0) {
			img.src = thumbnails[imageID].src;
			img.width = thumbnails[imageID].width;
			img.height = thumbnails[imageID].height;
			img.alt = galleries[gallery_id].title;
			if (updateLink) {
				$(img).parent().attr({					title: galleries[gallery_id].title				}).filter(function(){return this.href;}).attr({					href: thumbnails[imageID].fnGalleryLink(gallery_id)				});
			}
		}
	}
}

/***************************************************************************
* If we have dynamic HTML, replace the galleries link with a list that     *
* doesn't include thecurrent gallery                                       *
***************************************************************************/
function showGalleries(gallery_id) {
		
	
	if (!basic) {
		temp = '';
		for (i = 0; i < galleries.length; i++) {
						
			
			if (galleries[i].id != gallery_id) {
								
				if (temp != '') {
					temp += ' | ';
				}
								temp += '<a href="' + galleries[i].section_code + '_' + galleries[i].id + '.html">' + galleries[i].title + '</a>';
							}
		}
		document.all.galleryLinks.innerHTML = 'Other galleries: ' + temp;
	}
}

		

