var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

if (checkIt('safari'))
{
	browser = "Safari";
}
else {browser = "An unknown browser";}
function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}
if (browser != "Safari") {

var resized_images = new Array();
var maxImageWidth = 550;
	function fullsize(){
		var oSource = window.event.srcElement.src;
		tempvar = resized_images[oSource];
		showpopupwindow = window.open('', "_blank","toolbar=no,location=no,menubar=no,scrollbars=no,status=no,left=0,top=0"+tempvar);
		showpopupwindow.document.writeln("<html><head><title>Full size pic</title>");
		showpopupwindow.document.writeln("</head><body topmargin=\"0\" leftmargin=\"0\" marginheight=\"0\" marginwidth=\"0\">");
		showpopupwindow.document.writeln("<img src=\"" + oSource + "\" onclick=\"window.close()\" title=\"click to close\">");
		showpopupwindow.document.writeln("</body></html>");
		showpopupwindow.document.close();
	}

	function resize(image){
		if(!image){
			var image = window.event.srcElement;
		}

		width = image.width;
		height = image.height;
		var url = image.src;

		if(width>maxImageWidth){
			resized_images[url] = ",width="+width+",height="+height;
			image.width = maxImageWidth;
			image.title = 'Original size: '+width+'x'+height;
			image.style.border = "dashed 1px red";
			image.style.cursor = "hand";
			image.onclick = fullsize;
			image.height = Math.floor(height/(width/maxImageWidth));
		}
	}

	function check_images(){
		count = document.images.length;
		i = 0;

		while(count>i){
			
				if(document.images[i].complete){resize(document.images[i]);
				}else{document.images[i].onload = resize;
				}
			
			i++;
		}
	}
}
