﻿function chkFormatColor(line_id, obj){
	
	format_ids = new Array();
	i = 0;
	$(".color_format_chk").each(
		function () {
			
			if (this.checked) {
				format_ids[i] = this.value;
				i++;
			}
		}
	);
	
	ids = format_ids.join("_");
	
	$("#thickness_"+line_id).show();
	$("#thickness_"+line_id).load("/ajax_thickness", {line_id: line_id, formats: ids});
	
	$("#surfaces_"+line_id).load("/ajax_surfaces", {line_id: line_id, formats: ids});
	
	
}

function sndFormatColor(line_id){
	format_ids = new Array();
	i = 0;
	$(".color_format_chk").each(
		function () {
			
			if (this.checked) {
				format_ids[i] = this.value;
				i++;
			}
		}
	);
	
	formats = format_ids.join("_");
	
	if (formats == "") {
		alert("Выберите формат");
		return false;
	}
	
	surf_ids = new Array();
	i = 0;
	$(".color_surf_chk").each(
		function () {
			
			if (this.checked) {
				surf_ids[i] = this.value;
				i++;
			}
		}
	);
	
	surfs = surf_ids.join("_");
	
	$.ajax({
		type: "POST", 
		url: "/ajax_add_cart", 
		data: "color="+line_id+"&formats="+formats+"&surfaces="+surfs, 
		success: function (msg) {
			alert(msg);
		}
	});
	
	
}


$(document).ready(
	function() {
		$('.color_select').sSelect();
	}
);