function substr (str, start, len) {    str += '';    var end = str.length;    if (start < 0) {    	start += end;    }    end = typeof len === 'undefined' ? end : (len < 0 ? len + end : len + start);    return start >= str.length || start < 0 || start > end ? !1 : str.slice(start, end);}$(document).ready(function(){	$('#car').add('#sputnic').bind('mouseenter', function(){  		$('#sputnic').show();    });	$('#car').add('#sputnic').bind('mouseleave', function(){  		$('#sputnic').hide();    });    $('#showsub').add('#submenu').bind('mouseenter', function(){  			$('#submenu').show();    });    $('#showsub').add('#submenu').bind('mouseleave', function(){  			$('#submenu').hide();    });    $('#newsright').click(function(){    		var ajaxflag = false;    		var id = false;			$('#newsleft').hide();			$('#newsright').hide();			$('.news > div:visible:last + div').each(function () {    			$('.news > div:visible:first').each(function () {					$(this).hide();    			});    			$('.news > div:visible:last + div').each(function () {					$(this).show();					id = parseInt(substr(($(this).attr('id')),4));					id = id + 1;                    var flag = true;                    $("div[id='new_"+id+"']").each(function () {                    	flag = false;                    });                    if (flag) {                    	var count = parseInt($('#count_news').attr('value'));                    	if (id<=count) {							$('#newsright').before('<div id="new_'+id+'" style="display:none;"><img src="i/ajax-loader2.gif" alt="загрузка..." class="imgcenter"/></div>');							ajaxflag = true;						}					}    			});    			$('#newsleft > img').attr("src","i/left_arrow.png");    			flag=true;    			$('.news > div:visible:last + div').each(function () {    				flag = false;				});				if (flag) {            		$('#newsright > img').attr("src","i/right_arrow_current.png");				}    		});			$('#newsleft').show();			$('#newsright').show();			if (ajaxflag) {   				$.ajax({					type: "POST",					url: '/getnew/',					dataType: 'html',					cache: 'false',					data: {id: id},					success: function onAjaxSuccess(html) {						$("#new_"+id).empty();						$("#new_"+id).append(html);					} 	  			})			}			return false;    });    $('#newsleft').click(function(){			$('#newsleft').hide();			$('#newsright').hide();			$('.news > div:first:hidden').each(function () {    			$('.news > div:visible:last').each(function () {					$(this).hide();    			});    			$('.news > div:visible:first').prev().each(function () {					$(this).show();    			});    			$('#newsright > img').attr("src","i/right_arrow.png");    			var flag=true;    			$('.news > div:first:hidden').each(function () {    				flag = false;				});				if (flag) {            		$('#newsleft > img').attr("src","i/left_arrow_current.png");				}    		});			$('#newsleft').show();			$('#newsright').show();			return false;    });});
