/*
 Script: kLib.js
  Core of the kLib Javascrpt Library.
 
  Author:
   - Caleb Kniffen, <http://kniffenwebdesign.com>
 
  Version:
   1.9
  
  Required Files:
   - prototype.js or prototype.kLib.js
*/
$I = function(elem, inner){ $(elem).innerHTML=inner; }
$IA = function(elem, inner){ $(elem).innerHTML+=inner; }
$IC = function(elem){  $(elem).innerHTML = "";}
$S = function(elem){ return $(elem).style; }
$N = function(elem, tag){ return $(elem).getElementsByTagName(tag); }
$EN = function(name){
 elements = document.getElementsByTagName('*')
 matching = new Array();
 for(x=0;x<elements.length;x++) if(name == elements[x].name) matching[matching.length] = elements[x];
 return matching;
}
isParent=function(elem,target){
 try{
  while(elem.offsetParent!=document.body){
   if(target==null){ return false;}
   if(elem.offsetParent==target){return true;}
   elem=elem.offsetParent;
  }
 }
 catch(e){}
 return false;
}
isDefined = function(variable){ return (variable!='undefined'); }
isArray = function(variable) { return isObject(variable) && variable.constructor == Array; }
isObject = function(variable) {return (variable && typeof(variable) == 'object') || isFunction(variable);}
isFunction = function(variable) {return typeof(variable) == 'function'; }
Array.prototype.add = function(object){ this[this.length]=object; }
Array.prototype.remove = function(object){ 
 newArray = new Array();
 for(var x=0; x<this.length; x++){
  if(this[x]!=object){
   newArray.add(this[x]);
  }
 }
 return newArray;
}
makeAppendElem=function(type,parent,style){
 elem = document.createElement(type);
 if(style) Element.setStyle(elem,style);
 $(parent).appendChild(elem)
 return elem;
}
makeInput = function(parent, type, value, style){
 elem = makeAppendElem('input', parent, style);
 elem.type = type;
 elem.value = value;
 return elem;
}
makeButton = function(text, parent, style){ 
 button = makeAppendElem('button', parent, style)
 $I(button, text);
 return button;
}
makeImage = function(parent, src, alt, style){
 image = makeAppendElem('img', parent, style)
 image.alt = alt;
 image.src=src;
 return image;
}
makeInlineBlock = function(elem, offset, onlyInlineBlock){
 $S(elem).overflow = 'hidden';
 if(isIE){ 
  $S(elem).display = 'inline-block'; 
  if(onlyInlineBlock!=false) $S(elem).display = 'inline';
 }
 if(isNetscape){
  $S(elem).display = 'table-cell';
  $S(elem).display = '-moz-inline-box';
  if(offset!=false){
   $S(elem).position = 'relative';
   $S(elem).top = '-10px';
  }
 }
}
formatSquare=function(elem, size, makeInline, offset, onlyInlineBlock){
 if(makeInline) makeInlineBlock(elem, offset, onlyInlineBlock);
 $S(elem).width = size + 'px';
 $S(elem).height = size + 'px';
 $S(elem).lineHeight = size + 'px';
 $S(elem).fontSize = '0px';
}
CurrentPosition=function(elem){
 this.x=elem.offsetLeft;
 this.y=elem.offsetTop;
 elem=elem.offsetParent;
 while(elem!=null){
  this.x+=elem.offsetLeft;
  this.y+=elem.offsetTop;
  elem=elem.offsetParent;
 }
 return this;
}
optionAdder=function(select, array){
 for(x=0; x<array.length; x++){
  option = document.createElement('option');
  option.text = array[x]
  option.value = array[x]
  try{ select.add(option,null); }
  catch(ex){select.add(option); }
 }
}
var isIE =(navigator.appName == "Microsoft Internet Explorer");
var isNetscape = (navigator.appName =="Netscape");
