// JavaScript Document
function CreateBookmarkLink() {
	var title = "Besplatne online igre - www.svijet-zabeve.com"; 
  // Blogger - Replace with <$BlogItemTitle$> 
  // MovableType - Replace with <$MTEntryTitle$>

	var url = "http://www.svijet-zabave.com";
  // Blogger - Replace with <$BlogItemPermalinkURL$> 
  // MovableType - Replace with <$MTEntryPermalink$>
  // WordPress - <?php bloginfo('url'); ?>

	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"http://www.svijet-zabave.com/img/favicon.png");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
 }

function napraviFormu(){
	var form = document.createElement("form");
	form.setAttribute("method", "post");
	form.setAttribute("id", "f_test");
	var element = Array();
	for (i = 0,j = 0; i+1 < napraviFormu.arguments.length; i+=2,j++) {
		element[j] = document.createElement("input");
		element[j].setAttribute("type", "hidden");
		element[j].setAttribute("name", napraviFormu.arguments[i]);
		element[j].setAttribute("value", napraviFormu.arguments[i+1]);
    }
	for(i=0;i<element.length;i++)
		form.appendChild(element[i]);
	
	document.body.appendChild(form);
	document.getElementById("f_test").submit();
}
function enable(forma){
	if(forma.agree.checked){
		forma.submit1.disabled=false;
	}else	
		forma.submit1.disabled=true;
}

function enable_add(forma){
	if(forma.ime.value!="" && forma.kat.value!="" && forma.src.value!="" && forma.opis.value!="" && forma.slika.value!=""){
		forma.submit1.disabled=false; // prikazuje se
	}else	
		forma.submit1.disabled=true; // ne prikazuje se
}
function kontakt_enable(forma){
	if(forma.ime.value!="" && forma.mail.value!="" && forma.naslov.value!="" && forma.poruka.value!=""){
		forma.submit1.disabled=false; // prikazuje se
	}else{
		forma.submit1.disabled=true; // ne prikazuje se
	}

}
function enable_tri(forma){
	if(forma.elements[0].value!="" && forma.elements[1].value!="" && forma.elements[2].value!=""){
		forma.submit1.disabled=false; // prikazuje se
	}else{
		forma.submit1.disabled=true; // ne prikazuje se
	}
}
function login_provjera(forma){
	if(forma.elements[0].value!="" && forma.elements[1].value!="" && forma.elements[2].value!="" && forma.elements[3].value!=""){
			
	var goodEmail = forma.elements[1].value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
	  if (goodEmail)
	  {
			if(forma.elements[2].value==forma.elements[2].value)	
				forma.submit1.disabled=false; // prikazuje se
			else
				forma.submit1.disabled=true;
	  }
	  else
	  {
		forma.submit1.disabled=true; // ne prikazuje se
	  }
			
	}else{
		forma.submit1.disabled=true; // ne prikazuje se
	}
}
function zaporka_provjera(forma){
	
	var goodEmail = forma.elements[0].value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
	  if (goodEmail)
	  {
				forma.submit1.disabled=false; // prikazuje se
	  }
	  else
	  {
		forma.submit1.disabled=true; // ne prikazuje se
	  }
}

function pokaziKomentare(divizija)
// Function that will swap the display/no display for
// all content within span tags
{
if (divizija.style.display == "none")
{
divizija.style.display = "";
}
else
{
divizija.style.display = "none";
}
}

//// FS MENU KOD //////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// *** submenu position *******************************************************

// Two positions are available for now. New positions can be easily added.
var WM_BOTTOM = "bottom";
var WM_RIGHT = "right";

// Margin values in pixels. Allows for submenu position to be fine-tuned.
var MARGIN_BOTTOM = 1;
var MARGIN_RIGHT = 1;


// *** item activation ********************************************************

// One set of global values is enough, 
// no one can navigate more than one menu at the time.

// There can be only one active item at the time on the whole page.
var currentItem = null;

// There is only one way to reach a submenu. 
// The trail to that submenu is kept in this array.
// Every time an item is activated trail has to be reset. 
// All submenus after the current level removed and the current one added.
var menuTrail = new Array();

// This is needed when switching from one menu to another with two different
// styles, otherwise last element gets styleOff from the other menu.
var currentStyleOff = null;

// This function activates an item. 
// An item is active when mouse is over that item.
// Parameters:
// - item  . . . . . . . item to be activated
// - level . . . . . . . level of the submenu
// - styleOn . . . . . . style class name when item is active
// - styleOff. . . . . . style class name when item is not active
// - submenuId . . . . . id of the submenu that is to be attached to this item, pass null if no submenu
// - submenuPosition . . position of the submenu, ex: WM_RIGHT or WM_BOTTOM, pass null if no submenu
function wmItemOn(item, level, styleOn, styleOff, submenuId, submenuPosition) {

  debug("level:" + level + ", styleOn:" + styleOn + ", styleOff:" + styleOff + ", submenu:" + submenuId + "/" + submenuPosition);

  // assign timer off function to the item - makes html code cleaner
  if (item.onmouseout == null) {
    item.onmouseout = startOffTimer;
  }

  // stop timer on entry
  stopOffTimer();

  // turn off previous item 
  if (currentItem != null) {
    if (styleOff != currentStyleOff && currentStyleOff != null) {
      currentItem.className = currentStyleOff;
    } else {
      currentItem.className = styleOff;
    }
  }

  // make this item new current item
  currentItem = item;
  item.className = styleOn;
  currentStyleOff = styleOff;


  if (submenuId != null) {

    // take care of attached submenu

    hide(level);

    var menu = document.getElementById(submenuId);

    // item dimensions: item.offsetHeight, item.offsetWidth
    if (submenuPosition == WM_BOTTOM) {
      menu.style.top = findOffsetTop(item) + item.offsetHeight + MARGIN_BOTTOM;
      menu.style.left = findOffsetLeft(item);
    }

    if (submenuPosition == WM_RIGHT) {
      menu.style.top = findOffsetTop(item)+'px';
      menu.style.left = findOffsetLeft(item) + item.offsetWidth + MARGIN_RIGHT+'px';;
    }

    menu.style.visibility = "visible";

    menuTrail[level] = menu;
  } else {

    // item has no submenu attached, update the menuTrail
    
    hide(level);
  }

}


// Hide all submenus after the level passed in, inclusive.
function hide(level) {
  for (var i = level; i < menuTrail.length; i++) {
    menuTrail[i].style.visibility = "hidden";
  }
}


// *** timer ******************************************************************

// Timer is needed to turn off all the items and submenus, 
// once mouse moves away from the menu.

var timerID = null;
var timerOn = false;
var timecount = 250;

function startOffTimer() {
  if (timerOn == false) {
    timerID = setTimeout("offAll()", timecount);
    timerOn = true;
  }
}

function stopOffTimer() {
  if (timerOn) {
    clearTimeout(timerID);
    timerID = null;
    timerOn = false;
  }
}

// Hide all submenus and turn current item off.
function offAll() {
  hide(0);
  
  if (currentStyleOff != null) {
    currentItem.className = currentStyleOff;
  }
 
  debug("All off by timer.");
}


// Print text to the debug element. If the element that debugId is pointing to 
// is not found on the page, it does nothing.

var debugId = "wmDebug";

function debug(text) {
  var debug = document.getElementById(debugId);
  if (debug != null) {
     debug.innerHTML = "&raquo; " + text + "<br>" + debug.innerHTML;
  }
}


// *** position ***************************************************************

// Utility code to calculate element position.

// Find total left offset.
function findOffsetLeft(obj){
  var curleft = 0;
  if (obj.offsetParent){
    while (obj.offsetParent){
      curleft += obj.offsetLeft;
      obj = obj.offsetParent;
    }
  } else if (obj.x) {
    curleft += obj.x;
  }

  return curleft;
}

// Find total top offset.
function findOffsetTop(obj){
  var curtop = 0;
  if (obj.offsetParent)	{
    while (obj.offsetParent){
      curtop += obj.offsetTop;
      obj = obj.offsetParent;
    }
  }else if (obj.y){
    curtop += obj.y;
  }

  return curtop;
}






