// $Header: $
/***************************************************************************
 * Automatic Image Popup
 * Copyright 2002 by David Schontzler | www.stilleye.com
 * Free to use under GNU General Public License as long as this message
 *  remains intact.
 * Description:  Automate your image popup windows (centered and sized)
 * URI: http://www.stilleye.com/scripts/iPop
 ***************************************************************************
 * Version: 1.0
 ***************************************************************************/
function iPop(img, w, h, ttl){
    var iPopURL = '/ipop.html' // set as location of ipop.html
    var url = iPopURL + '?' + img + (ttl ? '&' + escape(ttl) : '')
    var l = Math.round((screen.availWidth-w)/2),t=Math.round((screen.availHeight-h)/2);
    var attribs = 'width=' + w + ',height=' + h + ',left=' + l + ',top=' + t;
    var w=window.open(url, 'imgWin', attribs);
    return false;
}

function domRollover() {
	var imgTemp=new Array();
	var imgarr=document.getElementsByTagName('img');
	for (var i=0;i<imgarr.length;i++){
	if (imgarr[i].getAttribute('hsrc')){
			imgTemp[i]=new Image();
			imgTemp[i].src=imgarr[i].getAttribute('hsrc');
			imgarr[i].setAttribute('xsrc', imgarr[i].getAttribute('src'));
			imgarr[i].onmouseover=function(){
				this.setAttribute('src',this.getAttribute('hsrc'))
			}
			imgarr[i].onmouseout=function(){
				this.setAttribute('src',this.getAttribute('xsrc'))
			}
		}
	}
}
domRollover();

/****************************************************
 *	Creates and centers a popup window
 *		by LWD-hk 20030722
 ****************************************************/
function rsPopUp(url, w, h, ttl){
    var l = Math.round((screen.availWidth-w)/2),t=Math.round((screen.availHeight-h)/2);
    var attribs = 'scrollbars=yes,resizable=yes,width=' + w + ',height=' + h + ',left=' + l + ',top=' + t
    var w=window.open(url, 'newWindow', attribs);
    return false;
}
//Package fader
function slideShow(id,delay) {
	var packages=$A($$('div#'+id+'_content div.fading'));
	if( packages.length>1)
	    setTimeout(switch_slides(id,1,1,packages.length,delay*1000),delay*1000);
}
function switch_slides(id,frame, start_frame, end_frame, delay) {
    return (function() {
        Effect.Fade(id+frame);
        frame++;
        if(frame>end_frame) frame=1;
        setTimeout("Effect.Appear('"+id+frame+"');", 850);
        setTimeout(switch_slides(id,frame, start_frame, end_frame, delay),delay + 850);
    })
}
function showInfoWin(id,method,lang,w,h,t,l) {
	var s=navigator.userAgent.toLowerCase();
	var browserInfo={
			IsIE		: /*@cc_on!@*/false,
			IsIE7		: /*@cc_on!@*/false && ( parseInt( s.match( /msie (\d+)/ )[1], 10 ) >= 7 )
	};
	var w=w||800,h=h||600;
	$$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'hidden' });
	var arrayPageSize = getPageSize();
	$('overlay').style.height = arrayPageSize[1] + "px";
	new Effect.Appear('overlay', { duration: 0.0, from: 0.0, to: 0.6 	});
    var xyscroll = ( browserInfo.IsIE && !browserInfo.IsIE7 )?document.viewport.getScrollOffsets():[0,0];
	var innerH=document.viewport.getHeight(),innerW=document.viewport.getWidth();
	var pars='objectid=' + id + '&method=' + method + '&lang=' + lang + '&' + Math.random(9999);
	var popup = $('popup');
	var m = new Ajax.Updater(popup, '/popup.cfm', {
		method: 'get',
		parameters: pars,
		onComplete: function(){
			var l=Math.round(xyscroll[0]+(innerW-w)/2),t=Math.round(xyscroll[1]+(innerH-h)/2);
			$('popup').setStyle({ top: t + "px", left: l + "px", width: w + "px", height: h + "px",cursor : 'pointer'});
			$('popup').style.position=( browserInfo.IsIE && !browserInfo.IsIE7 ) ? 'absolute' : 'fixed';
			preventDocScroll();
            Effect.Appear(popup,{duration:.5});
			new Draggable(popup,{});
		}
	});
}
function showPanorama(lid,angle) {
	var s=navigator.userAgent.toLowerCase();
	var browserInfo={
			IsIE		: /*@cc_on!@*/false,
			IsIE7		: /*@cc_on!@*/false && ( parseInt( s.match( /msie (\d+)/ )[1], 10 ) >= 7 )
	};
	var w=910,h=h||630;
	$$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'hidden' });
	var arrayPageSize = getPageSize();
	$('overlay').style.height = arrayPageSize[1] + "px";
	new Effect.Appear('overlay', { duration: 0.0, from: 0.0, to: 0.6 	});
	var xyscroll = ( browserInfo.IsIE && !browserInfo.IsIE7 )?document.viewport.getScrollOffsets():[0,0];
	var innerH=document.viewport.getHeight(),innerW=document.viewport.getWidth();
	var pars='lid=' + lid + '&angle' +angle;
	var popup = $('popup');
	var m = new Ajax.Updater(popup, '/panorama.cfm', {
		method: 'get',
		parameters: pars,
		onComplete: function(){
		var l=Math.round(xyscroll[0]+(innerW-w)/2),t=Math.round(xyscroll[1]+(innerH-h)/2);
		$('popup').setStyle({ top: t + "px", left: l + "px", width: w + "px", height: h + "px",cursor : 'pointer'});
		$('popup').style.position=( browserInfo.IsIE && !browserInfo.IsIE7 ) ? 'absolute' : 'fixed';
		Effect.Appear(popup,{duration:.5});
	}
	});
}
function hideInfoWin() {
	Effect.BlindUp('popup', {
		duration: 0.3
	});
    $('overlay').hide();
	$$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'visible' });
	allowDocScroll();
}
function getPageSize() {
    var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth)
			windowWidth = document.documentElement.clientWidth; 
		else
			windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	pageHeight=(yScroll < windowHeight)?windowHeight:yScroll;
	// for small pages with total width less then width of the viewport
	pageWidth=(xScroll < windowWidth)?xScroll:windowWidth;
	return [pageWidth,pageHeight];
}
function preventDocScroll()
{ 
    if (document.all)
    {               
        document.body.scroll = "no";
    }
    else
    {
        var oTop = document.body.scrollTop;
        document.body.style.overflow = "hidden";
        document.body.scrollTop = oTop;
    }
}
function allowDocScroll()
{
    document.body.scroll = "";
    document.body.style.overflow = "";
}