function lib_bwcheck()
{ 
	  this.ver=navigator.appVersion
	  this.agent=navigator.userAgent
	  this.dom=document.getElementById?1:0
	  this.opera5=this.agent.indexOf("Opera 5")>-1
	  this.opera=this.agent.indexOf("Opera")>-1
	  this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	  this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	  this.ie7=(this.ver.indexOf("MSIE 7")>-1 && this.dom && !this.opera5)?1:0;
		this.ie9=(this.ver.indexOf("MSIE 9")>-1 && this.dom && !this.opera5)?1:0;
	  this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	  this.ie=this.ie4||this.ie5||this.ie6||this.ie7
	  this.mac=this.agent.indexOf("Mac")>-1
		this.ns6=(this.dom && parseInt(this.ver) >= 5 && !this.opera && !this.ie9) ?1:0; 
		
		var nav = this.agent.split("/");
		var navver = parseInt(nav[nav.length-1].split(".")[0]);
		
		this.ns7=(this.dom && parseInt(navver) >= 7 && !this.ie7);
		
		if(this.ns7 == true) {
			this.ns7 = 1;
			this.ns6 = 0;
		}
		
	  this.ns4=(document.layers && !this.dom)?1:0;
	  this.ie = (this.ie7||this.ie6||this.ie5||this.ie4);
	  this.ns6=0;	  
	  this.bw=(this.ie7||this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5||this.opera)
	  return this
}

var bw = new lib_bwcheck() //Browsercheck object


//Debug function ******************
function lib_message(txt){alert(txt); return false}


//Lib objects  ********************
function lib_obj(obj,nest)
{ 
	  nest=(!nest) ? "":'document.'+nest+'.'
	  this.evnt=bw.dom? document.getElementById(obj):
	    bw.ie4?document.all[obj]:bw.ns4?eval(nest+"document.layers." +obj):0;	
	  if(!this.evnt) return lib_message('The layer does not exist ('+obj+')' 
	    +'- \nIf your using Netscape please check the nesting of your tags!')
	  this.css=bw.dom||bw.ie4?this.evnt.style:this.evnt; 
	  this.ref=bw.dom||bw.ie4?document:this.css.document;
	  this.x=parseInt(this.css.left)||this.css.pixelLeft||this.evnt.offsetLeft||0;
	  this.y=parseInt(this.css.top)||this.css.pixelTop||this.evnt.offsetTop||0
	  this.w=this.evnt.offsetWidth||this.css.clip.width||
	    this.ref.width||this.css.pixelWidth||0; 
	  this.h=this.evnt.offsetHeight||this.css.clip.height||
	    this.ref.height||this.css.pixelHeight||0
	  this.c=0 //Clip values
	  if((bw.dom || bw.ie4) && this.css.clip) {
	  this.c=this.css.clip; this.c=this.c.slice(5,this.c.length-1); 
	  this.c=this.c.split(' ');
	  for(var i=0;i<4;i++){this.c[i]=parseInt(this.c[i])}
	  }
	  this.ct=this.css.clip.top||this.c[0]||0; 
	  this.cr=this.css.clip.right||this.c[1]||this.w||0
	  this.cb=this.css.clip.bottom||this.c[2]||this.h||0;
	  this.close_in_progress = false; 
	  this.cl=this.css.clip.left||this.c[3]||0
	  this.obj = obj + "Object"; eval(this.obj + "=this")
	  
	  this.setPosition = setPosition;
	  this.moveIt = moveIt;
	  this.hideIt_now = hideIt_now;
	  this.hideIt = hideIt;
	  this.blend = blend;
	  this.showIt = showIt;
	  this.align_right = align_right;
	  this.setPosition_offset = setPosition_offset;
	  
  
}


function setPosition(pic_name)
{
	var offset = 31;
	if (bw.ns4 || bw.ns6) 
	{
     		    		
     		
     		pos = document.images[pic_name];
     		this.moveIt(pos.x,pos.y + offset);
	     	
	}
	
	else
	{
	
		var pos = document.all[pic_name];
		this.moveIt(getLeft(pos),getTop(pos)+offset);
	      
	}
}

function setPosition_offset(pic_name, offset)
{
	
	var yoffset = 22;
	if (bw.ns4 || bw.ns6) 
	{
     		
     		pos = document.images[pic_name];
		this.moveIt(pos.x - offset,pos.y+yoffset);
	     	
	}
	
	else
	{
	
		var pos = document.all[pic_name];
		this.moveIt(getLeft(pos) - yoffset,getTop(pos)+offset);
	      
	}
	
	
}


function getLeft(l)
{
  if (l.offsetParent) return (l.offsetLeft + getLeft(l.offsetParent));
  else return (l.offsetLeft);
}


function getTop(l)
{
  if (l.offsetParent) return (l.offsetTop + getTop(l.offsetParent));
  else return (l.offsetTop);
}

//Moving object to **************
function moveIt(x,y)
{
  		
  this.x=x;
  this.y=y; 
  this.css.left=x;
  this.css.top=y

}


//Showing object ************
function showIt(name)
{
	this.close_in_progress = false;
	this.setPosition(name);
	this.css.visibility="visible";
	
	
}

//Showing object ************
function align_right(name, offset)
{
	
	this.close_in_progress = false;
	this.setPosition_offset(name, offset);
	this.css.visibility="visible";
	
}

//Hiding object **********
function hideIt_now()
{ 
	if (this.close_in_progress == true)
	{
		this.close_in_progress = false;
		this.blend('hidden');
	}
		
}

//Hiding object **********
function hideIt()
{
	if (this.close_in_progress == false)
	{
		this.close_in_progress = true;
		window.setTimeout(this.obj + ".hideIt_now()",500);
	}
			
}


function blend (what)
{
	this.css.visibility = what;
}


		
function lib_init()
{		
	l0 = new lib_obj('elhidden');
	l1 = new lib_obj('Layer1');
	l2 = new lib_obj('Layer2');
	l3 = new lib_obj('Layer3');
	l4 = new lib_obj('Layer4');
	l5 = new lib_obj('Layer5');
	l6 = new lib_obj('Layer6');	

	if(bw.ie9 == 1){
    var a = [l0,l1,l2,l3,l4,l5,l6];
    for(var i=0; i<a.length; i++){
        var fun = function(el){
            el.moveIt = function(x, y){
                el.css.left = x+"px";
                el.css.top = (y)+"px";
            }
        }
        var el = a[i];
        if(el){
            fun(el);
        }
    }
}
}
			
function hideall(what_not)
{
	if (what_not != 'l1') l1.blend('hidden');
	if (what_not != 'l2') l2.blend('hidden');
	if (what_not != 'l3') l3.blend('hidden');
	if (what_not != 'l4') l4.blend('hidden');
	if (what_not != 'l5') l5.blend('hidden');
	if (what_not != 'l6') l6.blend('hidden');
}		

