function small2Big(){
	$('img.imgSmall').click(
		function(){
			var src = this.src;
			src=str_replace(src,'preview','');
			$('img#imgBig').attr('src',src);
		}
	);
}

function str_replace(haystack, needle, replacement) { 
	var temp = haystack.split(needle); 
	return temp.join(replacement); 
} 

function addCart(){
	$('*[id^="tovar"]').click(
		function(){
			var len = this.id.length;
			var number = this.id.substr(5,(len-5));
			var type=$('#hidden'+number).val();
			$('#cartBasket').load('http://'+location.hostname+'/cart.php?tov='+number+'&cat='+type);
			alert("Товар добавлен в корзину!");
		}
	);
	$('select[id^="select"]').change(function () {
		var len = this.id.length;
		var number = this.id.substr(6,(len-6));
		$('#'+this.id+" option:selected").each(
				function(){
					$('#dop_'+number).load('http://'+location.hostname+'/dop_price.php?tov='+this.value+'&id='+number);
					$('#super'+number).load('http://'+location.hostname+'/dop_super.php?tov='+this.value+'&id='+number);
					$('#hidden'+number).val(this.value);
				}
		);
		
		
	});
       

}
function delBasket(){
	$('*[id^="delete"]').click(
			function(){
				var len = this.id.length;
				var number = this.id.substr(6,(len-6));
				
				$('#myDel').load('http://'+location.hostname+'/dellcart.php?tov='+number);
				$(".border"+number).hide();
			}
		);
}
function changeBasket(){
	$('*[id^="count"]').keyup(
			function(){
				
				var len = this.id.length;
				var number = this.id.substr(5,(len-5));
				
				$('#myDel').load('http://'+location.hostname+'/change.php?tov='+number+'&count='+this.value);
				//$(".border"+number).hide();
			}
		);

}


function addCart2(id,type){
			var number = id;
			var type=type; 
			//alert(id +"-"+type);
			$('#cartBasket').load('http://'+location.hostname+'/cart.php?tov='+number+'&cat='+type);
			alert("Товар добавлен в корзину!");
}

function changeImages(){
	$('#second1').click(
		function(){
			var src = this.src;
			src=str_replace(src,'small','');
			$('#main').attr('src',src);	
		}
	);
	$('#second2').click(
			function(){
				var src = this.src;
				src=str_replace(src,'small','');
				$('#main').attr('src',src);	
			}
		);
	$('#second3').click(
			function(){
				var src = this.src;
				src=str_replace(src,'small','');
				$('#main').attr('src',src);	
			}
		);
}
















