     function delCookie (cookieName){
       document.cookie = cookieName + "=" +"; expires=Thu, 01-Jan-1970 00:00:01 GMT";
    }

function countLen(f,l) {
var realLength = 0;
var message = document.getElementById("element"+f);
var send_link = document.getElementById("link_len"+f);
message_text = message.value;
linkmaxlen = l;
realLength = 0;
storeLength = 0;
storeRealLength = 0;
	for (i=0; i<message_text.length; i++) {
	big_sign = false;
		if (realLength<=linkmaxlen) {
			storeRealLength = realLength;
			storeLength = i
		}
			if (!big_sign)  realLength += 1;
	}

		if (realLength>linkmaxlen) {
			realLength = storeRealLength;
			message.value = message_text.substring(0,storeLength);
		}

	send_link.value=linkmaxlen-realLength;
}

		function valid(id,num,txt) {
			if(id.value==num) {
			alert(txt);
			id.focus();
			return false;
			exit;
			}
		}
function added()
{
    // Confirmation is not required in the configuration file
    // or browser is Opera (crappy js implementation)
//    if (confirmMsg == '' || typeof(window.opera) != 'undefined') {
//        return true;
//    }
    var confirmMsg  = 'Только зарегистрованным пользователям! ';
    var is_confirmed = confirm(confirmMsg + ' \n зарегистрироваться сейчас?');
    if (is_confirmed) {
        wopen('reg.html','add',100,200);
    }

//    return is_confirmed;
}

function confirmLink(theLink, theSqlQuery)
{
    // Confirmation is not required in the configuration file
    // or browser is Opera (crappy js implementation)
    if (confirmMsg == '' || typeof(window.opera) != 'undefined') {
        return true;
    }
    var confirmMsg  = 'Вы уверены что хотите';
    var is_confirmed = confirm(confirmMsg + ' :\n' + theSqlQuery);
    if (is_confirmed) {
        theLink.href += '&is_js_confirmed=1';
    }

    return is_confirmed;
}

function ShowTip() {
//меняем стиль
var div1=document.getElementById("div1");
var div2=document.getElementById("div2");
    div1.style.display="block";
    div2.style.display="none";
}

function popupWindow(url, w, h) {
         var attributes = "width=" + w + ",height=" + h + ",";
         attributes += "resizable=yes,scrollbars=yes,status=no,";
         attributes += "menubar=no,toolbar=yes,location=no,directories=no";
         var popWin = window.open(url, 'popWin', attributes);
         popWin.focus();
}

function wopen(wurl,wname,h,w)
{
window.open(wurl,wname,'height='+h+',width='+w+',resizable=no,scrollbars=no,menbar=no,status=no');
}


function newPage(url,targetWin) {
 if (self.opener) {
          if ((targetWin == self.opener.name) && (!self.opener.closed)) {
            self.opener.location = url; }
          else {
            var newWin = window.open(url,targetWin);
            newWin.location = url;
   }
   self.close();
 }
 else {
     window.location = url;
 }
}

var v1=null;
function PopUp(h) {
if(!h) {
h=600;
}
if (v1==null || v1.closed) {
  var top=((screen.height)/2)-250;
    var height=((screen.width)/2)-550;
      v1=window.open("about:blank","v1","width=600,height="+h+",scrollbars=yes,top="+top+",left="+height+",resizable=0");
      }
      else
      v1.focus();
      }


// Lasto added functions start: //
function calc(id,email){window.open(host+'counter.php?id='+id+'&mail='+email+'&','secret_area');}
function calc_add(id){window.external.AddFavorite(location.href,document.title); calc(id,'');}
function checkEmail(str){if(!str.match(/^[\w]{1}[\w\.\-_]*@[\w]{1}[\w\-_\.]*\.[\w]{2,4}$/i)) return false; else return true;}

function validate_auth(f,id){if(!checkEmail(f.auth_email.value)){alert('Некорректный email');f.auth_email.focus(); return false; exit;}
 if(id)calc(id,f.auth_email.value); return true;}

function validate(f,id){if(!checkEmail(f.email.value)){alert('Некорректный email');f.email.focus(); return false; exit;}
 if(id)calc(id,f.email.value); return true;}
// Lasto added functions end: //

function MM_preloadImages() { //v3.0
   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_reloadPage(init) {  //reloads the window if Nav4 resized
   if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
      document.MM_pgW=innerWidth;
      document.MM_pgH=innerHeight;
      onresize=MM_reloadPage; }
   } else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_swapImgRestore() { //v3.0
   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) { //v4.01 // ?
   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() { //v3.0
   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 valid_cacc() {

var FormName = document.cangeacc;
	if(FormName.password.value==0) {
		alert('Пароль не может быть пустым!');
		FormName.password.focus();
		return false;
		} else if(FormName.name.value.length==0) {
            alert('Имя не может быть пустым!');
            FormName.name.focus();
            return false;
                } else if(!FormName.email.value.match(/^[a-z0-9\._-]+@[a-z0-9\.-]+\.[a-z]{2,4}$/i)) {
                    alert('Не корректный email!');
                    FormName.email.focus();
                    return false;
                    }
}

