function check(message, url)
{
  question = confirm(message);
  if (question != "0")
  {
    top.location = url;
  }
}

function getUrl(url)
{
  self.location = url;
}

function check2(message, menu, lang, userin, extralink, extralinkvalue)
{
  question = confirm(message);
  if (question != "0")
  {
    getCenterData(menu, lang, userin, extralink, extralinkvalue);
  }
}

function makeAlertConfirmation(message, url)
{
  question = confirm(message);
  if (question != "0")
  {
    url = intenda + url + intenda;
    ajax_get (url, 'hiddenField');
  }
}

/* Ajax functions */
url = document.location.href;
xend = url.lastIndexOf("/") + 1;
var base_url = url.substring(0, xend);

var ajax_get_error = false;

function ajax_do (url) {
	// Does URL begin with http?
	if (url.substring(0, 4) != 'http') {
		url = base_url + url;
	}
	
	//url = "http://localhost/Jadran/intenda/getfile.php?url=http://localhost/Jadran/intenda/modules/press_book/ajax.php?id=2";

	// Create new JS element

  var script = document.createElement('script');
script.type = 'text/javascript';
script.text = url;
document.body.appendChild(script);


/*

	var jsel1 = document.createElement('SCRIPT');
	//jsel1.type = 'text/javascript';
  jsel1.setAttribute('type','text/javascript');
	jsel1.src = url;


	// Append JS element (therefore executing the 'AJAX' call)
	document.body.appendChild(jsel1);

	//alert(jsel.src);
	*/

	return true;
}

function ajax_get (url, el) {
	// Has element been passed as object or id-string?
	if (typeof(el) == 'string') {
		el = document.getElementById(el);
	}

	// Valid el?
	if (el == null) { return false; }

	// Does URL begin with http?
	if (url.substring(0, 4) != 'http') {
		url = base_url + url;
	}

	// Create getfile URL
	getfile_url = base_url+'intenda/ajax_getfile.php?url='+escape(url)+'&el='+escape(el.id);

	// Do Ajax
	ajax_do (getfile_url);

	return true;
}



// clock

function stopClock()
{
  clearTimeout(tick);
}

function startClock()
{
  var ut=new Date();
  var h,m,s;
  var time="";
  h=ut.getHours();
  m=ut.getMinutes();
  s=ut.getSeconds();
  if(s<=9) s="0"+s;
  if(m<=9) m="0"+m;
  if(h<=9) h="0"+h;
  time+=h+":"+m+":"+s;
  document.rclock.rtime.value=time;
  tick=setTimeout("startClock()",1000);
}

function matrica_change_color(tempid)
{
  var myfield = document.all("matrica_" + tempid);
  var mybox = document.all("mybox_" + tempid);

  if(myfield.style.backgroundColor)
  {
    mybox.checked = false;
    myfield.style.backgroundColor = "";
  }

  else
  {
    mybox.checked = true;
    myfield.style.backgroundColor = "#123456";
  }
}


function openPicEditor(filePath, extralink)
{
  myWindow = window.open("ImageEditor/index.php?imageName=" + filePath + "&extralink=" + extralink, '', 'width=800, height=600, directories=no, scrollbars=yes, menubar=no, status=no, titlebar=no');
}

