sfHover = function() {
	var sfEls = document.getElementById("navmenu").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}

//if (window.attachEvent) window.attachEvent("onload", sfHover);
//----------------------------------------------------------

/*
	Opens popup window, whitch is centered in screen
	Param:
		url string (link to the file you want to open)
		width int (window width)
		height int (window height)
*/
function OpenImagePopup(url,width,height) {
	var rnd = (Math.round((Math.random()*999)+1));
	
	var SH = screen.height;
	var SW = screen.width;

	if (SW < width)
	{
		newW = Math.round(SW * 0.90);
		dif = newW / width;
		newH = Math.round(height * dif);
		height = newH;
		width = newW;
	}

	if (SH < height)
	{
		newH = Math.round(SH * 0.90);
		dif = newH / height;
		newW = Math.round(width * dif);
		height = newH;
		width = newW;
	}

	var top = (screen.height) ? (screen.height-height)/2 : 0;
	var left = (screen.width) ? (screen.width-width)/2 : 0;

	iw = width;
	ih = height;
	my_window = window.open("", "w"+rnd, "top="+top+",left="+left+",width="+width+",height="+height+",buttons=no,scrollbars=no,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no");
	my_window.document.writeln("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" "+"\"http://www.w3.org/TR/html4/strict.dtd\">");
	my_window.document.writeln("<html><head><title>Picture preview</title>");
	my_window.document.writeln("<meta http-equiv=\"Content-Script-Type\" ","content=\"text/javascript\"><\/head>");
	my_window.document.writeln("<body style='margin:0px;padding:0px;'>")
	my_window.document.writeln("<img src='" + url + "' onclick='window.close();' border='0' width='" + iw + "' height='" + ih + "' alt='' />");
	my_window.document.writeln("<\/body><\/html>");
	my_window.document.close();
}
//---------------------------------------------------------------

/*
	Opens popup window, whitch is centered in screen
	Param:
		url string (link to the file you want to open)
		width int (window width)
		height int (window height)
*/
function openPopup(url,width,height) {
	var rnd = (Math.round((Math.random()*999)+1));
	
	scrollbars = 'yes';
	
	var top = (screen.height) ? (screen.height-height)/2 : 0;
	var left = (screen.width) ? (screen.width-width)/2 : 0;

	my_window = window.open(url, "w"+rnd, "top="+top+",left="+left+",width="+width+",height="+height+",buttons=no,scrollbars="+scrollbars+",location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no");
	my_window.document.close();
}
//---------------------------------------------------------------

function trimString (str)
{
	while (str.charAt(0) == ' ')
		str = str.substring(1);
	while (str.charAt(str.length - 1) == ' ')
		str = str.substring(0, str.length - 1);

	return str;
}
//---------------------------------------------------------------

function truebody() {
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
//---------------------------------------------------------------

function backToTop() {
    var x1 = x2 = x3 = 0;
    var y1 = y2 = y3 = 0;

    if (document.documentElement) {
        x1 = document.documentElement.scrollLeft || 0;
        y1 = document.documentElement.scrollTop || 0;
    }

    if (document.body) {
        x2 = document.body.scrollLeft || 0;
        y2 = document.body.scrollTop || 0;
    }

    x3 = window.scrollX || 0;
    y3 = window.scrollY || 0;

    var x = Math.max(x1, Math.max(x2, x3));
    var y = Math.max(y1, Math.max(y2, y3));


    window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));

    if (x > 0 || y > 0) {
        window.setTimeout("backToTop()", 60);
    }
}
//---------------------------------------------------------------

function validateCommentsForm()
{
	var formObj = $('#addCommentForm');
	var result = true;
	
	formObj.find('input[name="name"], input[name="captcha_phrase"], textarea').each(function(){
		if (!$.trim($(this).val()) || ($(this).val() == $(this).attr('title')))
		{
			result = false;
		}
	});
	
	formObj.find('.button').blur();
	
	return result;
}
//---------------------------------------------------------------

function validateSendtofriendForm()
{
	var formObj = $('#sendtofreindForm');
	var result = true;
	
	formObj.find('input[type="text"], textarea').each(function(){
		if (!$.trim($(this).val()) || ($(this).val() == $(this).attr('title')))
		{
			result = false;
		}
	});
	
	formObj.find('.button').blur();
	
	return result;
}
//---------------------------------------------------------------

