var dvig_left = dvig_right = dvig_sim = td_width_left = td_width_right = td_width_sim = count_dvig_left = count_dvig_right= count_dvig_sim= 0;

function td_background_grey(id) {
	$("#"+id).css("background", "#eeeeee");
	$("#"+id+"_td").css("background", "#ffffff"); }

function td_background_white(id) {
	$("#"+id).css("background", "#ffffff"); }

function set_input_data(data, id) {
	$("#"+id).attr("value", data);
}

function set_param_left() {
	client_width = Math.round(document.body.clientWidth/1.49);
	tbl = $("#tbl_work_left");
	div = $("DIV.img", tbl);
	count = div.length;
	td_width_left = 154;
	count_display = parseInt(client_width/td_width_left);
	count_dvig_left = (count - count_display)+1;
}

function set_param_right() {
	client_width = Math.round(document.body.clientWidth/1.49);
	tbl = $("#tbl_work_right");
	div = $("DIV.img", tbl);
	count = div.length;
	td_width_right = 154;
	count_display = parseInt(client_width/td_width_right);
	count_dvig_right = (count - count_display)+1;
}

function set_param_similar() {
	client_width = Math.round(document.body.clientWidth/1.49);
	tbl = $("#sim_tbl_work_similar");
	div = $("DIV.img", tbl);
	count = div.length;
	td_width_sim = 154;
	count_display = parseInt(client_width/td_width_sim);
	count_dvig_sim = (count - count_display)+1;
}

function drag_tbl_left(type) {
	tbl_margin = 0;
	if (type == 'left' && dvig_left < count_dvig_left) {
		dvig_left++;
		/*if ($.browser.opera) {
			tbl_margin -= td_width_left;
		} else */{
			tbl_margin -= td_width_left;
		}
	} else if (type == 'right' && dvig_left != 0) {
		dvig_left--;
		/*if ($.browser.opera) {
			tbl_margin += td_width_left;
		} else */{
			tbl_margin += td_width_left;
		}
	}
	if ((dvig_left+count_dvig_left) <= count_dvig_left) {
		$("#str_left_1").attr("class", "div_str_left");
		$("#str_right_1").attr("class", "div_str_right activ");
	} else if (dvig_left != count_dvig_left) {
		$("#str_left_1").attr("class", "div_str_left activ2");
		$("#str_right_1").attr("class", "div_str_right activ");
	} else {
		$("#str_left_1").attr("class", "div_str_left activ2");
		$("#str_right_1").attr("class", "div_str_right");
	}
	$("#tbl_work_left").animate({"left": '+='+tbl_margin+"px"}, "slow");
}

function drag_tbl_right(type) {	tbl_margin = 0;
	if (type == 'left' && dvig_right < count_dvig_right) {
		dvig_right++;
		/*if ($.browser.opera) {
			tbl_margin -= td_width_right;
		} else */{
			tbl_margin -= td_width_right;
		}
	} else if (type == 'right' && dvig_right != 0) {
		dvig_right--;
		/*if ($.browser.opera) {
			tbl_margin += td_width_right;
		} else */{
			tbl_margin += td_width_right;
		}
	}
	if ((dvig_right+count_dvig_right) <= count_dvig_right) {
		$("#str_left_2").attr("class", "div_str_left");
		$("#str_right_2").attr("class", "div_str_right activ");
	} else if (dvig_right != count_dvig_right) {
		$("#str_left_2").attr("class", "div_str_left activ2");
		$("#str_right_2").attr("class", "div_str_right activ");
	} else {
		$("#str_left_2").attr("class", "div_str_left activ2");
		$("#str_right_2").attr("class", "div_str_right");
	}
	$("#tbl_work_right").animate({"left": '+='+tbl_margin+"px"}, "slow");
}

function drag_tbl_similar(type) {	tbl_margin = 0;
	if (type == 'sim_left' && dvig_sim < count_dvig_sim) {
		dvig_sim++;
		/*if ($.browser.opera) {
			tbl_margin -= td_width_right;
		} else */{
			tbl_margin -= td_width_sim;
		}
	} else if (type == 'sim_right' && dvig_sim != 0) {
		dvig_sim--;
		/*if ($.browser.opera) {
			tbl_margin += td_width_right;
		} else */{
			tbl_margin += td_width_sim;
		}
	}

	if ((dvig_sim+count_dvig_sim) <= count_dvig_sim) {
		$("#sim_str_left_2").attr("class", "div_str_left");
		$("#sim_str_right_2").attr("class", "div_str_right activ");
	} else if (dvig_sim != count_dvig_sim) {
		$("#sim_str_left_2").attr("class", "div_str_left activ2");
		$("#sim_str_right_2").attr("class", "div_str_right activ");
	} else {
		$("#sim_str_left_2").attr("class", "div_str_left activ2");
		$("#sim_str_right_2").attr("class", "div_str_right");
	}
	$("#sim_tbl_work_similar").animate({"left": '+='+tbl_margin+"px"}, "slow");
}

function change_submenu(id, div) {
	block = $(".vkl_border");
	for (i=0;i<block.length;i++) {
		$(block[i]).attr("class", "vkl_border");
		$("#div_"+$(block[i]).attr("id")).css("display", "none");
	}
	$("#"+id).attr("class", "vkl_border vkl_activ");
	$("#div_"+id).css("display", "block");
}

function change_color(id, text) {	if ($("#"+id).val() == text) {
		$("#"+id).attr("value", "");
	} else if ($("#"+id).val() == ''){
		$("#"+id).attr("value", text);
	}
}

function change_quan(id, type) {
	quan_a = $("#"+id).val();
	if (quan_a == 0 && type == 1) {
	} else {
		quan_a == '' || quan_a == undefined ? quan_a = 0 : '';
		type == 1 ? $("#"+id).attr("value", (parseInt(quan_a)-1)) : $("#"+id).attr("value", (parseInt(quan_a)+1));
	}
}