// -----------------------------
// Reload page
// -----------------------------

function ReloadPage()
{

history.go(0);

}

// -----------------------------
// Hide layer
// -----------------------------

function HideLayer(lName)
{

var skin;

skin=document.getElementById(lName);

if(skin==null) return;

skin.style.visibility="hidden";

}

// ---------------------------------------
// Create layer with content
// ---------------------------------------

function DestroyLayer(lName)
{

//alert(Data);

// Find control
var fnd = document.getElementById(lName);

// Check control
if(fnd!=null)
    {
    // Add new element to document
    document.body.removeChild(fnd);        
    }

}


// ---------------------------------------
// Create layer with content
// ---------------------------------------

function CreateLayer(lName, PosX, PosY, Data)
{

// Find control
var fnd = document.getElementById(lName);

// Check control
if(fnd!=null)
    {
    // Add new element to document
    document.body.removeChild(fnd);        
    }

// Create element
var s = document.createElement('div');

// Set id to new element
s.id = lName;

// Vertical position
s.style.top = PosY;

// Horizontal position
s.style.left = PosX;
s.style.position =  'absolute';
s.style.zIndex = 500;

// Set layer content
s.innerHTML = Data;

// Add new element to document
document.body.appendChild(s);        

// move window left
if( parseInt(PosX) + parseInt(s.clientWidth) > screen.width) 
    {
	s.style.left = screen.width - s.clientWidth - 40;
	}

//if(s.clientWidth);

}



// -----------------------------
// Get layer position by X - local
// -----------------------------
function GetCY(Control)
{
var Tmp = Control;
var Y = 0;

while(Tmp)
    {
    Y += Tmp.offsetTop;
    Tmp = Tmp.offsetParent;
    }

return ( parseInt(Y) );
}

// -----------------------------
// Get layer position by Y
// -----------------------------
function GetCX(Control)
{
var Tmp = Control;
var X = 0;

while(Tmp)
    {
    X += Tmp.offsetLeft;
    Tmp = Tmp.offsetParent;
    }

return ( parseInt(X) );
}

// -----------------------------
// Get layer position by X - local
// -----------------------------
function GetControlY(cName)
{

// Get control
var Control = document.getElementById(cName);

// If have this control - return function result
if(Control==null) return(0);

var Tmp = Control;
var Y = 0;

while(Tmp)
    {
    Y += Tmp.offsetTop;
    Tmp = Tmp.offsetParent;
    }

return ( parseInt(Y) );
}

// -----------------------------
// Get layer position by Y
// -----------------------------
function GetControlX(cName)
{

// Get control
var Control = document.getElementById(cName);

// If have this control - return function result
if(Control==null) return(0);

var Tmp = Control;
var X = 0;

while(Tmp)
    {
    X += Tmp.offsetLeft;
    Tmp = Tmp.offsetParent;
    }

return ( parseInt(X) );

}

// -----------------------------
// Set content to layer
// -----------------------------

function SetControlValue(lName, Content)
{
var skin = document.getElementById(lName);
alert(lName);
if(skin==null) return;
skin.value=Content;
}            


// -----------------------------
// Set content to layer
// -----------------------------

function SetLayerContent(lName, Content)
{

var skin = document.getElementById(lName);

if(skin==null) return;
skin.innerHTML=Content;
}            


// -----------------------------
// Get content of layer
// -----------------------------

function GetLayerContent(lName)
{
var skin = document.getElementById(lName);
if(skin==null) return('');
return(skin.innerHTML);
}            


// -----------------------------
// Get content of control
// -----------------------------

function GetControlValue(lName)
{
var skin = document.getElementById(lName);
if(skin==null) return('');
return(skin.value);
}            

//--------------------------
// Set layer Style
//--------------------------

function SetLayerStyle(lName, sName, sValue)
{
var skin = document.getElementById(lName);
if(skin==null) return;
var res = eval ('skin.style.' + sName + ' = ' + sValue + ';');
}