$(document).ready(function () {
	if ($('A.highslide')) {
		$('A.highslide').click(function () { 
			return hs.expand(this);
		});
	}

	if ($('A.ord_veh')) {
		$('A.ord_veh').click(function () { 
			arr = this.rel.split('_');
			if($('#veh_id')[0]){
				$('#veh_id')[0].value = arr[1];
			}
			
			if($('#cat_id')[0]){
				$('#cat_id')[0].value = arr[0];
			}
			tb_show(null,'#TB_inline?width=260&height=130&inlineId=order',false);
		});
	}
	
	if($("#ordform")){
		$("#ordform").bind("submit", function() { return false; });
	}
	
	if($("#ord")){
		$("#ord").bind("submit", function() { return false; });
	}	
	
});

function Send(form, veh, ajax, mess, d){
	char = false;
	max = false;

	if($('#'+veh+' input')){
		$('#'+veh+' input').each(function() {
		    if (this.type == 'text'){
  					if(isNaN(this.value)){
  						char = true;
  					} else if(!isNaN(this.value)){
  						if(this.value > 6){
  							max = true;
  						}
  					}
  				}	
 			});
 		}	
	
	if(char || max){
		str = '';
		if(char){
			str = str + 'Вы ввели символ не являющийся числом!\n'; 
		}
		if(max){
			str = str + 'Число должно быть не больше 6!\n'; 
		}
		alert(str);
		return;
	}
	$('#'+ajax)[0].value = '1';
	var str = $("#"+form).serialize();
	if(mess == 'true'){
		if($('#'+form)){
			$('#'+form).css({'display' : 'none'});
		}
		if($('#'+d)){
			$('#'+d+'-img').css({'display' : 'block'});
			//$('#'+d)[0].innerHTML = '<img src="/public/images/ajax-loader.gif" /><br/><span>отправка заказа...</span>';
		}
	}

  	$.post(	"/", 
  			str+'&div='+d, 
  			function(response){
  				eval(response);
  				if(!clear){
  					$('#'+form).css({'display' : 'block'});
  					$('#'+d+'-img').css({'display' : 'none'});
	  			//	$('#'+form+' input').each(function() {
				//	    var type = this.type;
				//	    var tag = this.tagName.toLowerCase(); 
				//	    if (type == 'text' || tag == 'textarea'){
     			//				this.value = "";
     			//			}	
		  		//	});
		  		}else{
		  			$('#'+d+'-img').css({'display' : 'none'});
		  		}	
  			});
}