// $Revision: 2.0 $

/************************************************************************/
/*                                                                      */
/*                                                                      */
/*                                                                      */
/*                                                                      */
/*                                                                      */
/*                                                                      */
/*                                                                      */
/*                                                                      */
/*                                                                      */
/*                                                                      */
/************************************************************************/

var ns = document.layers;
var ie = document.all;

function showModal(url, wSize, hSize) {
    w = wSize;
    h = hSize;
    var winwidth = screen.availWidth;
    var winheight = screen.availHeight;
    var leftt=Math.floor((winwidth/2)-(w/2));
    var topt=Math.floor((winheight/2)-(h/2));
  
    mod = window.open(url, 'modalFCM', 'height='+h+', width='+w+', left='+leftt+', top=' +topt+'location=0, menubar=0, resizable=0,titlebar=0,status=1,toolbar=0,scrollbars=1');
}  

function login_focus()
{
  if (document.login.bss_username.value == '')
    document.login.bss_username.focus();
  else
    document.login.bss_password.focus();
}

var browser = navigator.appName;

function init(){
  if (browser == "Netscape") {
    layerStyleRef="layer.";
    layerRef="document.layers";
    styleSwitch="";
  } else {
    layerStyleRef="layer.style.";
    layerRef="document.all";
    styleSwitch=".style";
  }
}


function showLayer(layerName){
    
  eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"');
 
}

function hideLayer(layerName){
  eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"');
}

function findObj(n, d) { 
  var p,i,x;  
  if(!d) d=document; 
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
  }
  
  if(!(x=d[n])&&d.all) x=d.all[n]; 
  
  for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);

  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

/*********************************************************/
/* Копирование текста из поля в буфер                    */
/*********************************************************/
function CopyClipboard(obj){
  obj = findObj(obj);
  if (obj) {
    window.clipboardData.setData('Text', obj.value);
  }
}


/*********************************************************/
/* Все свойства объекта                                  */
/*********************************************************/
function fnShowProps(obj, objName){
    var result = "";
    for (var i in obj) // обращение к свойствам объекта по индексу
        result += objName + "." + i + " = " + obj[i] + "<br />\n";
    document.write(result);
}

/* Added by Shirokovskiy D. jimmy@dp.ru */
function fcmShowModal(strPagePath, intWidth, intHeight, stScroll, stResize, strWinName) {
  var scroll = stScroll;
  var resize = stResize;

  if ( strWinName == '' )
    strWinName = 'fcmModal';

  if ( resize == '' )
    resize = 'yes';

  var top=0, left=0;
  if(intWidth > screen.width-10 || intHeight > screen.height-28) {
    scroll = 'yes';
  }

  if(intHeight < screen.height-28)
    top = Math.floor((screen.height - intHeight)/2-14);

  if(intWidth < screen.width-10)
    left = Math.floor((screen.width - intWidth)/2);

  intWidth = Math.min(intWidth, screen.width-10);
  intHeight = Math.min(intHeight, screen.height-28);
  window.open(strPagePath, strWinName, 'menubar=no, scrollbars='+scroll+', resizable='+resize+', width='+intWidth+', height='+intHeight+', left='+left+', top='+top);
}