/*var POPUP_FEATURES = 'location=0, statusbar=0, menubar=0, width=600, height=440, scrollbars, resizable';*/
var POPUP_FEATURES = 'location=0, menubar=0, scrollbars, resizable';

function raw_popup(url, target, width, height, features) 
{
	if (isUndefined(features))
	{
		features = POPUP_FEATURES;
	}

	//alert('width='+width+', height='+height+'.');
	if(width>600) width*=0.8;
	if(height>440) height*=0.8;
	
	features+=', width='+width;
	features+=', height='+height;

	var left=(get_width()-width)/2;
	var top=(get_height()-height)/2-10;

	features+=', top='+top;
	features+=', left='+left;

	var theWindow = window.open(url, target, features);
	theWindow.focus();
	return theWindow;
}

function link_popup(src, features)
{
	//alert('width='+get_width()+', height='+get_height()+'.');
	return raw_popup(src.getAttribute('href'), 'zivot', get_width(), get_height(), features);
}

function get_width()
{
	if(!isUndefined( screen.Width ) ) return screen.Width;
	else if(!isUndefined(screen.availWidth) ) return screen.availWidth;
	else { alert("get_width"); return 600; }
}

function get_height()
{
	if(!isUndefined( screen.Height ) ) return screen.Height;
	else if(!isUndefined(screen.availHeight) ) return screen.availHeight;
	else { alert("get_width"); return 440; }
}

function isUndefined(v)
{
	var undef;
	return v===undef;
}

function check_onama()
{
	if(document.forms['contactform'].txt.value=='')
	{
		alert('Niste unjeli tekst poruke.');
		return false;
	}

	if(document.forms['contactform'].email.value=='')
	{
		return confirm('Niste unjeli vašu e-mail adresu. Da li svejedno želite poslati poruku?');
	}
	
	return true;
}

function check_aboutus()
{
	/* prevesti!!!!!!!!!!! */
	if(document.forms['contactform'].txt.value=='')
	{
		alert('Field "Text" is empty. Please fill in the field "Text".');
		return false;
	}

	if(document.forms['contactform'].email.value=='')
	{
		return confirm('You didn\'t enter your e-mail. Do you want to send this message anyway?');
	}
	
	return true;
}

function setLang(lg)
{
	var expdate=new Date();
	expdate.setTime( expdate.getTime() + 2*365*24*60*60*1000 );
	document.cookie='zlang='+lg+'; expires='+expdate.toGMTString()+'; path=/';
	//alert(document.cookie);
}

