
// browser type
var ua = navigator.userAgent.toLowerCase(),
	isOpera = ua.indexOf("opera") > -1,
	isFirefox = ua.indexOf("firefox") > -1,
	isIE = ua.indexOf('msie') > -1,
	isIE6 = false /*@cc_on || @_jscript_version < 5.7 @*/,
	isIE7 = ua.indexOf('msie 7') > -1,
	isSafari = (/webkit|khtml/).test(ua);



// FUNCTIONS //

// returns reference to swf
function thisMovie(movieName) {
	if (isIE) {
		return window[movieName];
	} else{
		if (!document[movieName]) {
			return false;
		}
		if(document[movieName].length !== undefined){
			return document[movieName][1];
		}
		return document[movieName];
	}
}

// change size of flash movie
function resizeMovie (nsize) {
	var viewportwidth;
	var viewportheight;
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerWidth;
		viewportheight = window.innerHeight;
	} else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth !=	'undefined' && document.documentElement.clientWidth != 0) {
		viewportwidth = document.documentElement.clientWidth;
		viewportheight = document.documentElement.clientHeight;
	} else {
		viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
		viewportheight = document.getElementsByTagName('body')[0].clientHeight;
	}
	
	if (nsize < viewportheight) nsize = viewportheight;
	thisMovie("main").height = nsize;
}

// decodes "urlencoded" string
function urldecode (txt) {
	return unescape(txt).replace(/\+/g, " ");
}

// returns text requested
function getText (type) {
	if (this["txt_" + type]) {
		return urldecode(this["txt_" + type]);
	} else {
		return "Error.";
	}
}

//
// ENLARGE IMAGE
//

// enlarge image based on ID
function larger_image (id) {
	popImage('/data/gallery_l/' + id + '.jpg', 'Enlarged Image');
}
//-- functions --//
PositionX = 100;
PositionY = 100;
defaultWidth  = 500;
defaultHeight = 500;
var AutoClose = true;
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle)
{
	if (isNN){imgWin=window.open('about:blank','',optNN);}
	if (isIE){imgWin=window.open('about:blank','',optIE);}
	with (imgWin.document){
	writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
	writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
	writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
	writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(300,300);');
	writeln('width=300-(document.body.clientWidth-document.images[0].width);');
	writeln('height=300-(document.body.clientHeight-document.images[0].height);');
	writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
	writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
	writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
	if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
	else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
	writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
	close();
}}

// embeds flash objects
function EmbedFlash (flashWidth, flashHeight, flashMovie)
{
	var oeTags = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
		' width=' + flashWidth + ' height=' + flashHeight + ' id=' + flashMovie +
		' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">' +
		'<param id="objectid_' + flashMovie + '" name="movie" value="/flash/' + flashMovie + '.swf" />' +
		'<param name="quality" value="high" />' +
		'<param name="wmode" value="transparent" />' +
		'<param name="bgcolor" value="#000000" />' +
		'<param name="allowScriptAccess" value="always" />' +
		
		'<embed src="/flash/' + flashMovie + '.swf"' +
		' width="' + flashWidth + '" height="' + flashHeight + '" name="' + flashMovie + '" id="embedid_' + flashMovie + '"' +
		' align="left" wmode="transparent" loop="false" quality="high" bgcolor="#000000"' +
		' allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">' +
		'<\/embed>' +
		'<\/object>';
	
	document.write(oeTags);
}
