function	calculate(id){
		// get input element
		ft = $('#'+id+' input[@name=feet]').val();
		ft = parseFloat(ft);
		if (!ft){
			alert('Wrong number format');
		}

		// get price
		price = $('#'+id).attr('price');
		discount = $('#'+id).attr('discount');

		if (!price)	price = 0;
		if (!discount) discount = 0;

		tot  = ft*price*(100-discount)/100;
		tot = tot.toFixed(2);

		$('#'+id+' input[@name=result]').val(tot);
}

function	reset(id){
		$('#'+id+' input[@name=result]').val('');
}

//gallery
function swap(id){
	if(tot_pix==1){
		return false;
	}

	bigpic = document.getElementById('bigPic');
	lowpic = document.getElementById('p'+id);
	fn="pix/"+$(lowpic).attr("name");

	if(tot_pix>1){
		//set last pict inactive
//		thispic = document.getElementById('d'+pix_id);
		$('#d'+pix_id).removeClass('act');
//		thispic.setAttribute('class','por');

		//set this pict active
//		np =  document.getElementById('d'+id);		
//		np.setAttribute('class','por act');
		$('#d'+id).addClass('act');
	}

	pix_id = id;
    bigpic.src=fn;

    //set bigPic text
    txt = document.getElementById('descr');
    txt.innerHTML = lowpic.getAttribute('alt');
    txt2 = document.getElementById('p_descr');
    txt2.innerHTML = lowpic.getAttribute('descr');

    return false;
}

function set_on_time(id){

	bigpic = document.getElementById('bigPic');
	bp_src = bigpic.getAttribute('src');
	lowpic = document.getElementById('p'+id);
	fn="pix/"+$(lowpic).attr("name");

    bigpic.src=fn;

    //set bigPic text
    txt = document.getElementById('descr');
    txt.innerHTML = lowpic.getAttribute('alt');
    txt2 = document.getElementById('p_descr');
    txt2.innerHTML = lowpic.getAttribute('descr');

    return false;
}

function return_on_time(){
	bigpic = document.getElementById('bigPic');
	bp_src = bigpic.getAttribute('src');
	lowpic = document.getElementById('p'+pix_id);
	fn="pix/"+$(lowpic).attr("name");

    bigpic.src=fn;

    //set bigPic text
    txt = document.getElementById('descr');
    txt.innerHTML = lowpic.getAttribute('alt');
    txt2 = document.getElementById('p_descr');
    txt2.innerHTML = lowpic.getAttribute('descr');

    return false;
}

function	next(){
        next_id = pix_id*1+1*1;

        //set last pict inactive
        if(tot_pix>1){
			thispic = document.getElementById('d'+pix_id);
			thispic.setAttribute('class','por');
		}

        if (next_id==tot_pix*1+1*1){
        	pix_id=1;
        	swap(1);
          	return false;
        }

        pix_id++;
        swap(next_id);

		return false;
	}

function	prev(){
		prev_id=pix_id*1-1*1;

		//set last pict inactive
		if(tot_pix>1){
			thispic = document.getElementById('d'+pix_id);
			thispic.setAttribute('class','por');
		}

		if (prev_id==0){
			pix_id=tot_pix;
        	swap(tot_pix);
        	return false;
        }

		pix_id--;
        swap(prev_id);

		return false;
	}
