function ProslediKontaktPoruku(){
	$('div#GreskaKontaktMejl2').css('display', 'none');
	$('div#GreskaKontaktMejl').css('display', 'none');
	$('div#UspehKontaktMejl').css('display', 'none');
	$.ajax({
		type: "POST",
		url: "Plugins/PLG_CON543/Ajax/PosaljiMail.php",
		data: $("form#KontaktForma").serialize(),
		cache: false,
		success: function(html){
			if(html == "1"){
				$('div#UspehKontaktMejl').css('display', 'block');
				clear_form_elements("form#KontaktForma");
			}
			if(html == "0"){
				$('div#GreskaKontaktMejl').css('display', 'block');
			}
			if(html == "2"){
				$('div#GreskaKontaktMejl2').css('display', 'block');
			}
		}
	});
}
function UkloniPorukuKontaktMejl(){
	$("div.PorukaKontaktMejl").slideUp("slow");
}
/*funkcija koja čisti formu*/
function clear_form_elements(ele) {
    $(ele).find(':input').each(function() {
        switch(this.type) {
            case 'password':
            case 'select-multiple':
            case 'select-one':
            case 'text':
            case 'textarea':
                $(this).val('');
                break;
            case 'checkbox':
            case 'radio':
                this.checked = false;
        }
    });
}
// -------------------------------------------------------------------
// gAjax RSS Feeds Displayer- By Dynamic Drive, available at: http://www.dynamicdrive.com
// Created: July 17th, 2007 Updated: n/a
// -------------------------------------------------------------------

var gfeedfetcher_loading_image="Images/loading.gif" //Full URL to "loading" image. No need to config after this line!!

google.load("feeds", "1") //Load Google Ajax Feed API (version 1)

function gfeedfetcher(divid, divClass, linktarget){
	this.linktarget=linktarget || "" //link target of RSS entries
	this.feedlabels=[] //array holding lables for each RSS feed
	this.feedurls=[]
	this.feeds=[] //array holding combined RSS feeds' entries from Feed API (result.feed.entries)
	this.feedsfetched=0 //number of feeds fetched
	this.feedlimit=5
	this.showoptions="" //Optional components of RSS entry to show (none by default)
	this.sortstring="date" //sort by "date" by default
	document.write('<div id="'+divid+'" class="'+divClass+'"></div>') //output div to contain RSS entries
	this.feedcontainer=document.getElementById(divid)
	this.itemcontainer="<li>" //default element wrapping around each RSS entry item
}

gfeedfetcher.prototype.addFeed=function(label, url){
	this.feedlabels[this.feedlabels.length]=label
	this.feedurls[this.feedurls.length]=url
}

gfeedfetcher.prototype.filterfeed=function(feedlimit, sortstr){
	this.feedlimit=feedlimit
	if (typeof sortstr!="undefined")
	this.sortstring=sortstr
}

gfeedfetcher.prototype.displayoptions=function(parts){
	this.showoptions=parts //set RSS entry options to show ("date, datetime, time, snippet, label, description")
}

gfeedfetcher.prototype.setentrycontainer=function(containerstr){  //set element that should wrap around each RSS entry item
this.itemcontainer="<"+containerstr.toLowerCase()+">"
}

gfeedfetcher.prototype.init=function(){
	this.feedsfetched=0 //reset number of feeds fetched to 0 (in case init() is called more than once)
	this.feeds=[] //reset feeds[] array to empty (in case init() is called more than once)
	this.feedcontainer.innerHTML='<img src="'+gfeedfetcher_loading_image+'" /> Retrieving RSS feed(s)'
	var displayer=this
	for (var i=0; i<this.feedurls.length; i++){ //loop through the specified RSS feeds' URLs
		var feedpointer=new google.feeds.Feed(this.feedurls[i]) //create new instance of Google Ajax Feed API
		var items_to_show=(this.feedlimit<=this.feedurls.length)? 1 : Math.floor(this.feedlimit/this.feedurls.length) //Calculate # of entries to show for each RSS feed
		if (this.feedlimit%this.feedurls.length>0 && this.feedlimit>this.feedurls.length && i==this.feedurls.length-1) //If this is the last RSS feed, and feedlimit/feedurls.length yields a remainder
			items_to_show+=(this.feedlimit%this.feedurls.length) //Add that remainder to the number of entries to show for last RSS feed
		feedpointer.setNumEntries(items_to_show) //set number of items to display
		feedpointer.load(function(r){displayer._fetch_data_as_array(r)}) //call Feed.load() to retrieve and output RSS feed
	}
}


gfeedfetcher._formatdate=function(datestr, showoptions){
	var itemdate=new Date(datestr)
	var parseddate=(showoptions.indexOf("datetime")!=-1)? itemdate.toLocaleString() : (showoptions.indexOf("date")!=-1)? itemdate.toLocaleDateString() : (showoptions.indexOf("time")!=-1)? itemdate.toLocaleTimeString() : ""
	return "<span class='datefield'>"+parseddate+"</span>"
}

gfeedfetcher._sortarray=function(arr, sortstr){
	var sortstr=(sortstr=="label")? "ddlabel" : sortstr //change "label" string (if entered) to "ddlabel" instead, for internal use
	if (sortstr=="title" || sortstr=="ddlabel"){ //sort array by "title" or "ddlabel" property of RSS feed entries[]
		arr.sort(function(a,b){
		var fielda=a[sortstr].toLowerCase()
		var fieldb=b[sortstr].toLowerCase()
		return (fielda<fieldb)? -1 : (fielda>fieldb)? 1 : 0
		})
	}
	else{ //else, sort by "publishedDate" property (using error handling, as "publishedDate" may not be a valid date str if an error has occured while getting feed
		try{
			arr.sort(function(a,b){return new Date(b.publishedDate)-new Date(a.publishedDate)})
		}
		catch(err){}
	}
}

gfeedfetcher.prototype._fetch_data_as_array=function(result){
	var thisfeed=(!result.error)? result.feed.entries : "" //get all feed entries as a JSON array or "" if failed
	if (thisfeed=="") //if error has occured fetching feed
		alert("Google Feed API Error: "+result.error.message)
	for (var i=0; i<thisfeed.length; i++) //For each entry within feed
		result.feed.entries[i].ddlabel=this.feedlabels[this.feedsfetched] //extend it with a "ddlabel" property
	this.feeds=this.feeds.concat(thisfeed) //add entry to array holding all feed entries
	this._signaldownloadcomplete() //signal the retrieval of this feed as complete (and move on to next one if defined)
}

gfeedfetcher.prototype._signaldownloadcomplete=function(){
	this.feedsfetched+=1
	if (this.feedsfetched==this.feedurls.length) //if all feeds fetched
		this._displayresult(this.feeds) //display results
}


gfeedfetcher.prototype._displayresult=function(feeds){
	var rssoutput=(this.itemcontainer=="<li>")? "<ul>\n" : ""
	gfeedfetcher._sortarray(feeds, this.sortstring)
	for (var i=0; i<feeds.length; i++){
		var itemtitle="<a href=\"" + feeds[i].link + "\" target=\"" + this.linktarget + "\" class=\"titlefield\">" + feeds[i].title + "</a>"
		var itemlabel=/label/i.test(this.showoptions)? '<span class="labelfield">['+this.feeds[i].ddlabel+']</span>' : " "
		var itemdate=gfeedfetcher._formatdate(feeds[i].publishedDate, this.showoptions)
		var itemdescription=/description/i.test(this.showoptions)? "<br />"+feeds[i].content : /snippet/i.test(this.showoptions)? "<br />"+feeds[i].contentSnippet  : ""
		rssoutput+=this.itemcontainer + itemtitle + " " + itemlabel + " " + itemdate + "\n" + itemdescription + this.itemcontainer.replace("<", "</") + "\n\n"
	}
	rssoutput+=(this.itemcontainer=="<li>")? "</ul>" : ""
	this.feedcontainer.innerHTML=rssoutput
}

function initialize() {
	var pozicijaFirme = new google.maps.LatLng($('#LongMapa').val(), $('#LatMapa').val());
	var infowindow = new google.maps.InfoWindow();
    var myOptions = {
      zoom: 14,
      center: pozicijaFirme,
	  navigationControlOptions: {style: google.maps.NavigationControlStyle.ANDROID},
      mapTypeId: google.maps.MapTypeId.HYBRID
    };
    var map = new google.maps.Map(document.getElementById("LokacijaGoogle"), myOptions);
	var marker = new google.maps.Marker({
      position: pozicijaFirme, 
      map: map, 
      title:"Opština Boljevac"
	});  
  }

function prikazistranicu(stranica, formname){
	var f=document.getElementById(formname);
	if(f){
		f.action = 'index.php?id=21&idpag='+stranica;
		f.submit();
	}
}
$(function() {
	$("ul.tabs").tabs("div.panes > div");
	if($("ul.tabs a").size() == 1){
		
	}else{
		$("div.panes").css("display", "none");
		$("ul.tabs a:first").removeClass("current");
	}
	$("ul.tabs").click(function(){
		if($("div.panes").is(":hidden")){
			$("div.panes").css("display", "block");
		}
	});
	$("ul.tabs a:first").click(function() {
		if(!$("div.panes").hasClass('current')){
			$("ul.tabs a:first").addClass("current");
		}
	});
});
function ObrisiBaner(idBaner, Redosled, Aktiv, idRed){
	jConfirm('Želite li da obrišete baner? ', 'Obaveštenje o akciji', function(r) {
		if(r){
			$.ajax({
			      type: "GET",
			      url: "../Plugins/PLG_SLIDER/Ajax/BrisanjeBanera.php",
			      data: "idbaner=" + idBaner + "&redosled=" + Redosled + "&active=" + Aktiv,
			      success: function(html) {
				      if(html == "1"){
				    	  $("tr.ListaBanera"+ idRed).fadeOut('slow');
				      }
				      if(html == "2"){
				    	  jAlert('Greška! Baner nije obrisan.', 'Obaveštenje o akciji');
				      }
				  }
			});
		}
	});
}
function ArhivirajBaner(idBaner, Redosled, idRed){
	jConfirm('Želite li da arhivirate baner? ', 'Obaveštenje o akciji', function(r) {
		if(r){
			$.ajax({
			      type: "GET",
			      url: "../Plugins/PLG_SLIDER/Ajax/ArhiviranjeBanera.php",
			      data: "idbaner=" + idBaner + '&redosled=' + Redosled,
			      success: function(html) {
				      if(html == "1"){
				    	  $("tr.ListaBanera"+ idRed).fadeOut('slow');
				      }
				      if(html == "2"){
				    	  jAlert('Greška! Baner nije arhiviran.', 'Obaveštenje o akciji');
				      }
				  }
			});
		}
	});
}
function AktivirajBaner(idBaner, idRed){
	$.ajax({
	      type: "GET",
	      url: "../Plugins/PLG_SLIDER/Ajax/AktivirajBanera.php",
	      data: "idbaner=" + idBaner,
	      success: function(html) {
		      if(html == "1"){
		    	  $("tr.ListaBanera"+ idRed).fadeOut('slow');
		      }
		      if(html == "2"){
		    	  jAlert('Greška! Baner nije aktiviran.', 'Obaveštenje o akciji');
		      }
		  }
	});
}
$(document).ready(function(){
	$("a.imgnav").css("opacity", "0.7");
	$("a.imgnav").mouseover(function(){
		$(this).stop(true, true).animate({
			opacity:1.0
		},500);
	});
	$("a.imgnav").mouseout(function(){
		$(this).animate({
			opacity:0.7
		},500);
	});
});

$(function() {
	$("ul.stattabs").tabs("div.statpanes > div");
});
function ObrisiVest(idVest, idRed){
	jConfirm('Želite li da obrišete vest? ', 'Obaveštenje o akciji', function(r) {
		if(r){
			$.ajax({
			      type: "GET",
			      url: "../Plugins/PLG_VESTIV/Ajax/BrisanjeVesti.php",
			      data: "idvest=" + idVest,
			      success: function(html) {
				      if(html == "1"){
				    	  $("tr.ListaVesti"+ idRed).fadeOut('slow');
				      }
				      if(html == "2"){
				    	  jAlert('Greška! Vest nije obrisana.', 'Obaveštenje o akciji');
				      }
				  }
			});
		}
	});
}
function ArhivirajVest(idVest, idRed){
	jConfirm('Želite li da arhivirate vest? ', 'Obaveštenje o akciji', function(r) {
		if(r){
			$.ajax({
			      type: "GET",
			      url: "../Plugins/PLG_VESTIV/Ajax/ArhiviranjeVesti.php",
			      data: "idvest=" + idVest,
			      success: function(html) {
				      if(html == "1"){
				    	  $("tr.ListaVesti"+ idRed).fadeOut('slow');
				      }
				      if(html == "2"){
				    	  jAlert('Greška! Vest nije arhivirana.', 'Obaveštenje o akciji');
				      }
				  }
			});
		}
	});
}
function AktivirajVest(idVest, idRed){
	jConfirm('Želite li da aktivirate vest? ', 'Obaveštenje o akciji', function(r) {
		if(r){
			$.ajax({
	        type: "GET",
	        url: "../Plugins/PLG_VESTIV/Ajax/AktivirajVest.php",
	        data: "idvest=" + idVest,
	        success: function(html) {
		        if(html == "1"){
					$("tr.ListaVesti"+ idRed).fadeOut('slow');
				}
				if(html == "2"){
					jAlert('Greška! Vest nije aktivirana.', 'Obaveštenje o akciji');
				}
		        }
	       });
		}
	});
}


