function checkform ( obj ){
  for ( var i=0; i<obj.elements.length; i++ )
  {
      if ( obj.elements[i].getAttribute( "required" ) != null )
      {
          if ( obj.elements[i].value == '' )
          {
                alert('Не заполнено обязательное поле!');
                return false;
          }
      }
  }
  return true;
}


var tmp = new Array();
function emptyInput(obj){
	var name = $(obj).attr('name');
	if(tmp[ name ] != 1){
		tmp[ name ] = 1;
		$(obj).val("");
	}
}

var now_sm = 1;
function onSmenu(t){
	$("#tabs").removeClass();
	$("#tabs").addClass('m'+t);
	
	$(".t"+now_sm).removeClass('white');
	$(".t"+t).addClass('white');
	
	/*$("#pic").removeClass('pic'+now_sm);
	$("#pic").addClass('pic'+t);*/
	$("#pic .pic"+now_sm).toggle('slow');
	$("#pic .pic"+t).toggle('slow');
	clearTimeout(myTimeout);
	new AnimateVis('.pic'+t);
	
	$("#sm_content .cont"+now_sm).hide();
	$("#sm_content .cont"+t).show();
		
	now_sm = t;
}

function nextSmenu(){
	var new_t = now_sm+1;
	if(new_t > 4) new_t = 1;
	onSmenu(new_t);
}

/* SEARCH */

function typeSrch(obj){
	var id = $(obj).val();
	$(".sel_101").hide();
	$(".sel_102").hide();
	$(".sel_103").hide();
	$(".sel_"+id).show('slow');
	
}

/** Visual */
var visualGo = true;
var myTimeout;
function AnimateVis(divId)
{
	
	var oThis = this;
	var aImg  = $( "#pic " + divId ).find('img');
	
	var m1 = 100, m2 = 0, nextImage = 0, block1 = 0, block2 = 0, t = "";
	var oImg1 = '', oImg2 = '';

	this.next = function()
	{   
		if (t != "") return;
		m1 = 100;
		m2 = 0;
		oImg1 = aImg[nextImage];	
		nextImage++;
		if (nextImage == aImg.length) { nextImage = 0; }  
		oImg2 = aImg[nextImage];			
		oThis.changeSlide();  

	}

	this.changeSlide = function(){
		if(visualGo){ m1-=2; m2+=2; }
		oImg1.style.opacity = m1/100;
		oImg1.style.filter="alpha(opacity="+m1+")";
		oImg2.style.opacity = m2/100;
		oImg2.style.filter="alpha(opacity="+m2+")";
		t = setTimeout(oThis.changeSlide,15);
		if (m2 == 100) {    
			clearTimeout(t); t = "";
			myTimeout = setTimeout(oThis.next,3400);
		}
	}
    
	myTimeout = setTimeout(oThis.next,3400);
}

function clearAnimate(){
	alert(myTimeout);
	clearTimeout(myTimeout);
}
/* Visual **/


