﻿// ******************************************************************************************************************************
//  GACREAAdmin.js
//
//  Date        By  Version Description
//  ----------  --  ------- ----------------------------------------------------------------------------------------------------
//  03/11/2010  SL  v2.71   - seller bid counter-off
//                          - created 2 client-side jscript functions:
//                              -OpenrwinPopup(rwinPopupClientID, strURL, iPopupHeight, iPopupWidth)
//                              -FindViewport()
// ******************************************************************************************************************************

// *********************************************************************************
// close current Rad Window
// *********************************************************************************
function CloseRADWindow()
{
	var rwinWindow = null;

	if (window.radWindow)
	{
		rwinWindow = window.radWindow;
	}
	else
	{
		rwinWindow = window.frameElement.radWindow;
	}

	rwinWindow.close();
} // CloseRADWindow


// *********************************************************************************
// returns current window's height and width in a 2-dimensional array
// sample code: 
//      var aryWindowDim = FindViewport();
//      var iheight = aryWindowDim[0];
//      var iwidth = aryWindowDim[1];
// *********************************************************************************
function FindViewport() {
    var iVPHeight;    //viewport
    var iVPWidth;     //viewport

    if (typeof window.innerWidth != "undefined") {
        iVPHeight = window.innerHeight;
        iVPWidth = window.innerWidth;
    }
    else if ((typeof document.documentElement != "undefined") && (typeof document.documentElement.clientWidth != "undefined") && (document.documentElement.clientWidth != 0)) {
        iVPHeight = document.documentElement.clientHeight;
        iVPWidth = document.documentElement.clientWidth;
    }
    else {
        iVPHeight = document.getElementsByTagName("body")[0].clientHeight;
        iVPWidth = document.getElementsByTagName("body")[0].clientWidth;
    }
    return (new Array(iVPHeight, iVPWidth));
} // FindViewport


// *********************************************************************************
// Open Rad Window Popup
// calls FindViewport() to determine current window dimension and shrink the pop, if
// if necessary, to fit inside the window 
// *********************************************************************************
function OpenrwinPopup(rwinPopupClientID, strURL, iPopupHeight, iPopupWidth) {
    var rwinPopup = $find(rwinPopupClientID);
    rwinPopup.setUrl(strURL);

    var ViewportDimension = FindViewport();
    var ivpHeight = ViewportDimension[0];
    var ivpWidth = ViewportDimension[1];
        
    if (ivpHeight < iPopupHeight) {
        rwinPopup.setSize(iPopupWidth + 10, (ivpHeight - 10));
        rwinPopup.set_behaviors(Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Resize);
    }
    else {
        rwinPopup.setSize(iPopupWidth, iPopupHeight);
        rwinPopup.set_behaviors(Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Close);
    }

    rwinPopup.center();
    rwinPopup.show();
} // OpenPopup
