	var cashCategory = new Array;
	var cashProduct  = new Array;

	function doSearch(){
		updateCategory({search: $("#search").val()});
	}

	function showBigCart(){
		
		try {
			$.modal.close();
		}catch(e) {}		
		
		$("#centerContent").html('<div id="divBigCart">Загрузка...</div>');
		updateCart('open',0,0,'big');
				
	}

	function updateProduct(productID){

		$('html,body').animate({scrollTop: 230}, 1000);
		
		if (typeof(cashProduct[productID]) != 'undefined'){

			//alert("I am from product cash");
			
			$("#centerContent").html(cashProduct[productID]);
			
		} else {	

			showProcess();
			
			$.post(
				"ajax/getProduct.php",
				{productID: productID},
	  			function(data){
	  				//alert(data);
	  				hideProcess();

	  				cashProduct[productID] = data;
	  				
	  				$("#centerContent").html(data);	  					
	  			}
	    	);
		}	
	}

	function showRegister(){

		//$("#modalContainer").hide();
		$.modal.close();
		showProcess();
			
		$.post(
			"ajax/showRegister.php",
			{},
  			function(data){
  				//alert(data);
  				hideProcess();
	  				$("#centerContent").html(data);	  					
  			}
    	);
	}

	function showLostpass(){

		$.modal.close();
		showProcess();
		
		$.post(
			"ajax/showLostpass.php",
			{},
  			function(data){
  				//alert(data);
  				hideProcess();

  				$("#centerContent").html(data);	  					
  			}
    	);
	}
	
	function showRozd(rozdID){

		showProcess();
		
		$.post(
			"ajax/showRozd.php",
			{rozdID: rozdID},
  			function(data){
  				//alert(data);
  				hideProcess();

  				$("#centerContent").html(data);	  					
  			}
    	);
	}

	function showArticle(articleID){

		showProcess();
		
		$.post(
			"ajax/showArticle.php",
			{articleID: articleID},
  			function(data){
  				//alert(data);
  				hideProcess();

  				$("#centerContent").html(data);	  					
  			}
    	);
	}
	
	function updateCategory(params){

		//params.start = params.start || 0; 
		//alert(params.search); 
		$('html,body').animate({scrollTop: 230}, 1000);
		
		if (typeof(cashCategory[params.categoryID]) != 'undefined' && 
			typeof(params.start) == 'undefined'&&
			typeof(params.search) == 'undefined'){

			//alert("I am from cash");
			
			$("#centerContent").html(cashCategory[params.categoryID]);
			$("a.fancybox").fancybox({ 'overlayOpacity': 0.8 });
			
		} else {	

			showProcess();
			
			$.post(
				"ajax/getCategory.php",
				params,
	  			function(data){
	  				//alert(data);
	  				hideProcess();
	  				if (typeof(params.start) == 'undefined' && 
	  					typeof(params.search) == 'undefined'){
						cashCategory[params.categoryID] = data;
	  				}
	  				$("#centerContent").html(data);	
	  				//update fancylincs
	  				$("a.fancybox").fancybox({ 'overlayOpacity': 0.8 });
	  			}
	    	);
		}	
	}

	function showProcess(){
		var height = $(document).height();
		var txt = '<div id="jquery-overlay" style="background-color:rgb(255,255,255); height:'+height+'px; line-height:0pt; position:absolute; text-align:center; top:0px; z-index:999; opacity:0.6; left:0px; width:100%; display:none;"></div>';
		$("body").append(txt);
		$("#jquery-overlay").animate({opacity:0.6},50).show(50);
		//$("body").css('cursor','progress');

		if(document.documentElement&&document.documentElement.scrollTop){
			t=document.documentElement.scrollTop;
		}else{
			if(document.body){
			t=document.body.scrollTop;
			}
		}
		elDiv = document.getElementById('divProcess');
		elDiv.style.top=t + (screen.height / 2) - 150+'px';
		elDiv.style.left=(screen.width / 2) - 100+'px';
		elDiv.style.display='block';

	}

	function hideProcess(){
	  	$("#jquery-overlay").remove();
	  	$('#divProcess').css('display','none');

	  	//$("#jquery-overlay").hide();
	    //$("body").css('cursor','auto');	
	}

