jQuery.fn.extend({
maxTabs: function(){

 // this.each(function(){console.log(this);});
  this.each(function(){ createOneTab(this); });

  return;


  function createOneTab(container){
    var obj = container.jQuery?container:$(container);
    var elements = $('>.tab-body > .tab-body-element ',container);
    //console.log(elements[0]);
    //console.log(elements);
    elements.css({display:'none'});
    //$(elements[0]).css({display:'block'});

    var handles = $('>.tab-header > .tab-handle',container);
    handles.each(function(index,handle){
        var bodies = elements;
        var me = handle;
        me.idx = index;
        var siblings = handles;
        $(me).click(
          function(){
            bodies.css({display: 'none'});
            $(bodies[this.idx]).css({display:'block'});
            handles.removeClass('active-tab-handle');
            $(this).addClass('active-tab-handle');
          }
        );
    });

    $(handles[0]).click();

  }
 // this.each(createOneTab);
}
});

//---------------------------
function checkForm(stat, idForm, page)
	{
		var stat, idForm, page;
		var redy = 0;
		var errColor = '#e3c2c2';
		var goColor = '#c4f5b8';
		
		$("div#"+idForm+" input").not("[type=button]","[name=email]").each(function(){
			if($.trim($(this).val()) == "")
				{	
					$(this).css({
						backgroundColor:errColor
					});
					
					redy++;
				}
			else
				{
					$(this).css({
						backgroundColor:goColor
					});
				}
				
		});
		
		if($.trim($('div#'+idForm+' textarea').val()) == '')
			{
				$('div#'+idForm+' textarea').css({
						backgroundColor:errColor
					});
					
					redy++;
			}
		else
			{
				$('div#'+idForm+' textarea').css({
						backgroundColor:goColor
					});
			}
			
		var emailValue = $('div#'+idForm+' input[name=email]').val().split('@');
		
		if($.trim(emailValue[1]) == '')
			{
				$('div#'+idForm+' input[name=email]').css({
						backgroundColor:errColor
					});
					
					redy++;
			}
		else
			{
				$('div#'+idForm+' input[name=email]').css({
						backgroundColor:goColor
					});
			}

			
		if(redy == 0)
			{
				var name = $('div#'+idForm+' input[name=fio]').val();
				var email = $('div#'+idForm+' input[name=email]').val();
				var telefon = $('div#'+idForm+' input[name=phone]').val();
				var company = $('div#'+idForm+' input[name=comp]').val();
				var text = $('div#'+idForm+' textarea[name=message]').val();
				
				$.post("../mailSender/", {name:name, telefon:telefon, email:email, company:company, text:text, subj:stat, page:page}, function(){
					
					$('div#'+idForm+' div#redy').html('');
					$('div#'+idForm+' table#sended').css({
						display: 'block'
					});
					
					});
			}
	}
//--------------------

//---------------------------
function uniSender(stat, idForm)
	{
		var stat, idForm;
		var redy = 0;
		var errColor = '#e3c2c2';
		var goColor = '#c4f5b8';
		
		$("div#"+idForm+" input").not("[type=button]","[name=email]").each(function(){
			if($.trim($(this).val()) == "")
				{	
					$(this).css({
						backgroundColor:errColor
					});
					
					redy++;
				}
			else
				{
					$(this).css({
						backgroundColor:goColor
					});
				}
				
		});
			
		var emailValue = $('div#'+idForm+' input[name=email]').val().split('@');
		
		if($.trim(emailValue[1]) == '')
			{
				$('div#'+idForm+' input[name=email]').css({
						backgroundColor:errColor
					});
					
					redy++;
			}
		else
			{
				$('div#'+idForm+' input[name=email]').css({
						backgroundColor:goColor
					});
			}

			
		if(redy == 0)
			{
				var name = $('div#'+idForm+' input[name=fio]').val();
				var email = $('div#'+idForm+' input[name=email]').val();
				var company = $('div#'+idForm+' input[name=comp]').val();
				var oldText = $('div#'+idForm+' table#sended td').html();
				
					$('div#'+idForm+' div#redy').html('');
					$('div#'+idForm+' table#sended td').html('Пожалуйста подождите...');
					$('div#'+idForm+' table#sended').css({
						display: 'block'
					});
				
				$.post("../uniSender/", {name:name, email:email, company:company}, function(){
					
					$('div#'+idForm+' table#sended td').html(oldText);
				});

			}
	}
//--------------------
