// general.js

function changeImg(link, aWidth, aHeight ){
	while (aWidth > 375){
		aWidth = aWidth * .9;
		aHeight = aHeight *.9;
		//alert("reducing size: " + aWidth + "-" + aHeight);
	}
	while (aHeight > 400) {
		aWidth = aWidth * .9;
		aHeight = aHeight *.9;
	}
	var elem = document.getElementById("bigPic");
	elem.style.width=aWidth;
	elem.style.height=aHeight;
	elem.style.display="inline";
	elem.setAttribute("src", link);
	var elem2 = document.getElementById("hideText");
	elem2.style.display="none";
}
function changeImg2(link, aWidth, aHeight ){
	while (aWidth > 375){
		aWidth = aWidth * .9;
		aHeight = aHeight *.9;
	}
	while (aHeight > 400) {
		aWidth = aWidth * .9;
		aHeight = aHeight *.9;
	}
	var elem = document.getElementById("bigPic");
	elem.style.width=aWidth;
	elem.style.height=aHeight;
	elem.style.display="inline";
	elem.setAttribute("src", link);
	var elem2 = document.getElementById("hideText");
	elem2.style.display="none";
}
function show(layer){
	var element = document.getElementById(layer);
	element.style.display="block";
}
function hide(layer){
	var element = document.getElementById(layer);
	element.style.display="none";
}
function changeImg2(link, aWidth, aHeight)
{
	newwindow2=window.open('','name','height=400,width=300');
	var tmp = newwindow2.document;
	tmp.write('<html><head><title>Photo</title>');
	tmp.write('<link rel="stylesheet" href="theme/saskia.css">');
	tmp.write('</head><body><table><tr><td>');
	tmp.write('<img src="' + link + '"></img>' );
	tmp.write('</td></tr></table>');
	tmp.write('</body></html>');
	tmp.close();
}
function test(aClass){
// should have function to access all elements conforming to class x
	var element = document.getElementByClass(aClass);
	element.style.display = "none";
}
function changecss(myclass,element,value) {
var CSSRules
	if (document.all) {
	CSSRules = 'rules';
	}
	else if (document.getElementById) {
	CSSRules = 'cssRules';
	}
	else return
	for (var i = 0; i < document.styleSheets.length; i++) {
		for (var j = 0; j < document.styleSheets[i][CSSRules].length; j++) {
			if (document.styleSheets[i][CSSRules][j].selectorText == myclass) {
			document.styleSheets[i][CSSRules][j].style[element] = value
			}
		}
	}
}
function adjustFloat(){
var element = document.getElementById("posBarLeft");
var middle = document.getElementById("posMiddle");
var soundDiv = document.getElementById("soundBox");
var pos =middle.clientWidth + element.clientWidth - 60;
soundDiv.style.position="absolute";
soundDiv.style.left=pos;
soundDiv.style.top=40;
show("soundBox");
}
