function photovideo(mark){
if (mark == "photo"){
document.getElementById('photoBlock').style.display="block"; document.getElementById('videoBlock').style.display="none";
document.getElementById('photo').src = "/img/01_44.png"; document.getElementById('video').src = "/img/01_46.png"; 
}
if (mark == "video"){
document.getElementById('videoBlock').style.display="block"; document.getElementById('photoBlock').style.display="none";
document.getElementById('photo').src = "/img/01_44a.png"; document.getElementById('video').src = "/img/01_46a.png";
}
}

function loginwi(){
var width=0;

IE = (document.all); // Internet Explorer?
NC = (document.layers); // Netscape?
Opera = (document.getElementById); // Opera?

if (IE || Opera) width = document.body.clientWidth;
if (NC) width = window.innerWidth;

width = (width/2) - 174;
document.getElementById('loginwindow').style.left=width;
document.getElementById('loginwindow').style.display="block";
}

function loginres(){
var width=0;

IE = (document.all); // Internet Explorer?
NC = (document.layers); // Netscape?
Opera = (document.getElementById); // Opera?

if (IE || Opera) width = document.body.clientWidth;
if (NC) width = window.innerWidth;

width = (width/2) - 174
document.getElementById('loginwindow').style.left=width;
}

var IE = document.all?true:false
document.onmousemove = getMouseXY


function tipgo(text){
document.getElementById('ttout').style.display="block";
document.getElementById('tiptext').innerHTML=text;

}
function tipout(){
document.getElementById('ttout').style.display="none";
}

function getMouseXY(e) {
if (IE) {
l = event.clientX + document.body.scrollLeft
t = event.clientY + document.body.scrollTop
}
else {
l = e.pageX
t = e.pageY
}
document.getElementById('ttout').style.left = l + "px"
document.getElementById('ttout').style.top = t + "px"
return true
}




var $main = jQuery.noConflict();

$main(document).ready(function()
{
	$main('.mback02 table').each(function()
	{
		if( $main(this).width() > 220 )
		{
			$main(this).width(210);
			
			$main('.mback02 .bullitTitle').css('margin-left','10px');
		}
	});


    var w = $main('.ann03 .highslide-gallery img.ima02:first').parents('.ann03').parent().find('.tback11').find('h1').html();
    if(w != null)
        w = w.toLowerCase();

    if( w == "фото" )
    {
    	$main('.ann03 .highslide-gallery img.ima02').load(function(){
            updateImages($main(this),120,115);
        });
        
        $main('.ann03 .highslide-gallery img.ima02').each(function(){
            updateImages($main(this),120,115);
        });
            
    }
    
    
    var w = $main('table.tback11 td.level01 h1').html();
    if(w != null)
        w = w.toLowerCase();

    if( w == "фото" )
    {
        $main('img.ima02').each(function()
        {
            if($main(this).attr('width') != "undefined")
            {
                $main(this).css('max-width',$main(this).attr('width')+'px');
                $main(this).removeAttr('width');
            }
            if($main(this).attr('height') != "undefined")
            {
                $main(this).css('max-height',$main(this).attr('height')+'px');
                $main(this).removeAttr('height'); 
            }
        });
    }



    
    

});


function updateImages(img,width,height)
{
    //var width	= 120,
	//	height	= 115;

	$main(img).removeAttr('width');
	$main(img).removeAttr('height');

    if($main(img).width() < width && $main(img).height() < height)
    {
        
    }
    else
	if( $main(img).width()/$main(img).height() > width/height )
	{
		$main(img).attr('width',width);
		new_height	= $main(img).height() * width / $main(img).width();
		$main(img).attr('height',new_height);
		var margin	= Math.round((height - new_height)/2);
		$main(img).css('margin-top',margin+'px' );
		$main(img).css('margin-bottom',margin+'px' );
	}
	else
	{
		$main(img).attr('height',height);
		new_width	= $main(img).width() * height / $main(img).height();
		$main(img).attr('width',new_width);
		$main(img).css('margin-top', '0px' );
	}
}
