﻿// Modified version - Adapted from author Ron Grafe grafer@columbus.rr.com http://www.gdevresources.com/Pages/Scripts/Dynamicscroller/Dynamicscroller.htm
// Courtesy of SimplytheBest.net - http://simplythebest.net/scripts/
var contentobj;
var contentheight;
var containerheight;
var step = 3;
var scrollspeed = 5; //Lower is faster
var iens6 = document.all||document.getElementById;
var ns4 = document.layers;

function SetupScroller(top)
{
    containerheight = parseInt(document.getElementById("container").style.height);
    if (iens6)
    {
	    contentobj=document.getElementById? document.getElementById("content") : document.all.content;
	    contentheight=contentobj.offsetHeight;
	    
        if (document.getElementById&&!document.all)
        {
	        step *= 4;
        }
    }
    else if(ns4)
    {
	    contentobj=document.nscontainer.document.nscontent;
	    contentheight=contentobj.clip.height;
    }
    
	if(top != null)
    {
        contentobj.style.top = -top;
    }
    
    window.onload=getcontent_height;
}

function scrolldown()
{
	if(window.scrolltimerup)
	{
		clearTimeout(scrolltimerup);
	}
	
    if(iens6 && contentheight-containerheight+parseInt(contentobj.style.top) > 0)
	{
		contentobj.style.top=parseInt(contentobj.style.top)-step;
	}
	else if(ns4&&contentobj.top>=(contentheight*(-1)+100))
	{
		contentobj.top-=step;
	}

	scrolltimerdown = setTimeout("scrolldown()",scrollspeed);
}

function pagedown()
{
    temp=step;
    step = 425;
	if(iens6 && contentheight-containerheight+parseInt(contentobj.style.top) > 0)
	{
		contentobj.style.top=parseInt(contentobj.style.top)-step;
	}
	else if(ns4&&contentobj.top>=(contentheight*(-1)+100))
	{
		contentobj.top-=step;
	}
	step=temp;
}

function pageup()
{
    temp=step;
    step = 425;

	if(iens6&&parseInt(contentobj.style.top)<0)
	{
		contentobj.style.top=parseInt(contentobj.style.top)+step;
	}
	else if(ns4&&contentobj.top<=0)
	{ 
		contentobj.top+=step;
	}
	step=temp;
}

function scrollup()
{
	if(window.scrolltimerdown)
	{
		clearTimeout(scrolltimerdown);
	}
	if(iens6&&parseInt(contentobj.style.top)<0)
	{
		contentobj.style.top=parseInt(contentobj.style.top)+step;
	}
	else if(ns4&&contentobj.top<0)
	{ 
		contentobj.top+=step;
	}

	scrolltimerup = setTimeout("scrollup()",scrollspeed);
}

<!-- function to stop all scroll timers -->
function stopall()
{
	if(window.scrolltimerup)
	{
		clearTimeout(scrolltimerup);
	}
	if(window.scrolltimerdown)
	{
		clearTimeout(scrolltimerdown);
	}
}

<!-- function that shifts the object to top -->
function shifttotop()
{
	stopall();
	if (iens6)
	{
		contentobj.style.top=0;
	}
	else
	{
		contentobj.top=0;
	}
}

function getcontent_height()
{
	if (iens6)
	    contentheight=contentobj.offsetHeight;
}

function ShowDesignerDetails(visible)
{
    div = document.getElementById('about_designerDetails');
    if(visible)
    {
        refObj = document.getElementById('about_designer');
        div.style.top = String(getBottom(refObj)-div.clientHeight-5) + 'px';
        div.style.left = String(getLeft(refObj)+25) + 'px';
        div.style.visibility = 'visible';
     }
     else
     {
        div.style.visibility = "hidden";
     }
}

function getBottom(obj)
{
    bottom = 0;
    if(obj.offsetParent)
    {
	    while (obj.offsetParent)
	    {
		    bottom += obj.offsetTop;
		    obj = obj.offsetParent;
	    }
    }
    else if (obj.y)
	    bottom += obj.y;
    return bottom;
}

function getLeft(obj)
{
    left = 0;
    if(obj.offsetParent)
    {
	    while (obj.offsetParent)
	    {
		    left += obj.offsetLeft;
		    obj = obj.offsetParent;
	    }
	    left -= 7;
    }
    else
    {
        //Safari
        left = obj.offsetLeft * .95;
        left += 10;
    }
    return left;
}

function getQueryVariable(variable)
{
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i=0;i<vars.length;i++)
    {
        var pair = vars[i].split("=");
        if (pair[0] == variable)
            return pair[1];
    } 
    return null;
}
