//===========================
function getPageSize()
{ var xScroll, yScroll;

  if (window.innerHeight && window.scrollMaxY) {
            xScroll = window.innerWidth + window.scrollMaxX;
            yScroll = window.innerHeight + window.scrollMaxY;
        } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
            xScroll = document.body.scrollWidth;
            yScroll = document.body.scrollHeight;
        } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
            xScroll = document.body.offsetWidth;
            yScroll = document.body.offsetHeight;
        }

  var windowWidth, windowHeight;

  if (self.innerHeight) {    // all except Explorer
     if(document.documentElement.clientWidth){
                windowWidth = document.documentElement.clientWidth;
            } else {
                windowWidth = self.innerWidth;
            }
            windowHeight = self.innerHeight;
        } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
            windowWidth = document.documentElement.clientWidth;
            windowHeight = document.documentElement.clientHeight;
        } else if (document.body) { // other Explorers
            windowWidth = document.body.clientWidth;
            windowHeight = document.body.clientHeight;
        }
        // for small pages with total height less then height of the viewport
        if(yScroll < windowHeight){
            pageHeight = windowHeight;
        } else {
            pageHeight = yScroll;
        }

        // for small pages with total width less then width of the viewport
        if(xScroll < windowWidth){
            pageWidth = xScroll;
        } else {
            pageWidth = windowWidth;
        }

        //get scroll coordinates
        var xCoord;
        var yCoord;
        if (document.all){
                xCoord = document.documentElement.scrollLeft;
                yCoord = document.documentElement.scrollTop;
            }
        else{
                xCoord = window.pageXOffset;
                yCoord = window.pageYOffset;
            }

    if(pageWidth<940) { pageWidth=940; };
    var arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight,xCoord,yCoord);
    return arrayPageSize;
}
//===========================
function getObjLeft(obj)
{ if (document.layers) { return docjslib_getImageXfromLeft(obj);  }
  else if (document.all) { return docjslib_getRealLeft(obj); }
  else if (document.getElementById) { return firefox_getRealLeft(obj); }
}
//===========================
function docjslib_getRealLeft(imgElem)
{ xPos = eval(imgElem).offsetLeft;  tempEl = eval(imgElem).offsetParent;
  while (tempEl != null)
   { xPos += tempEl.offsetLeft;  tempEl = tempEl.offsetParent;
   }
  return xPos;
}
//===========================
function firefox_getRealLeft(imgElem)
{ xPos = imgElem.offsetLeft;  tempEl = eval(imgElem).offsetParent;
  while (tempEl != null)
   { xPos += tempEl.offsetLeft;  tempEl = tempEl.offsetParent;
   }
  return xPos;
}
//===========================
function getObjTop(obj)
{ if (document.layers) { return docjslib_getImageYfromTop(obj); }
  else if (document.all) { return docjslib_getRealTop(obj); }
  else if (document.getElementById) { return firefox_getRealTop(obj); }
}
//===========================
function docjslib_getRealTop(imgElem)
{ yPos = eval(imgElem).offsetTop;  tempEl = eval(imgElem).offsetParent;
  while (tempEl != null)
  {	yPos += tempEl.offsetTop;  tempEl = tempEl.offsetParent;
  }
  return yPos;
}
//===========================
function firefox_getRealTop(imgElem)
{ xPos = imgElem.offsetTop;  tempEl = eval(imgElem).offsetParent;
  while (tempEl != null)
   { xPos += tempEl.offsetTop;  tempEl = tempEl.offsetParent;
   }
  return xPos;
}
//==========================
function key_press(e,key,key2,num)
{ var flag=0; if(key==0) { key=key2; }
  switch(num)
   { case 1: if((key==45) || ((key>47)&(key<58)) || ((key>96)&(key<123))||(key==8)||(key==39)||(key==37)) {  flag=1; };
             break;
     case 2: if((key>47)&(key<58)||(key==8)||(key==39)||(key==37)||(key==46)) { flag=1; };
             break;
     case 3: if((key==46) || ((key>47)&(key<58))||(key==8)||(key==39)||(key==37)) {  flag=1; };
             break;
     case 6: if((key==63) || (key==43) || (key==61) || (key==38) || (key==35)||(key==8)||(key==39)||(key==37)) { flag=0; }
             else { flag=1; }
             break;
     case 7: if((key==45)||(key==46)||(key==95)||((key>47)&(key<58))||((key>96)&(key<123))||((key>63)&(key<91))||(key==8)||(key==39)||(key==37)) { flag=1; };
             break;
     case 8:
             if((key==32)||(key==45)||((key>47)&(key<58))||(key==8)||(key==39)||(key==37)) {  flag=1; };
             break;
   }
  if(flag==0) { return false; };
}
//===========================
function setOpacity(obj, value)
{ obj.style.opacity = value/10;
  obj.style.filter = 'alpha(opacity=' + value*10 + ')';
}
//===========================
function minus_px(str)
{ str=str+" ";
  return (str.replace(/px / ,""))*1;
}
//=======================
function add_favourite(a,url,title) {
  try { // Internet Explorer
        window.external.AddFavorite(url, title);
      }
  catch (e) {
  try { // Mozilla
        window.sidebar.addPanel(title, url, "");
      }
  catch (e) { // Opera
      if (typeof(opera)=="object") {
        a.rel="sidebar";
        a.title=title;
        a.url=url;
        return true;
      }
      else { // Unknown
        alert('Press Ctrl-D');
      }
    }
  }
  return false;
}
//==========================
function status_url(type,str)
{ //if(window.status) { alert(123); }
  //self.status="234";

  window.defaultStatus="";
  if(type=="add")   { window.status=str;}
  if(type=="clear") { window.status=window.defaultStatus; }
  return true;
}
//=====================
function link_url(adr) { window.location.href=adr; }
//=====================
function checkEmail(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){return false}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){return false}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){return false}
		if (str.indexOf(at,(lat+1))!=-1){return false}
		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){return false}
		if (str.indexOf(dot,(lat+2))==-1){return false}
		if (str.indexOf(" ")!=-1){return false}
 		return true;
}
