function openpopup(url) {
    popup=window.open(url,"popup","width=200,height=200,top=0,left=0,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no");
    return false;
}

function openPopupGallery(url) {
    var windowTop = 50;
    var windowLeft = 50;
    w = 600;
    h = 600;
    var Options = "width=" + w + ",height=" + h + ",top=" + windowTop + ",left=" + windowLeft + ",resizable=no,scrollbars=no"
    var imageWindow = window.open (url, "imageWin", Options);
    imageWindow.document.close ();
    if (window.focus) imageWindow.focus();
    //return false;
}
function openpopup(url, name1, w , h) {
    popup=window.open(url, name1, "width=" + w + ",height=" + h + ",top=0,left=0,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no");
}

// открываем картинку в окошке
function win_open(url, w, h) {
  width = w + 10;
  height = h + 10;
  win = window.open("","popup","width=" + width + ",height=" + height + ",top=100,left=100,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no");
  win.document.writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">');
  win.document.writeln('<html>');
  win.document.writeln('<head>');
  win.document.writeln('<title>' + '' + '</title>');
  win.document.writeln('<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">');
  win.document.writeln('</head>');
  win.document.writeln('<body bgcolor="#ffffff" leftmargin="10" topmargin="10" rightmargin="10" bottommargin="10">');
  win.document.writeln('<img src="' + url + '" width="' + w + '" height="' + h + '">');
  win.document.writeln('</body>');
  win.document.writeln('</html>');
  return true;
}

function openPopupGallery(url) {
    var windowTop = 50;
    var windowLeft = 50;
    w = 600;
    h = 600;
    var Options = "width=" + w + ",height=" + h + ",top=" + windowTop + ",left=" + windowLeft + ",resizable=no,scrollbars=no"
    var imageWindow = window.open (url, "imageWin", Options);
    imageWindow.document.close ();
    if (window.focus) imageWindow.focus();
    //return false;
}

function openFlashPopup(file, w, h) {
  var winW = w + 2;
  var winH = h + 2;
  flashWin = window.open('', 'play', "width="+ winW +",height="+ winH +",top=0,left=0,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no");
  flashWin.document.write('<body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">');
  flashWin.document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+ w +'" height="'+ h +'"  id="main" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="'+ file +'" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><embed src="'+ file +'" quality="high" bgcolor="#000000" width="'+ w +'" height="'+ h +'"  name="main" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
  flashWin.document.write('</body>');
}

function contentErase(obj) {
  if (obj.value == 'Искать') obj.value = '';
}

// проверка заполненности формы отправки резюме
function checkForm() {

  var obj = window.document.forms['resume'];

  var fio =  obj.fio.value.toString();
  var phone =  obj.phone.value.toString();
  var position =  obj.position.value.toString();
  var education = obj.education.value.toString();
  var experience = obj.experience.value.toString();
  //re = new RegExp(/\S+/);
  var re = /\S+/;
  
  //alert(topic);
  //alert(re);
  //alert(topic.search(re));
  if (fio.length > 0 && fio.search(re) != -1
      && phone.length > 0 && phone.search(re) != -1
      && position.length > 0 && position.search(re) != -1
      && education.length > 0 && education.search(re) != -1
      && experience.length > 0 && experience.search(re) != -1
      )
      return true;
  else {
    alert("Поля, обязательные для заполнения, не заполнены или заполнены неправильно.");
    return false;
  }
}

// ограничитель кол-ва вводимых символов для текстарии
function textCounter(field, maxlimit) {
    if (field.value.length > maxlimit) {
        field.value = field.value.substring(0, maxlimit);
    }
}


/*
// проверка заполненности формы добавления поста в разделе "форум"
function checkForm(obj) {
  if (obj.topic.value && obj.author.value && obj.message.value) return true;
  else {
    alert("Заполнены не все поля, обязательные для заполнения. Исправтесь.");
    return false;
  }
}
*/

//browser check
var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

if (checkIt('konqueror'))
{
    browser = "Konqueror";
    OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible'))
{
    browser = "Netscape Navigator"
    version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
    if (checkIt('linux')) OS = "Linux";
    else if (checkIt('x11')) OS = "Unix";
    else if (checkIt('mac')) OS = "Mac"
    else if (checkIt('win')) OS = "Windows"
    else OS = "an unknown operating system";
}

function checkIt(string)
{
    place = detect.indexOf(string) + 1;
    thestring = string;
    return place;
}
//browser check end