var id=new Array();
var basket_order=new Array();
var order=document.cookie.split('; ');

fl=false;
flpath=true;

for(z=0;z<order.length;z++){
  t=order[z].split('=');
  
if(t[0]=='streetnetwork_order'){
	fl=true;
	basket_order=order[z];
}else{
	if(t[0]=='flpath'){
		flpath=false;
	}
 }
}

if(fl) {
	c = unescape(basket_order);
	var v = c.split('=');
	var basket = v[1].split('~');

	for( i=0; i<basket.length; i++ ) {
		id[i] = basket[i];
	}
}

function basketSum(){
	if((id.length==0)||(!flpath))document.getElementById('basket').style.display='none';
	else {
		document.getElementById('basket').style.display='';
		document.getElementById('sum_kol').innerHTML=id.length;
	}
}

function isan(string) {
	if (string.length == 0)
	return false;
	for (var i=0;i < string.length;i++)
	if ((string.substring(i,i+1) < '0') || (string.substring(i,i+1) > '9'))
	return false;
	string-=0;
	if(string>1000||string<=0)
	return false;
	return true;
}

function round(number,X) {
    X = (!X ? 2 : X);
    return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
}


function SetCookies( p_id ) {

	date=new Date();
	date.setTime(date.getTime() + 1000 * 60 * 60 * 24);

	fl=true;
	if(fl) {
		n=id.length;
		id[n]=p_id;
	}

	str='';

	for(i=0;i<id.length;i++) {
		str+=id[i];
		str+=(i!=(id.length-1))?'~':'';
	}

	document.cookie='streetnetwork_order='+escape(str)+'; expires='+date.toGMTString()+'; path=/';
	//alert("Сторона добавлена в заказ. \nВсего сторон в заказе: "+id.length);
	basketSum();

}
