// JavaScript Document

// no PHP patiešo iegutos datus varam parverst objektos.
function json_decode(jsonstr) {
	data = eval('('+jsonstr+')');
	return data;
}


// extendojam jquery.. tipa generejam pogu ar noapalotiem sturiem.
// jaizsauc šadi: 
// $('#atlasitbutton').createGreenButton('Atlasit!', 'document.searchform.submit();');
jQuery.fn.extend({
	createGreenButton: function(title, oclick) {
		
		this.html('');
		
		buttonhtml = 
		'<div style="width:5px; height:22px; background-image:url(/static/img/greenbutton_left.gif); background-repeat:no-repeat; float:left;"></div>'+
		'<div class="greenbg" style="font-size:0.9em; color:white; float:left; height:22px; line-height:20px; vertical-allign:middle; padding-left:8px; padding-right:8px;">'+title+'</div>'+
		'<div style="width:5px; height:22px; background-image:url(/static/img/greenbutton_right.gif); background-repeat:no-repeat; float:left;"></div>'+
		'<br clear="all" />';

		this.html(buttonhtml);
		
		if(typeof(oclick)=='undefined') {
			this.unbind('click'); //nonemam visus klikus nost
			//this.unbind('mouseover');
			//this.unbind('mouseout');
			this.mouseover(function(){this.style.cursor = 'default';});
			//this.mouseout(function(){this.style.cursor = 'default';});
		} else {			
			this.mouseover(function(){this.style.cursor = 'pointer';});
			this.mouseout(function(){this.style.cursor = 'default';});
			this.click(function() {eval(oclick);});
		}
	}
});


