function imagePopUp(filename,fwidth,fheight) {
	var windowname = 'popup.html?imagename='+filename;
	var width;
	var height;
	if (fwidth==null)
	{
		width = 700 + 20;
	}else{
		width = fwidth + 20;
	}
	if (fheight==null)
	{
		height = 625 + 45;
	}else{
		height = fheight + 45;
	}
	if (width >= screen.availWidth)
	{
		width = screen.availWidth;
	}
	if (height>= screen.availHeight)
	{
		height = screen.availHeight;
	}
	leftAlign = parseInt((screen.availWidth/2) - (width/2));
	topAlign = parseInt((screen.availHeight/2) - (height/2));
	var myPopupWindow = window.open( windowname, 'myWindow', 'height = ' + height + ',width = ' + width + ', left=' + leftAlign + ',top=' + topAlign + ', resizable = 1, scrollbars=1');
	myPopupWindow.focus() 
	}
function pageloadImagePopUp()
{
	var ImageFileName = getQuerystring('imagename'); 
	var pImageURL='images/large/'+ImageFileName;
    var img = document.createElement('img');
    img.onload = function () {
        document.getElementById('MainImage').src=this.src;
        document.getElementById('MainImage').width=this.width;
        document.getElementById('MainImage').height=this.height;
		document.getElementById('MainImage').className='popup-imgmain';
    }
    img.src = pImageURL;

}
	
function getQuerystring(key, default_)
{
	  if (default_==null) default_="";
	  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
	  var qs = regex.exec(window.location.href);
	  if(qs == null)
		return default_;
	  else
		return qs[1];
} 
function collapsePanel(PoemID)
{
	var linkcurrent='link'+ PoemID;
	var titlecurrent='title'+ PoemID;
	var contentcurrent='content'+ PoemID;

	var xLinkID='';

	for (var xlink=1; xlink<=10; xlink++)
	{
		xLinkID='linkPoem'+xlink;
		xTitleID='titlePoem'+xlink;
		xContentID='contentPoem'+xlink;
		/*links style*/
        if (document.getElementById(xLinkID))
		{
			document.getElementById(xLinkID).style.fontWeight='normal';
			document.getElementById(xLinkID).style.textDecoration='none';
			var xLinkID='';
		}
		/*title style*/
		if (document.getElementById(xTitleID))
		{
			document.getElementById(xTitleID).style.display='none';
			var xTitleID='';
		}
		/*content style*/
		if (document.getElementById(xContentID))
		{
			document.getElementById(xContentID).style.display='none';
			var xTitleID='';
		}
	}
	if (document.getElementById(linkcurrent))
	{
		document.getElementById(linkcurrent).style.fontWeight='bold';
		document.getElementById(linkcurrent).style.textDecoration='underline';
	}
	if (document.getElementById(titlecurrent))
	{
			document.getElementById(titlecurrent).style.display='block';
	}
	if (document.getElementById(contentcurrent))
	{
			document.getElementById(contentcurrent).style.display='block';
	}
}
function pageloadPoems()
{
	var PoemID = getQuerystring('poemid'); 
	if (PoemID=='')
	{
		if (document.getElementById('linkPoem1'))
		{
			document.getElementById('linkPoem1').style.fontWeight='bold';
			document.getElementById('linkPoem1').style.textDecoration='underline';
		}
		if (document.getElementById('titlePoem1'))
		{
				document.getElementById('titlePoem1').style.display='block';
		}
		if (document.getElementById('contentPoem1'))
		{
				document.getElementById('contentPoem1').style.display='block';
		}
	}else{
		collapsePanel(PoemID);
	}
}
function albumSummary(albumname)
{
	var albumNameTitle= albumname+'TITLE';
	var albumSpecificName = albumname;
	var blockNum=0;
	var albumList=xmlDoc.getElementsByTagName(albumNameTitle);
	if(albumList.length !=0)
	{
	document.write('<div class="myalbums-block">');
    document.write('<div class="myalbums-title">');
    document.write('<a href="album-pictures.html?albumname=',albumSpecificName,'">');
    document.write('<img src="defaultimages/',albumList[0].getElementsByTagName("IMGSRC")[0].childNodes[0].nodeValue,'" width="60" alt="',albumList[0].getElementsByTagName("MAINTITLE")[0].childNodes[0].nodeValue,'" />');
    document.write('</a>');
    document.write('<h1 class="h1-v2">');
    document.write('<a href="album-pictures.html?albumname=',albumSpecificName,'">',albumList[0].getElementsByTagName("MAINTITLE")[0].childNodes[0].nodeValue,'</a></h1>');
                                            
    document.write('&nbsp;<img src="defaultimages/vine_002.gif" alt="" />');
    document.write('</div>');
    document.write('<div class="myalbums-description">');
    document.write(albumList[0].getElementsByTagName("DESCSUM")[0].childNodes[0].nodeValue,'... '); 
	document.write('<a class="link-readmore" href="album-pictures.html?albumname=',albumSpecificName,'">read more</a>');
    document.write('</div>');

    document.write('<div class="myalbums-pictures">');
                                        
	var albumName= albumname+ 'FRONT';
	var albumList=xmlDoc.getElementsByTagName(albumName);
    for (i=0;i<4;i++)
	{
	document.write('<div class="myalbums-pictures-block" align="center">');
	document.write('<a href="images/large/',albumList[i].getElementsByTagName("IMGSRC")[0].childNodes[0].nodeValue,'" rel="lightbox[',albumName,']" title="',albumList[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue,'"');
	document.write('<img src="images/thumbnails/',albumList[i].getElementsByTagName("IMGSRC")[0].childNodes[0].nodeValue,'" title="+ZOOM" alt="',albumList[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue,'" width="100" />');
	document.write("</div>");
	}
	document.write('<div class="myalbums-pictures-more" align="left">');
    document.write('<a href="album-pictures.html?albumname=',albumSpecificName,'">more...</a>');
    document.write('</div>');
	document.write('</div>');
	document.write('</div>');
	}
}

