
var isDOM = (document.getElementById  ? true : false); 
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers          ? true : false);
var isDyn = (isDOM || isIE4 || isNS4);

var w = screen.width;
var h = screen.height;

function getRef(id)
{
	if (isDOM) return document.getElementById(id);
	if (isIE4) return document.all[id];
	if (isNS4) return document.layers[id];
}

function getSty(id) 	{ return (isNS4 ? getRef(id) : getRef(id).style); } 
function toggleDiv (id) { s = getSty(id); s.display = (s.display == 'none') ? 'block' : 'none'; }
function showDiv (id)	{ s = getSty(id); s.display = 'block'; }
function hideDiv (id)	{ s = getSty(id); s.display = 'none'; }

function user_confirm (prompt_text, url) { if (confirm(prompt_text)) self.location = url; }
function openWin(windowURL,windowName,windowFeatures) { return window.open(windowURL,windowName,windowFeatures); }

function PopWin (url,width,height,name)
{
	var left = (w - width) / 2;
	var top = (h - height) / 2;
	options = "left="+left+",top="+top+",width="+width+",height="+height;
	options += ",toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0,fullscreen=no"
	openWin (url, name, options );
}

function PopWinScroll (url,width,height,name)
{
	if (height <= 0) 	{ var top = 10; var height = h-80; }
	else 				{ var top = (h - height) / 2; }
	if (width <= 0) 	{ var left = 10; var width = w-20; }
	else 				{ var left = (w - width) / 2; }
	options = "left="+left+",top="+top+",width="+width+",height="+height;
	options +=",toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0,fullscreen=no"
	openWin (url, name, options );
}

function askSubmit (frm, msg)
{
	if (confirm(msg))
	{
		document.forms[frm].submit();
	}
}

function checkSearchField()
{
	var id = document.forms['search'].search_text;
	if (id.value.length == 0)
	{
		alert('Niste uneli kriterijum pretraživanja!');
		return false;
	}
	else if (id.value.length <3)
	{
		alert('Morate uneti najmanje tri slova kako bi izvršili pretraživanje!');
		return false;
	}else{
		return true;
	}
}

function toogleCancelDiv(id)
{
	var link_id = 'link_' + id;
	var form_id = 'form_' + id;
	var row_id 	= 'row_' + id;
	if (document.getElementById(link_id).style.display == 'none')
	{
		document.getElementById(link_id).style.display = 'block';
		document.getElementById(form_id).style.display = 'none';
		document.getElementById(row_id).style.background = '#F1F1F1';
	}else{
		document.getElementById(link_id).style.display = 'none';
		document.getElementById(form_id).style.display = 'block';
		document.getElementById(row_id).style.background = '#FFDD00';
	}
}

function showContactForm(pack_id, period, price)
{
	document.forms['orderPackage'].pack_id.value = pack_id;
	document.getElementById('order_form').style.display = 'block'
	document.getElementById('order_room_desc').innerHTML = document.getElementById('room_details'+pack_id).innerHTML;
	document.getElementById('order_room_period').innerHTML = 'Od <b>'+period +'</b> cena: <b>'+price+'</b>';
}

function cancelContactaForm()
{
	document.getElementById('order_form').style.display = 'none'
}

function showReplyDiv(id)
{
	var ref = document.getElementById('reply_'+id);
	if (ref.style.display == 'none')
	{
		ref.style.display = 'block';
	}else{
		ref.style.display = 'none';
	}
}
