function pics(img,ref)
{
	document.getElementById(img).src = ref;
}

function openwin(img,w,h,title)
{
 var hWnd;
 if(hWnd!=null) hWnd.close();
 hWnd=window.open(img,"","toolbar=no,location=no,directories=no,resizable=yes,scrollbars=yes,left=100,top=100,width="+w+",height="+h);
 hWnd.document.open();
 hWnd.document.write("<html><head><title>"+title+"</title></head><body topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>");
 hWnd.document.write("<img src=\""+img+"\" width="+w+" height="+h+">");
 hWnd.document.write("</body></html>");
 hWnd.document.close();
}

function IEPngFix(pngimg, gifimg, width, height)
{
	var code = '<img src="'+ gifimg +'" width="' + width + '" height="' + height + '" border="0" style="background:url('+pngimg+') no-repeat 0px 0px;"/>';
	if( navigator.userAgent.indexOf("Opera") > 1 ) document.write(code);
	else
		if( navigator.userAgent.indexOf("MSIE 6") > 1 ) document.write('<img src="'+gifimg+'" width="' + width + '" height="' + height + '" border="0" style="filter: progid:DXImageTransform.Microsoft.AlphaImageLoader (src=' + pngimg + ' , sizingMethod=crop );"/>');
		else
			if(navigator.userAgent.indexOf("MSIE 5") != -1) document.write(code);
			else document.write(code);
}


////////////////------считает общую цену и количество единиц товара
function Count(form, infoprice, infoamount)
{
	var Amount = 0;
	var Price = 0;
	var ss = "";

	InputsCollection = document.getElementsByTagName("INPUT");

	for (i=0; i<InputsCollection.length; i+=1)
	{
		CurrentInputID = InputsCollection[i].id;
		if (CurrentInputID.indexOf('count_id') >= 0)
		{
			eval('CurrentCount = document.getElementById(\'' + CurrentInputID + '\');');

			ss = new String(CurrentInputID); //определяем id инпута
			ss = ss.substr(8,ss.length);

			eval('var CurrentCheck = document.getElementById(\'check_id' + ss + '\');');

			if ( parseInt(CurrentCount.value) > 0 )
			{
				eval('var CurrentPrice = document.getElementById(\'price_id' + ss + '\');');
				
				if (!CurrentCheck.checked)
				{//если выделили (поставили флажок), то приплюсовывать цену и количество
					Amount += parseInt(CurrentCount.value);
					Price += (CurrentPrice.value) * (CurrentCount.value);
					
//					eval('document.getElementById(\'prcount_id'+ss+'\').innerHTML = \'<b>\'+(CurrentPrice.value * CurrentCount.value).toFixed(2)+\'</b>\'');

				}
			}
		}
	}

	Price = Price.toFixed(2);

	//eval('document.'+form+'.'+infoprice+'.value = Price;');
	eval('document.getElementById(\'price\').innerHTML = Price+\' <span>руб.</span>\'');

//	eval('document.'+form+'.'+infoamount+'.value = Amount;');
	eval('document.getElementById(\'amount\').innerHTML = Amount');
}




function post_to_del()
{
	document.getElementById("show_table").value=1;
	document.cartlist.submit();
}

function check_count(id, count)
{
	var c = parseInt(document.getElementById("count_id"+id).value);
	if( document.getElementById("kolonfirm_id"+id).value < c)
	{
		document.getElementById("count_id"+id).value = count;
		alert("Количество товара недопустимо, для заказа необходимо связаться с менеджером");
	}
}
///////



$(document).ready(function(e){
	$('.tocart_count').keypress(function(evt){
		 var charCode = (evt.which) ? evt.which : event.keyCode;
		 if (charCode!=13 && charCode!=9 && charCode!=8 && charCode!=46 && charCode!=36 && charCode!=35 && charCode!=37  && charCode!=39 && charCode!=0 && (charCode<48 || charCode>57) )
			 return false;
		 return true;
	});
})

