$(document).ready(function() {
	//var ip = '<!--#echo var="REMOTE_ADDR"-->';	//alert(ip);

        

	if ($('#lang').html()!=undefined){
	$('#lang ul#languages li a').click(function(){
		var lang = $(this).html();
		//alert(lang);
		$.get("/backend/lang?lang="+lang, function(data) {
			//alert(data);
			location.reload();					
		});		

	
	});
	}

	var href = window.location.pathname;		
	var href = href.replace('/','');		

	$.get('/backend/ajax?hash=1'+'&href='+href, function(data) {//		alert(data);
			$('#main-image').html('<img src="'+data+'" border="0" />');		
	});	

	$('#more_photos img').click(function(){
		var url = $(this).parent().attr('href');
		var hash = url.substring(url.indexOf('#'));
		var hash = hash.replace('#','');
		if (hash == undefined) hash = 1;
		var href = window.location.pathname;		
		var href = href.replace('/','');		
		$.get('/backend/ajax?hash='+hash+'&href='+href, function(data) {
			$('#main-image').html('<img src="'+data+'" border="0" />');		
		});

    $.getJSON("http://jsonip.appspot.com?callback=?",function(data){
		var hs = $('.art-post-body').height();
		$('#submenu').height(hs);
    });		
	});
	
	$('#more_photos img').show(function(){
    	$.getJSON("http://jsonip.appspot.com?callback=?",function(data){
			var hs = $('.art-post-body').height();
			$('#submenu').height(hs);
    	});			
	});
	var hash = '';
	$('#hash').html(hash);
	
	$('.art-post-body').resize(function(){
		var hs = $('.art-post-body').height();
		$('#submenu').height(hs);
	});
    
	var hs = $('.art-post-body').height();
	$('#submenu').height(hs);    	
	
	var h = $('#page').height();
	//$('#page').find('#container').each(function(){
	
		var container = $('#container').height();
		var top = $('#body-top').height();
		var header = $('#header').height();
		var footer = $('#footer').height();
		
		if (h - top-header-footer > container) {
			$('#container').height(h - top-header-footer + 10); 
		}
		
		$('#content').css('margin-bottom',105);
		$('#logosy').css('position','absolute');
		$('#logosy').css('bottom',50);
		
	//});
	
	var item = $('#galery-block-items').html();
	if (item == undefined) item = 2;
	

	
	var html = $('#header ul.navigation li.active').html();
	html = '<div id="mark-menu"><img src="/images/menu-mark.jpg" alt="" title="" /></div>'+html; 
	$('#header ul.navigation li.active').html(html);
	//var w = $('#header ul.navigation').find('li.active').width();
	
	$('#header ul.navigation li').find('#mark-menu').each(function(){
		
		var w = $(this).parent().width();
		var w = Math.round(w / 2);
		
		if (w > 300) w = 25;
		
		$(this).css('left',w);
	});
	
	



 
 $('.two-columns-page td').each(function(){
	 var w = $(this).width();
	 
	 var img_w = $(this).find('img').width();
	 var img_h = $(this).find('img').height();
	 var h = w*img_h/img_w;
	 if (img_w > w){
		 $(this).find('img').width(w);
		 $(this).find('img').height(h);
	 }
 });

	
 
	//alert(w);
});


