function size(){
	//alert(document.body.clientWidth);
	var W = document.body.clientWidth;
	var nWidth = "940";
	if(W < nWidth){
		document.getElementById('base').style.width = nWidth + "px";
	}else{
		document.getElementById('base').style.width = "100%";
	}
	window.status = document.body.clientWidth + "x" + document.body.clientHeight + " | " + document.getElementById('base').style.width;
}

function PrintVersion(){
	if (document.print_form){
		PR=window.open("","wndPrint","alwaysRaised=yes,left=0,top=0,height=500,width=730,menubar=yes,toolbar=yes,resizable=yes,status=yes,scrollbars=yes");
		document.print_form.submit();

	}else{
		alert("No print version for this page!");
	}

}

// Atention!!! Link on this function insert into FCk-editor!!!--------------------------
function wo(_wurl,_ww,_wh,_wscrl){

/***************
	wurl: window URL
	wh: window height
	ww: window width
	wsr: scrollbars 1 - yes, 0 - no
***************/
 if(screen.width){
  wpos_x = (screen.width-_ww)/2;
  if (wpos_x < 0){ wpos_x = 0;}
  wpos_y = (screen.height-_wh)/2;
  if (wpos_y < 0){ wpos_y = 0;}
 }else{
  wpos_x = 0;
  wpos_y = 0;
 }
// if(_wscrl==undefined){ _wscrl = 0;}
 wind_desc = window.open(_wurl,"","alwaysRaised=0,top="+wpos_y+",left="+wpos_x+",height="+_wh+",width="+_ww+",menubar=0,resizable=1,scrollbars="+_wscrl+",status=1");
 wind_desc.focus();
}
///-------------------------------------------------------------------------------------

function wopen(_wurl,_wn,_ww,_wh,_wscrl){

/***************
	wurl: window URL
	wh: window height
	ww: window width
	wsr: scrollbars 1 - yes, 0 - no
***************/
 if(screen.width){
  wpos_x = (screen.width-_ww)/2;
  if (wpos_x < 0){ wpos_x = 0;}
  wpos_y = (screen.height-_wh)/2;
  if (wpos_y < 0){ wpos_y = 0;}
 }else{
  wpos_x = 0;
  wpos_y = 0;
 }
// if(_wscrl==undefined){ _wscrl = 0;}
 if(_wn==""){ _wn = "w_test";}
 wind_desc = window.open(_wurl,_wn,"alwaysRaised=0,top=0,left="+wpos_x+",height="+_wh+",width="+_ww+",menubar=0,resizable=0,scrollbars="+_wscrl+",status=0");
 wind_desc.focus();
}


function checkPressedKey(event, obj, type){
		/*
		e-mail
		text
		number
		*/
		if (document.all){
			Key = event.keyCode;
		}else{
			Key = event.which;
		}
		switch(type){
			case "not numder":
				if ( (Key>47 && Key<58)){
					obj.value = obj.value;
					return false;
				}
			break;

			case "numder":
				if ( (Key>47 && Key<58) || Key == 8 || Key == 0 || Key == 46 ){
					return true;
				}else{	
					obj.value = obj.value;
					return false;
				}
			break;
		}
	
	}

function calculate(id){
	var count = document.getElementById('num_'+id).value;
	count = Math.round(count);
	document.getElementById('num_'+id).value = count;
	var price = document.getElementById('cost_'+id).innerHTML;
	var price_vat = document.getElementById('cost_vat_'+id).innerHTML;

	//alert(count + " * " + price +" = " + count * price)
	document.getElementById('sum_'+id).innerHTML = round(count * price);
	document.getElementById('sum_vat_'+id).innerHTML = round(count * price_vat);
}
var count_s;
function total(){
	//alert(count_s)
	var sum=0;
	var sum_vat=0;

	for (i=1; i<=count_s; i++){
		sum += document.getElementById('sum_'+i).innerHTML*1;
		sum_vat += document.getElementById('sum_vat_'+i).innerHTML*1;
	}
	document.getElementById('sum').innerHTML = round(sum);
	document.getElementById('sum_vat').innerHTML = round(sum_vat);
}
function check_prod(){
	prod = false;
	for (i=1; i<=count_s; i++){
		if(document.getElementById('num_'+i).value != 0)
			prod = true;
	}
	return prod;
}
function round(val){
	return Math.round(val*100)/100;
}
///-----Sliding-text-----------------------------------------------------
/* EXAMPLE
	fullInfo(ID, BLOCK HEIGHT, SPEED, SPEEDUP);
*/

var bHeight = new Array();
var i = new Array();
var condition = new Array;
var blocked = new Array();
var sVal; 

function move(id,opHeight,speed,speedup){

	bHeight[id] = 1;
if(!i[id])
	i[id] = bHeight[id];

if(speed <= 0)
	speed = 1;

	blocked[id] = 1;
	if(!condition[id]){
		if(i[id] < opHeight){

			if(speedup > 0){
				i[id] += speed * speedup * ((opHeight-i[id])/opHeight)
				i[id] = Math.round(i[id] * 40) / 40;
				if(i[id] > (opHeight-1))
					i[id] = opHeight;
			}else{
				i[id] = i[id] + speed
			}

			if(i[id] > opHeight)
				i[id] = opHeight;
			
			//document.getElementById('trace').innerHTML += i[id] + "<br>";

			document.getElementById(id).style.height = i[id]+'px';
			setTimeout("move('"+id+"',"+opHeight+","+speed+","+speedup+")",50);
		}else{
			
			condition[id] = condition[id]?0:1;
			blocked[id] = 0;
		}
	
	}else{
		if(i[id] > bHeight[id]){
			
			if(speedup > 0){
				i[id] -= speed * speedup * (i[id]/opHeight)
				i[id] = Math.round(i[id] * 40) / 40;
				if(i[id] < (bHeight[id]+1))
					i[id] = bHeight[id];
			}else{
				i[id] = i[id] - speed;
			}			
			//document.getElementById('trace2').innerHTML += i[id] + "<br>";

			if(i[id] < bHeight[id])
				i[id] = bHeight[id];
			document.getElementById(id).style.height = i[id]+'px';
			setTimeout("move('"+id+"',"+opHeight+","+speed+","+speedup+")",50);	
		}else{
			condition[id] = condition[id]?0:1;
			blocked[id] = 0;
		}
	}

}


function fullInfo(id,opHeight,speed,speedup){
if(condition[id] !=1){
	condition[id] = 0;
	i[id] = bHeight[id];
}
if(!blocked[id])
	move(id,opHeight,speed,speedup);
}
///----------------------------------------------------------------------
