var galDiv = 'gallery-wrap'; // the div that houses the entire gallery
var simpDefImg = '/wp-content/uploads/2011/03/yell_video_uk.png'; // default image URL
var simpImgDiv = 'gallery-img'; //image ID
var simpImgWrapDiv = 'gallery-img-wrap'; //div around image
var simpCap = 'gallery-img-meta'; //ID for tag that houses image caption
var simpGalList = 'gal-thumb-wrap'; //the wrap around the list of links to be clicked to view each image
var simpGalItem = 'p-gallery'; //the div around each thumbnail


function prepImgPlaceholder() {
	var support = document.createElement && document.getElementById && document.createTextNode;
	if(!support) return false; //if the support value doesn't exist, then stop the function
	var simpAddDefImgWrap = document.createElement("div");
	simpAddDefImgWrap.setAttribute("id",simpImgWrapDiv);
	simpAddDefImgWrap.style.position ="relative";
	simpAddDefImgWrap.style.zIndex ="10";
	var galDivWrap = document.getElementById(galDiv);
	galDivWrap.appendChild(simpAddDefImgWrap);

	var simpAddDefImg = document.createElement("img");
	simpAddDefImg.setAttribute("id",  simpImgDiv);
	simpAddDefImg.setAttribute("src",  simpDefImg);
	simpAddDefImgWrap.appendChild(simpAddDefImg);

	var simpGalList = document.getElementById(simpGalList);
	galDivWrap.insertBefore(simpAddDefImgWrap, simpGalList);
}

function simpGal(thePic) {
	if(!document.getElementById(simpImgDiv)) return true; //if the image can't be gotten / doesn't exist, continue with the function anyway which in this case executes the default action of a click link which is to go to the link
	imgDiv = document.getElementById(simpImgDiv);
	imgDiv.src = thePic.getAttribute('href');
        if(!document.getElementById('gallery-img-meta')) return false; //if the ID for the caption can't be gotten, then stop the function
	capTitle = document.getElementById('gal-img-title');
        titleLi = thePic.childNodes[0].getAttribute('alt');
	capTitle.childNodes[0].nodeValue = titleLi;


        capDesc = document.getElementById('gal-img-desc');
        DescLi = thePic.childNodes[1].childNodes[0].nodeValue;
	capDesc.childNodes[0].nodeValue = DescLi;

        capUrl = document.getElementById('gal-img-url');
        UrlLi = thePic.childNodes[2].childNodes[0].nodeValue;
	capUrl.childNodes[0].nodeValue = UrlLi;


}



function prepSimpGalLinks() {
	var support = document.getElementsByTagName && document.getElementById;
	if(!support) return false; //if the support value doesn't exist, then stop the function
	var getUl = document.getElementById(simpGalList);
	var getLinks = getUl.getElementsByTagName('a');
	for (var i=0; i < getLinks.length; i++) {
		getLinks[i].onclick = function() {
		 simpGal(this);
                        return false;
		}

	}
}



