$(document).ready( function(){


$(".myform").validate({
rules: {
   name: "required",
   dop_info: "required",
   elmail: {
    email: true,
	required: true
   }
  },
messages: {
   name: "Как к вам обращаться?",
   dop_info: "Что за материал вы высылаете?",
   elmail: {
    email: "Укажите правильный e-mail",
	required: "Укажите ваш e-mail"
   }
  },
  errorElement: "em"
});


	$("#arrright").click( function(){
	
		var max = $("#newslong > .onenews");
		max = (max.size() - 3)*-290;
				
		var l = parseInt($("#newslong").css("left"));
		
		if($("#newslong").is(":animated") == false){
			if(l > max){
				$("#newslong").animate({
					left: '-=290'
				}, 500);
			}
		}

	});
	
	$("#arrleft").click( function(){
	
		//var max = $("#newslong > .onenews");
		//max = (max.size() - 3)*-295;
				
		var l = parseInt($("#newslong").css("left"));
		
		if($("#newslong").is(":animated") == false){		
			if(l < 0){
				$("#newslong").animate({
					left: '+=290'
				}, 500);
			}
		};
		
	});
	
	$("#tal").click( function(){
	
		var a = $("#sact").attr("name");
		a = explode("_", a);
		var n = parseInt(a[1]) + 1;
	
		var size = $(".score").size();
		
		if(n<=size){
	
			$("#sact").fadeOut(500);
			$("#sact").attr("id","");
			//var nb = $(".score [name='"+n+"']");
			$("div [name='m_"+n+"']").fadeIn(500);
			$("div [name='m_"+n+"']").attr("id", "sact");
	
		};
		
		if(n == size){
		
			$(this).hide();
		
		};
		
		if(n < size){
			$(this).show();
			$("#tar").show();
		};
	
	});
	
	$("#tar").click( function(){
	
		var a = $("#sact").attr("name");
		a = explode("_", a);
		var n = parseInt(a[1]) - 1;
		//alert(n);
		if(n>=1){
	
			$("#sact").fadeOut(500);
			$("#sact").attr("id","");
			//var nb = $(".score [name='"+n+"']");
			$("div [name='m_"+n+"']").fadeIn(500);
			$("div [name='m_"+n+"']").attr("id", "sact");
	
		};
		
		if(n == 1){
		
			$(this).hide();
		
		};
		
		if(n > 1){
			$(this).show();
			$("#tal").show();
		};
	
	});

});

function explode( delimiter, string ) { // Split a string by string
    //
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: kenneth
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
 
    var emptyArray = { 0: '' };
 
    if ( arguments.length != 2
        || typeof arguments[0] == 'undefined'
        || typeof arguments[1] == 'undefined' )
    {
        return null;
    }
 
    if ( delimiter === ''
        || delimiter === false
        || delimiter === null )
    {
        return false;
    }
 
    if ( typeof delimiter == 'function'
        || typeof delimiter == 'object'
        || typeof string == 'function'
        || typeof string == 'object' )
    {
        return emptyArray;
    }
 
    if ( delimiter === true ) {
        delimiter = '1';
    }
 
    return string.toString().split ( delimiter.toString() );
}
