//detect flash
var flashversion = 0;
if (navigator.plugins && navigator.mimeTypes.length) {
	var x = navigator.plugins["Shockwave Flash"];
	if(x && x.description) {
		var y = x.description;
		flashversion = parseInt(y.substr(y.indexOf(".") - 2, 2), 10);
	}
} else {
	result = false;
	for(var i = 30; i >= 3 && result != true; i--){
		execScript('on error resume next: result = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'"))','VBScript');
		flashversion = i;
	}
}

if (flashversion >= 8) {
	// remove flicker of non flash
    document.getElementsByTagName('html')[0].className = 'flashInstalled';

}
	

function getFlash(what, movie, query, width, height) {

	new_txt = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="'+width+'" height="'+height+'">\n';
	new_txt += '<param name="movie" value="'+movie+query+'">\n';
	new_txt += '<param name="quality" value="high" />\n';
	new_txt += '<param name="menu" value="false">\n';
	new_txt += '<param name="wmode" value="transparent">\n';
	new_txt += '<param name="scale" value="noscale" />\n';
	new_txt += '<param name="salign" value="lt" />\n';
	new_txt += '<embed src="'+movie+query+'" width="'+width+'" height="'+height+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="false" scale="noscale" salign="lt" wmode="transparent"></embed>\n';
	new_txt += '</object>';
	what.innerHTML = new_txt;
	what.style.visibility= 'visible';
	
}

function flashRewrite(x, movie, query, type){

	if (flashversion >= 5){
		
	if (type == '1'){
	
	xArea = x.split('>'); //if TagName in a id
	if (xArea[1]){
		
	var x = document.getElementById(xArea[0]).getElementsByTagName(xArea[1]);	
	} else {	
	var x = document.getElementsByTagName(x);	
	}
	
	for (var i=0;i<x.length;i++){
	
		width = x[i].offsetWidth;
		height = x[i].offsetHeight;
		title = x[i].innerHTML;
		if (title) {title = title.replace("&", "%26")}
		
			if (!query){
				q= "?title="+ title;
			}else{
				q= query +"&title="+ title;
			}

			getFlash(x[i], movie, q, width, height)
			q = '';
	}
	} else {
	
	var x = document.getElementById(x);
	
		width = x.offsetWidth;
		height = x.offsetHeight;
		getFlash(x, movie, query, width, height)
	}
}	
}


function openWindow(){
	var x = document.getElementsByTagName('a');
	for (var i=0;i<x.length;i++)
	{
	if (x[i].getAttribute('title') >'') {
		
		if (x[i].getAttribute('title').indexOf("Link opens in a new window") >= 0)
		{
		x[i].onclick = function () {window.open(this.href); return false}
		}	
	}	
	}
}

function formStyle(){
	var formRoot = document.getElementsByTagName("form"); 
	for (var f=0;f<formRoot.length;f++)
	{
		var r = formRoot[f].elements;
		var rlen = r.length;

		for (var h = 0; h < rlen; h++) {
		 var node = r[h];
				
					node.onfocus=function() {
					if(this.type !=='checkbox' && this.type !=='radio' && (this.tagName =='INPUT' || this.tagName =='TEXTAREA')) {
							this.className="textformfocus";
							if (this.value.charAt(0) == '-') { this.value='' } 
					}
			}
												
					node.onblur=function() {
					if(this.type !=='checkbox' && this.type !=='radio' && (this.tagName =='INPUT' || this.tagName =='TEXTAREA')) {
							this.className="textform";
					}
			}
			
		}
	}
}	
 
 function showPop(thisurl){
	
		win2=window.open(thisurl, '', 'scrollbars=no, status=yes, left=0, top=0, width=800, height=1')

	}
	
 function showimg() {
	if (document.getElementById("thumbnails") && (document.getElementById("project-image"))) {
		var theroot = document.getElementById("thumbnails");
			for (i=0; i<theroot.childNodes.length; i++) {
				node = theroot.childNodes[i];
  					if (node.nodeName=="LI") {
						node.onclick=function() {
						document.getElementById("project-image").src = this.childNodes[0].href.replace("l_","");
							if (document.getElementById("image-address")) {
									 if (this.childNodes[0].href.indexOf("/")) {
										 var thelink = this.childNodes[0].href.split("/");
										 var j = thelink.length;
									 document.getElementById("image-address").href = 'window.asp?image=' + thelink[j-1];  
									 }
							}
						return false;
					}
						
				} 

			} 

	  } 
} 


function addEvent( obj, type, fn )
{
	if (obj.addEventListener)
		obj.addEventListener( type, fn, false );
	else if (obj.attachEvent)
	{
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
	}
}


addEvent(window, 'load', openWindow);
addEvent(window, 'load', formStyle);
addEvent(window, 'load', showimg);
addEvent(window, 'load', function() {
					  
	document.getElementById("Fprint").onclick = function() {window.print();}

});



	