/* Pop up prozor */
function popUp(page, pageWidth, pageHeight, pageTop, pageLeft)
{
    window.open("/" + page + ".tpl.php", null, "width=" + pageWidth +",height=" + pageHeight + ",top=" + pageTop + ",left=" + pageLeft + ",status=yes,toolbar=no,menubar=no,location=no");
}

/* Pop up za upitnik */
function popUpUpitnik(page, pageWidth, pageHeight, pageTop, pageLeft) 
{
    window.open("/clanovi/rr-upitnik.php" + page, null, "width=" + pageWidth +",height=" + pageHeight + ",top=" + pageTop + ",left=" + pageLeft + ",status=yes,toolbar=no,menubar=no,location=no,scrollbars=1");
}

function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}

function Komentar(url){
	window.open("/ecms/comments/index.php?id="+url,"komentari","width=505,height=300,toolbars=0,scrollbars=1,resizable=0,locationbar=0,menubar=0,status=1,toolbar=0,left=150,top=50")
} 

function Comment(url_1,url_2){
    window.open("http://ecms.infostud.com/inc/comments/?s_id=" + url_1 + "&id=" + url_2 ,"komentari","width=505,height=300,toolbars=0,scrollbars=1,resizable=0,locationbar=0,menubar=0,status=1,toolbar=0,left=150,top=50")
}

function CommentNews(url_1,url_2){
    window.open("http://ecms.infostud.com/inc/comments/index.php?s_id=" + url_1 + "&id=" + url_2 +"&action=write&order=" ,"komentari","width=805,height=600,toolbars=0,scrollbars=1,resizable=0,locationbar=0,menubar=0,status=1,toolbar=0,left=150,top=50")
}

function posaljiVest(url){
	window.open("/ecms/mailto.php?id="+url,"ecms","width=405,height=315,toolbars=0,scrollbars=1,resizable=0,locationbar=0,menubar=0,status=1,toolbar=0,left=150,top=50")
}

function posaljiLinkDS(url){
window.open("/ecms/mailto.php?sendurl="+url,"PosaljiLink","width=405,height=315,toolbars=0,scrollbars=1,resizable=0,locationbar=0,menubar=0,status=1,toolbar=0,left=150,top=50")
}

function newPosaljiVest(id, sec){
	window.open("http://poslovi.infostud.com/ecms/v2_mailto.php?mail_id="+id+"&sec="+sec,"ecms","width=590,height=430,toolbars=0,scrollbars=1,resizable=0,locationbar=0,menubar=0,status=1,toolbar=0,left=150,top=50")
}

function posaljiLink(url){
if(arguments.length == 1)
	window.open("/inc/posalji_link.php?id="+url,"pop","width=465,height=280,toolbars=0,scrollbars=0")
else if(arguments.length == 3)
	window.open("/inc/posalji_link.php?type="+arguments[1]+"&sid="+arguments[2]+"&id="+url,"pop","width=465,height=260,toolbars=0,scrollbars=0")
} 
/* Pop up prozor */

function prijaviGresku(){
	window.open("/inc/prijavapl.php","prijavigresku","width=405,height=350,toolbars=0,scrollbars=1,resizable=0,locationbar=0,menubar=0,status=1,toolbar=0,left=150,top=50")
}

/* Pop up prozor - pošalji na mail - Pravnik odgovara */
function PravnikS2M(ID, pageWidth, pageHeight, pageTop, pageLeft)
{
    window.open("/info/saveti/pravnik-odgovara/mailto.php?id=" + ID , null, "width=505,height=415,top=50,left=150,status=yes,toolbar=no,menubar=no,location=no");
}



/* Pop up prozor - pošalji savet */
function PredlogSaveta(ID, pageWidth, pageHeight, pageTop, pageLeft)
{
    window.open("/info/saveti/predlozi-savet.php", null, "width=505,height=415,top=50,left=150,status=yes,toolbar=no,menubar=no,location=no");
}

/* Infostud Poslovi mail */
function poslovi(){
document.write('<a href="mai');
document.write('lto');
document.write(':&#112;&#111;&#115;&#108;&#111;&#118;&#105;');
document.write('@');
document.write('&#105;&#110;&#102;&#111;&#115;&#116;&#117;&#100;&#46;&#99;&#111;&#109;" class="white-link2">');
document.write('&#112;&#111;&#115;&#108;&#111;&#118;&#105;');
document.write('@');
document.write('&#105;&#110;&#102;&#111;&#115;&#116;&#117;&#100;&#46;&#99;&#111;&#109;<\/a>');
}
/* Infostud Poslovi mail */

/* Tooltip */
var tipwidth='280px' //default tooltip width
var tipbgcolor='#FFFFFF'  //tooltip bgcolor
var disappeardelay="150"  //tooltip disappear speed onMouseout (in miliseconds)
var vertical_offset="10px" //horizontal offset of tooltip from anchor link
var horizontal_offset='3px'//horizontal offset of tooltip from anchor link

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="fixedtipdiv" style="visibility:hidden;width:'+tipwidth+';background-color:'+tipbgcolor+'" ></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, tipwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
}
return edgeoffset
}

function tooltip(menucontents, obj, e, tipwidth, tiphorizontal){
if(tiphorizontal!="")
horizontal_offset=tiphorizontal

if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidetip()
dropmenuobj=document.getElementById? document.getElementById("fixedtipdiv") : fixedtipdiv
dropmenuobj.innerHTML=menucontents

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", tipwidth)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}
}

function hidetip(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function SakrijInfo(){
if (ie4||ns6)
delayhide=setTimeout("hidetip()",disappeardelay)
}

function clearhidetip(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}
/* Tooltip */

/*  */
function drgrad(drzava, grad)
	{
	if (document.getElementById(drzava).options[document.getElementById(drzava).selectedIndex].value != 434) 
		{
		document.getElementById(grad).disabled = true;
		document.getElementById(grad).selectedIndex = 0;
		}
	else 
		{
		document.getElementById(grad).disabled = false;
		}
	return true;
	}
/*  */

/* UTOKU */
function utoku()
	{
	var utoku = document.getElementById('ZaposlenjeUToku');
	var ch = utoku.checked;
	if (ch)
		{
		document.getElementById('ZaposlenjeMesZav').disabled = true;
		document.getElementById('ZaposlenjeGodZav').disabled = true;
		document.getElementById('ZaposlenjeMesZav').selectedIndex = 0;
		document.getElementById('ZaposlenjeGodZav').selectedIndex = 0;
		}
	else 
		{
		document.getElementById('ZaposlenjeMesZav').disabled = false;
		document.getElementById('ZaposlenjeGodZav').disabled = false;
		}
	}
/* UTOKU */

/* RESET MULTISELECT */
function reset_multiselect(box)
 {
 var b = document.getElementById(box);
 for (i=0; i<b.options.length; i++)
 {
 b.options[i].selected = false;
 }
 }
/* RESET MULTISELECT */

/* SHOWHIDE GRADOVI */
function showhide_gradovi()
	{
	var v = document.getElementById('VanMesta_4');
	var m = document.getElementById('MestoZaposlenja');
	var r = document.getElementById('reset_MestoZaposlenja');
	var zv = document.getElementById('MestoZaposlenja_zvezdica')
	if (v.checked)
		{
		m.disabled = false;
		r.disabled = false;
		zv.style.visibility = 'visible';
		}
	else
		{
		m.disabled = true;
		r.disabled = true;
		zv.style.visibility = 'hidden';
		reset_multiselect('MestoZaposlenja');
		}
	}
/* SHOWHIDE GRADOVI */

/* PROVERA EMAIL */
function checkEmail(thisform)
{
	var obj=document.getElementById("umail");
	var apos=obj.value.indexOf("@");
	var dotpos=obj.value.lastIndexOf(".");
	if (obj.value == null || obj.value == "" || apos<1 || dotpos-apos<2) {
		alert("Morate upisati vaš email!");
		obj.focus();
		return false
	}
}
/* PROVERA EMAIL */

//IE6 link image flicker fix
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}
//IE6 link image flicker fix

/* SLANJE EMAIL-A */
function kontakt(user){
 window.location='mailto:'+user+'\@infostud.com';
}
/* SLANJE EMAIL-A */

function validateOnSubmit() 
{
	err = "";
	var f = document.form_pravnik;
	if(f.email.value=="")
		err = err + "Unesite email adresu\n";
	
	if(f.pitanje.value=="")
		err = err + "Upisite pitanje\n";

	if(err!="")
	{
		alert(err);
		return false;
	} else {
		return true;
	}
}

function toggleLayer(whichLink,whichLayer,whichImage) {

	if(document.getElementById(whichLayer).style.display)
	{
		document.getElementById(whichLayer).style.display = "";
		document.images[whichImage].src = "/img/minus.gif";//menja ikonicu
		document.getElementById(whichImage).alt = "Sakrij opcije";//tooltip IE
		document.getElementById(whichLink).title = "Sakrij opcije";//tooltip Mozilla, Opera
	} else {
		document.getElementById(whichLayer).style.display = "none";
		document.images[whichImage].src = "/img/plus.gif";//menja ikonicu
		document.getElementById(whichImage).alt = "Prikaži opcije";//tooltip IE
		document.getElementById(whichLink).title = "Prikaži opcije";//tooltip Mozilla, Opera
	}
	
	return false;
}

function validateOnSubmit() 
{
	err = "";
	var f = document.form_pravnik;
	if(f.email.value=="")
		err = err + "Unesite email adresu\n";
	
	if(f.pitanje.value=="")
		err = err + "Upisite pitanje\n";

	if(err!="")
	{
		alert(err);
		return false;
	} else {
		return true;
	}
}

// Tips
function showTip(nr)
    {
        if(document.getElementById("tip" + nr).style.display == "none")
            document.getElementById("tip" + nr).style.display = "block";
        else
            document.getElementById("tip" + nr).style.display = "none";
    } 

function email_valid(s) { 
//	var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; 
	var emailPattern = /^[a-zA-Z0-9]+[_a-zA-Z0-9-]*(\.[_a-z0-9-]+)*@[a-z0-9]+(-[a-z0-9]+)*(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/;
	return emailPattern.test(s); 
}

function KomentarKonkursa(posaoID){
	window.open("/inc/komentari/konkurs/unos.php?konkursID="+posaoID,"komentar","width=655,height=300,toolbars=0,scrollbars=1,resizable=0,locationbar=0,menubar=0,status=1,toolbar=0,left=150,top=50")
}


function initialize_jqm(jqm_window, jqm_trigger, jqm_link, jqm_response) {
		$(jqm_window).jqm({trigger: jqm_trigger, 
										onShow: function(hash){ 
											hash.w.html(jqm_loading_html).css('left', ($(window).width() - hash.w.width())/2).show();
											$.getJSON(jqm_link, function(response) {
												hash.w.html(response[jqm_response]).css('left', ($(window).width() - hash.w.width())/2).jqmAddClose('.jqmClose');	
												});
											}
										});
}

function center_jqm(jqsel) 
	{
	$(jqsel).css('left', ($(window).width() - $(jqsel).width())/2);	
	}

function setCaret(ctrl) {
	var pos = ctrl.value.length;
	if (ctrl.setSelectionRange)
		{
		ctrl.focus();
		ctrl.setSelectionRange(pos,pos);
		}
	else if (ctrl.createTextRange) {
		var range = ctrl.createTextRange();
		range.collapse(true);
		range.moveEnd('character', pos);
		range.moveStart('character', pos);
		range.select();
	}
}

function dump(arr,level) {
var dumped_text = "";
if(!level) level = 0;

//The padding given at the beginning of the line.
var level_padding = "";
for(var j=0;j<level+1;j++) level_padding += "    ";

if(typeof(arr) == 'object') { //Array/Hashes/Objects
 for(var item in arr) {
  var value = arr[item];
 
  if(typeof(value) == 'object') { //If it is an array,
   dumped_text += level_padding + "'" + item + "' ...\n";
   dumped_text += dump(value,level+1);
  } else {
   dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
  }
 }
} else { //Stings/Chars/Numbers etc.
 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
}
return dumped_text;
} 

/*http://www.learningjquery.com/2007/08/clearing-form-data :::: $('form').clearForm(); */
function clearForm(form) {
// iterate over all of the inputs for the form
// element that was passed in
$(':input', form).each(function() {
var type = this.type;
var tag = this.tagName.toLowerCase(); // normalize case
// it's ok to reset the value attr of text inputs,
// password inputs, and textareas
if (type == 'text' || type == 'password' || tag == 'textarea')
this.value = "";
// checkboxes and radios need to have their checked state cleared
// but should *not* have their 'value' changed
else if (type == 'checkbox' || type == 'radio')
this.checked = false;
// select elements need to have their 'selectedIndex' property set to -1
// (this works for both single and multiple select elements)
else if (tag == 'select')
this.selectedIndex = -1;
});
};


// Simple JavaScript Templating
// John Resig - http://ejohn.org/ - MIT Licensed
(function(){
  var cache = {};
 
  this.tmpl = function tmpl(str, data){
    // Figure out if we're getting a template, or if we need to
    // load the template - and be sure to cache the result.
    var fn = !/\W/.test(str) ?
      cache[str] = cache[str] ||
        tmpl(document.getElementById(str).innerHTML) :
     
      // Generate a reusable function that will serve as a template
      // generator (and which will be cached).
      new Function("obj",
        "var p=[],print=function(){p.push.apply(p,arguments);};" +
       
        // Introduce the data as local variables using with(){}
        "with(obj){p.push('" +
       
        // Convert the template into pure JavaScript
        str
          .replace(/[\r\t\n]/g, " ")
          .split("<%").join("\t")
          .replace(/((^|%>)[^\t]*)'/g, "$1\r")
          .replace(/\t=(.*?)%>/g, "',$1,'")
          .split("\t").join("');")
          .split("%>").join("p.push('")
          .split("\r").join("\\'")
      + "');}return p.join('');");
   
    // Provide some basic currying to the user
    return data ? fn( data ) : fn;
  };
})();


function handle_json_response(data)
			{
			if (data.a)
				$.each(data.a, function(k, v) 
					{ 
					if (v[0] == "appendF")
						$(v[1]).append(v[2]); 
					else if (v[0] == "removeF")
						$(v[1]).remove(); 
					else if (v[0] == "hideF")
						$(v[1]).hide(); 
					else if (v[0] == "slideDown")
						$(v[1]).slideDown(v[2]); 
					else if (v[0] == "slideUp")
						$(v[1]).slideUp(v[2]); 
					else if (v[0] == "showF")
						$(v[1]).show(); 
					else if (v[0] == "replaceWithF")
						$(v[1]).replaceWith(v[2]); 
					else if (v[0] == "htmlF")
						$(v[1]).html(v[2]); 
					else if (v[0] == "fadeOut")
						$(v[1]).fadeOut(v[2], function() { $(this).html(""); }); 
					else if (v[0] == "addClass")
						$(v[1]).addClass(v[2]); 
					else if (v[0] == "removeClass")
						$(v[1]).removeClass(v[2]); 
					else
						alert("Unhandled response type: "+ v[0]);
					});
			}

function htmlspecialchars_decode (string, quote_style) {
    // http://kevin.vanzonneveld.net
    // +   original by: Mirek Slugen
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Mateusz "loonquawl" Zalega
    // +      input by: ReverseSyntax
    // +      input by: Slawomir Kaniecki
    // +      input by: Scott Cariss
    // +      input by: Francois
    // +   bugfixed by: Onno Marsman
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
    // +      input by: Ratheous
    // +      input by: Mailfaker (http://www.weedem.fr/)
    // +      reimplemented by: Brett Zamir (http://brett-zamir.me)
    // +    bugfixed by: Brett Zamir (http://brett-zamir.me)
    // *     example 1: htmlspecialchars_decode("<p>this -&gt; &quot;</p>", 'ENT_NOQUOTES');
    // *     returns 1: '<p>this -> &quot;</p>'
    // *     example 2: htmlspecialchars_decode("&amp;quot;");
    // *     returns 2: '&quot;'

    var optTemp = 0, i = 0, noquotes= false;
    if (typeof quote_style === 'undefined') {
        quote_style = 2;
    }
    string = string.toString().replace(/&lt;/g, '<').replace(/&gt;/g, '>');
    var OPTS = {
        'ENT_NOQUOTES': 0,
        'ENT_HTML_QUOTE_SINGLE' : 1,
        'ENT_HTML_QUOTE_DOUBLE' : 2,
        'ENT_COMPAT': 2,
        'ENT_QUOTES': 3,
        'ENT_IGNORE' : 4
    };
    if (quote_style === 0) {
        noquotes = true;
    }
    if (typeof quote_style !== 'number') { // Allow for a single string or an array of string flags
        quote_style = [].concat(quote_style);
        for (i=0; i < quote_style.length; i++) {
            // Resolve string input to bitwise e.g. 'PATHINFO_EXTENSION' becomes 4
            if (OPTS[quote_style[i]] === 0) {
                noquotes = true;
            }
            else if (OPTS[quote_style[i]]) {
                optTemp = optTemp | OPTS[quote_style[i]];
            }
        }
        quote_style = optTemp;
    }
    if (quote_style & OPTS.ENT_HTML_QUOTE_SINGLE) {
        string = string.replace(/&#0*39;/g, "'"); // PHP doesn't currently escape if more than one 0, but it should
        // string = string.replace(/&apos;|&#x0*27;/g, "'"); // This would also be useful here, but not a part of PHP
    }
    if (!noquotes) {
        string = string.replace(/&quot;/g, '"');
    }
    // Put this in last place to avoid escape being double-decoded
    string = string.replace(/&amp;/g, '&');

    return string;
}

function jqm_message_show(message)
	{
	$('#jqm_message #jqm_message_container').html(message);
	$('#jqm_message').css('left', ($(window).width() - $('#jqm_message').width())/2).jqmAddClose('.jqmClose');
	$('#jqm_message').jqm().jqmShow();
	}
function jqm_message_queue(message)
{
    if($('#queue').length == 0)
    {
        $('body').append(message.holder);
    }
    $('#jqm_message_queue').jqm();       
    $('#jqm_message_queue #jqm_message_container_queue').html(message.content);
    $('#jqm_message_queue').css('left', ($(window).width() - $('#jqm_message_queue').width())/2).jqmAddClose('.jqmClose1');
}

function sacuvaj_konkurs_u_profil(posaoID)
	{
	$.blockUI({ message: null, fadeIn: 0, fadeOut: 0, overlayCSS:  {backgroundColor: '#F7F7F7', opacity: 0.6} }); 
	$.getJSON('/clanovi/sacuvaj_konkurs_u_profil.php?posaoID=' + posaoID, function(response){
	$.unblockUI({fadeIn: 0, fadeOut: 0}); 
		if (response.ok)
			{
			jqm_message_show(response.msg);
			setTimeout("$('#jqm_message').jqm().jqmHide();", 5000);
			}
		else
			{
			jqm_message_show(response.msg);
			}
		});
	}

function jqtools_tooltip(id, text, vertical, horisontal, offset_vertical, offset_horisontal)
	{
	var v = vertical || 'top';
	var h = horisontal || 'right';
	var ov = offset_vertical || 5;
	var oh = offset_horisontal || 0;
	
	$('body').append('<div class="help-tooltip" id="help_div_'+ id +'"><img src="/img/tooltips/formular-info-top_small_IE.png" /><div class="help-tooltip-content">' + text + '</div></div>');
	$('#' + id).tooltip({position: v + " " + h , delay: 0, offset: [ov, oh], effect: "toggle", opacity: 1, tipClass : 'help-tooltip', tip: '#help_div_' + id });
	}

function jqtools_tooltip_ajax(id, link, response_field, vertical, horisontal, offset_vertical, offset_horisontal)
	{
	var v = vertical || 'top';
	var h = horisontal || 'right';
	var ov = offset_vertical || 5;
	var oh = offset_horisontal || 0;

	//jqm_loading_html global definisan u head.inc
	var global_id = id;
	$('body').append('<div class="help-tooltip" id="help_div_'+ id +'"><img src="/img/tooltips/formular-info-top_small_IE.png" /><div class="help-tooltip-content" id="help_tooltip_content_' + id + '"></div></div>');
	$('#' + id).tooltip({position: v + " " + h, delay: 0, offset: [ov, oh], effect: "toggle", opacity: 1, tipClass : 'help-tooltip', tip: '#help_div_' + id, 
			onBeforeShow: function() { 
					$("#help_tooltip_content_"  + global_id).html(jqm_loading_html); 
					$.getJSON(link, {}, function(response) {
	                    $("#help_tooltip_content_"  + global_id).html(response[response_field]); 
					});
                }
		});
	}

function in_array (needle, haystack, argStrict) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: vlado houba
    // +   input by: Billy
    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
    // *     example 1: in_array('van', ['Kevin', 'van', 'Zonneveld']);
    // *     returns 1: true
    // *     example 2: in_array('vlado', {0: 'Kevin', vlado: 'van', 1: 'Zonneveld'});
    // *     returns 2: false
    // *     example 3: in_array(1, ['1', '2', '3']);
    // *     returns 3: true
    // *     example 3: in_array(1, ['1', '2', '3'], false);
    // *     returns 3: true
    // *     example 4: in_array(1, ['1', '2', '3'], true);
    // *     returns 4: false
    var key = '',
        strict = !! argStrict;

    if (strict) {
        for (key in haystack) {
            if (haystack[key] === needle) {
                return true;
            }
        }
    } else {
        for (key in haystack) {
            if (haystack[key] == needle) {
                return true;
            }
        }
    }

    return false;
}

function SetSelected(form,SelValue,Objname)
	{
	try
		{
		obj = form.elements[Objname];
		for (var i = 0; i < obj.options.length; i++) 
			{
		   	if (obj.options[i].value == SelValue)      
		   		{
			   	obj.options[i].selected = true;
				}
			}
		}
	catch (e)
	{
	
	}
}

function GetSelected(form,Objname)
	{
	var str = "";
	obj = form.elements[Objname];
	for (var i = 0; i < obj.options.length; i++) 
	{
	   if (obj.options[i].selected)      
	   {
		if (str=="") str = obj.options[i].value ;
				else str += "_" + obj.options[i].value ;
				
	   }
	}
	return(str);
	}

function grade(contentType, contentId, score)
	{
	$.getJSON('/ajaxgrade.php?content_type=' + contentType + '&content_id=' + contentId + '&grade=' + score, function(data){
		if (data.errors == 0)
			{
			$('#grade-'+contentId).hide();
			gradeOver('graded-'+contentId,data.average_star);
			$('#grade_value-'+contentId+' strong').text(data.average_decimal);
			$('#graded-'+contentId).show();
			}
		});
	}

function gradeOver(elem, which)
	{
	var x = 170 - which * 34;
	$('#'+elem).css('backgroundPosition','0 -' + x + 'px');
	return true;
	}


