//browser object
var browser=new Object();
browser.isIE=(navigator.appName=="Microsoft Internet Explorer" && navigator.userAgent.indexOf("Opera")<0)?true:false;
browser.isOpera=navigator.userAgent.indexOf("Opera")>0?true:false;




function getEl(elid){
  return document.getElementById(elid);
}


//return viewport height
function winH(){
  if(window.innerHeight)return window.innerHeight;
  else if(document.documentElement&&document.documentElement.clientHeight)return document.documentElement.clientHeight;
  else if(document.body&&document.body.clientHeight)return document.body.clientHeight;
}



//returns viewport width
function winW(){
  if(window.innerWidth)return window.innerWidth;
  else if(document.documentElement&&document.documentElement.clientWidth)return document.documentElement.clientWidth;
  else if(document.body&&document.body.clientWidth)return document.body.clientWidth;
}


//returns computed height of el
function getH(elid){
  if (document.all)pupik=document.all.item(elid).offsetHeight;
  else{
    obj=document.getElementById(elid);
    pupik=document.defaultView.getComputedStyle(obj,"").getPropertyValue("height");
    //pupik=pupik.substring(0,pupik.length-2);
  };
  return parseInt(pupik);
}



//returns computed width of el
function getW(elid){
  if (document.all)pupik=document.all.item(elid).offsetWidth;
  else{
    obj=document.getElementById(elid);
    pupik=document.defaultView.getComputedStyle(obj,"").getPropertyValue("width");
    //pupik=pupik.substring(0,pupik.length-2);
  };
  return parseInt(pupik);
}



//finds x position of an object
function findPosX(elid){
  var obj=getEl(elid);
  var curleft=0;
  if(obj.offsetParent){
    while(obj.offsetParent){
      curleft+=obj.offsetLeft;
      obj=obj.offsetParent;
    }
  }else if(obj.x)curleft+=obj.x;
  return curleft;
}


//finds y position of an object
function findPosY(elid){
  var obj=getEl(elid);
  var curtop=0;
  if(obj.offsetParent){
    while(obj.offsetParent){
      curtop+=obj.offsetTop
      obj=obj.offsetParent;
    }
  }else if(obj.y)curtop+=obj.y;
  return curtop;
}


function getElementsByClassName(parel,clsname){
  var outp=new Array();
  var els=getEl(parel).getElementsByTagName("*");
  for(var i=0;i<els.length;i++){
    if(els[i].className==clsname)outp.push(els[i]);
  };
  return outp;
}


function clipEl(elid,l,t,r,b){
  getEl(elid).style.clip="rect("+t+"px,"+(getW(elid)-r)+"px,"+(getH(elid)-b)+"px,"+l+"px)";
}


function setDN(elid){
  getEl(elid).style.display="none";
}


function setDB(elid){
  getEl(elid).style.display="block";
}

function setDI(elid){
  getEl(elid).style.display="inline";
}


function setVH(elid){
  getEl(elid).style.visibility="hidden";
}


function setVV(elid){
  getEl(elid).style.visibility="visible";
}



//php trim() analogue
function trim(inpstr){
  inpstr=inpstr.replace(/^[\s]+/g,"");
  inpstr=inpstr.replace(/[\s]+$/g,"");
  return inpstr;
}



function picWin(im,wi,he,php,parname,winpars){
  if(typeof(php)=="undefined" || php=="")php="image.php";
  if(typeof(parname)=="undefined" || parname=="")parname="im";
  var wp="width="+wi+",height="+he;
  if(typeof(winpars)!="undefined")wp+=","+winpars;
  var vokno=window.open(php+"?"+parname+"="+im,"",wp);
  return typeof(vokno)=="object"?false:true;
}



function killTeckos(){
  window.focus();
};



//swaps display property of element with elid - block->none / none->block
function swapDisplay(elid){
  el=getEl(elid);
  el.style.display=el.style.display=="none"?"block":"none";
};





