function newText(text,width,height)
	{
		win=open("","","width="+width+"px ,height="+height+"px");
		win.document.write('<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1251"><link href="http://oda.ua/images/jscript/style.css" rel="stylesheet"></head><body><div style="padding:30px;">'+text+'</div></body></html>');
       		win.document.close();
	}

function newWin(nameImg,width,height)
	{
		win=open("","","width="+width+"px ,height="+height+"px");
		win.document.write('<body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0><table width="'+width+'px" height="'+height+'px" cellpadding=0 cellspacing=0 border=0><tr><td align=center><img src="'+nameImg+'" style="cursor:hand;" onclick="window.close();" alt="Picture" title="Picture"></td></tr></table></body></html>');
       		win.document.close();
	}



function newWinHtml(nameImg,width,height)
	{
		win=open(nameImg,"","width="+width+"px ,height="+height+"px, scrollbars=yes");
	}

function open_window(link,w,h) {
 var win = "width="+w+",height="+h+",menubar=no,location=no,resizable=no,scrollbars=yes";
 newWin = window.open(link,'newWin'+w+h,win);
} 



function supp_show(posx,posy){
supp_e = document.getElementById('supp');
supp_e.style.display='';
supp_e.style.left=posx+document.body.scrollLeft;
supp_e.style.top=posy-100+document.body.scrollTop;
}

function alt_object(obj,st,posx,posy){
supp_e = document.getElementById(obj);
supp_e.style.display=st;
supp_e.style.left=posx+document.body.scrollLeft;
supp_e.style.top=posy-100+document.body.scrollTop;
}



function supp_notshow(){
supp_e = document.getElementById('supp');
supp_e.style.display='none';
}

function AddTableShadow(element){
var ret='<table border="0" cellpadding="0" cellspacing="0"><tr><td style="background:url(http://oda.ua/images/jscript/sha_tl.png) left top no-repeat;" width="35" height="35"><img src="http://oda.ua/images/jscript/0.gif" width="35" height="35" class="nullgif"></td><td style="background:url(http://oda.ua/images/jscript/sha_t.png) left top repeat-x;" height="35"><img src="http://oda.ua/images/jscript/0.gif" width="1" height="35" class="nullgif"></td><td style="background:url(http://oda.ua/images/jscript/sha_tr.png) right top no-repeat;" width="35" height="35"><img src="http://oda.ua/images/jscript/0.gif" width="35" height="35" class="nullgif"></td></tr><tr><td style="background:url(http://oda.ua/images/jscript/sha_l.png) left top repeat-y;" width="35"><img src="http://oda.ua/images/jscript/0.gif" width="35" height="1" class="nullgif"></td><td style="background-color:#fff;">'+element+'</td><td style="background:url(http://oda.ua/images/jscript/sha_r.png) right top repeat-y;" width="35"><img src="http://oda.ua/images/jscript/0.gif" width="35" height="1" class="nullgif"></td></tr><tr><td style="background:url(http://oda.ua/images/jscript/sha_bl.png) left bottom no-repeat;" width="35" height="35"><img src="http://oda.ua/images/jscript/0.gif" width="35" height="35" class="nullgif"></td><td style="background:url(http://oda.ua/images/jscript/sha_b.png) left bottom repeat-x;" height="35"><img src="http://oda.ua/images/jscript/0.gif" width="1" height="35" class="nullgif"></td><td style="background:url(http://oda.ua/images/jscript/sha_br.png) right bottom no-repeat;" width="35" height="35"><img src="http://oda.ua/images/jscript/0.gif" width="35" height="35" class="nullgif"></td></tr></table>';                
return ret;
}

function SetRelPosition(element,toelement,pos){
  //pos =2- слева от toelement
  //pos = 1- сверху над toelement
  //pos = 3- справа от toelement
  //pos = 4 - снизу под toelement
  if (pos == 2) {
    var newleft=$(toelement).position().left - $(element).width();
    var newtop=$(toelement).position().top - $(element).height()/2 + $(toelement).height()/2;
  } else if (pos == 1) {
    var newleft=$(toelement).position().left - $(element).width()/2 + $(toelement).width()/2;
    var newtop=$(toelement).position().top - $(element).height() ;
  } 
  else if (pos == 3) {
    var newleft=$(toelement).position().left + $(toelement).width();
    var newtop=$(toelement).position().top - $(element).height()/2 + $(toelement).height()/2;
  } 
  else if (pos == 4) {
    var newleft=$(toelement).position().left - $(element).width()/2 + $(toelement).width()/2;
    var newtop=$(toelement).position().top + $(toelement).height();
  } 
  
  var ewidth = $(element).width()+20;
  var newright = newleft+ewidth;
  var maxright = $(document).width();
  if (newleft<0) {
    do {
      newleft=newleft+10;
      newright = newleft+ewidth;
    } while (newleft<0 && newright<maxright)
  }
  if (newright>maxright) {
    do {
      newleft=newleft-10;
      newright = newleft+ewidth;
    } while (newleft>0 && newright>maxright)
  }
  $(element).css('left',newleft);
  $(element).css('top',newtop);
}


