///////////////////////////////////////
// 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+"");
	}	
}

///////////////////////////////////////
// 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).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).visibility  = 'hidden';
}

///////////////////////////////////////
// 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);
}

///////////////////////////////////////
// JS function for uncrypting spam-protected emails:
function SA_UnCryptMailto(e) 
{	
	var n=0;
	var r="";
	for(var i=0; i < e.length; i++) {
		n=e.charCodeAt(i);
		if (n>=8364) {n = 128;}
		r += String.fromCharCode(n-(1));
	}
	return r;
}

///////////////////////////////////////
// JS function for uncrypting spam-protected emails:
function linkTo_UnCryptMailto(e)	
{	
	location.href=SA_UnCryptMailto(e);
}