///////////////////////////////////////
// Preload Images
function SA_preloadImage(imgObj,imgSrc) 
{
	if (document.images) {
		eval(imgObj+' = new Image()');
		eval(imgObj+'.src = "'+imgSrc+'"');
	}
}

///////////////////////////////////////
// Change Image Object
function SA_changeImage(imgName,imgObj) 
{
	var images;
//		alert(eval( imgObj+".src" ));
		images = document.images;
	if (images) 
		images[imgName].src = eval( imgObj+".src" );
}

///////////////////////////////////////
// Change parent window location.
// Close this.window
function SA_doMain(URL)
{
	window.opener.location.href = URL;
	this.window.close();
}

///////////////////////////////////////
// Close this.window & refresh parent
// window
function SA_closePopup() 
{
	window.opener.refresh();
	this.window.close();
}

///////////////////////////////////////
// send form
function SA_sendForm(f) 
{
	document.forms[""+f+""].submit();
}

///////////////////////////////////////
// Send form with loading confirmation
// layer
function SA_doLoaderSubmit(f)
{
	setVisibility(getLayerRef('loader'), true);
	document.forms[""+f+""].submit();
}

///////////////////////////////////////
// Show object
function SA_show(object) 
{
  	if (document.layers && document.layers[object] != null)
        document.layers[object].visibility = 'visible';
	if (document.all)
        document.all[object].style.visibility = 'visible';
	else if ( document.getElementById )
		document.getElementById(object).style.visibility  = 'visible';
}

///////////////////////////////////////
// Hide object
function SA_hide(object) 
{
    if (document.layers && document.layers[object] != null)
        document.layers[object].visibility = 'hidden';
    if (document.all)
        document.all[object].style.visibility = 'hidden';
	else if ( document.getElementById )
		document.getElementById(object).style.visibility  = 'hidden';
}

///////////////////////////////////////
// Swap backgroundColor
function SA_swapBgClr(id, bgColor)
{

	if(document.layers && document.layers[object] != null)
	{ 
		document.layers[id].cursor='hand';
		document.layers[id].bgColor=bgColor;         
		
	}
	if(!document.all && document.getElementById)
	{
		document.getElementById(id).style.backgroundColor=bgColor;
		document.getElementById(id).cursor='hand';
	}
	else
	{
		document.all[id].style.backgroundColor=bgColor;
		document.all[id].style.cursor='hand';
	}

}

///////////////////////////////////////
// Open Popup Window
function SA_openWindow( url, title, x, y ) 
{
	w = window.screen.width;
	h = window.screen.height;
	px = w / 2 - x / 2; if ( px < 0 ) px = 0;
	py = h / 2 - y / 2; if ( py < 0 ) py = 0;
	a=window.open(url, title, "toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes, height="+y+", width="+x);
	a.moveTo(px,py);
	document.title=document.title;		
	return ( a );
}

///////////////////////////////////////
// Handle form enter
function SA_handleFormEnter( command ) 
{
	if ( window.event.keyCode == 13 ) {
//		alert(eval ( command ));
		window.event.cancelBubble = true;
	}
}

///////////////////////////////////////
// Cancel form enter
function SA_cancelFormEnter( ) 
{
	if ( window.event.keyCode == 13 ) {
		window.event.cancelBubble = true;
	}
//	alert(window.event.keyCode);
}