var isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;


function exactImgWin(imgPath,w,h){
	// exactImgWin(imgPath,w,h,[resize/scroll],[image description])
	// default image description
	var imgDescrip = "";
	// image descriptions?
	if(arguments.length == 5 && arguments[4].length){
		imgDescrip = '<p align="center" class="imgDescrip">' + arguments[4] + '</p>';
	}
	// window width
	var winW = (!isMac) ? w : w - 15;
	// window height
	var winH = (!isMac) ? h : h - 15;
	// if image description is provided, add 40 to window's height
	if(imgDescrip.length){
		winH += 30;
	}
	// window left position
	var posL = (window.screen.availWidth - winW) / 2;
	// window top position
	var posT = (window.screen.availHeight - winH) / 2;
	// window content
	var winContent = '\n<html>\n<head>\n<title>Kaylemusic</title>\n<link rel="stylesheet" type="text/css" href="/etc/css/common.css">\n</head>\n<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">\n<a href="javascript:window.close()"><img src="'+ imgPath +'" alt="Click To Close" border="0"></a>\n' + imgDescrip + '\n</body>\n</html>\n';
	// window params
	var winParams = 'width=' + winW + ',height=' + winH + ',top=' + posT + ',left=' + posL;
	// srollbars and resizable?
	if(arguments.length == 4 && arguments[3]){
		winParams += ',scrollbars=1,resizable=1';
	}
	// create an unique window name
	rn = new Date();
	winName = rn.getHours();
	winName = winName + '_' + rn.getMinutes();
	winName = winName + '_' + rn.getSeconds();
	// open window
	fotoWin = window.open('', winName, winParams);
	fotoWin.document.write(winContent)
	fotoWin.focus();
}


function popCenterWin(w,h,url){
	// popCenterWin(w,h,url,[window name],[extra parameter])
	// name of the new window
	var wName = "centreWindow";
	// width of the new window
	var wWidth = w;
	// height of the new window
	var wHeight = h;
	// window left position
	var posL = (window.screen.availWidth - wWidth) / 2;
	// window top position
	var posT = (window.screen.availHeight - wHeight) / 2;
	// see if new window name has specified
	if(arguments.length==4 && arguments[3].length){
		var wName = arguments[3];
	}
	// see if extra param has passed in
	if(arguments.length==5){
		var extra = ',' + arguments[4];
	}else{
		var extra = "";
	}
	
	var newWin = window.open(url,wName,'width=' + wWidth + ',height=' + wHeight + ',top=' + posT + ',left=' + posL + extra);
	newWin.focus();
}



function closeWindow(){
	this.window.close();
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

// Mortgage Calculator Plus
// ------------------------------------------------------------------------
// Copyright (c) 2005, MortgageCalculatorPlus.com
// ------------------------------------------------------------------------
// This file is part of "Mortgage Calculator Plus" software
// ------------------------------------------------------------------------

function show_tip(tipid){
	destobj=document.getElementById(tipid);
	tipbox=document.getElementById("tiplayer");
	objpos=getAbsolutePosition(destobj);
	tipbox.style.left=destobj.offsetWidth+objpos[0]+10;
	tipbox.style.top=objpos[1]-10;
	tipbox.innerHTML=tips[tipid];
	tipbox.style.visibility="visible";
};
function hide_tip(){
	document.getElementById("tiplayer").style.visibility="hidden";
};
function getAbsolutePosition(oNode){
	var oCurrentNode=oNode;
	var iLeft=0;
	var iTop=0;
	while(oCurrentNode.tagName!="BODY"){
		iTop+=oCurrentNode.offsetTop;
		iLeft+=oCurrentNode.offsetLeft;
		oCurrentNode=oCurrentNode.offsetParent;
	}
	return Array(iLeft, iTop);
};
