// user's functions

function cart_pict_off() {
	var table=document.getElementById('eshop_cart'); 
	
	for (i=0; i<=table.rows.length-1; i++) {
	
		if (table.rows[i].cells[2]) {
			table.rows[i].cells[2].style.display = 'none';
			
			if (navigator.userAgent.indexOf("MSIE") != -1) {
				table.rows[i].cells[3].style.display = 'block';
			}
			else {
				table.rows[i].cells[3].style.display = 'table-cell';
			}
		}
	}
	
}

function cart_pict_on() {
	var table=document.getElementById('eshop_cart'); 
	
	for (i=0; i<=table.rows.length-1; i++) {
	
		if (table.rows[i].cells[2]) {
			if (navigator.userAgent.indexOf("MSIE") != -1) {
				table.rows[i].cells[2].style.display = 'block';
			}
			else {
				table.rows[i].cells[2].style.display = 'table-cell';
			}
			table.rows[i].cells[3].style.display = 'none';
		}
	}	
}

function AddToCartPropPrep(catalog_lnk, item_id, backurl) {
	
	var __curr_sel_value = '';
	var form = document.getElementById('color_form');
	var qty=document.getElementById('qty_field_dp').value;
	
	if (form.__prop_id.length) { /*если опций цвета 1 единица, то массив не создается*/
		for (var i=0; i<=form.__prop_id.length-1; i++) {	
			
			if (form.__prop_id[i].checked == true) {
				__curr_sel_value = form.__prop_id[i].value;
			}
		}
	}
	else {
		if (form.__prop_id.checked == true) {
			__curr_sel_value = form.__prop_id.value;
		}
	}
	
	if (__curr_sel_value == '') {
		alert('Для добавления товара в корзину, пожалуйста, укажите его цвет.');
	}
	else {
	/*alert('' + catalog_lnk + '?itemId=' + item_id + '&propId=' + __curr_sel_value + '&action=add&eshop_special=1&url=' + backurl, item_id, __curr_sel_value, 0, qty);*/
		AddToCartPropDP('' + catalog_lnk + 'itemId=' + item_id + '&propId=' + __curr_sel_value + '&action=add&eshop_special=1&url=' + backurl, item_id, __curr_sel_value, 0, qty);
	}
}


function isIE5() { return (navigator.userAgent.indexOf("MSIE 5") > -1); }
function isIE6() { return ((navigator.userAgent.indexOf("MSIE 6") > -1) && (navigator.userAgent.indexOf("Opera") == -1)); }
function isIE() { return (isIE5() || isIE6());}

function fixpng()
{
 for (var i = 0; i < document.images.length; i++)
 {
  var img = document.images[i];
  imgSrc = img.src;
  if (imgSrc.substr(imgSrc.length-3).toLowerCase() == "png")
  {
   var w, h;
   w = img.width, h = img.height;
   img.src = "_img/spacer.gif";
   img.width = w, img.height = h;
   img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'" + imgSrc + "\', sizingMethod='scale');";
  }
 }
}

var isIE = isIE();
if (isIE) window.attachEvent("onload", fixpng); 

