/* Copyright (c) Motoki, 2010 */
/*   motokisensei@gmail.com   */
/*  Developed for FarGate.RU  */

var Supernatural = {};

function trimString(value)
{
	return value.toString().replace(/^\s+/g, "").replace(/\s+$/g, "");
}

function toggleDisplay(link, id)
{
	var element = document.getElementById(id);
	if (!element) return;
	
	var button = link.firstChild;
	if (element.style.display == "none" || element.style.display == "")
	{
		element.style.display = "inline";
		if (button) button.src = relPath + "images/icons/minus.gif";
	}
	else
	{
		element.style.display = "none";
		if (button) button.src = relPath + "images/icons/plus.gif";
	}
}

function stripWhitespace(el)
{
	for(var i = 0; i < el.childNodes.length; i++)
	{
		var node = el.childNodes[i];
		if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
			node.parentNode.removeChild(node);
	}
}

function popUp(name, url, width, height, toolbar, resizable, menubar, status, scrollbars)
{
	var instance = window.open(url, name, "width=" + width + 
			       ", height=" + height + 
			       ", toolbar=" + (toolbar || 0) + 
			       ", resizable=" + (resizable || 0) + 
			       ", menubar=" + (menubar || 0) + 
			       ", status=" + (status || 0) + 
			       ", scrollbars=" + (scrollbars || 0));
	instance.title = name;
	return instance;
}

$(document).ready(function() {
	var quicksearch = $('#quicksearch input').each(function() {
		this.initial = this.value;
		$(this).focus(function() {
			this.value = '';
			$(this).addClass('focused');
		});
		$(this).blur(function() {
			$(this).removeClass('focused');
			this.value = this.initial;
		});
	});
});

