var ifile, title, h, w;
var swval = 2;
function swap1(place, pic1, title1, pic2, title2, pic3, pic4) 
{
	var image, name, big;
	image = "image5" + place;
	name = "name5" + place;
	big = "big5" + place;	
	switch (swval)
	{
	case 1:
		document.getElementById(image).src = pic1;
		ifile = document.getElementById(image).src;
		extracthw();
		h = document.getElementById(image).height;
		w = document.getElementById(image).width;
		document.getElementById(big).src = pic3;
		ifile = document.getElementById(big).src;
		document.getElementById(name).innerHTML = title1;
		title = document.getElementById(name).innerHTML;
		swval = 2;
		break;
	case 2:
		document.getElementById(image).src = pic2;
		ifile = document.getElementById(image).src;
		extracthw();
		h = document.getElementById(image).height;
		w = document.getElementById(image).width;
		document.getElementById(big).src = pic4;
		ifile = document.getElementById(big).src;
		document.getElementById(name).innerHTML = title2;
		title = document.getElementById(name).innerHTML;
		swval = 1;
		break;
	}
}
function extracthw()
{
	var str1, len1, posx, finalx, count, character;
	count = 0;
	str1 = ifile.toLowerCase();
	len1 = str1.length;
	posx = str1.indexOf('x', 0);
	do 
	{
		count = count + 1;
		if (posx < 1)
			{posx = 1;
			}
		character = str1.charAt(posx - 1);
		IsNumeric(character);
		finalx = posx;
		posx = str1.indexOf('x', (posx + 1));
		if (posx === -1)
			{posx = finalx;
			}
	}
	while (IsNumber === false && count < len1);
	character = str1.charAt(posx + 1);
	IsNumeric(character);
	if (IsNumber === false)
		{w = 100; h = 600;
		}
	w = ifile.substr((posx - 3), 3);
	h = ifile.substr((posx + 1), 3);
}
function IsNumeric(character)
{
	var valid = "0123456789";
	IsNumber = true;
	if (valid.indexOf(character) === - 1)
		{IsNumber = false;
		}
	return IsNumber;	
}
function JointView()
{
	extracthw(); 
	HorizOffset = Math.floor((screen.availHeight - h) / 2);
	VertOffset = Math.floor((screen.availWidth - w) / 2);
	w = w * 1;				         
	w = w + 60;                      
	if (w < 450)
		{w = 450;
		}			
	w = w.toString();	            
	h = h * 1;
	h = h + 100;
	h = h.toString();
	win = window.open('', 'name', 'height = '+h+', width = '+w+', toolbar = no, directories = no, status = no, menubar = no, scrollbars = no, resizable = no'); 
	win.document.open();
	win.document.write("<html><head><title>Leeds Co-operative Photographic Society</title></head>");
	win.document.write('<body style="text-align: center; font-family: arial; font-weight: 600; font-size: 16px; color:#111111; background: #778899">');
	win.document.write('<div>');
	win.document.write("<p></p>" + title);
	win.document.write("<p><img src="+ifile+"></img></p>");
	win.document.write('<p align="right"><a href="#" onclick="self.close(); return false;"></p>'); //close window on click
	win.document.write('</div><div style="position:relative; margin-top: -10px">');
	win.document.write('<Form><Input Type="button" Value="Return"  onClick="history.back()">');  //close window on button click
	win.document.write("</div></body></html>");
	win.moveTo(Math.floor(screen.availWidth / 2 - (w / 2)),Math.floor(screen.availHeight / 2 - (h / 2)));	//--move to centre
	win.document.focus;
	win.document.close();
}

