var submitcount=0;
   function checkSubmit() {

      if (submitcount == 0)
      {
      submitcount++;
      document.Surv.submit();
      }
   }


function wordCounter(field, countfield, maxlimit) {
wordcounter=0;
for (x=0;x<field.value.length;x++) {
      if (field.value.charAt(x) == " " && field.value.charAt(x-1) != " ")  {wordcounter++}  
      if (wordcounter > 250) {field.value = field.value.substring(0, x);}
      else {countfield.value = maxlimit - wordcounter;}
      }
   }

function textCounter(field, countfield, maxlimit) {
  if (field.value.length > maxlimit)
      {field.value = field.value.substring(0, maxlimit);}
      else
      {countfield.value = maxlimit - field.value.length;}
  }
function checkBrowser(){
this.ver=navigator.appVersion;
this.dom=document.getElementById?1:0;
this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;
this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
this.ns6=(this.dom && parseInt(this.ver)>= 5)?1:0;
this.safari=(this.ver.indexOf("safari")>-1)?1:0;
this.ns4=(document.layers && !this.dom)?1:0;
this.opr=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1)?1:0;
return this
}

function paste_strinL(strinL,isQuote){ 
if(strinL=='') alert('Please, select some text first!');
else{
if (isQuote==1) {
strinL='[i]'+strinL+'[/i]'+'\n';
}
if (isQuote==2) {
strinL='[b]'+strinL+'[/b]'+'\n';
}
var isForm=document.forms["postMsg"];
if (isForm) {
var input=document.forms["postMsg"].elements["postText"];
input.value=input.value+strinL; 
}
else alert('Posting BBCodem has been disabled.');
}
}

function pasteSel() { 
if(document.getSelection) selection=document.getSelection(); 
else if(document.selection) selection=document.selection.createRange().text; 
else if(window.getSelection) selection=window.getSelection(); 
else selection=''; 
}

function confirmDelete(id,what){
var mes,url='forum={$forum}&topic={$topic}&';
if(what==0) { mes='{$l_areYouSureDeletePost}'; url=url+'action=delmsg&pages={$page}&post='+id; } else { mes='{$l_areYouSureDeleteTopic}'; url=url+'action=deltopic'; }
if(confirm(mes))
document.location='{$main_url}{$indexphp}'+url;
}

function FCx(x){
  var min=30; // minimum minutes between interstitials (needs to be >15)
  if(x.indexOf('get.media')>0){
    x=unescape(x.substring(x.indexOf('&url=')+5,x.length));
  }else{
    if(document.cookie.indexOf('CxIC=1')<=0){
      x='http://media.fastclick.net/w/get.media?sid=25607&m=5&tp=6&url='+escape(x);
      var date_ob=new Date();
      date_ob.setTime(date_ob.getTime()+min*1000*60);
      document.cookie='FCxIC=1; path=/; expires='+date_ob.toGMTString();
    }
  }
  return x
}

var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}

var popUpWin=0;
function popUpWindow(URLStr, width, height) {
if(popUpWin) if(!popUpWin.closed) popUpWin.close();
var left = (screen.width/2) - width/2;
var top = (screen.height/2) - height/2;
popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function MM_preloadImages() {
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; }
function MM_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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() {
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function confirmLink(Link, Msg){
if (typeof(window.opera) != 'undefined') return true;
var is_confirmed = confirm(Msg);
return is_confirmed;
}

colorover='#E0E0E0'; colorout='#F0F0F0'; colorclick='#F0D8D8';
function mv (object) { if (object.style.backgroundColor.toUpperCase()!=colorclick) object.style.backgroundColor=colorover; }
function mo (object) { if (object.style.backgroundColor.toUpperCase()!=colorclick) object.style.backgroundColor=colorout; }
function mc (object) { if (object.style.backgroundColor.toUpperCase()!=colorclick) object.style.backgroundColor=colorclick; else object.style.backgroundColor=colorover; }
function m (object, color) { object.style.backgroundColor=color; }

if (document.getElementById && !document.all) { var nsmousepos = new Object(); nsmousepos.pageX = 0; nsmousepos.pageY = 0; nsmousepos.clientX = 0; nsmousepos.clientY = 0; }
function getMouseXY(e) { if (document.getElementById && !document.all) { nsmousepos.pageX = e.pageX; nsmousepos.pageY = e.pageY; nsmousepos.clientX = e.clientX; nsmousepos.clientY = e.clientY; }}

function ietruebody() { return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body }

function tooltip(obj){
var ie=document.all
var ns6=document.getElementById && !document.all
if (ie||ns6) {
var tipobj=document.all?document.all[obj] : document.getElementById? document.getElementById(obj) : ""
var curX=(ns6)?nsmousepos.pageX : event.x+ietruebody().scrollLeft;
var curY=(ns6)?nsmousepos.pageY : event.y+ietruebody().scrollTop;
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX : window.innerWidth-nsmousepos.clientX-16
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY : window.innerHeight-nsmousepos.clientY
var leftedge= -1000
if (rightedge<tipobj.offsetWidth) tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+nsmousepos.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge) tipobj.style.left="5px"
else tipobj.style.left=curX+"px"
if (bottomedge<tipobj.offsetHeight) tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight+16+"px" : window.pageYOffset+nsmousepos.clientY-tipobj.offsetHeight-16+"px"
else tipobj.style.top=curY+16+"px"
tipobj.style.visibility="visible"
document.body.style.cursor="help";
}}

function hidetip(obj){
var ie=document.all
var ns6=document.getElementById && !document.all
if (ie||ns6) {
var tipobj=document.all?document.all[obj] : document.getElementById? document.getElementById(obj) : ""
tipobj.style.visibility="hidden";
tipobj.style.left="-1000px";
document.body.style.cursor="auto";
}}

function floatit(obj){
var ie=document.all
var ns6=document.getElementById && !document.all
if (ie||ns6) {
var tipobj=document.all?document.all[obj] : document.getElementById? document.getElementById(obj) : ""
tipobj.style.left = "0px"
tipobj.style.top = ie? ietruebody().scrollTop+"px" : window.pageYOffset+"px"
}}
function goAni(){
    window.setTimeout(function(){ document.getElementById('img').src=document.getElementById('img').src; }, 50);
}