function logout()
{
	document.location.href = 'login.php?action=logout';
}

function realtorlogout()
{
	document.location.href = 'realtor_login.php?action=realtorlogout';
}

function product_enlargeview(title, image)
{
	var winopen=window.open("../enlargeview.php?title="+title+"&image="+image,"New_page","scrollbars=yes,Toolbar=no,align=center,location=no,resizable=yes,height=600,width=650");
}

function enlargeview(title, image)
{
	var winopen=window.open("enlargeview.php?title="+title+"&image="+image,"New_page","scrollbars=yes,Toolbar=no,align=center,location=no,resizable=yes,height=600,width=650");
}

function popup(URL)
{
	ScreenWidth  = screen.width
	ScreenHeight = screen.height
	PopupWidth   = 802
	PopupHeight  = 540
	PopupLeft    = (ScreenWidth-PopupWidth)/2
	PopupTop     = (ScreenHeight-PopupHeight)/2
	window.open(URL,"PopupWindow","toolbar=no, location=no,directories=no,status=no,menubar=no,resizable=YES,copyhistory=no,scrollbars=Yes,width=" + PopupWidth + ",height=" + PopupHeight + ",top=" + PopupLeft + ",left=" + PopupTop + "");
}

function requestquote(product_name)
{
	var winopen=window.open("../request_featuredproduct.php?name="+product_name,"New_page","scrollbars=no,Toolbar=no,align=center,location=no,resizable=no,height=436,width=650");

}

var scroller = {
  init:   function() {

    //collect the variables
    if ( !document.getElementById("scrollContent") || !document.getElementById("scrollBox") || !document.getElementById("scrollArea") ) {
    	return false;
    }
    scroller.docH = document.getElementById("scrollContent").offsetHeight;
    scroller.contH = document.getElementById("scrollBox").offsetHeight;
    scroller.scrollAreaH = document.getElementById("scrollArea").offsetHeight;
      
    //calculate height of scroller and resize the scroller div
    //(however, we make sure that it isn't to small for long pages)
    scroller.scrollH = (scroller.contH * scroller.scrollAreaH) / scroller.docH;
    //if(scroller.scrollH < 15) scroller.scrollH = 15;
    document.getElementById("scroller").style.height = Math.round(scroller.scrollH) + "px";
    
    //what is the effective scroll distance once the scoller's height has been taken into account
    scroller.scrollDist = Math.round(scroller.scrollAreaH-scroller.scrollH);
    
    //make the scroller div draggable
    Drag.init(document.getElementById("scroller"),null,0,0,-1,scroller.scrollDist);
    
    //add ondrag function
    document.getElementById("scroller").onDrag = function (x,y) {
      var scrollY = parseInt(document.getElementById("scroller").style.top);
      var docY = 0 - (scrollY * (scroller.docH - scroller.contH) / scroller.scrollDist);
      document.getElementById("scrollContent").style.top = docY + "px";
    }
  }
}

onload = scroller.init;


