﻿// JScript File
function UseWindowManager(message){

    //Getting rad window manager
    var oManager = GetRadWindowManager();

    //Success. Getting existing window DialogWindow using GetWindowByName
    var oWnd = oManager.GetWindowByName("RWndMsg");

    //Success. Setting a size and a Url to the window using its client API before showing
    oWnd.SetSize(320,200);
    if (message){
        oWnd.SetUrl(rootpath + "/msg.aspx?msgerr="+message);
    }
    else{
        oWnd.SetUrl(rootpath + "/msg.aspx");
    }
    //Success. Opening window

    oWnd.Show();
}

function GetRadWindow(){

var oWindow = null;

if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including 
else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;//IE (

return oWindow;
}

function CloseRadWindow(){
    var oWindow = GetRadWindow();    
    oWindow.Close();
}


 function OnClientShow(radWindow){ 
    var oTop = 0;
    var flash;
    
    
    if (document.all){               
        oTop = document.body.scrollTop;
        document.body.scrollTop = oTop;
     }else{
        oTop =document.documentElement.scrollTop
        document.documentElement.scrollTop = oTop;
     }
     
        flash=getFlashMovieObject('id_SWF');
    	if(flash){
			flash.style.visibility = 'hidden';
        }
}

function OnClientClose(radWindow){
    var flash;
    
    flash=getFlashMovieObject('id_SWF');
    	if(flash){
			flash.style.visibility = 'visible';
        }
    
    document.body.scroll = "";
    document.body.style.overflow = "";
}   

function openAlertMsg(msg){

    UseWindowManager(msg);
    return;
}

function RedirectDepositPopup(pstrurl){
	CloseRadWindow();
	if(top){
	    top.location=pstrurl;
	}	
    else{
        OuvreDepositWindow(pstrurl)
    }
}

function RedirectDepositPopup2(pstrurl){
    CloseRadWindow();  
    if (top){
        top.close();
    }
    if (top.opener){
        top.opener.location=pstrurl;	
    }
    else{
        OuvreDepositWindow(pstrurl)
    }
}

function RedirectDepositPopup3(pstrurl){
    CloseRadWindow();  
    if (top){
        top.close();
    }
    if (top.opener.opener){
        top.opener.opener.location=pstrurl;	
        top.opener.opener.focus();
    }
    else{
        OuvreDepositWindow(pstrurl)
    }
}

function RedirectDeposit(pstrurl){
CloseRadWindow();
	setTimeout("parent.location='" + pstrurl + "';",1000);
}

function openTelerikWindow(strPageName,strParams,iHeight, iWidth,bModal){
  UseWindowManagerFree(strPageName,strParams,iHeight, iWidth,bModal);
    return;
}

function openTelerikWindowFromJS(strPageName,strParams,iHeight, iWidth,bModal){
  UseWindowManagerFreeFromJS(strPageName,strParams,iHeight, iWidth,bModal);
    return;
}

function UseWindowManagerFree(strPageName,strParams,iHeight, iWidth,bModal){

    //Getting rad window manager
    var oManager = GetRadWindowManager();

    //Success. Getting existing window DialogWindow using GetWindowByName
    var oWnd = oManager.GetWindowByName("RWndMsg");

    //Success. Setting a size and a Url to the window using its client API before showing
    oWnd.SetSize(iWidth,iHeight);
    oWnd.SetUrl(strPageName + "?" + strParams);

    //Success. Opening window
    oWnd.Show();
    oWnd.SetSize(iWidth,iHeight); // on force le redimension suite bug popup debutant taille reduite
    oWnd.Center();    
    
}

function UseWindowManagerFreeFromJS(strPageName,strParams,iHeight, iWidth,bModal){

    //Success. Getting existing window DialogWindow using GetRadWindow
    var oWnd = GetRadWindow();

    //Success. Setting a size and a Url to the window using its client API before showing
    oWnd.SetSize(iWidth,iHeight);
    oWnd.SetUrl(strPageName + "?" + strParams);

    //Success. Opening window
    oWnd.Show();
    oWnd.SetSize(iWidth,iHeight); // on force le redimension suite bug popup debutant taille reduite
    oWnd.Center();
}

function getOffsetPosition(inID, inTYPE)
{
 var iVal = 0;
 var oObj = WebForm_GetElementById(inID);
 var sType = 'oObj.offset' + inTYPE;
 while (oObj && oObj.tagName != 'BODY') {
  iVal += eval(sType);
  oObj = oObj.offsetParent;
 }
 return iVal;
}

function CloseRadWindowsEmpty()
{
    var elt = WebForm_GetElementById('lblMsg');
    if( elt!= null)
    {
        if( elt.innerHTML != null)
        {
            if( elt.innerHTML == '')
            {
                   var oWindow = GetRadWindow();
                    oWindow.Close();
            }
        }
    }
}

function WebForm_GetElementById(elementId) {
    if (document.getElementById) {
        return document.getElementById(elementId);
    }
    else if (document.all) {
        return document.all[elementId];
    }
    else return null;
} 
