function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // getStyleObject

function changeImage(imgfile,bgid) {
        newImage = 'url(' +imgfile+ ')';
        document.getElementById(bgid).style.backgroundImage = newImage;
		document.getElementById('backtohomepage').innerHTML = "Back To Homepage"
}


function changeObjectVisibility(objectId, newVisibility) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.visibility = newVisibility;
	return true;
    } else {
	// we couldn't find the object, so we can't change its visibility
	// newVisibility option value : visible or hidden
	return false;
    }
} // changeObjectVisibility

function moveObject(objectId, newXCoordinate, newYCoordinate) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.left = newXCoordinate;
	styleObject.top = newYCoordinate;
	return true;
    } else {
	// we couldn't find the object, so we can't very well move it
	return false;
    }
} // moveObject

function fadeIt(ele,url){
	Spry.Effect.DoFade(ele,{ duration: 400, from: 100, to: 0, finish: function() {
		Spry.Utils.updateContent(ele, url, function() {
			Spry.Effect.DoFade(ele,{ duration: 100, from: 0, to: 100 });
		});
  }
 });
}

function CommaFormatted(amount)
{
	var delimiter = ","; // replace comma if desired
	var a = amount.split('.',2)
	var d = a[1];
	var i = parseInt(a[0]);
	if(isNaN(i)) { return ''; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	var n = new String(i);
	var a = [];
	while(n.length > 3)
	{
		var nn = n.substr(n.length-3);
		a.unshift(nn);
		n = n.substr(0,n.length-3);
	}
	if(n.length > 0) { a.unshift(n); }
	n = a.join(delimiter);
	if(d.length < 1) { amount = n; }
	else { amount = n + '.' + d; }
	amount = minus + amount;
	return amount;
}

// Center Pop-up Window
var win = null;
function NewWindow(mypage,myname,w,h,stat,scroll,rsize){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',status='+stat+',toolbars=no,left='+LeftPosition+',scrollbars='+scroll+',resizable='+rsize+',location=no,directories=no,menubars=no,copyhistory=yes'
win = window.open(mypage,myname,settings)

if (!document.all) {
document.captureEvents (Event.CLICK);
}
document.onclick = function() {
if (win != null && !win.closed) { 
win.focus();
}
}
}

function url_direct(targetwin,url,querystring){
	var urldata = url + querystring;
//	alert(targetwin);
//	alert(urldata);
	Spry.Utils.updateContent(targetwin,urldata);
}

function handleSearchKeyPress(e,targetwin1,url1,targetwin2,url2,querystring){
var key=e.keyCode || e.which;
if (key==13){
//	alert(targetwin1);
//	alert(url1);
//	alert(targetwin2);
//	alert(url2);
//	alert(querystring);
	url_direct(targetwin1,url1,querystring);
	url_direct(targetwin2,url2,querystring);
}
}


