/* Javascript iPublisher Functionality
   Copyright iProp Services | All Rights Reserved
*******************************/
/* Show
--------------------------- */
function Show(obj){
	if (obj == 'homeView'){document.getElementById('sortView').style.display = 'none';document.getElementById('hyp_sortView').className = '';}
	else{document.getElementById('homeView').style.display = 'none';document.getElementById('hyp_homeView').className = '';}
	document.getElementById(obj).style.display = 'block';document.getElementById('hyp_'+obj).className = 'current';
}
function ToggleShow(obj1,obj2){
	document.getElementById(obj1).style.display = 'block';document.getElementById(obj2).style.display = 'none'; 
	if(document.getElementById('hyp_'+obj1)){document.getElementById('hyp_'+obj1).className = 'current';}
	if(document.getElementById('hyp_'+obj2)){document.getElementById('hyp_'+obj2).className = '';}
}
/* Box On/Off
--------------------------- */
function BoxOn(row){row.id = 'hovered';}
function BoxOff(row){row.id = '';}

// create popup window for images on the fly 
// script by Michael Paige (http://www.treetrybe.com/imm/)
// edited for Mac by Mark Howells (http://www.mark.ac/journal/) 
// found on http://www.bigwhiteguy.com; modified further by JNG
var imgWindow = new Object;
var imgWindow = null;
function popImg(thepic, caption, w, h ){
	var specs 	= 'width=' + w + ', height=' + h;
	var winScroll = 0;
	if (w > screen.availWidth - 20) {w = screen.availWidth - 20;winScroll = 1;}
	if (h > screen.availHeight - 20) {h = screen.availHeight - 20;winScroll = 1;}
	if (!imgWindow || imgWindow.closed) {
        var winFeatures = "width="+w+",height="+h+",location=0,toolbar=0,menubar=0,directories=0,scrollbars=" +winScroll+ ",status=0,resizable=1";
		imgWindow = open("", "imgWindow", winFeatures);
		imgWindow.document.write('<?xml version="1.0" encoding="UTF-8"?\>'); 
		imgWindow.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'); 
		imgWindow.document.write('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">'); 
		imgWindow.document.write('<head><title>Virtual Tour</title>'); 
		imgWindow.document.write('<style type="text/css"><!--'); 
		// Works in NN4 to achieve zero margins
 		imgWindow.document.write('body {margin:-10px 0 0 -10px;padding:0}');		
		imgWindow.document.write('html body {margin:0}'); 
		imgWindow.document.write('img {display:block;border:0}'); 
		imgWindow.document.write('\/\/--></style></head>'); 
		imgWindow.document.write('<body">');	
		imgWindow.document.write('<APPLET name="IpixViewer" code="IpixViewer.class" archive="IpixViewer.jar" codebase="http://www.vvco.com/" width="400" height="300">');
		imgWindow.document.write('<PARAM NAME="url" VALUE="tours/' + thepic + '">');
		imgWindow.document.write('<PARAM NAME="toolbar" VALUE="on"> ');
		imgWindow.document.write('<PARAM NAME="splash" VALUE="graphics/masthead.gif">');
		imgWindow.document.write('<PARAM NAME="splashbg" VALUE="ffffff"> ');
		imgWindow.document.write('<PARAM NAME="initfov" VALUE="100"> ');
		imgWindow.document.write('<PARAM NAME="spinspeed" VALUE="2"> ');
		imgWindow.document.write('<PARAM NAME="spinstyle" VALUE="flat"> ');	
        imgWindow.document.write(caption);	
		imgWindow.document.write('</body></html>');
		imgWindow.document.close();
		// Center window (unless Opera)
		if (navigator.userAgent.indexOf("Opera")==-1){
			var gowidth  = (screen.availWidth/2-(w/2));
			var goheight = (screen.availHeight/2-(h/2));
			imgWindow.moveTo(gowidth, goheight);
			imgWindow.focus();
		}
	}
	else {imgWindow.focus();}
}
function updateBackLink(){
	if(document.getElementById('backLink')){
		var searchString = document.location.search;searchString = searchString.substring(1);var nvPairs = searchString.split("&");
		for (i = 0; i < nvPairs.length; i++)
		{var nvPair = nvPairs[i].split("=");var name = nvPair[0];var value = nvPair[1];if (name == 'refType'){var refType = value;}if (name == 'retURL'){var returnURL = value;}}
		if(refType){refType = refType.replace("_"," ");}
		if(returnURL && refType){document.getElementById('backLink').innerHTML= '<a href="' + returnURL + '"><< Back to ' + refType + '</a>';}
		else if(refType){document.getElementById('backLink').href = 'javascript:history.go(-1);';document.getElementById('backLink').innerHTML= '<a href="javascript:history.go(-1);"><< Back to ' + refType + "</a>";}
		else{document.getElementById('backLink').href = 'javascript:history.go(-1);';document.getElementById('backLink').innerHTML= '<a href="" onclick="history.go(-1);"><< Back</a>';}
	}
}
function initAccordian(){
	try{
		var stretchers = document.getElementsByClassName('stretcher');
		var toggles = document.getElementsByClassName('display');
		var myAccordion = new fx.Accordion(toggles, stretchers, {opacity: true, duration: 400});
		function checkHash(){
			var found = false;
			toggles.each(function(h3, i){
				if (window.location.href.indexOf(h3.title) > 0) {
					myAccordion.showThisHideOpen(stretchers[i]);
					found = true;
				}
			});
			return found;
		}
		if (!checkHash()) myAccordion.showThisHideOpen(stretchers[0]);
	}catch(err){}
}