$(document).ready(function(){
	//$(".lightbox").lightbox({ fitToScreen : true });
	//$(document).pngFix({blankgif: 'images/blank.gif'}); 
	$('#short_info').expander({
		slicePoint: 300,
		expandText: 'още',
		userCollapseText: ''
		
	});

	
	$('.clr').click( function() {
		$(this).attr('value', '');
	});
	
	$('.title').click( function(){
		var id = $(this).attr('id').split('_')[1] ;
		
		$('.hide').hide(200);
		
		$el = $('.show' + id );
		
		if ( $el.is(':hidden') ) {
			$el.show(200);
		} else {
			$el.hide(200);
		}
		
	});
	
	$('#weather_city').change( function(){
		getWeather( $(this).val() );
	});
	
	getWeather(3);
	
});

function getWeather( cityID ) {
	
	var lang  = getUriSigment(1);
	
	if ( lang == '' ) {
		lang = 'ru';
	}
	
	$.getJSON( lang + '/eur/ajax/getweather/' + cityID, function( data ){
		$('#weather p.img').css({'background-image':'url(images/weather/' + data.cond_number + 'd.png)'});
		$('#weather p.temp').html( data.temp + '&deg;');
		$('#weather p.cond').html( data.conditions );
	});
}

function getUriSigment( num ) {
	var uri = window.location;
	var base = $('base').attr('href');
	
	uri += '';
	var sigments = uri.replace( base, "");
	
	num--;
	
	return sigments.split('/')[num];
}


