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 PNG(element)
{
if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent))
{
var src;

if (element.tagName=='IMG')
{
if (/\.png$/.test(element.src))
{
src = element.src;
element.src = "/img/sys/t.gif";
}
}
else
{
src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i)
if (src)
{
src = src[1];
element.runtimeStyle.backgroundImage="none";
}
}

if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
}
}


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;
}
// tags menu 
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
function read() {
	var x = readCookie('menuview')
	
	if (!x) {
		document.getElementById('menu').style.display = 'none';	
		document.getElementById('tags_menu').style.display = 'block';
	} else {	
		if (x=="menu") {
			document.getElementById('menu').style.display = 'block';	
			document.getElementById('tags_menu').style.display = 'none';
			
		} else {
		
			if (x=="tags_menu") {
				document.getElementById('menu').style.display = 'none';	
				document.getElementById('tags_menu').style.display = 'block';
			
			} 
		}
	}		
} 
function showmenu(theid) {
	createCookie('menuview',theid,7);
	var x = readCookie('menuview');
	if (!x) {
		document.getElementById('menu').style.display = 'none';	
		document.getElementById('tags_menu').style.display = 'block';
		createCookie('menuview',theid,7);
		
		if (theid=="menu") {
			document.getElementById('menu').style.display = 'block';	
			document.getElementById('tags_menu').style.display = 'none';
			createCookie('menuview','menu',7);
			
		} else {		
			if (theid=="tags_menu") {
				document.getElementById('menu').style.display = 'none';	
				document.getElementById('tags_menu').style.display = 'block';
				createCookie('menuview','tags_menu',7);				
			} 
		}		
	} else {	
		if (x=="menu") {
			document.getElementById('menu').style.display = 'block';	
			document.getElementById('tags_menu').style.display = 'none';
			createCookie('menuview','menu',7);			
		} else {
		
			if (x=="tags_menu") {
				document.getElementById('menu').style.display = 'none';	
				document.getElementById('tags_menu').style.display = 'block';
				createCookie('menuview','tags_menu',7);
			} 
		}
	}	
}
/*add Bookmark*/
function addBookmark(title,url) {  
if (window.sidebar) {  
	window.sidebar.addPanel(title, url,"");  
	} else if( document.all ) {  
		window.external.AddFavorite( url, title);  
		} else if( window.opera && window.print ) {  
			return true;  
			}  
} 
/* show and hide popup */
function showdiv(id) {
	var el=document.getElementById(id);
	if (el.style.display=='block') {
		el.style.display = 'none';
	}
	else {
		el.style.display='block';		
	}
}
