$(document).ready(function(){

	$('#closeLowPr').click(function() {
		$('#lowPriceGur').hide();
	});

	$('#showGarLowPr').click(function() {
	    var offTop = $("#showGarLowPrTop").offset().top;
	    offTop = offTop+50;
	    var offLeft = $("#showGarLowPrTop").offset().left;
	    offLeft = offLeft-640;
	    $('#lowPriceGur').css("left", offLeft+"px");
	    $('#lowPriceGur').css("top", offTop+"px");

	    var brows =  navigator.userAgent;
	    if (brows.indexOf('MSIE') != -1) {
	        $('#lowPriceGur').css("width","480");
	        $('#lowPriceGur').css("height","340");
	        $('#ieTab').css("margin-left", "-15px");
	        $('#ieTab2').css("margin-left", "25px");
	    }

		$('#lowPriceGur').show();

	});

	 $("#winContent").ajaxStart(function(){
   			$(this).hide();
   			$('#successContent').html('<div align="center"><img src="/img/loading.gif"></div>');
   			$('#successContent').show();
	 });


	$('#subLpButt').click(function() {
	    $.ajax({
	        url:'/jqAjax.php',
	        type: 'POST',
	        data: $('#lowPriceForm').serialize(),
	        cache: false,
	        success: function(table){
	            var spl = table.split('**|');
	            if (spl[1] == 'error') {
	               $('#lowPriceGur').css("height", "365px");
	               $('#successContent').html(spl[2]);
	               $('#winContent').show();
	            } else {
	               $('#lowPriceForm').hide();
	               $('#successContent').html(spl[1]);
	            }
	        },
	        error: function(){
	            alert('Возникла ошибка, попробуйте обновить страницу.');
	        }
	    });

	});


	$('#closeFreeDelive').click(function() {
		$('#freeDeliveGur').hide();
	});

	$('#showFreeDelive').click(function() {
	    var offTop = $("#showFreeDeliveTop").offset().top;
	    offTop = offTop+50;
	    var offLeft = $("#showFreeDeliveTop").offset().left;
	    offLeft = offLeft-640;
	    $('#freeDeliveGur').css("left", offLeft+"px");
	    $('#freeDeliveGur').css("top", offTop+"px");
	    var brows =  navigator.userAgent;
	    if (brows.indexOf('MSIE') != -1) {
            $('#freeDeliveGur').css("height", "230px");
	    } else {
            $('#freeDeliveGur').css("height", "180px");
	    }
		$('#freeDeliveGur').show();
	});


	$('#closeTodayDelive').click(function() {
		$('#todayDeliveGur').hide();
	});

	$('#showTodayDelive').click(function() {
	    var offTop = $("#showTodayDeliveTop").offset().top;
	    offTop = offTop+50;
	    var offLeft = $("#showTodayDeliveTop").offset().left;
	    offLeft = offLeft-640;
	    var height = $.browser.msie ? 245 : 220;
	    $('#todayDeliveGur').css("left", offLeft+"px");
	    $('#todayDeliveGur').css("top", offTop+"px");
	    $('#todayDeliveGur').css("height", height + "px");
		$('#todayDeliveGur').show();
	});


});



function show_me(a) {
	document.getElementById('qty_b').innerHTML = a[1];
	document.getElementById('b_popup').innerHTML = a[0];
	document.getElementById('b_popup').style.display = 'block';
}



function fun(i)  {
	s = 0;
	var cond_setup = 0;
	if (document.getElementById('pix')) {
		if (document.getElementById('pix').checked == true) {
			s = $('#pix').val();
		} else {
			s = 0;
		}
	}

	if (document.getElementById('cond_setup')) {
		if (document.getElementById('cond_setup').checked == true) {
			cond_setup = 1;
		} else {
			cond_setup = 0;
		}
	}
	x_add2basket(i, s, cond_setup, show_me)
}




function OpenPage(param, w, h){
	n=window.open(param,"welcome","menubar=none, scrollbars=no, width="+w+", height="+h);
}



function cbs_result(a) {
	if (a != '') {
		document.getElementById('scat').innerHTML=a;
	}
}


function cbs() {

	var bid = document.forms['sfe'].brand.value;
	x_cbs2(bid, cbs_result);

}

			     		function compare_res(a) {


		var str = 'ppp'+a[0];
		document.getElementById('rr2').innerHTML=a[1];
		document.getElementById(str).innerHTML='добавлено к сравнению.';

	}

function add2compare(i)  {

	if (i == 0) {
		alert('Ничего не выбрано.');
	} else {
		x_add2compare(i, compare_res);
	}

}

