$(function(){
	$('.city .city-chosen').click(function(){
		$('.city .citysBox').show();
		$(document).bind('mousedown',function(e){
			trg = $(e.target);
			if (trg.parents('.city .citysBox').html() == null) {
				$(document).unbind('mousedown');
				$('.city .citysBox').hide();
			}
		});
		return false;
	});
	$('.city .citysBox a').live('click',function(){
                tel = $(this).attr('rel');
		gorod = $(this).attr('id');
                  $('.city .city-tel').html(tel);
		  city = $(this).html();
		  $('.city .city-chosen strong').html(city);
		  temp = $(this).clone();
		  temp.prependTo($('.city .citysBox-content'));
		  $(this).remove();
		  $('.city .citysBox').hide();
                  if(gorod=="nsk") {$('#ppnsk').show();} else {$('#ppnsk').hide();}
                  if(gorod=="krsk") {$('#ppkrsk').show();} else {$('#ppkrsk').hide();}
                  if(gorod=="brnl") {$('#ppbrnl').show();} else {$('#ppbrnl').hide();}
                  if(gorod=="nvk") {$('#ppnvk').show();} else {$('#ppnvk').hide();}
                  
                $.post("/order/action.php",{action:"region",region:gorod},function(data,textStatus){ 
		if(data=="OK") {
		    flag=true;
		  }
	        },"html");
                return false;
	});
	$('.city .basket').hover(function(){
		basket = $(this);
		if (basket.hasClass('basketHidden')) {
				basket.addClass('bigBasketShow');
				$(this).find('.basket-item-controls').css({visibility:'visible'});
		} else {
			$(this).addClass('basketShow');
			$(this).find('.basket-item-controls').css({visibility:'visible'});
		};
	},function(){
			basket = $(this);
		if (basket.hasClass('basketHidden')) {
				basket.removeClass('bigBasketShow');
				$(this).find('.basket-item-controls').css({visibility:'hidden'});
		} else {
			$(this).removeClass('basketShow');
			$(this).find('.basket-item-controls').css({visibility:'hidden'});
		};
	});
	$('.item-pb-box').hover(function(){
		$(this).find('.pb-pop').show();
	},function(){
		$(this).find('.pb-pop').hide();
	});
	$('.pb-pop-controls span').click(function(){
		pbc = $(this);
		if (!pbc.hasClass('pb-pop-c-inactive')) {
			if (pbc.hasClass('pb-pop-c-inc')) {
				b = pbc.parent().find('b');
				current = parseInt(b.html())+1;
				b.html(current);
				rstring = b.attr("id");
				rstring = rstring.substr(1,rstring.length);
                                $('#QUANTITY' + rstring).val(current);
				if ((current) == 99) {
					pbc.addClass('pb-pop-c-inactive')
				};
				if ((current) > 1) {
					pbc.parent().find('.pb-pop-c-dec').removeClass('pb-pop-c-inactive');
				};
			} else {
				b = pbc.parent().find('b');
				current = parseInt(b.html())-1;
				b.html(current);
                                rstring = b.attr("id");
				rstring = rstring.substr(1,rstring.length);
                                $('#QUANTITY' + rstring).val(current);
				if ((current) == 1) {
					pbc.addClass('pb-pop-c-inactive')
				};
				if ((current) < 99) {
					pbc.parent().find('.pb-pop-c-inc').removeClass('pb-pop-c-inactive');
				};
			};
		};
	});
	if (window.opera && window.opera.version() == 10) { document.documentElement.className += ' opera10';	}
});


$(function(){
	$('.all_category .city-chosen').click(function(){
		$('.all_category .citysBox').show();
		$(document).bind('mousedown',function(e){
			trg = $(e.target);
			if (trg.parents('.all_category .citysBox').html() == null) {
				$(document).unbind('mousedown');
				$('.all_category .citysBox').hide();
			}
		});
		return false;
	});
	$('.all_category .citysBox a').live('click',function(){
                tel = $(this).attr('rel');
		gorod = $(this).attr('id');
                  $('.all_category .city-tel').html(tel);
		  city = $(this).html();
		  $('.all_category .city-chosen strong').html(city);
		  temp = $(this).clone();
		  temp.prependTo($('.all_category .citysBox-content'));
		  $(this).remove();
		  $('.all_category .citysBox').hide();
                  if(gorod=="nsk") {$('#ppnsk').show();} else {$('#ppnsk').hide();}
                  if(gorod=="krsk") {$('#ppkrsk').show();} else {$('#ppkrsk').hide();}
                  if(gorod=="brnl") {$('#ppbrnl').show();} else {$('#ppbrnl').hide();}
                  if(gorod=="nvk") {$('#ppnvk').show();} else {$('#ppnvk').hide();}
                  
                $.post("/order/action.php",{action:"region",region:gorod},function(data,textStatus){ 
		if(data=="OK") {
		    flag=true;
		  }
	        },"html");
                return false;
	});
	$('.all_category .basket').hover(function(){
		basket = $(this);
		if (basket.hasClass('basketHidden')) {
				basket.addClass('bigBasketShow');
				$(this).find('.basket-item-controls').css({visibility:'visible'});
		} else {
			$(this).addClass('basketShow');
			$(this).find('.basket-item-controls').css({visibility:'visible'});
		};
	},function(){
			basket = $(this);
		if (basket.hasClass('basketHidden')) {
				basket.removeClass('bigBasketShow');
				$(this).find('.basket-item-controls').css({visibility:'hidden'});
		} else {
			$(this).removeClass('basketShow');
			$(this).find('.basket-item-controls').css({visibility:'hidden'});
		};
	});
	$('.item-pb-box').hover(function(){
		$(this).find('.pb-pop').show();
	},function(){
		$(this).find('.pb-pop').hide();
	});
	$('.pb-pop-controls span').click(function(){
		pbc = $(this);
		if (!pbc.hasClass('pb-pop-c-inactive')) {
			if (pbc.hasClass('pb-pop-c-inc')) {
				b = pbc.parent().find('b');
				current = parseInt(b.html())+1;
				b.html(current);
				rstring = b.attr("id");
				rstring = rstring.substr(1,rstring.length);
                                $('#QUANTITY' + rstring).val(current);
				if ((current) == 99) {
					pbc.addClass('pb-pop-c-inactive')
				};
				if ((current) > 1) {
					pbc.parent().find('.pb-pop-c-dec').removeClass('pb-pop-c-inactive');
				};
			} else {
				b = pbc.parent().find('b');
				current = parseInt(b.html())-1;
				b.html(current);
                                rstring = b.attr("id");
				rstring = rstring.substr(1,rstring.length);
                                $('#QUANTITY' + rstring).val(current);
				if ((current) == 1) {
					pbc.addClass('pb-pop-c-inactive')
				};
				if ((current) < 99) {
					pbc.parent().find('.pb-pop-c-inc').removeClass('pb-pop-c-inactive');
				};
			};
		};
	});
	if (window.opera && window.opera.version() == 10) { document.documentElement.className += ' opera10';	}
});


$(function(){
	$('.all_cityes .city-chosen').click(function(){
		$('.all_cityes .citysBox').show();
		$(document).bind('mousedown',function(e){
			trg = $(e.target);
			if (trg.parents('.all_cityes .citysBox').html() == null) {
				$(document).unbind('mousedown');
				$('.all_cityes .citysBox').hide();
			}
		});
		return false;
	});
	$('.all_cityes .citysBox a').live('click',function(){
                tel = $(this).attr('rel');
		gorod = $(this).attr('id');
                  $('.all_cityes .city-tel').html(tel);
		  city = $(this).html();
		  $('.all_cityes .city-chosen strong').html(city);
		  temp = $(this).clone();
		  temp.prependTo($('.all_cityes .citysBox-content'));
		  $(this).remove();
		  $('.all_cityes .citysBox').hide();
                  if(gorod=="nsk") {$('#ppnsk').show();} else {$('#ppnsk').hide();}
                  if(gorod=="krsk") {$('#ppkrsk').show();} else {$('#ppkrsk').hide();}
                  if(gorod=="brnl") {$('#ppbrnl').show();} else {$('#ppbrnl').hide();}
                  if(gorod=="nvk") {$('#ppnvk').show();} else {$('#ppnvk').hide();}
                  
                $.post("/order/action.php",{action:"region",region:gorod},function(data,textStatus){ 
		if(data=="OK") {
		    flag=true;
		  }
	        },"html");
                return false;
	});
	$('.all_cityes .basket').hover(function(){
		basket = $(this);
		if (basket.hasClass('basketHidden')) {
				basket.addClass('bigBasketShow');
				$(this).find('.basket-item-controls').css({visibility:'visible'});
		} else {
			$(this).addClass('basketShow');
			$(this).find('.basket-item-controls').css({visibility:'visible'});
		};
	},function(){
			basket = $(this);
		if (basket.hasClass('basketHidden')) {
				basket.removeClass('bigBasketShow');
				$(this).find('.basket-item-controls').css({visibility:'hidden'});
		} else {
			$(this).removeClass('basketShow');
			$(this).find('.basket-item-controls').css({visibility:'hidden'});
		};
	});
	$('.item-pb-box').hover(function(){
		$(this).find('.pb-pop').show();
	},function(){
		$(this).find('.pb-pop').hide();
	});
	$('.pb-pop-controls span').click(function(){
		pbc = $(this);
		if (!pbc.hasClass('pb-pop-c-inactive')) {
			if (pbc.hasClass('pb-pop-c-inc')) {
				b = pbc.parent().find('b');
				current = parseInt(b.html())+1;
				b.html(current);
				rstring = b.attr("id");
				rstring = rstring.substr(1,rstring.length);
                                $('#QUANTITY' + rstring).val(current);
				if ((current) == 99) {
					pbc.addClass('pb-pop-c-inactive')
				};
				if ((current) > 1) {
					pbc.parent().find('.pb-pop-c-dec').removeClass('pb-pop-c-inactive');
				};
			} else {
				b = pbc.parent().find('b');
				current = parseInt(b.html())-1;
				b.html(current);
                                rstring = b.attr("id");
				rstring = rstring.substr(1,rstring.length);
                                $('#QUANTITY' + rstring).val(current);
				if ((current) == 1) {
					pbc.addClass('pb-pop-c-inactive')
				};
				if ((current) < 99) {
					pbc.parent().find('.pb-pop-c-inc').removeClass('pb-pop-c-inactive');
				};
			};
		};
	});
	if (window.opera && window.opera.version() == 10) { document.documentElement.className += ' opera10';	}
});
