//для всплывающих окон типа Pop-up. Можно указать размеры и положение на экране
//если не указано, то берется размер равный 350*500, а положение top=40, left=150
//можно задавать размер окна в процентах, а так же в математических выражениях в
//формате javascript (для tx и ty только либо в пикселах, либо в математических выражениях)
//причем в математических выражениях можно использовать ссылку на сами аргументы. Например:
//Pop('some.htm',650,'100%','screen.width/2 - x/2',0)
function Pop(item,x,y,tx,ty){
   res = item.indexOf(".htm");
   if(res<0){
      res = item.indexOf(".php");
   }
   if(res<0){
      res = item.indexOf(".pdf");
   }
   if(isNaN(y) && y!=undefined){
      if((tmp = y.indexOf("%"))>0){
         y = Math.round(screen.height * y.substring(0,tmp)/100);
      }else{
         y = Math.round(eval(y));
      }
   }
   if(isNaN(x) && x!=undefined){
      if((tmp = x.indexOf("%"))>0){
         x = Math.round(screen.width * x.substring(0,tmp)/100);
      }else{
         x = Math.round(eval(x));
      }
   }
  if(isNaN(tx) && tx!=undefined){
      tx = Math.round(eval(tx));
   }
  if(isNaN(ty) && ty!=undefined){
      ty = Math.round(eval(tx));
   }
   if(res>=0){
      if(x==undefined || x==0) x=350;
      if(y==undefined || y==0) y=500;
      if(tx==undefined || tx==0) tx=150;
      if(ty==undefined || ty==0) ty=40;
      win_atr = "directories=0,height="+y+",width="+x+",top="+ty+",left="+tx+",location=no,menubar=no,resizable=yes,status=no,toolbar=no,titlebar=No,scrollbars=Yes";
   }else{
      if(x==undefined || x==0) x=300;
      if(x==undefined || x==0) y=300;
      if(x==undefined || x==0) tx=20;
      if(x==undefined || x==0) ty=100;
      win_atr = "directories=0,height="+y+",width="+x+",top="+ty+",left="+tx+",location=no,menubar=no,resizable=yes,status=no,toolbar=no,titlebar=No";
   }
   if(res >= 0){
      MyWin = window.open(item,"_blank",win_atr);
   }else{
      MyWin = window.open("","_blank",win_atr);
      MyWin.document.open();
      MyWin.document.write("<script>function sh(){X=document.images[0].width+30;Y=document.images[0].height+60;if(X>screen.width || Y>screen.height) document.body.scroll='yes';if(X>screen.width) X=screen.width;if(Y>screen.height) Y=screen.height;window.resizeTo(X,Y);}</script>");
      MyWin.document.write("<body onClick=javascript:window.close() style='text-Align:justify' onLoad=sh();>");
      MyWin.document.write("<center><img border=0 src="+item+"></center>");
      MyWin.document.close();
   }
}

BlinkItCnt = 0;
function BlinkItBG(IDName,FirstColor,SecondColor,msPerColor,msPerLoop){
   Obj = document.getElementById(IDName);
   if(BlinkItCnt%2>0){
      Obj.style.color = FirstColor;
   }else{
      Obj.style.color = SecondColor;
   }
   BlinkItCnt ++;
   if(BlinkItCnt>5){
      BlinkItCnt = 0;
      clearTimeout(BlinkItTimer);
      BlinkItTimer = setTimeout('BlinkItBG("'+ IDName +'","'+ FirstColor +'","'+ SecondColor +'",'+msPerColor+','+ msPerLoop +')',msPerLoop);
   }else{
      BlinkItTimer = setTimeout('BlinkItBG("'+ IDName +'","'+ FirstColor +'","'+ SecondColor +'",'+msPerColor+','+ msPerLoop +')',msPerColor);
   }
}

/**
*
*  Javascript trim, ltrim, rtrim
*  http://www.webtoolkit.info/
*
**/
 
//function trim(str, chars) {
//	return ltrim(rtrim(str, chars), chars);
//}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}