opera = (navigator.userAgent.indexOf('Opera') >= 0)? true : false; ie = (document.all && !opera)? true : false; dom = (document.getElementById && !ie && !opera)? true : false; 
function simpleTextCounter(field, countfield)
{
  var textCount = field.value.length;
  var plural = "s";
  if( field.value.match(/\r\n/) ) {
    // Some browsers count newline as two characters
    var numNewlines = field.value.match(/\r\n/g).length;
    textCount = field.value.length;
  }
  else if( field.value.match(/\n/) ) {
    // Some browsers count newline as one character
    var numNewlines = field.value.match(/\n/g).length;
    textCount = field.value.length + (numNewlines);
  }

  countfield.innerHTML = '&nbsp;&nbsp;(' + textCount + ' symbols)';

}
function SelectAllCheck(obj,mark,name) { var form = obj.form; for (i = 0; i < form.elements.length; i++) { var item = form.elements[i]; if (item.name == name) { item.checked = mark;}; if (item.id == obj.id) { item.checked = mark;}
}
}
function select_check(obj,name, name2) { var form = obj.form; var k = 0; var j = 0; var x = Array(); var num_all = 0; for (i = 0; i < form.elements.length; i++) { var item = form.elements[i]; if (item.name == name) { j++; if (item.checked) { k++;}
}
if (item.name == name2) { x[num_all] = item; num_all++;}
}
var x1; for (i = 0; i < num_all; i++) { x1 = x[i]; if (x1 && j == k) { x1.checked = true;} else { x1.checked = false;}
}
}
function doPreviewImg(param1, param2) { if (dom) { var src = document.getElementById(param1).value;} else if (ie) { var src = document.all[param1].value;}
if (dom) { document.getElementById(param2).src = src;} else if (ie) { document.all[param2].src = src;}
}
function PreviewAdImg() { document.add_personal_ad_form.act.value = "preview_image"; document.add_personal_ad_form.submit(); return false;}
var img_i = 1; function changeImages(id, imagesCount, images_dir) { var el = document.getElementById(id); var i = img_i; el.src = images_dir + sprintf("%08.0d", i) + ".jpg"; img_i = (i + 1) % imagesCount;}
function getWindowWidth()
{ return window.innerWidth ? window.innerWidth : document.body.offsetWidth;}
function getWindowHeight()
{ return window.innerHeight ? window.innerHeight : document.body.offsetHeight;}
function viewPopup(m, w, h) { var scroll = 'yes'; var settings; var LeftPosition; var TopPosition; var win; if (document.body.offsetWidth) { w = w + 20; h = h + 1;}
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0; TopPosition = (screen.height) ? (screen.height-h)/2 : 0; settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll; settings = settings + ',resizable=no,maximize=yes,status=no,toolbar=no,directories=no,menubar=no,location=no'; win = window.open(m, 'pre', settings); win.focus();}
function __hsShowMessage(msg, cssClass) { 
  res = hs.htmlExpand(document.getElementById('update_show_'), { contentId: 'highslide-html-'} ); 
}
function _hsShowMessage(msg, cssClass, msg_time) { 
  var el = document.getElementById("highslide-body"); 
  el.innerHTML = msg; 
  id = el.id; 
  var align = hs.align; 
  var expandSteps = hs.expandSteps; 
  var restoreSteps = hs.restoreSteps; 
  var expandDuration = hs.expandDuration; 
  var restoreDuration = hs.restoreDuration; 
  var outlineType = hs.outlineType; 
  var allowSizeReduction = hs.allowSizeReduction; 
  var anchor = hs.anchor; 
  var _flag = hs._flag; 
  hs.align = "center"; 
  hs.expandSteps = 50; 
  hs.restoreSteps = 50; 
  hs.expandDuration = 500; 
  hs.restoreDuration = 500; 
  hs.outlineType = null; 
  hs.allowSizeReduction = true; 
  hs.anchor = "top"; hs._flag = 1; if (!msg_time) { msg_time = 4000;}
  if (msg_time > 0) {
     setTimeout("hsHideMessage();", msg_time); 
  }
  var res; 
  __hsShowMessage(msg, cssClass);
  el.id = id; 
  hs.align = align; 
  hs.expandSteps = expandSteps; 
  hs.restoreSteps = restoreSteps; 
  hs.expandDuration = expandDuration; 
  hs.restoreDuration = restoreDuration; 
  hs.outlineType = outlineType; 
  hs.allowSizeReduction = allowSizeReduction; 
  hs.anchor = anchor; 
//  return false;
}
function hsHideMessage() { hs._flag = null; return hs.close(document.getElementById('update_hide_'));}
