$(document).ready(function(){
 
   $('select [title]').tipsy({trigger: 'focus', gravity: 's'});
   $('#leftc [title]').tipsy({trigger: 'focus', gravity: 'w'});
   $('#bizoffer [title]').tipsy({trigger: 'focus', gravity: 'e'});
	$('#mapform [title]').tipsy({trigger: 'focus', gravity: 's'});
	$('#accmore [title]').tipsy({trigger: 'focus', gravity: 'n'});
	$('#resize [title]').tipsy({trigger: 'focus', gravity: 's'});
	$('#c [title]').tipsy();

	


//   Image preview
$("ul.thumb li").hover(function() {
	$(this).css({'z-index' : '10'});
	$(this).find('img').addClass("hover").stop()
		.animate({
			marginTop: '-40px', 
			marginLeft: '-40px', 
			top: '50%', 
			left: '50%', 
			width: '70px', 
			height: '70px',
			padding: '10px' 
		}, 200);
	
	} , function() {
	$(this).css({'z-index' : '0'});
	$(this).find('img').removeClass("hover").stop()
		.animate({
			marginTop: '0', 
			marginLeft: '0',
			top: '0', 
			left: '0', 
			width: '50px', 
			height: '50px', 
			padding: '5px'
		}, 400);
});

//Swap Image on Click
	$("ul.thumb li a").click(function() {
		var mainImage = $(this).attr("atr"); //Find Image Name
            $("#oimages img").hide();
//            $('#oimages').removeClass('loading').append(this);
            $("#oimages img").fadeIn();

		$("#oimages img").attr({ src: 'imoti/pics/thumbs/medium-' +  mainImage });
		$("#oimages a").attr({ href: 'imoti/pics/' +  mainImage });		
		return false;		
	});


// contact 
	  $('#writeA').click(function() {
	  $("#contform").show("fast");
	  });

	  $('#write').click(function() {
	  $("#contform").show("fast");
	  });

// show class bar

	  $('#ctitlemore').click(function() {
	  $("#allclas").toggle("fast");
	  });


/* change text comment  */
var deft = $("#comments #ncom").text();
$("#comments #ncom").hover(function(){
	$(this).text("добави нов");
}, 
function(){
	$(this).text(deft);

});


/* scrolls */

	$('#ncom').click(function(){
		
		$("#comboxAA").show("fast");		
		$.scrollTo( '#comboxAA', 1200);
		//$("#otherF").show("fast");
	});


	$('#adcom').click(function(){
		$("#comboxAA").show("fast");		
		$.scrollTo( '#comboxAA', 1200);
		//$("#otherF").show("fast");
	});

	$('#adcoms').click(function(){
		$("#comboxAA").show("fast");		
		//$("#comment").focus();
		$.scrollTo( '#comboxAA', 1200);
		//$("#otherF").show("fast");
	});	
	
/* comment options */	
	$('#comment').click(function(){
		$("#otherF").show("fast");
	});

/* news fades */	
	/*
	$('#rightc #rln').click(function(){
		$("div[si=L]").slideDown("slow");
		$("div[si=C]").hide("slow");
		
		
		


		
	});

	*/
	
	
	
	$('#rightc #rln').click(function(){
		$("div[si=L]").slideDown("slow");
		$("div[si=C]").hide("slow");
		
		$("#rln").removeClass("neotr");
		$("#rln").addClass("actu");
		$("#rcn").removeClass("actu");
		$("#rcn").addClass("neotr");
	});
	
	$('#rightc #rcn').click(function(){
		$("div[si=L]").hide("slow");
		$("div[si=C]").slideDown("slow");
		$("#rcn").removeClass("neotr");
		$("#rcn").addClass("actu");

		$("#rln").removeClass("actu");
		$("#rln").addClass("neotr");
	});


	


/* font size */

		var resetfontsize = 13;
		$('#resize a').click(function(){
			var mt = $('#news');
			var currFontSize = mt.css('fontSize');
			var finalNum = parseFloat(currFontSize, 10);
			var stringEnding = currFontSize.slice(-2);
			if(this.id == 'large') {
				finalNum *= 1.2;
			}
			else if (this.id == 'small'){
				finalNum /=1.2;
			}
			else if (this.id == 'reset'){
				finalNum = resetfontsize;
			}

			mt.css('fontSize', finalNum + stringEnding);
		});







// EOF document.ready

});


function rygai_kvartali(id) {  
	$.ajax({
	  url: 'imoti/service.php?p=load_subregionsB&id='+id,
	  success: function(data) {
	    $('#kvartalen').html(data);
	    //alert('Load was performed.');
	  }
	});
}  