﻿function comlete_order(form) {
	input_name=new Array();
	input_value=new Array();
	var elements_to_post="";
	var elements_to_post_="";

 for (var i=0; i<form.elements.length; i++) {
	var el = form.elements[i];
	if ($("#"+el.id).is(":visible"))
		if (((i < 5)&&(el.value.length < 3)) | (el.id=='prigorod')&&(el.value.length < 2)) {
			$("#"+el.id).css("background-color","#FFBBD1");
			$("#"+el.id).css("border","1px dotted");
			return false;	
		} else {
			$("#"+el.id).css("background-color","");
			
			input_name[i]=el.id;
			input_value[i]=el.value;
		 }
	if (i>=12) { //два последних невидимых поля
		input_name[i]=el.id;
		input_value[i]=el.value;
	}
 };

for(var key in input_name) elements_to_post_+=input_name[key]+"="+input_value[key]+"&";
elements_to_post=encodeURI(elements_to_post_.substr(0,elements_to_post_.length-1));
request("completeorder.php?"+elements_to_post,"mainwindow");

$("#sum_cart").text("0");
$("#kol_cart").text("0");
$("html,body").animate({scrollTop:-100}, 300);
}
