
	var vno = '';

	function add2compare(id, cat, scat, no) {
		
	    $.ajax({
		    url:'/ajax.php',
	        type: 'GET',
	        data: 'compare=1&item='+id+'&cat='+cat+'&no='+no,
	        dataType : "json",
	        cache: false,
	        success: function(table){

	        	/*if (jQuery.trim(table['del']) == 0) {
	        		$('#cmpa').html('Добавить к сравнению');
	        	} else {
	        		$('#cmpa').html('Удалить из сравнения');
	        	}*/
	        	
	        	/*if (jQuery.trim(table['content']) == '') {
	        		$('#cmp_but').css('display', 'none');
	        	} else {
	        		$('#cmp_but').css('display', 'block');
	        	}*/
	        	
				//$('#sItems').html(table['content']);
				
				if (vno != '') {
					vno.close();
				}

				scat = scat.replace('c', '');
				if (no != 'no') {
 					 vno = window.open('/catalog/c'+scat+'/s'+cat+'/compare/','window1', 'width = 1024, height = 768, resizable=1, scrollbars=1');
				} else {
					location.reload();
				}
	        },
	        error: function(){
	          //  alert('ERROR');
	        }
	    });
		
	}
 

	function submit_form(reg, dop) {

		if ($('#fio') && $('#fio').attr('value') == '') {
			alert("Поле Ф.И.О не заполнено.");
			$('#fio').focus();
			return;
		}
		
		if ($('#phone') && $('#phone').attr('value') == '') {
			alert("Поле телефон не заполнено.");
			$('#phone').focus();
			return;
		}

		if ($('#email').attr('value') == '') {
			alert("Поле e-mail не заполнено.");
			$('#email').focus();
			return;
		}
		
		 
		if (reg == 1) {
			
			if (dop != 1) {
			
				if ($('#password').attr('value') == '') {
					alert("Поле пароль не заполнено.");
					$('#password').focus();
					return;
				}
				 
				if ($('#password_conf').attr('value') == '') {
					alert("Поле пароль еще раз не заполнено.");
					$('#password_conf').focus();
					return;
				}
				
				if ($('#password_conf').attr('value') != $('#password').attr('value')) {
					alert("Пароль и подтверждение не совпадают.");
					$('#password').focus();
					return;
				}
			
			}
			
			if ($('#pic_text').attr('value') == '') {
				alert("Введите текст с картинками.");
				$('#pic_text').focus();
				return;
			}
			
		} else {
		
		
			if ($('#client_jurik').attr('value') == 'jurik' && $('#client_jurik').attr('checked') == true) 
			{
	
				var flag = 0;
				
				$('#nfo input').each(function(){
					
					
					
					if ($(this).attr('rel') == 'req') {
					   if ($(this).attr('value') == '') {
							if (flag == 0) { flag = 1; }
					   }
					}
				});
			
				if (flag == 1) {
					
					alert("Не все обязательные поля заполнены.");
					return;
					
				}
				
			}
		
		}
		

		
		$('#nfo').submit();
		
	}

	function cat_sel() {
		var data  = $('#catSel').attr('value');
		var data2 = $('#catSel2').attr('value');
		location.href = '/catalog/'+data2+'/s'+data+'/';
	} 
	
	
	function kill(cid) {
		 
	    $.ajax({
		    url:'/ajax.php',
	        type: 'GET',
	        data: 'del=1&cid='+cid,
	        dataType : "json",
	        cache: false,
	        success: function(table) {  
	        	if (table['data'] == 0) {
					location.reload();
	        	} else {
				   $('#bContent').html(table['data']);
				   $('#itogo2').html(table['price']); 
				   Cufon.replace('.button');
	        	}
	        },
	        error: function(){
	          //  alert('ERROR');
	        }
	    });
		
	}
	
	
	function brand_sel() {
		
		var brand = $('#brand_sel').attr('value');
		
		if (brand != 0) {
			location.href='/brand/'+brand+'/';
		}
		
	}
	
	function make_search() {

		var search_text = $('#search_text').attr('value')
		var search_cat  = $('#search_options').attr('value');
		location.href   = '/search/'+search_cat+'/?search='+search_text; 
	}
	
	
	function rcn(cid) {
		
		var qty = $('#qq_'+cid).attr('value');
		 
	    $.ajax({
		    url:'/ajax.php',
	        type: 'GET',
	        data: 'recount=1&cid='+cid+'&qty='+qty,
	        dataType : "json",
	        cache: false,
	        success: function(table) {  
			   $('#bContent').html(table['data']);
			   $('#itogo2').html(table['price']); 
			   Cufon.replace('.button');
	        },
	        error: function(){
	          //  alert('ERROR');
	        }
	    });
		
	}
	
	
	function recount(cid) {
		setTimeout("rcn("+cid+")", 300);
	}
	
	
   function add2basket(item, type) {
	
	   	if (type == 2) {
			var itemd = 'qq2_'+item; 
	   	} else {
			var itemd = 'qq_'+item; 
	   	}
	   	
		var qty   = $('#'+itemd).attr('value');
		
	 
	    $.ajax({
		    url:'/ajax.php',
	        type: 'GET',
	        data: 'basket=1&item='+item+'&qty='+qty,
	        dataType : "json",
	        cache: false,
	        success: function(table){
	
	        	$('#top_cart').html(table['count']);
	        	$('#b_popup').html(table['data']);
				$('#b_popup').css('display', 'block');
				/*$('#status').html(table['count']);*/
				Cufon.replace('.button');
	        },
	        error: function(){
	          //  alert('ERROR');
	        }
	    });
	
   } 
   
   
   function prf(cat) {
   	
		if (!cat) {
			cat = $('#cdata').attr('value');	
		}   
			
	    $.ajax({
		    url:'/ajax.php',
	        type: 'POST',
	        data: 'cat='+cat+'&'+$("#mf1").serialize(),
	        dataType : "json",
	        cache: false,
	        success: function(table){
	        	$('#filter_result').html('Подбрано товаров: <b>'+table['count_items']+'</b> <a onclick="send_form()" style="cursor:pointer;">Показать</a>');
				/*$('#status').html(table['count']);*/
	        },
	        error: function(){
	          //  alert('ERROR');
	        }
	    });
   	
   }
   
   
   function filter_perofm(cat) {
		 
		setTimeout('prf('+cat+')', 700);
   	
   }
   
   
   function reset_filters(href) {
   		location.href=href;
   }
   
   
   
   
   function send_form() {
   		$('#mf1').submit();
   }
   
   
   
   function jsel(type) {
   	
   		if (type == 'fizik') {
   			
   			for (i=1; i<=12; i++) {
   				$('#j'+i).css('display', 'none');
   			}
   			
   		} else {
   			
   			for (i=1; i<=12; i++) {
   				$('#j'+i).css('display', '');
   			}
   			
   		}
   	
   }
   
   function pl_vote() {
   	
   		$('#poll').each(function(){
   			
   			if ($(this).attr('name') == 'poll') {
   				alert($(this).attr('value'))
   			}
   			
   		});
   	
   }

	
