// JavaScript Document
window.onload = popup;

function popup() { 
	//if there are no anchors quit
	if (!document.getElementsByTagName) return; 

	//retrieve all the anchors and put them into an array
	var anchors = document.getElementsByTagName("a"); 


	//start looping through the anchors
	for (var i=0; i<anchors.length; i++) { 


	//set the variable anchor to be the current anchor in the anchors array
	var anchor = anchors[i]; 

 	//if the anchor has an href and its rel attribute is set to popup, call thr function popup when the link is clicked.
	if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "popup") {

		anchor.onclick = buildwindow; 
			}
		
		//now use those settings to set the settings for the window
 		anchor.settings = Array ( "", "width=375,height=550,scrollbar=yes,menubar=no,top=30,left=10");
		}
}

function buildwindow() {
	newWin = window.open("",this.target,this.settings);
	
 	windowHTMLCode =  '<html>';
	windowHTMLCode += '<head>';
 	windowHTMLCode += '<title>Arnold Engravers</title>';
	windowHTMLCode += '<link rel="stylesheet" type="text/css" media="screen" href="javascriptpopup.css" />';
	windowHTMLCode += '</head>';
 	windowHTMLCode += '<body>';
	windowHTMLCode += '<div class="jspopup">';
 	windowHTMLCode += '<img src="' + this.href + '" ></img>';
 	windowHTMLCode += '<p><a href="#" onClick="self.close()">Close Window</a></p>';
	windowHTMLCode += '</div>';
 	windowHTMLCode += '</body>';
	windowHTMLCode += '</html>';
	
	newWin.document.write(windowHTMLCode);
	newWin.document.close();
	newWin.focus();	
return false;
}


