var menuButtonCurSel = "";

function changeContent(name) {
	document.getElementById("frameContent").src = name + ".html";
	if (name.indexOf('/') > -1) {
		name = name.substr(name.indexOf('/') + 1);
	}
	document.getElementById("frameLeft").src = name + "Left.html";
}

function onMenuButtonOver(menuImage) {
	if (menuButtonCurSel != menuImage) {
		document.getElementById(menuImage).src = "images/" + menuImage + "Hov.jpg";
	}
}

function onMenuButtonOut(menuImage) {
	if (menuButtonCurSel != menuImage) {
		document.getElementById(menuImage).src = "images/" + menuImage + ".jpg";
	}
}

function onMenuButtonClick(menuImage) {
	if (menuButtonCurSel.indexOf(menuImage) == -1) {
		if (menuButtonCurSel.length > 0) {
			document.getElementById(menuButtonCurSel).src = "images/" + menuButtonCurSel + ".jpg";
		}
		document.getElementById(menuImage).src = "images/" + menuImage + "Sel.jpg";
		menuButtonCurSel = menuImage;
	}
}

function preloadImages() {
	document.imgMenuButtons = new Array();

	var i, j, args = preloadImages.arguments; 
	for (i = 0, j = 0; i < args.length; i++, j += 2) {
		document.imgMenuButtons[j] = new Image();
		document.imgMenuButtons[j].src = "images/" + args[i] + "Hov.jpg";
		
		document.imgMenuButtons[j + 1] = new Image();
		document.imgMenuButtons[j + 1].src = "images/" + args[i] + "Sel.jpg";	   
	}
}

function openImageWindow(img, width, height) {
	xsize = width + 6;
	ysize = height + 54;

	screenWidth = screen.width;
	screenHeight = screen.height;

	xpos = screenWidth / 2 - width / 2;
	ypos = screenHeight / 2 - height / 2;

	newWindow = window.open("","Image","height="+ysize+",width="+xsize+",scrollbars=no,resizable=no,top="+ypos+",left="+xpos+"");
	newWindow.document.write ("<html><head><title>British Knights - British Shorthair Cattery</title></head>");
	newWindow.document.write ("<body bgcolor=\"#321d08\" onload=\"focus()\"");
	newWindow.document.write ("style=\"text-align:center;margin-top:0; margin-left:0\">");
	newWindow.document.write ("<p style=\"margin-top: 0; margin-bottom: 5\">");
	newWindow.document.write ("<img src=");
	newWindow.document.write (img);
	newWindow.document.write ("></p>");
	newWindow.document.write ("<p style=\"margin-top: 0; margin-bottom: 0\">");
	newWindow.document.write ("</body></html>");
	newWindow.document.close();
	newWindow.resizeTo(xsize, ysize); 
}

function openWindow(url, width, height) {
	xsize = width + 6;
	ysize = height + 54;
    
	screenWidth = screen.width;
	screenHeight = screen.height;

	xpos = screenWidth / 2 - width / 2;
	ypos = screenHeight / 2 - height / 2;

	newWindow = window.open(url,"window","height="+ysize+",width="+xsize+",scrollbars=yes,resizable=no,top="+ypos+",left="+xpos+"");
  	newWindow.resizeTo(xsize, ysize); 
}

function adjustFrames() {
	var winHeight = 0;
	
	if (typeof( window.innerWidth ) == 'number') { //Non-IE
		winHeight = window.innerHeight;
	} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {//IE 6+ in 'standards compliant mode'
		winHeight = document.documentElement.clientHeight;
	} else if (document.body && (document.body.clientWidth || document.body.clientHeight)) { //IE 4 compatible
		winHeight = document.body.clientHeight;
	}
	
	document.getElementById("frameLeft").height = winHeight - 275;
	document.getElementById("frameContent").height = winHeight - 275;
}

function resizeFrames() {
	//var newHeight = document.body.offsetHeight + 30;
	//parent.window.document.getElementById("frameContent").height = newHeight;
}
