function pageScroll() {
	scrolldelay = setTimeout('pageScroll()',100); // scrolls every 100 milliseconds
  if (document.getElementById("sendtofriend").style.display != 'none') {
   window.scrollBy(0,350); // horizontal and vertical scroll increments
   clearTimeout(scrolldelay);
  }  
}

$(document).ready(function(){
	
	$("#stabs").each(function()
	       {
           $(this).find( "a" ).click( chFastTab );
	       }
	);
	$("#s_country").each(function()
	       {
           $(this).change( chFastcountry );
	       }
	);
	
	$("#requestreview").click (function ()
		{
			$("#request").toggle();
		}
	);
	$("#sendfriend").click (function ()
		{
			$("#sendtofriend").toggle();
			pageScroll();
		}
	);
        $("#s_pricefrom, #s_priceto").click(function() {
                $(this).attr("value","");
        });	
	
});

function chFastTab(event)
{
 var all=$("#stabs li").size();	

 for(var i=0;i<all;i++) 
 	{
 	$("#stabs li strong").eq(i).replaceWith("<a href='javascript:;'><span>" + $("#stabs li strong span").eq(i).text() + "</span></a>");
 		$("#stabs li a").eq(i).click( chFastTab );
	}
$(this).replaceWith("<strong><span>" + $(this).text() + "</span></strong>");
var p=$("#stabs li strong").parent();
var sel1=p.attr("id");
var sel=sel1.split("_");

if(sel[1]==1)  $("#usluga").val("000_PROD");
if(sel[1]==2)  $("#usluga").val("000_OTDAVA");
if(sel[1]==3)  $("#usluga").val("");

$("#s_country").selectOptions("0");	
$("#s_grad").removeOption(/./);

$("#s_grad").ajaxAddOption("../include/scripts/_script_gradove.php",{},false,function() {
	});
}

function chFastcountry(event)
{

	$("#s_grad").removeOption(/./);
    $("#s_grad").ajaxAddOption("../include/scripts/_script_gradove.php",{"country" : $(this).val()},false,function() {
    	});
}

function request(url) {
		$("#request").load(url);
}

$(function() {
	$('a.bm, .smallim a, a.mp').lightBox();
});