var timer = null;
var speed = 3; //1 is  slow
var endTop = 0;
var endLeft = 0;

//******************************************************
// Simple little function to get Elements as an object
//******************************************************
function getEl(id)
{
	var el = document.getElementById(id);
	return el;
}
//******************************************************
// Function to show Elements
//******************************************************
function showEl(id)
{
	getEl(id).style.display ="";
}
//******************************************************
// Function to hide Elements
//******************************************************
function hideEl(id)
{
	getEl(id).style.display ="none";
}
function ToggleEl(id)
{

	var popup = getEl( id );
	sStat = getEl(id).style.display;
	if ( sStat == "none" ) {
		getEl(id).style.display ="";
	} else {
		getEl(id).style.display ="none";

	}
	//var Width = parseInt( getStyle( popup, "width" ) );
	//var Height = parseInt( getStyle( popup, "height" ) );

	Width=0; Height=0;
 	var Left =  parseInt (document.images.LibIcon.offsetLeft ) + Width/2-20;
	var Top =  parseInt (document.images.LibIcon.offsetTop) + Height /2-20;

	popup.style.top = Top + "px";
	popup.style.left = Left + "px";

}


function getStyle(el, style) {
   if(!document.getElementById) return;
   
     var value = el.style[toCamelCase(style)];
   
    if(!value)
        if(document.defaultView)
            value = document.defaultView.
                 getComputedStyle(el, "").getPropertyValue(style);
       
        else if(el.currentStyle)
            value = el.currentStyle[toCamelCase(style)];
     
     return value;
}
function toCamelCase( sInput ) {
    var oStringList = sInput.split('-');
    if(oStringList.length == 1)   
        return oStringList[0];
    var ret = sInput.indexOf("-") == 0 ?
       oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1) : oStringList[0];
    for(var i = 1, len = oStringList.length; i < len; i++){
        var s = oStringList[i];
        ret += s.charAt(0).toUpperCase() + s.substring(1)
    }
    return ret;
}




//******************************************************
// Function to move Element
//******************************************************
function moveEl(id)
{
	var popup = getEl(id);
	var currentTop = parseInt(popup.offsetTop);
	var currentLeft = parseInt(popup.offsetLeft);
	
	var keepMoving = false;
	//Move
	if (currentTop <= endTop)
	{
		popup.style.top = (currentTop + speed) + "px";
		keepMoving = true;
	}
	if(currentLeft <= endLeft)
	{	
		popup.style.left = (currentLeft + speed) + "px";
		keepMoving = true;
	}
	if (keepMoving)
	{
		startMove(id);
	}
	else
	{
		endMove();
	}
}
//******************************************************
// Function to start the move
//******************************************************
function startMove(id)
{
	timer = setTimeout("moveEl('"+id+"')", 1);
}
//******************************************************
// Function to end the move
//******************************************************
function endMove()
{
	clearTimeout(timer);
}

