//****** FastEdit V2.0 ******//

function fncSetPage(sPath)
{
    if (sPath.length>0)
        location.href = sSiteURL + sPath;
}

function fncSetOptionPage(sPage)
{
    var oSelect = document.getElementById("PageSelector");
    oSelect.value = sPage;
    if(oSelect.selectedIndex>=0)
        oSelect.options[oSelect.selectedIndex].className += " OptionPageSelectorSelected";
}

function fncGetLeftPos(oObj)
{
    nLeftPos = oObj.offsetLeft;
    oParent = oObj.offsetParent;
    while (oParent != null) 
    {
        nLeftPos += oParent.offsetLeft;
        oParent = oParent.offsetParent;
    }
    
    return nLeftPos;
}


function fncGetTopPos(oObj)
{
    nTopPos = oObj.offsetTop;
    oParent = oObj.offsetParent;
    while (oParent != null) 
    {
        nTopPos += oParent.offsetTop;
        oParent = oParent.offsetParent;
    }
    
    return nTopPos;
}


function fncGetScreenWidth()
{
    var n_width = 0;
    if(typeof(window.innerWidth) == 'number') 
    {
        //Non-IE
        n_width = window.innerWidth;
    }
    else if(document.documentElement && document.documentElement.clientWidth) 
    {
        //IE 6+ in 'standards compliant mode'
        n_width = document.documentElement.clientWidth;
    }
    else if(document.body && document.body.clientWidth) 
    {
        //IE 4 compatible
        n_width = document.body.clientWidth;
    }
    
    if (n_width==0)
        n_width = screen.availWidth;
    
    return n_width;
}

function fncGetScreenHeight()
{
    var n_height = 0;
    if(typeof(window.innerHeight) == 'number') 
    {
        //Non-IE
        n_height = window.innerHeight;
    }
    else if(document.documentElement && document.documentElement.clientHeight) 
    {
        //IE 6+ in 'standards compliant mode'
        n_height = document.documentElement.clientHeight;
    }
    else if(document.body && document.body.clientHeight) 
    {
        //IE 4 compatible
        n_height = document.body.clientHeight;
    }
    
    if (n_height==0)
        n_height = screen.availHeight;
    
    return n_height;
}



// Changing Image modules //

var iChangeImagesInterval; //global var
var iLastChangingImages;
var iChangingImagesCounter;

function fncSetChangingImage()
{
    var oImage = document.getElementById("ChangingImage");
    if (isNaN(iChangingImagesCounter) && iChangingImagesCounter!="0") //no images
    {
        oImage.src = sSiteURL + "/~Design/Clear.gif"
    }
    else
    {
        var iRnd = Math.floor(Math.random()*iChangingImagesCounter); 
        if (iRnd == iLastChangingImages) //give it another try
            var iRnd = Math.floor(Math.random()*iChangingImagesCounter); 
        iLastChangingImages = iRnd;
        
        oImage.src = sSiteURL + "/~Up/changing_images/" + arrChangingImagesPath[iRnd];
        oImage.alt = arrChangingImagesTitle[iRnd];
        
        if (arrChangingImagesLink[iRnd]!="")
        {
            oImage.style.cursor = "pointer";
            if (arrChangingImagesLinkType[iRnd]=="0") //same window
            {
                oImage.onclick = new Function("location.href='" + arrChangingImagesLink[iRnd] + "'");
            }
            else //new window
            {
                oImage.onclick = new Function("window.open('" + arrChangingImagesLink[iRnd] + "','NewWin','')");
            }
        }
        else
        {
            oImage.style.cursor = "default";
        }                
    }
}

function fncChangeImageGo(iInterval)
{
    fncSetChangingImage()
    iChangeImagesInterval = iInterval;
    setTimeout('fncChangeImage()', iChangeImagesInterval);
}

function fncChangeImage()
{
    fncSetChangingImage()
    setTimeout('fncChangeImage()', iChangeImagesInterval);
}

function fncGetBrowserType() {
	var sBrowserType = "";
	var sBrowserName = window.navigator.appName.toLowerCase();
	if (sBrowserName.indexOf("netscape") != -1)
		sBrowserType = "ff";
	else if (sBrowserName.indexOf("internet explorer") != -1)
		sBrowserType = "ie";
	
	return sBrowserType;
}
