function MyPopupResize(pWidth, pHeight)
{ 
  MyCallback.SendCallback('R|' + pWidth + '|' + pHeight);

}


function MyPopUpCallback(keyValue) {
        //popup.ShowAtElement(element);
        PopupGlobal.PerformCallback(keyValue);
}

// popup okno z ASCX sablony
function MyPopupASCX(pASCX, pID, pParam, width, height, textHeader, imgHeader) 
{ 

  oFunction = 'oGridPopup.aspx?ID=@PK&gID1=' + pASCX + pParam;

  while (oFunction.indexOf("@PK") > 0)
  {
    oFunction = oFunction.replace('@PK', pID); 
  }


  MyPopup(oFunction, width, height, textHeader, imgHeader);

}

function MyPopupHTML(oHTML, width, height, textHeader, imgHeader) 
{ 

  PopupGlobal.SetHeaderText(textHeader);
  
  if (imgHeader!='')
  {
     PopupGlobal.SetHeaderImageUrl('Images/' + imgHeader + '.png'); 
  }
  else
  {
      PopupGlobal.SetHeaderImageUrl('Images/0080000.png');
  }
 
  // pokud 0 vypocitam rozmery
  if (width==0)
  {
      width = winW() - 26;
  }
  
  if (height==0)
  {
      height = winH() - 10;
  }  
  
  // pokud je mensi jak 0 vypocitam rozmery  a pouziji minus  
  if (width<0)
  {
      width = winW() - 26 + width;
  }
  
  if (height<0)
  {
      height = winH() - 10 + height;
  }      
      
  if ((width>0)&&(height>0))
  { 
    PopupGlobal.SetSize(width,height);
  }

    PopupGlobal.SetContentHTML(oHTML);
    PopupGlobal.Show();    
}


// PopupGlobal
function MyPopup(oFunction, width, height, textHeader, imgHeader) 
{


  pUrl = oFunction;
  
  PopupGlobal.SetHeaderText(textHeader);
  
  if (imgHeader!='')
  {
     PopupGlobal.SetHeaderImageUrl('Images/' + imgHeader + '.png'); 
  }
  else
  {
      PopupGlobal.SetHeaderImageUrl('Images/0080000.png');
  }
 
  // pokud 0 vypocitam rozmery
  if (width==0)
  {
      width = winW() - 26;
  }
  
  if (height==0)
  {
      height = winH() - 10;
  }  
  
  // pokud je mensi jak 0 vypocitam rozmery  a pouziji minus  
  if (width<0)
  {
      width = winW() - 26 + width;
  }
  
  if (height<0)
  {
      height = winH() - 10 + height;
  }      
      
  if ((width>0)&&(height>0))
  { 
    PopupGlobal.SetSize(width,height); 
  }
 
/* 
  PopupGlobal.SetContentUrl(pUrl);    
  PopupGlobal.Show();
*/  
  
    var iframe = PopupGlobal.GetContentIFrame();
    iframe.src = pUrl + '&PWH=' + (height-20);
    PopupGlobal.SetContentUrl(iframe.src); 
    PopupGlobal.Show();    
  
  
  
}


// PopupEditN
function MyPopupEditN(oFunction, width, height, textHeader, imgHeader) 
{ 

  pUrl = oFunction;
  
  PopupEditN.SetHeaderText(textHeader);
  
  if (imgHeader!='')
  {
     PopupEditN.SetHeaderImageUrl('Images/024' + imgHeader + '.png'); 
  }
  else
  {
      PopupEditN.SetHeaderImageUrl('Images/0080000.png');
  }
 
  // pokud 0 vypocitam rozmery
  if (width==0)
  {
      width = winW() - 26;
  }
  
  if (height==0)
  {
      height = winH() - 10;
  }  
  
  // pokud je mensi jak 0 vypocitam rozmery  a pouziji minus  
  if (width<0)
  {
      width = winW() - 26 + width;
  }
  
  if (height<0)
  {
      height = winH() - 10 + height;
  }      
      
  if ((width>0)&&(height>0))
  { 
    PopupEditN.SetSize(width,height); 
  }
 
/* 
  PopupGlobal.SetContentUrl(pUrl);    
  PopupGlobal.Show();
*/  
  
    var iframe = PopupEditN.GetContentIFrame();
    iframe.src = pUrl + '&PWH=' + (height-20);
    PopupEditN.SetContentUrl(iframe.src); 
    PopupEditN.Show();    
  
}

function MyPopUpEditorGPU(pID, pPK, width, height, textHeader, pParam) {

    var url = 'oDialog.aspx?ID=' + pID + '&PKID=' + pPK + pParam;

    url += '&IsGPU=1&IsPU=1&IsPUN=0';
    /*
    while (textHeader.indexOf("~") > 0)
    {
    textHeader = textHeader.replace('~', '"'); 
    }
    */


    PopupEdit.SetHeaderText(textHeader);


    if ((width > 0) && (height > 0)) {
        PopupEdit.SetSize(width, height);
    }

    /*
    PopupGlobal.SetContentUrl(url);
    PopupGlobal.Show();
    */

    var iframe = PopupEdit.GetContentIFrame();
    iframe.src = url + '&PWH=' + (height-20);
    PopupEdit.SetContentUrl(iframe.src);
    PopupEdit.Show();

} 

/*
function MyPopUpEditor(pID, pPK, width, height, textHeader, pParam) 
{ 

   var url = 'oDialog.aspx?ID=' + pID + '&PKID=' + pPK + pParam;

      url += '&IsGPU=0&IsPU=1&IsPUN=0';  
     

      
      PopupEdit.SetHeaderText(textHeader);
      

      if ((width>0)&&(height>0))
      { 
        PopupEdit.SetSize(width,height); 
      }

    var iframe = PopupEdit.GetContentIFrame();
    iframe.src = url + '&PWH=' + (height-20);
    PopupEdit.SetContentUrl(iframe.src); 
    PopupEdit.Show();  
      
}

*/



function MyPopUpEditor(pID, pPK, width, height, textHeader, pParam) {

    var url = 'oDialog.aspx?ID=' + pID + '&PKID=' + pPK + pParam;

    url += '&IsGPU=0&IsPU=1&IsPUN=0';



    PopupEdit.SetHeaderText(textHeader);

    if ((width > 0) && (height > 0)) {
        PopupEdit.SetSize(width, height);
    }

    url += '&PWH=' + (height - 20);

    var iframe = PopupEdit.GetContentIFrame();

    iframe.src = "oDialogLoad.aspx";
    PopupEdit.SetContentUrl(iframe.src);
    PopupEdit.Show();

    setTimeout("MyLoadFunction('" + url + "')", 1000);

}


function MyLoadFunction(url) {
    var iframe = PopupEdit.GetContentIFrame();
    iframe.src = url;
    PopupEdit.SetContentUrl(iframe.src);
    PopupEdit.Show();
}


function MyPopUpUpload(ID) 
{ 

   var url = 'jUploadFile.aspx?ID=' + ID;
   
      url += '&IsPU=1'; 
      
      PopupGlobal.SetContentUrl(url);

      PopupGlobal.SetSize(700,350); 
      PopupGlobal.Show();
}

function MyPopUpUploadVF(ID,VF) 
{ 

   var url = 'jUploadFile.aspx?ID=' + ID + '&VF=' + VF;
   
      url += '&IsPU=1'; 
      
      PopupGlobal.SetContentUrl(url);

      PopupGlobal.SetSize(700,350); 
      PopupGlobal.Show();
}

function MyPopupGlobalorHide()
{
   PopupGlobal.SetHeaderText("");

   PopupGlobal.Hide();
  
   PopupGlobal.SetContentUrl('oPopupEmpty.aspx');
} 


function MyPopUp_Form_Send(ev)
{
    var kCode = ev.keyCode*1;
    var isCtrl = ev.ctrlKey;
    
    if(kCode == 13 && isCtrl)//ctrl + enter
    {
        window.ASPxButtonOK.DoClick();
    }
}

function MyPopUpHelp(pHelp) 
{ 
   var url = 'oHelp.aspx?ID=' + pHelp;
 
   PopupHelp.SetContentUrl(url);

   PopupHelp.Show();
}

function MyHelpHide()
{
   PopupHelp.Hide();

}





