function generateOptions(json_arr, first_key, first_value) 
{
  var options = '';
	if (first_key && first_value) {
		options += '<option value="' + first_key + '">' + first_value + '</option>';   	
	}
  $.each(json_arr, function(i, n) {
    options += '<option value="' + i + '">' + n + '</option>';    
  });
  
  return options;
}

function trim(stringToTrim) 
{
    return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function go_there(link)
{
    var where_to = confirm("Сигурни ли сте ??");
    if (where_to == true) {
        window.location = link;
    }
}

function sureSubmit(el, frm, action)
{
  var where_to = confirm("Сигурни ли сте ??");
    if (where_to == true) {
				if (action) {
					frm.action.value = action;
				}
        frm.submit();
    } else {
      el.selectedIndex = 0;
      return false;
    }
}

function goImgWin(myImage, myWidth, myHeight, origLeft, origTop)
{
    myHeight += 24;
    myWidth += 24;

    TheImgWin = window.open(myImage,'image','height=' +
    myHeight + ',width=' + myWidth +
    ',toolbar=no,directories=no,status=no,' +
    'menubar=no,scrollbars=no,resizable=no');

    TheImgWin.resizeTo(myWidth+2, myHeight + 30);
    TheImgWin.moveTo(origLeft, origTop);
    TheImgWin.focus();
}

function in_array(needle, haystack)
{
    var i = haystack.length;
    if(i > 0) {
        do {
            if (haystack[i] === needle)
                return true;
        } while (i--);
    }
    
    return false;
}
