function test(i,w){	//alert(w)	var $w = parseInt(i.offsetWidth);	var $h = parseInt(i.offsetHeight);	var $b = parseInt($('body').width());	var $bh = parseInt(window.innerHeight?window.innerHeight:document.documentElement.clientHeight);	//alert($bh);	var $l = parseInt($(i).css('left'));	var $t = parseInt($(i).css('top'));	$sum = $w +  $l;	$sum2 = $h + $t;	$scTop = window.scrollY?window.scrollY:document.documentElement.scrollTop;	//alert($bh)	//alert($sum2)	//alert($t)	if($sum > $b )	{		$(i).css({'left' : 'auto', 'right':$b-w-$l-4})	}		if($sum2 > ($bh+$scTop))	{			$(i).css({'top' : $t-($sum2-$bh-$scTop)})	}	//document.onmouseout=function(event){if($(i)[0]==(event?event.target:window.event.srcElement)){$(i).remove(); alert(event.type)}}			}function getTop(e) {	var top = e.offsetTop; 	while (e.offsetParent) {						e = e.offsetParent; 		top += e.offsetTop; 	}	return top; }function getLeft(e) {	var left = e.offsetLeft; 	while (e.offsetParent) {		e = e.offsetParent; 		left += e.offsetLeft; 	}	return left; }function slideSwitch() {    var $active = $('#slideshow IMG.active');    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');$active.removeClass('active')    // use this to pull the images in the order they appear in the markup    var $next =  $active.next().length ? $active.next()        : $('#slideshow IMG:first');    // uncomment the 3 lines below to pull the images in random order        // var $sibs  = $active.siblings();    // var rndNum = Math.floor(Math.random() * $sibs.length );    // var $next  = $( $sibs[ rndNum ] );    $active.addClass('last-active');    $next.css({opacity: '0'})        .addClass('active')        .animate({opacity: 1.0}, 1000, function() {            $active.removeClass('active last-active').css({'opacity':'0'});        });}$(function(){			   		if($('#svitok').length){			$('body').addClass('color');		}	setInterval( "slideSwitch()", 3500 );	$('img').each(function(){$(this)[0].alt=='я'?$(this)[0].alt='':''})	// Кусок скрипта для ссылок на фотки в контекстах	$('img').each(function(){		var $obj = $(this);		if($obj.parent('a').length>0 &&  $obj.parents('#imgs').length == 0 && $obj.parents('div.img2').length==0 && $obj.parents('ul.li-prev3').length ==0 && !$obj.hasClass('big-img') && $obj.parents('ul.li-prev2').length == 0 && $obj.parents('#imgs2').length == 0 && $obj.parents('ul.li-prev').length==0 && $obj.parents('#img4').length == 0 ) { 			if(  $obj.parent('a').attr('href').indexOf('.jpg')>0 ){				$obj.parent('a').mouseover(function(){					var $w = parseInt($obj.width()); 												$('body').find('img#popup').remove().end().append('<img id="popup" onload="test(this,'+$w+'); $(this).removeClass(\'hide\')" class="popup b-i hide" src="'+$obj.parent('a').attr('href')+'" alt="" style="position:absolute;z-index:1000;top:'+getTop($obj[0])+'px; left:'+getLeft($obj[0])+'px"/>');										$('img.popup').mouseout(function(){$(this).remove()});															//$('body').mousemove(function(event){event.target!=$('img.popup')?$('img.popup').remove():''; })																			});					}		} else if($obj.parents('div.img2').length > 0 || $obj.parents('div.img3').length > 0 ) {			if(  $obj.parent('a').attr('href').indexOf('.jpg')>0 ){				$obj.parent('a').click(function(){					var $w = parseInt($obj.width()); 												$('body').find('img#popup').remove().end().append('<img id="popup" onload="test(this,'+$w+'); $(this).removeClass(\'hide\')" class="popup b-i hide" src="'+$obj.parent('a').attr('href')+'" alt="" style="position:absolute;z-index:1000;top:'+getTop($obj[0])+'px; left:'+getLeft($obj[0])+'px"/>');										$('img.popup').mouseout(function(){$(this).remove()});										return false;				});					}		}			});		$('a.name').click(function(){		var $obj = $(this);		$obj.parents('div.w-320').find('img.big-img').attr('src',$obj.attr('href'));		return false;							});			$('#imgs a,#imgs2 a').click(function(){		var $obj = $(this);		$('#popup').remove();		$('body').append('<div id="popup" style="position:fixed!important; z-index:100; top:0; left:0; width:100%; height:100%;"><table class="spec" style="width:100%; height:100%;"><tr><td style="vertical-align:middle; text-align:center"><a style="color:#000; display:inline-block; position:relative; " onmouseout="$(this).parents(\'#popup\').remove();" onclick="return false;" href="#"><div style="position:absolute; right:10px; background:#fff; font-size:16px; padding:5px; top:10px;">'+$obj.text()+'</div><img src="'+$obj[0].href+'" alt="" class="b-i" /></a></td></tr></table></div>')		return false;	});			// Кусок скрипта для табов в портфолио		$('ul.li-tabs a').live('click',function(){		var $obj = $(this);		var $act = $obj.parents('ul.li-tabs').find('li.act');		var $tab = $obj.parent().parents('li').find('div.tab');		var $acttab = $tab.filter('.act-tab');		$acttab.removeClass('act-tab');		$act.removeClass('act').html('<a href="#" rel="'+$acttab.attr('class').split(' ')[0]+'">'+$act.text()+'</a>');		$tab.addClass('hide');				$obj.parent('li').addClass('act').html($obj.text());		$tab.filter('.'+$obj.attr('rel')).removeClass('hide').addClass('act-tab');		return false;	});			// Кусок скрипта для фоток 9 штук с каруселью	$('div.jcarousel').each(function(){		var $obj = $(this);				 		var $next = $('a.next',$obj);		var $prev = $('a.prev',$obj);		var $n = 0;		var $uls = $obj.find('ul.li-prev3');		var $ouls = $obj.find('div.o-ul');		$ouls.css({width:$uls.length*320+'px'});		$uls.each(function(n){			var $ul = $(this);			$ul.attr('num',n);				});				$next.click(function(){								if($n<($uls.length-1))						{				$obj.find('ul.li-prev3[num='+$n+']').animate({marginLeft:'-320px',opacity:'0'},1000,function(){ $(this).addClass('hide').css({opacity:'1',marginLeft:'0'})});							} 			$n++;			if($n==0)					$prev.addClass('hide');				else 				$prev.removeClass('hide');			if($n==($uls.length-1))						$next.addClass('hide');				else 				$next.removeClass('hide');				return false;		});				$prev.click(function(){			if($n!=0) {				$obj.find('ul.li-prev3[num='+($n-1)+']').removeClass('hide').css({marginLeft:'-320px', opacity:'0'}).animate({marginLeft:'0',opacity:'1'},1000);						}			$n--;			if($n==0)					$prev.addClass('hide');				else 				$prev.removeClass('hide');			if($n==($uls.length-1))						$next.addClass('hide');				else 				$next.removeClass('hide');						return false;		});			});	$('ul.li-prev a').mouseover(function(){		var $obj = $(this);		$obj.parents('ul.li-prev').find('img.pop2').remove().end().append('<img onmouseout="$(this).remove()" class="pop2" src="'+$obj.attr('href')+'" alt="" style="position:absolute; top:-3px; right:-4px; " />');	});	// это я уже не помню что	$('ul.li-prev2 a').click(function(){		var $obj = $(this);		var $img = $obj.parents('div.img3').find('img.big-img');				$img.attr('src',$obj.attr('href'));				return false;	});	$('ul.li-prev3 a').click(function(){		var $obj = $(this);		var $img = $obj.parents('div.tab').find('img.big-img');				$img.attr('src',$obj.attr('href')).parent('a').attr('href',$obj.attr('rel'));				return false;					});											  });