// JavaScript Document
<!--
// function to get the url link of the gallery. Note: adjusmtnets need to be made as same as events
function getGalLink(region, lookupFunc){
	var id = lookupFunc('{ts:id}');
	var u = lookupFunc('{link/@href}');
	var url = (u).match('galleries')? null : u;
	return url != null? (url + (url.match('id')? '' : '&id=' + id )) : (galDisplayUrl+ ((galDisplayUrl.indexOf("?") == -1 )? '?id=' : '&id=') + id);
	//return (galDisplayUrl+ ((galDisplayUrl.indexOf("?") == -1 )? '?id=' : '&id=') + id);
}

function getGalleryDate(region, lookupFunc){
	return setDateFormatted(lookupFunc('{galleryPagingDs::published}'),'D jS M Y'); 
}
// this is a function to change the display type
function changeDisplayStyle(){
	galDisplayType = galDisplayType == 'image'? 'text' : 'image';
	/* pagesSize = displayType == 'image'? minDefaultPageSize : maxDefaultPageSize;
	galleryPagingDs.setPageSize(pagesSize);*/
	Spry.Data.updateRegion('galListingRegion');
}
function getGalThumb(region,lookupFunc){ //(region, lookupFunc){
	var id = lookupFunc('{galleryPagingDs::ts:id}');
	return id.toLowerCase();
	/*var div = id+'Img';
	var img = id+'_version1';
	Spry.Utils.updateContent(div,'includes/widgets/media/get_media.php?folder=galleries&match='+img);*/
}
function toggleDetails(div){
	Spry.$$(div).toggleClassName('blurbhide');
}
// this is a function to get galleries by category. Note: need to use a filter object
function getGalleryByCategory(notifier,data){
	var url;
	var params;
	url = galleryListDs.getURL();
	params = 'search=true&'+data+'&'+galFilterParams;
	galleryListDs.setURL(url,{method:"POST",postData:params,headers: {  "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" },useCache:false});
	galleryListDs.loadData();
}
var params = ((window.location.search).search('search') != -1)? (window.location.search).replace("?",'') : 'search=true&'+galFilterParams; // search from url params
var galDisplayType = 'image'; // to display images and text or just images
var galDisplayUrl = defaultGalDisplayURL? defaultGalDisplayURL : 'galleries/?page=display'; // url to display gallery details
var galURL = "includes/widgets/galleries/get_galleries_com.php?max="+maxGalPageSize;
var galleryListDs = new Spry.Data.XMLDataSet(galURL, "feed/entry",{method:"POST", postData: params, headers: {  "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" },useCache:false});
galleryListDs.setColumnType("published", "date");
galleryListDs.setColumnType("updated", "date");
galleryListDs.setColumnType("content", "html");
var galleryPagingDs = new Spry.Data.PagedView(galleryListDs, {method:"POST", pageSize: galPagesSize, postData: params, headers: {  "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" },useCache:false,subPaths:['contributor/name'] });
var galleryPagingDsInfo = galleryPagingDs.getPagingInfo();
var filterNotifier = filterNotifier? filterNotifier : new Spry.Utils.Notifier();
var galObserver = {};
galObserver.getByFilter = getGalleryByCategory;
filterNotifier.addObserver(galObserver);
//-->