function showModalWindow(url, name, height, width)
{
	var handle;
	if (window.showModalDialog1)
		handle = window.showModalDialog(url, name, "dialogHeight:" + height + "px;dialogWidth:" + width+ "px;resizable=yes");
	else
	{
		handle = window.open(url, name, "height=" + height + ",width=" + width+ ",toolbar=no,modal=yes,dependent=yes,directories=no,status=no,location=no,menubar=no,scrollbars=no,resizable=yes");
		handle.focus();
	}
}
function showPopupWindow(url, name, height, width)
{
	var handle;
	handle = window.open(url, name, "height=" + height + ",width=" + width+ ",toolbar=no,dependent=yes,directories=no,status=no,location=no,menubar=no,scrollbars=yes,resizable=yes");
	handle.focus();
}
function showLeaseTech(PurchasePrice)
{
	var url = "/acquire/leaseTech/payment_calculator.asp?PurchasePrice=" + PurchasePrice;
	 showModalWindow(url, "leasetech", 330, 560);
//	var LeaseTech = window.open(,'LeaseTech','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,width=560,height=330,resizable=no');
}

function showPartnerProfile(Profile) {
	window.open ('assets/partnerprofiles/partnerprofile.asp?Profile='+Profile, 'Profile','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=550,left = 100,top = 100');
}

function getElement(item)
{
    var el;
    if (document.getElementById) // Standards
        el = document.getElementById(item);
    else if (document.all) // IE
        el = document.all[item];
    else if (document.layers) // NN
        el = document.layers[item];
    return el;
}

// Show/hide an element
function showHide(id)
{
    var el = typeof(id)=='string' ? getElement(id) : id;
    var s = el.style;
    var show = false;
    if(s.display=='' && el.offsetWidth!=undefined && el.offsetHeight!=undefined)
        show = (el.offsetWidth!=0 && el.offsetHeight!=0) ? true : false;
    show = (s.display=='' || s.display=='block') ? false : true;
    
    s.display = show  ? 'block' : 'none';

    // todo: make it hide/show multiple times only revealing bit hidden
    if (show)
    {
        var height = el.scrollHeight>0 ? el.scrollHeight : el.offsetHeight;
        var top = el.scrollTop>0 ? el.scrollTop : el.offsetTop;
        if (top+height>document.documentElement.clientHeight)
            window.scrollBy(0, height);
    }

    return false;
}
function getScrollXY()
{
    var x = 0, y = 0;
    if (document.body && (document.body.scrollLeft || document.body.scrollTop)) // Standards
    {
        y = document.body.scrollTop;
        x = document.body.scrollLeft;
    }
    else if (document.documentElement &&
        (document.documentElement.scrollLeft || document.documentElement.scrollTop)) // IE6
    {
        y = document.documentElement.scrollTop;
        x = document.documentElement.scrollLeft;
    }
    else if (typeof(window.pageYOffset) == 'number' ) // NN
    {
        y = window.pageYOffset;
        x = window.pageXOffset;
    }
    return [x, y];
}