function toggle(obj)
{
	var el = document.getElementById(obj)
	if(el == 'undefined' || el == null) return
	if(el.style.display == 'none')
		el.style.display = ''
	else
		el.style.display = 'none'

	return false	
}

function find_set(his, str)
{
	if(his.value == str) his.value = ''
}

function find_restore(his, str)
{
	if(his.value == '') his.value = str
}

function check_box()
{
	var val = false
	
	for(i = 0; i < arguments.length; i++)
	{
		id = document.getElementById(arguments[i])
		if(id && id.checked)
		{
			val = id.value
		}	
	}
	if(!val)
	{
		alert('Daj se skoncentriraj!')
		return false
	}

	var frm = document.getElementById('pollform')
	if(frm == 'undefined' ||frm == null)
		return false

	if(!frm.action)
		return false
		
	return true
}

function sure(str)
{
	if(str == 'undefined' || str == null)
		return confirm('Are you sure?')
	return confirm(str)
}

function check_form(src)
{
	var ln = document.getElementById(src)
	var le = ln.value.length
	if(!le || ln.value == ln.title)
	{
		alert('Ne primam prazno.')
		if(ln.focus) ln.focus()
		return false
	}
	if(le < 4)
	{
		alert('URL stranice od ' + le + ' znaka? Ne vjerujem ti!')
		if(ln.focus) ln.focus()
		return false
	}
	if(ln.value.indexOf('.') == -1)
	{
		alert('Sumnjiv URL!')
		if(ln.focus) ln.focus()
		return false
	}
	return true
}
function f1(that)
{
	if(that.value == that.title) that.value = ''
}

function f0(that)
{
	if(that.value == '') that.value = that.title
}

function openwin(f, w, h)
{
	var l = Math.round(((window.innerWidth ? window.innerWidth  : screen.width) - w) / 2)
	var t = Math.round(((window.innerHeight ? window.innerHeight : screen.height) - h) / 2)
	var p = ',directories=no,location=no,menubar=no,resizable=yes,status=no,toolbar=no,scrollbars=yes'
	window.open(f, 'new', 'width=' + w + ',height=' + h + ',top=' + t + ',left=' + l + p)
	return false
}

function maxlen(his, dest)
{
	id = document.getElementById(dest)
	if(id != 'undefined' && id != 'null')
	{
		maxch = 100 - his.value.length
		if (maxch < 0)
			id.value = "MAKSIMALNO 100 ZNAKOVA!";
		else
			id.value = 'Preostalo znakova: ' + maxch
	}
}

function init()
{
	var el = document.getElementById('focus_this')
	if(el == 'undefined' || el == null) return
	if(el.focus) el.focus()
}

onload = init