﻿function showorhide()
{

	// Change text on link
	var div = document.getElementById('selectiontitle');
	if(div== null)
    	var div = document.getElementById('selected');
	if(div != null) {
    	var tekst = div.innerHTML;
	    if(tekst.indexOf("[-]") > 0)
		    div.innerHTML = tekst.replace("[-]","[+]");
	    else
		    div.innerHTML = tekst.replace("[+]","[-]");
    }
    
	// Show/Hide the div
	var div = document.getElementById('selectionbox');
	if(div != null) {
		if(div.style.display != "none")
			div.style.display = "none";
		else
			div.style.display = "";
	}
} 


function wopenFull(url, name, w, h, scrollbars, resizable)
{
  // Fudge factors for window decoration space.
  // In my tests these work well on all platforms & browsers.
  w += 32;
  h += 96;
  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;
  // IE5 and other old browsers might allow a window that is
  // partially offscreen or wider than the screen. Fix that.
  // (Newer browsers fix this for us, but let's be thorough.)
  if (wleft < 0) {
    w = screen.width;
    wleft = 0;
  }
  if (wtop < 0) {
    h = screen.height;
    wtop = 0;
  }
  var win = window.open(url,
    name,
    'width=' + w + ', height=' + h + ', ' +
    'left=' + wleft + ', top=' + wtop + ', ' +
    'location=no, menubar=no, ' +
    'status=no, toolbar=no, scrollbars=' + scrollbars + ', resizable=' + resizable);
  // Just in case width and height are ignored
  win.resizeTo(w, h);
  win.document.title = 'Partena - Payroll Management & HR Support';
  // Just in case left and top are ignored
  win.moveTo(wleft, wtop);
  win.focus();
}

function wopen(url, name, w, h)
{
    wopenFull(url, name, w, h, 'no', 'no');
}

function getSelectedDemande(id)
{
    var id = getDropDownSelectedValue(id);
    wopenFull('s_mp_edoc_generate_pdf.aspx?id=' + id, 'MyPartena', 820, 580, 'yes', 'yes');
}

function getDropDownSelectedValue(id)
{

    var options = document.getElementById(id);
    
    for (var i = 0; i < options.length; i++) 
    {
        if (options[i].selected)
        {
            return (options[i].value);
        }
    }
    
    return null;
}

function DisableButton() 
{
    document.forms[0].submit();
	window.setTimeout("disableButton('" + window.event.srcElement.id + "')", 0);
}

function disableButton(buttonID) 
{
    document.getElementById(buttonID).disabled=true;
}


function openEdoc(url)
{
  w = 1056;
  h = 676;

  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;
  
  if (wleft < 0) 
  {
    w = screen.width;
    wleft = 0;
  }
  
  if (wtop < 0) 
  {
    h = screen.height;
    wtop = 0;
  }
  
  var win = window.open(url,
    'edoc',
    'width=' + w + ', height=' + h + ', ' +
    'left=' + wleft + ', top=' + wtop + ', ' +
    'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes');
  
  win.resizeTo(w, h);
  win.document.title = 'e-doc';

  win.moveTo(wleft, wtop);
  win.focus();
}

function CheckUncheckPAL(e)
{
    var index = e.id.indexOf('_cbAll'); 
    var idctrl = e.id.substr(0, index); 

    var input = document.getElementsByTagName("input");
    for(i = 0; i < input.length; i++)
    {
        
        if (input[i].id.substr(0,idctrl.length) == idctrl && input[i].id != e.id)
        {
            input[i].checked = e.checked;
        }
    }
}

function ShowPopup(divId)
{
    window.onscroll = function () { document.getElementById(divId).style.top = document.body.scrollTop; };
    document.getElementById(divId).style.display = "block";
    document.getElementById(divId).style.top = document.body.scrollTop;
}

function ClosePopup(divId)
{
    document.getElementById(divId).style.display = "none";
}

function ShowPopupControl(close)
{
    if (document.getElementById) 
    { // DOM3 = IE5, NS6 
        document.getElementById('hideshow').style.visibility = 'visible'; 
    } 
    else 
    { 
        if (document.layers) 
        { 
            // Netscape 4 
            document.hideshow.visibility = 'visible'; 
        } 
        else 
        { 
        // IE 4 
        document.all.hideshow.style.visibility = 'visible'; 
        }
     }
     UpdatePosition();
     
     if (close)
        document.getElementById('PopupCloseBox').className = 'Visible';
     else
        document.getElementById('PopupCloseBox').className = 'Hidden';
}

function ShowPopup(divId, close)
{
    if (document.getElementById) 
    { // DOM3 = IE5, NS6 
        document.getElementById('hideshow').style.visibility = 'visible'; 
    } 
    else 
    { 
        if (document.layers) 
        { 
            // Netscape 4 
            document.hideshow.visibility = 'visible'; 
        } 
        else 
        { 
        // IE 4 
        document.all.hideshow.style.visibility = 'visible'; 
        }
     }
     document.getElementById(divId).className = 'Visible';
     var size = document.getElementById(divId).offsetWidth;
     document.getElementById(divId).className = 'Hidden';
     
     UpdatePopupContent(document.getElementById(divId).innerHTML);
     UpdatePosition();
     
     if (close)
        document.getElementById('PopupCloseBox').className = 'Visible';
     else
        document.getElementById('PopupCloseBox').className = 'Hidden';
        
}

function HidePopup() 
{ 

    if (document.getElementById) 
    { // DOM3 = IE5, NS6 
        document.getElementById('hideshow').style.visibility = 'hidden'; 
    } 
    else 
    { 
        if (document.layers) 
        { // Netscape 4 
            document.hideshow.visibility = 'hidden'; 
        } 
        else 
        { // IE 4 
            document.all.hideshow.style.visibility = 'hidden'; 
        } 
    } 
    
    document.getElementById('PopupCloseBox').className = 'Hidden';
   
}

function ShowLoadingPopup(loadingText)
{
    document.getElementById('LoadingText').innerHTML = loadingText;
    ShowPopup('LoadingContent', false);
}

function HideLoadingPopup()
{
    HidePopup();   
}

function UpdatePosition()
  {
  
      var myWidth = 0, myHeight = 0;
      if( typeof( window.innerWidth ) == 'number' ) 
      {
          //Non-IE
          myWidth = window.innerWidth;
          myHeight = window.innerHeight;
      } 
      else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
      {
          //IE 6+ in 'standards compliant mode'
          myWidth = document.documentElement.clientWidth;
          myHeight = document.documentElement.clientHeight;
      } 
      else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
      {
          //IE 4 compatible
          myWidth = document.body.clientWidth;
          myHeight = document.body.clientHeight;
      }
      
    var block = document.getElementById('block');
  	
    var valWidth = (myWidth - (block.offsetWidth)) / 2;
    var valHeight = (myHeight - block.clientHeight) / 2;
 	
  	if (parseInt(myWidth) < parseInt(block.clientWidth))
  	    block.style.left = 15;
  	else
        block.style.left = valWidth + document.body.scrollLeft + 'px';
    
    if (parseInt(myHeight) < parseInt(block.clientHeight))
  	    block.style.top = 15;
  	else
        block.style.top = valHeight + document.body.scrollTop + 'px';
    
    var fade = document.getElementById('fade');
       
    if (parseInt(document.body.clientHeight) > parseInt(document.documentElement.clientHeight))
    {
    	 fade.style.height = parseInt(document.body.clientHeight) + parseInt(document.body.scrollTop) + 'px';
       fade.style.width = parseInt(document.body.clientWidth) + parseInt(document.body.scrollLeft) + 'px';
    }
    else
    {
      fade.style.height = '100%';
      fade.style.width = '100%';
    }
  }
  
  function UpdatePopupContent(content)
  {
      document.getElementById('popupContent').innerHTML = content;
      curvyCorners.redraw();
      UpdatePosition();
  }
  
function ScrollPopup()
{
    UpdatePosition();
}

function InitCorners()
{
    var settings = {
      tl: { radius: 10 },
      tr: { radius: 10 },
      bl: { radius: 10 },
      br: { radius: 10 },
      antiAlias: true
    } 
    curvyCorners(settings, document.getElementById("block"));
}


