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 switch_class(cn, obj)
{
	obj.className = cn;
}



function show_div(id)
{
	var div;
	div = document.getElementById(id);
	if ( div.style.display == "none" ) div.style.display = "block";
		else div.style.display = "none";
}



////////////////------считает общую цену и количество единиц товара
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 = (CurrentPrice.value * CurrentCount.value);');
					
					eval('document.getElementById(\'prcount_id'+ss+'\').innerHTML = \'<b>\'+(CurrentPrice.value * CurrentCount.value).toFixed(2)+\'</b>\'');

/*					CurrentCount.style.color = "#DB0A56";
					CurrentCount.style.backgroundColor = "#EEEEEE";
					CurrentCount.style.fontWeight = "bold";*/
				}
			}
		}
	}

	Price = Price.toFixed(2);

	eval('document.'+form+'.'+infoprice+'.value = Price;');
	eval('document.'+form+'.'+infoamount+'.value = 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){
	$('.search_block input[type:text]').click(function()
	{
		if ($(this).attr('is_not_default') != 1)
		{
			$(this).val('');
			$(this).attr('is_not_default', 1);
		}
	});

	

	if( $('#yur').attr("checked") ) $('.yur_params').each(function(){ $(this).show(); });
	else $('.yur_params').each(function(){ $(this).hide(); });

	$('#yur').click(function()
	{
		if( $('#yur').attr("checked") ) $('.yur_params').each(function(){ $(this).show(); });
		else $('.yur_params').each(function(){ $(this).hide(); });
	});


});