///////////////////////////////////////
// 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();
}

///////////////////////////////////////
// Send form check form query field
function SA_checksearchquery(f)
{
	if ( document.forms[""+f+""].query_string.value=='' )
	{
		alert("Please enter at least one search word.");
		return(false)
	}
	else
	{
		SA_sendForm(""+f+"");
	}	
}

///////////////////////////////////////
// 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);
}
