
function getObjectY(Elem) {
   yPos = eval(Elem).offsetTop;
   tempEl = eval(Elem).offsetParent;
     while (tempEl != null) {
      yPos += tempEl.offsetTop;
      tempEl = tempEl.offsetParent;
     }
   return yPos;
}

function getObjectX(Elem) {
   xPos = eval(Elem).offsetLeft;
   tempEl = eval(Elem).offsetParent;
     while (tempEl != null) {
      xPos += tempEl.offsetLeft;
      tempEl = tempEl.offsetParent;
     }
   return xPos;
}



function putSwfCode(ObjSrc, W, H, Params)
{
        var str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+W+'" height="'+H+'">' +
                      '<param name="movie" value="'+ObjSrc+'"/>\n' +
                      '<param name="quality" value="high"/>\n';
        if(Params){
        	for(ind in Params) { str += '\n<param name="'+ind+'" value="'+Params[ind]+'"/>';}
        }
        str += '<embed src="'+ObjSrc+'" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'+W+'" height="'+H+'"';
        if(Params){
        	for(ind in Params){str += ' '+ind+'="'+Params[ind]+'"';}
        }
        str += '></embed>\n' +
                  '</object>';
        document.write(str);
}


function openform(url){
  another=open(url, 'OpenFile', 'top=140, left=140, width=560, height=440, scrollbars=yes, status=no, titlebar=no, toolbar=no, location=no, menubar=no, resizable=no');

  //return false;
}


/* для появления формы по клику чекбокса
function feedback(name,id,url) {
//alert(url);
    if(document.getElementById(name).checked) {
      document.getElementById("submit_form").src="/services/official_part.phtm?mech=feedback&action_=add&id="+id+"&url="+url;
      document.location = url;
    }
    else {
      document.getElementById("submit_form").src="/services/official_part.phtm?mech=feedback&action_=del&id="+id+"&url="+url;
      document.location = url;
    }
}
*/

function submit_mess(url) {

  if(document.getElementById('f_name').value.length < 1) {
    alert("Не заполнено поле Имя");
    document.getElementById('f_name').focus();
    return false;
  }
  if(document.getElementById('f_email').value.length < 1) {
    alert("Не заполнено поле E-mail");
    document.getElementById('f_email').focus();
    return false;
  }

  /*  Проверка E-mail  */
    var email=eval("document.getElementById('f_email')");
    var reg = new RegExp('[0-9a-z_]+@[0-9a-z_^.]+\\.[a-z]', 'i');
    if (!reg.test(email.value)) {
      alert('E-mail введен неверно');
      email.focus();
      return false;
    }
    /*  Проверка E-mail  */

  if(document.getElementById('f_theme').value.length < 1) {
    alert("Не заполнено поле Тема");
    document.getElementById('f_theme').focus();
    return false;
  }
  if(document.getElementById('f_mess').value.length < 1) {
    alert("Не заполнено поле Сообщение");
    document.getElementById('f_mess').focus();
    return false;
  }
  alert("Ваше сообщение отправлено!");
  document.location = url;
}

function positioning(arg)
{
	alert('1-'+document.body.scrollTop);
        arg.style.top=document.body.scrollTop;
}

// узнаем размеры окошка броузера пользователя
function SizeScreen(divw,divh) {

  var hh = '';
  var ww = '';

  if(navigator.appName == "Opera" || navigator.appName == "Netscape") {

        hh = innerHeight;
        ww = innerWidth;
  }
  else {
        hh = document.getElementById('body').clientHeight;
        ww = document.getElementById('body').clientWidth;
  }
  divw = divw.replace('px','');
  divh = divh.replace('px','');
  if(divw!='' && divh!='') {
    ww=Math.round(50-(((100/ww)*divw)/2),1,2);
    hh=Math.round(50-(((100/hh)*divh)/2),1,2);

    arg.style.top = hh+'%';
    arg.style.left = ww+'%';
  }
  else {

    hh = (hh/2);
    ww = (ww/2);

    arg.style.top = hh;
    arg.style.left = ww;
  }
}

// клик на онке
function ClickFaq() {
        flag = 0;
}

function CloseFaq() {
  if(flag == 1) {
                arg = eval("document.getElementById('faq_div')");
                arg.style.display = 'none';
                document.onclick = null;
  }
  flag = 1;
}



function faq(question,count1,answer,count2) {

  //alert(question+' - '+count1);
  //alert(answer+' - '+count2);

  arg = eval("document.getElementById('faq_div')");

  SizeScreen(arg.style.width,arg.style.height);


  arg.style.display = 'block';

  if(arg.style.display!='block')
    {
      positioning(arg);
      arg.style.display = 'block';
    }

  var qu = question;
  if(count1 != 0) {
    for (var i = 0; i < count1; i++) {
      qu = qu.replace("<1>",'"');
    }

    document.getElementById('faq_quest').innerHTML = qu;
  }
  else {
    document.getElementById('faq_quest').innerHTML = qu;
  }


  var an = answer;
  if(count2 != 0) {
    for (var i = 0; i < count2; i++) {
      an = an.replace("<1>",'"');
    }
    document.getElementById('faq_ans').innerHTML = an;
  }
  else {
    document.getElementById('faq_ans').innerHTML = an;
  }

  flag = 0;
  document.onclick = CloseFaq;
  arg.onclick = ClickFaq;
  return false;


}

function open_window() {
	if(!arguments[0]) return(false);
	var win_width, win_height;
	win_width = arguments[1] ? arguments[1] : 800;
	win_height = arguments[2] ? arguments[2] : 600;
	var popupWin = window.open(arguments[0], 'modal_window', 'frameborder=0,toolbar=0,location=0,directoties=0,status=0,menubar=0,scrollbars=1,resizable=1,width=' + win_width + ',height=' + win_height + '');
	popupWin.focus();
}