  // put in this function all function calls which have to execute on body.onLoad 
  function body_on_load() {

  }

  function checkbox_set(obj, chk_name, img_prefix) {
    document.getElementById(chk_name).checked = !document.getElementById(chk_name).checked;
    img_src = img_prefix + document.getElementById(chk_name).checked + '.gif';
    obj.src = img_src;    
  }
  
  function set_description_text(obj, text, set) {
    if(set) {
      if(obj.value == '') 
        obj.value = text;
    }
    else {
      if(obj.value == text) {
        obj.value = '';
      }
    }
  
  }
  
  function std_select_move_up(prefix, select_count) {
      for(i=1;i<select_count;i++) {
          document.getElementById(prefix+i).selectedIndex = document.getElementById(prefix+(i+1)).selectedIndex;
      }
      document.getElementById(prefix+select_count).selectedIndex = 0;
      std_select_disable_next(prefix, select_count)
  }
  
  function std_select_move_down(prefix, select_count) {
      for(i=select_count;i>1;i--) {
          document.getElementById(prefix+i).selectedIndex = document.getElementById(prefix+(i-1)).selectedIndex;
      }
      document.getElementById(prefix+'1').selectedIndex = 0;
      std_select_disable_next(prefix, select_count)
  }
  
  function std_disable_same_news(prefix, select_count) {
      std_select_disable_next(prefix, select_count);
      for(i=1;i<=select_count;i++) {
          std_select_enable_all(document.getElementById(prefix+i));
          for(j=1;j<=select_count;j++) {
              if(j!=i) {
                  if(document.getElementById(prefix+j).selectedIndex != 0)
                      document.getElementById(prefix+i).options[document.getElementById(prefix+j).selectedIndex].disabled = true;
              }
          }
      }
  }
  
  function std_select_enable_all(obj_select) {
      for(var i=0;i<obj_select.options.length;i++) {
          obj_select.options[i].disabled = false;
      }
  }
  
  function std_select_disable_next(prefix, select_count) {
      for(i=1;i<select_count;i++) {
          if(document.getElementById(prefix+i).selectedIndex == 0) {
              if(document.getElementById(prefix+(i+1)))
                  if(document.getElementById(prefix+(i+1)).selectedIndex == 0)
                      document.getElementById(prefix+(i+1)).disabled = true;
          }
          else {
              if(document.getElementById(prefix+(i+1)))
                  document.getElementById(prefix+(i+1)).disabled = false;
          }
      }
  }
  
  function showHideDiv(div_name)
	{
		var obj = document.getElementById(div_name);
		if(obj.style.display=='block'){
			obj.style.display='none';
		}else{
			obj.style.display='block';
		}		
	}
	
  function showMessage(html_obj, action, msg) {
	if(action == "OK") {
		$(html_obj).html('<div class="msg_ok">'+((msg != undefined) ? msg : "Operacija uspela")+'</div>').fadeIn(500);
	}
	else {
		$(html_obj).html('<div class="msg_error">'+((msg != undefined) ? msg : "Operacija NI uspela")+'</div>').fadeIn(500);;
	}
	setTimeout('$("'+html_obj+'").fadeOut(1500);',2500);
  	
  }
	
	function edit_points(id, value, chk) {
		$('#points_'+id).append('<div id="edit_points" style="padding:3px; border:1px solid #0753A3; background-color:#ffffff; position:absolute; z-index:10;">' +
						'<input type="text" id="rank_points" name="rank_points" size="5" value="'+value+'" />' +
						'<button onClick="edit_points_save('+id+','+chk+');">Shrani</button></div>');
	}
	
	function edit_points_save(id, chk) {				
		var points = $('#rank_points').val();
		$('#points_'+id).html('Shranjujem...');
		$('#points_'+id).load('public.php?module=405&mode=add_point&rank_id='+id+'&rank_points='+points+'&rank_chk='+chk);
		$('#edit_points').remove();
	}
	
	function edit_price(id, product, market, price_from, price_to) {
		$('#price_'+id).append('<div id="edit_price_'+id+'" style="padding:3px; border:1px solid #0753A3; background-color:#ffffff;  position: fixed; z-index:10;">' +
						'<div>Uredi</div>' +
						'<input type="hidden" id="price_id" name="price_id" value="'+id+'" />' +
						'<input type="hidden" id="product_id" name="product_id" value="'+product+'" />' +
						'<input type="hidden" id="market_id" name="market_id" value="'+market+'" /><br />' +
						'od: <input type="text" id="price_from" name="price_from" size="10" value="'+price_from+'" /><br />' +
						'do: <input type="text" id="price_to" name="price_to" size="10" value="'+price_to+'" /><br />' +
						'<button onClick="edit_price_save('+id+');">Shrani</button><button onClick="edit_price_close('+id+');">Zapri</button></div>');
	}
	
	function edit_price_save(id) {				
		var price_from = $('#price_from').val();
		var price_to = $('#price_to').val();
		var market_id = $('#market_id').val();
		var product_id = $('#product_id').val();
		
		$('#price_'+id).html('Shranjujem...');
		$('#price_'+id).load('cms.php?module=203&mode=edit_price&price_id='+id+'&product_id='+product_id+'&market_id='+market_id+'&price_from='+price_from+'&price_to='+price_to);
		$('#edit_price_'+id).remove();
	}
	
	function add_price(product, market) {
		$('#price_'+product+'_'+market).append('<div id="add_price_'+product+'_'+market+'" style="padding:3px; border:1px solid #0753A3; background-color:#ffffff; position:fixed; z-index:10;">' +
						'<div>Dodaj</div>' +
						'<input type="hidden" id="product_id" name="product_id" value="'+product+'" />' +
						'<input type="hidden" id="market_id" name="market_id" value="'+market+'" />' +
						'od: <input type="text" id="price_from" name="price_from" size="10" value="" /><br />' +
						'do: <input type="text" id="price_to" name="price_to" size="10" value="" /><br />' +
						'<button onClick="add_price_save();">Shrani</button><button onClick="add_price_close('+product+','+market+');">Zapri</button></div>');
	}
	function add_price_save() {				
		var price_from = $('#price_from').val();
		var price_to = $('#price_to').val();
		var market_id = $('#market_id').val();
		var product_id = $('#product_id').val();
		
		$('#price_'+product_id+'_'+market_id).html('Shranjujem...');
		$('#price_'+product_id+'_'+market_id).load('cms.php?module=203&mode=add_price&product_id='+product_id+'&market_id='+market_id+'&price_from='+price_from+'&price_to='+price_to);
		$('#add_price_'+product_id+'_'+market_id).remove();
	}
	
	function edit_price_close(id) {
		$('#edit_price_'+id).remove();
	}
	
	function add_price_close(product, market) {
		$('#add_price_'+product+'_'+market).remove();
	}
	
	function file_select(obj, id) {
		if($('#file_select').size() > 0) {
			$('#file_select').remove();	
		}
		else {
		$(obj).after('<div id="file_select" style="padding:3px; border:1px solid #0753A3; background-color:#ffffff; position:absolute; z-index:10;">' +
						'<form action="public.php?module=405&mode=rank&event=import&event_id=' + id + '" method="post" id="file_select_form" enctype="multipart/form-data">' +
						'<input type="file" id="cvs_file" name="cvs_file" />' +
						'</form>' +
						'<button onClick="$(\'#file_select_form\').submit();">Shrani</button></div>');
		}
	}

  // getPageSize()
  // Returns array with page width, height and window width, height
  // Core code from - quirksmode.com
  // Edit for Firefox by pHaez
  function getPageSize() {
  	
  	var xScroll, yScroll;
  	
  	if (window.innerHeight && window.scrollMaxY) {	
  		xScroll = window.innerWidth + window.scrollMaxX;
  		yScroll = window.innerHeight + window.scrollMaxY;
  	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
  		xScroll = document.body.scrollWidth;
  		yScroll = document.body.scrollHeight;
  	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
  		xScroll = document.body.offsetWidth;
  		yScroll = document.body.offsetHeight;
  	}
  	
  	var windowWidth, windowHeight;
  
  	if (self.innerHeight) {	// all except Explorer
  		if(document.documentElement.clientWidth){
  			windowWidth = document.documentElement.clientWidth; 
  		} else {
  			windowWidth = self.innerWidth;
  		}
  		windowHeight = self.innerHeight;
  	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
  		windowWidth = document.documentElement.clientWidth;
  		windowHeight = document.documentElement.clientHeight;
  	} else if (document.body) { // other Explorers
  		windowWidth = document.body.clientWidth;
  		windowHeight = document.body.clientHeight;
  	}	
  	
  	// for small pages with total height less then height of the viewport
  	if(yScroll < windowHeight){
  		pageHeight = windowHeight;
  	} else { 
  		pageHeight = yScroll;
  	}
  
  	// for small pages with total width less then width of the viewport
  	if(xScroll < windowWidth){	
  		pageWidth = xScroll;		
  	} else {
  		pageWidth = windowWidth;
  	}
  
  	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
  	return arrayPageSize;
  }

  //
  // getPageScroll()
  // Returns array with x,y page scroll values.
  // Core code from - quirksmode.com
  //
  function getPageScroll(){
  
  	var xScroll, yScroll;
  
  	if (self.pageYOffset) {
  		yScroll = self.pageYOffset;
  		xScroll = self.pageXOffset;
  	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
  		yScroll = document.documentElement.scrollTop;
  		xScroll = document.documentElement.scrollLeft;
  	} else if (document.body) {// all other Explorers
  		yScroll = document.body.scrollTop;
  		xScroll = document.body.scrollLeft;	
  	}
  
  	arrayPageScroll = new Array(xScroll,yScroll) 
  	return arrayPageScroll;
  }
  
  function show_groups(id) {
		$('#groups_'+id).toggle();
	}

	function send_newsletter(id, url) {
	  var group = $('select',$('#groups_'+id)).val();
	  if(group != null) {
			url = url + "&group_id=" + group;
			window.location = url;
		}
	}
  //+ Jonas Raoni Soares Silva
//@ http://jsfromhell.com/forms/masked-input [rev. #1]

	MaskInput = function(f, m){
    function mask(e){
        var patterns = {"1": /[A-Z]/i, "2": /[0-9]/, "4": /[\xC0-\xFF]/i, "8": /./ },
            rules = { "a": 3, "A": 7, "9": 2, "C":5, "c": 1, "*": 8};
        function accept(c, rule){
            for(var i = 1, r = rules[rule] || 0; i <= r; i<<=1)
                if(r & i && patterns[i].test(c))
                    break;
                return i <= r || c == rule;
        }
        var k, mC, r, c = String.fromCharCode(k = e.key), l = f.value.length;
        (!k || k == 8 ? 1 : (r = /^(.)\^(.*)$/.exec(m)) && (r[0] = r[2].indexOf(c) + 1) + 1 ?
            r[1] == "O" ? r[0] : r[1] == "E" ? !r[0] : accept(c, r[1]) || r[0]
            : (l = (f.value += m.substr(l, (r = /[A|9|C|\*]/i.exec(m.substr(l))) ?
            r.index : l)).length) < m.length && accept(c, m.charAt(l))) || e.preventDefault();
    }
    for(var i in !/^(.)\^(.*)$/.test(m) && (f.maxLength = m.length), {keypress: 0, keyup: 1})
        addEvent(f, i, mask);
};

// --- RECORD LIST --- //
$(function(){
  
	  
		
	
});

