var najdiprevoz = {
    getregion: function(data)
    {
		data = data.replace("{", "");
		data = data.replace("}", "");
		data = data.split(",");
//		var u = "categoryid=" + categoryid;
		var l = new Array();
		for(i=0;i<data.length;i++)
		{
	    	var ui = data[i].split(":");
//	    	u = u + "&id[]=" + ui[1];
	    	l[i] = ui[1];
		}
		var lang = (langflag) ? langflag : "en";
		var link = "/" + lang + sitelink + countryid + "/" + l.join(",") + "/";		
		window.location = link;
		
/*		$.ajax({
	    	type: "POST",
	    	url: "/" + lang + "/ponudniki/ajax?&c=" + countryid,
	    	data: u,
	    	success: function(data)
	    	{
				$("#bidderslist").html(data);
	    	}
		});*/
    },
    getcountry: function(id)
    {
/*		if(id==46)
		{
	    	$("#sloregions").show();
		} else {
	    	$("#sloregions").hide();
		}
		
		if(id==13)
		{
	    	$("#deregions").show();
		} else {
	    	$("#deregions").hide();
		}
*/		
		countryid = id;
		var lang = (langflag) ? langflag : "en";
		window.location = "/" + lang + sitelink + countryid;
/*		$.ajax({
	    	type: "GET",
	    	url: "/" + lang + "/ponudniki/ajax/?&c=" + id,
	    	success: function(data)
	    	{
			$("#bidderslist").html(data);
	    	}
		});*/
    }
}

function theRotator() {
	//Set the opacity of all images to 0
	$('div#rotator ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('div#rotator ul li:first').css({opacity: 1.0});
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('rotate()',5000);
	
}

function rotate() {	
	//Get the first image
	var current = ($('div#rotator ul li.show')?  $('div#rotator ul li.show') : $('div#rotator ul li:first'));

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#rotator ul li:first') :current.next()) : $('div#rotator ul li:first'));	
	
	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 2000);

	//Hide the current image
	current.animate({opacity: 0.0}, 2000)
	.removeClass('show');
	
};

$(document).ready(function(){


	//Load the slideshow
	theRotator();
	
	//Vertical Ticker
	$('.home-ticker').vTicker({
	speed: 700,
	pause: 3500,
	showItems: 1,
	animation: 'fade in',
	mousePause: true,
	height: 0,
	direction: 'up'
	});

	$('#tickerLoad').hover(function() {
	$(this).css('cursor','pointer');
	}, function() {
	$(this).css('cursor','auto');
	});

	$('#tickerLoad').click(function() {
	window.location = 'borza/seznam/tovor/';
	});

	$('#tickerRides').hover(function() {
	$(this).css('cursor','pointer');
	}, function() {
	$(this).css('cursor','auto');
	});

	$('#tickerRides').click(function() {
	window.location = 'borza/seznam/voznje/';
	});

});

function setlang(id)
{
    $.ajax({
	type: "GET",
	url: "/borza/jezik/?&id=" + id,
	success: function(data)
	{
	    window.location.reload();
	}
    });
}

var photos = {
	show: function(link)
	{
    	$.ajax({
		type: "GET",
		url: link,
		success: function(data)
		{
	    	$("#photos").html(data);
		}
    	});
	},
	mainphoto: function(link,id)
	{
    	$.ajax({
		type: "GET",
		url: link + "mainphoto/" + id + "/",
		success: function(data)
		{
	    	photos.show(link);
		}
    	});
	},
	delphoto: function(link,id)
	{
    	$.ajax({
		type: "GET",
		url: link + "delphoto/" + id + "/",
		success: function(data)
		{
	    	photos.show(link);
		}
    	});
	}
}

function askwindow(url)
{
return window.open(url,'voznje','toolbar=0,scrollbars=0,location=0,status=1,statusbar=1,menubar=0,resizable=0,width=810,height=560');
}
