
//gallery popup img
function showPop(thisimg,showhide){
    
    if(showhide == 'h'){
        document.getElementById('popimg').style.backgroundImage = '';
        document.getElementById('popup').style.minHeight = '';
        document.getElementById('popup').style.visibility = 'hidden';
        document.getElementById('text').style.overflow = 'auto';
        }
    else {
        
        if (navigator.userAgent.toLowerCase().indexOf('safari') != -1) {
            winheight = document.clientHeight
            }else {
            winheight = document.documentElement.clientHeight
            }
        
        
        document.getElementById('popimg').style.backgroundImage = 'url('+thisimg+')';
        document.getElementById('popcontent').style.marginTop = (winheight- 550) /2 +'px';
        document.getElementById('popup').style.minHeight = '500px';
        scroll(0,0);
        document.getElementById('popup').style.visibility = 'visible';
        document.getElementById('text').style.overflow = 'hidden';
    }
}
function showPop2(thisimg,showhide){
    
    if(showhide == 'h'){
        document.getElementById('popimg2').style.backgroundImage = '';
        document.getElementById('popup2').style.minHeight = '';
        document.getElementById('popup2').style.visibility = 'hidden';
        document.getElementById('text').style.overflow = 'auto';
        }
    else {
        
        if (navigator.userAgent.toLowerCase().indexOf('safari') != -1) {
            winheight = document.clientHeight
            }else {
            winheight = document.documentElement.clientHeight
            }
        
        
        document.getElementById('popimg2').style.backgroundImage = 'url('+thisimg+')';
        document.getElementById('popcontent2').style.marginTop = (winheight- 550) /2 +'px';
        document.getElementById('popup2').style.minHeight = '500px';
        scroll(0,0);
        document.getElementById('popup2').style.visibility = 'visible';
        document.getElementById('text').style.overflow = 'hidden';
    }
}

//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 = y.charAt(y.indexOf('.')-1);
	}
} else {
	result = false;
	for(var i = 15; i >= 3 && result != true; i--){
		execScript('on error resume next: result = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'"))','VBScript');
		flashversion = i;
	}
}

if (flashversion >= 5) {
	// 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+'">\n';
	new_txt += '<param name="quality" value="high" />\n';
	new_txt += '<param name="menu" value="false">\n';
	new_txt += '<param name="flashvars" value="'+query+'">\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+'" width="'+width+'" height="'+height+'" flashvars="'+query+'" 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){

// x: the element, movie: swf address, query: added info to send, type: 1 = TagName  0 = id	
	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;
			}
			
		// check for flash in 'a' tag
		if(x[i].nodeName == 'A') {
			
			thelink = x[i].href
			q+= "&link="+ thelink.replace("&", "%26");
			if (x[i].className == "flash" || x[i].className == "flash on"){
				
				if (x[i].className == "flash on"){ q+= "&s=1" }
				getFlash(x[i], movie, q, width, height)
				}
			
		}else{
			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 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);