
$(document).ready (function(){
	var so = new SWFObject('tpl/fla/headerflash.swf', 'header_anim', '779', '219', '8');
	so.addParam('wmode','transparent');
	so.write('headerflash')
});

// pop-up for opening news and project images
var popwin = null;
function popImage(imagesrc,winwidth,winheight,alt){
	var left = (screen.width/2) - winwidth/2;
 	var top = (screen.height/2) - winheight/2;
 	var look='width='+winwidth+',height='+winheight+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
 	if(winwidth>1024 || winheight>736) {
		winwidth2 = 1024;
		winheight2 = 736;
		left = 0;
		top = 0;
		look="resizable,scrollbars,height="+winheight2+",width="+winwidth2+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
	}
	if (popwin != null && !popwin.closed) popwin.close();
	popwin=window.open(imagesrc,"imgWin",look);
	popwin.document.open();
	popwin.document.write('<html>\n<head>\n');
	popwin.document.write('<title>'+alt+'</title>\n');
	popwin.document.write('<style type="text/css">\n');
	popwin.document.write('body { margin:0; background-color:black;}\n');
	popwin.document.write('a img { border:0; display:block; }\n');
	popwin.document.write('</style>\n');
	popwin.document.write('<script type="text/javascript">\n');
	popwin.document.write('window.onload = function(){\n');
	popwin.document.write('var img = document.getElementsByTagName("IMG")[0];\n');
	popwin.document.write('  window.resizeTo(img.width+8, img.height+56)\n');
	popwin.document.write('}\n');
	popwin.document.write('</script>\n');
	popwin.document.write('</head>\n<body>\n');
	popwin.document.write('<a href="javascript:;" onclick="window.close()"><img src="'+imagesrc+'" alt="'+alt+' (Click to close)"></a>\n');
	popwin.document.write('</body>\n</html>');
	popwin.document.close();
}

// imagewindow.js
// --------------
// Displays an image in a new window
// @requires imgwin.css
var win = null;
var ImageWindow = {
    
    src: null,
    
    options: {padding:0},
    
    open: function(src, options) {
        this.src = src;

        if (arguments.length == 2 && (typeof options == 'object')) {
            this.options = options;
        }
            
        var fullImg = new Image();
        
        fullImg.onload = function() {
            var width = this.width + ImageWindow.options.padding;
            var height = this.height + ImageWindow.options.padding;
            var left = (screen.width/2) - width/2;
 			var top = (screen.height/2) - height/2;
 			
 			// only works if popups are on the same page
 			if (win != null && !win.closed)  win.close();
 			
            win = window.open('', 'image', 'toolbar=no,resizable=yes,menubar=no,scrollbars=no,width=' + width + ',height=' + height + ',screenX=' + left + ',screenY=' + top + ',left=' + left + ',top=' + top);
            ImageWindow.displayImage(this.src, ImageWindow.options.title, win);
            
            // as above
            win.focus();
        };
                
        fullImg.src = this.src;
    },

    displayImage : function(href, caption, win) {
        var title = (typeof(caption) != 'undefined' && caption != null) ? caption : '';
        var doc = win.document;
        doc.open();
        doc.writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">');
        doc.writeln('<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">');
        doc.writeln('<head>');
        doc.writeln('<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />');
        doc.writeln('<meta http-equiv="imagetoolbar" content="no" />');
        doc.writeln('<title>' + title + '</title>');
        doc.writeln('<style type="text/css">\n');
		doc.writeln('body { margin:0; background-color:black;}\n');
		doc.writeln('a img { border:0; display:block; }\n');
		doc.writeln('</style>\n');
        doc.writeln('</head>');
        doc.writeln('<body>');
        //doc.writeln('<div id="container">');
        doc.writeln('<a href="javascript:;" onclick="window.close()"><img src="' + href + '" alt="' + title + ' (Click to close)" /></a>');
//        if (typeof(caption) != 'undefined' && caption != null) {
//            doc.writeln('<strong class="caption">' + caption + '</strong>');
//        }
        //doc.writeln('</div>');
        doc.writeln('</body>');
        doc.writeln('</html>');       
        doc.close();
        
        return true; 
    }
}
