﻿var ie = false;
var open = true;
var oldwidth = -1;
if (document.all) { ie = true; }

function getObj(id) {
    if (ie) { return document.all[id]; }
    else { return document.getElementById(id); }
}

function setSidebarTop() {
    //alert('hoy');
    var sidec = getObj('ctl00_divBuyOnline');
    if (sidec != null) {
        //alert('here');
        if (self.pageYOffset) // all except Explorer
        {
            toppos = self.pageYOffset;
        }
        else if (document.documentElement) {
            toppos = document.all ? document.documentElement.scrollTop : window.pageYOffset;
        }
        else {
            toppos = document.all ? document.body.scrollTop : window.pageYOffset;
        }
        toppos -= 400;
        maxpos = document.body.clientHeight - 1100;
        //alert(document.body.clientHeight);
        toppos = (toppos > maxpos) ? maxpos : toppos;
        //alert(toppos);
//        if (toppos > 400) {
//            toppos = toppos + 10;
//            sidec.style.top = toppos + 'px';
//        }
//        else {
//            sidec.style.top = 400 + 'px';
        //                }
        if (toppos > 0) {
            sidec.style.top = toppos + 'px';
        }
        else {
            sidec.style.top = '0px';
        }
        //alert(sidec.style.top);
        //alert(toppos);
        setTimeout('setSidebarTop()', 100);
        //alert(document.body.clientHeight);
    }
}

function getPageName()
{
var sPath = window.location.pathname;
//var sPage = sPath.substring(sPath.lastIndexOf('\\') + 1);
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
alert(sPage);
}

setTimeout('setSidebarTop();', 500);
