// Author: Simon Moore April 2002
// Last Modified: November 2002
// Some ideas (moving pictures about) and Javascript adapted from www.glish.com a DHTML resource site.
var smallImg;
var smallImgDIV;
var origH=48;
var origW=64;
var startX=0;
var startY=0;
var finalX=10;
var finalY=152;
var steps=8;
var currImg;
var currTab='tabC1';
var thumbsA;
var loaded=false;
var displaying=false;
var printM=false;


function init() {
	// setup browser
	setBrowser();
	
	if (!ns6) alert("Old broser eg netscape 4 detected - disabling dhtml javascript");
	loaded=true;
	//window.onresize=moveAbsPosDivs;
	if (ns6) {
		if (!document.all) steps=6
		smallImg=document.getElementById('smallImg');
		smallImgDIV=document.getElementById('smallImgDIV');
		document.onmousemove=trackMouse;		
		showAside(openAside);
		growImg(openImage);
	};
	
	firefox = (smallImg.width)? true:false;
	

};

function dynamics() {
	if (steps>0) {
		steps=0;
		document.getElementById('don').style.color="#C00";
		document.getElementById('doff').style.color="#0A0";
	}
	else {
		steps=8;
		document.getElementById('don').style.color="#0A0";
		document.getElementById('doff').style.color="#c00";
	}
	return false;
}


function getMyProperty(obj,prop) {
	if (ns6) {
			if (prop=='top') return obj.offsetTop; //+document.body.scrollTop;
			if (prop=='left') return obj.offsetLeft;
			if (prop=='height') return obj.offsetHeight;	
	}
	else if (document.all) {
			if (prop=='top') return obj.offsetTop; //+document.body.scrollTop;
			if (prop=='left') return obj.offsetLeft;
			if (prop=='height') return obj.offsetHeight;
	} 
	else {
			if (prop=='top') return (parseInt(document.defaultView.getComputedStyle(obj,'').getPropertyValue('top')));
			if (prop=='left') return parseInt(document.defaultView.getComputedStyle(obj,'').getPropertyValue('left'));
			if (prop=='height') return parseInt(document.defaultView.getComputedStyle(obj,'').getPropertyValue('height'));
	}
	
}

function mouseOut() {
if (ns6) {
 	setTimeout('checkCursor()',700)
}
	}
function checkCursor() {
if (ns6) {
	if (currX<getMyProperty(document.getElementById('smallImgDIV'),'left')||currX>finalX+340||currY<finalY||currY>finalY+242) hideText()
}
	}

function showText() {
if (ns6) {
	if (!displaying) return true;
	document.getElementById('imgText').style.visibility='visible'
	document.getElementById('imgTextFrame').style.visibility='visible'
}
	}

function hideText() {
if (ns6) {
	document.getElementById('imgText').style.visibility='hidden'
	document.getElementById('imgTextFrame').style.visibility='hidden'
}
	}

function hideSmallImg() {
if (ns6) {
	//changeTabs('tabC1')
	displaying=false;
	hideText()
	if(currImg) document.images[currImg].style.visibility='visible';
	smallImgDIV.style.visibility='hidden';
	currImg=false;
	return false;
}
	}
	
/**/

function growImg(imgID) {
if (ns6) {
	if(!loaded) return false;
	if(currImg==imgID) return false;
	if(printM) return true;
	displaying=false;
	hideText()
	if(currImg) document.images[currImg].style.visibility='visible';
	smallImg.src=document.images[imgID].src;
	if(firefox){
		smallImgDIV.width='64px'; 
	}else{
		smallImgDIV.style.width='64px'; // otherwise there is a display bug in IE5 PC
	}
	currImg=imgID;
	startX=getMyProperty(document.getElementById('thumbsDIV'),'left') // + getMyProperty(document.getElementById(imgID),'left');
	startY=getMyProperty(document.getElementById(imgID),'top') + getMyProperty(document.getElementById('thumbsDIV'),'top');
	if (steps==1) {
		smallImg.width=smallImgDIVwidth;
		smallImg.height=smallImgDIVheight;
		smallImg.style.width=(smallImgDIVwidth); //+'px';
		smallImg.style.height=(smallImgDIVheight); //+'px';

	} else {
		if(firefox){
			smallImg.width=origW; 
			smallImg.height=origH; 
		}else{
			smallImg.style.width=(origW); //+'px';
			smallImg.style.height=(origH); //+'px';
		}
	};
	smallImgDIV.style.visibility='visible';
	smallImgDIV.style.top=startY+'px';
	smallImgDIV.style.left=startX+'px';
	//finalX=getMyProperty(document.getElementById('navDIV'),'left')

	incrementImg();
	return false;
}
	}

function newSrc(src) { return src.replace(/t.jpg/i,'s.jpg')}

function getStartCoords(imgID) {	}

currX=0; currY=0

function trackMouse(e) {
if (ns6) {
	if (document.all) { 
		currX=event.x+document.body.scrollLeft; currY=event.y+document.body.scrollTop }
	else { 
		currX=e.pageX; currY=e.pageY } }		
	}

function incrementImg() {
	if(firefox){

		newW=(parseInt(smallImg.width)+((smallImgDIVwidth-origW)/steps));
		newH=(parseInt(smallImg.height)+((smallImgDIVheight-origH)/steps));
		newX=(parseInt(smallImgDIV.style.left)+(finalX-startX)/steps);
		newY=(parseInt(smallImgDIV.style.top)+(finalY-startY)/steps);

		//alert("W: "+newW+"H: "+newH+"X: "+newX+"Y: "+newY+"smallImgDIVwidth"+smallImgDIVwidth);

		if (newW>=smallImgDIVwidth) {
			newX=finalX;
			newY=finalY;
			smallImgDIV.style.top=(finalY) +'px'; //bug in opera
			smallImgDIV.style.left=(finalX) +'px';
			smallImg.width=(smallImgDIVwidth); // +'px';
			smallImg.height=(smallImgDIVheight); // +'px';
			smallImgDIV.width=smallImgDIVwidth+'px';
			smallImgDIV.height=smallImgDIVheight+'px';

			smallImg.src=newSrc(smallImg.src);
			showText();
			displaying=true;
			//changeTabs('tabC2');
			document.getElementById('imgText').innerHTML=document.images[currImg].title //+'<br \/>'+document.images[currImg].sizes;
			document.getElementById('imgTextFrame').innerHTML=document.getElementById('imgText').innerHTML;
			showText();
			setTimeout('checkCursor()',3000);
			return false;
		}
		smallImg.width=newW; //+'px'
		smallImg.height=newH; // +'px'

		smallImgDIV.width=newW+'px';
		smallImgDIV.height=newH +'px';
		smallImgDIV.style.left=newX +'px';
		smallImgDIV.style.top=newY+'px'; // bug in opera

		setTimeout('incrementImg()',50)

	}else{
		if (ns6) {
			newW=(parseInt(smallImg.style.width)+((smallImgDIVwidth-origW)/steps))
			newH=(parseInt(smallImg.style.height)+((smallImgDIVheight-origH)/steps))
			newX=(parseInt(smallImgDIV.style.left)+(finalX-startX)/steps)
			newY=(parseInt(smallImgDIV.style.top)+(finalY-startY)/steps)
			if (newW>=smallImgDIVwidth) {
				newX=finalX;
				newY=finalY;
				smallImgDIV.style.top=(finalY) +'px'; //bug in opera
				smallImgDIV.style.left=(finalX) +'px';
				smallImg.style.width=(smallImgDIVwidth); // +'px';
				smallImg.style.height=(smallImgDIVheight); // +'px';
				smallImgDIV.style.width=smallImgDIVwidth+'px';
				smallImgDIV.style.height=smallImgDIVheight+'px';

				smallImg.src=newSrc(smallImg.src);
				showText();
				displaying=true;
				//changeTabs('tabC2');
				document.getElementById('imgText').innerHTML=document.images[currImg].title //+'<br \/>'+document.images[currImg].sizes;
				document.getElementById('imgTextFrame').innerHTML=document.getElementById('imgText').innerHTML;
				showText();
				setTimeout('checkCursor()',3000);
				return false;
			}
		smallImg.style.width=newW; //+'px'
		smallImg.style.height=newH; // +'px'

		smallImgDIV.style.width=newW+'px';
		smallImgDIV.style.height=newH +'px';
		smallImgDIV.style.left=newX +'px';
		smallImgDIV.style.top=newY+'px'; // bug in opera

		setTimeout('incrementImg()',50)
		}
	}
}

function hideAside(asideId){
	if (ns6) { 	
		if(!printM) { 
			document.getElementById(asideId).style.visibility='hidden'; 
			document.getElementById(asideId).style.position='absolute';
			}; 
		}; 
}

function showAside(asideId){
	if (ns6) {
		if(!printM) { 
			hideAside(openAside); 
			};
		document.getElementById(asideId).style.visibility='visible';
		document.getElementById(asideId).style.position='relative';
		//POSITION: relative;
		openAside = asideId;
		//alert(document.getElementById(asideId).width);
	};
}

function printMode() {
	if (ns6) {
		
	};
}
	

function setSheet(aName) {
	var i, sheet;
	/*
	var tempasides = document.getElementsByTagName('div');
	for (i=0;  i<tempasides.length; i++) {
     		tempasides[i].visibility='visible';
     };

	for (i=0; i<document.styleSheets.length; i++) {
		sheet = document.styleSheets[i];
		sheet.disabled = (sheet.id != aName);
     };

	for (i=0; i<tempasides.length; i++) {
		tempasides[i].visibility='hidden';
     };
	*/
	
	if (aName=='on') printM=true;
	if (aName=='off') printM=false;
	
	var tempasides = document.getElementsByName('a');	
		for(i=0;i<tempasides.length; i++){
			alert("hello" + i);
			tempasides[i].style.visibility='visible';
		};
		
	printMode();

}
