﻿
function GetDropDownSelectedText(clientid) {
    var ddlReport = document.getElementById(clientid);
    var Text = ddlReport.options[ddlReport.selectedIndex].text;
    return Text;

}
function GetDropDownSelectedValue(clientid) {
    var ddlReport = document.getElementById(clientid);
    var Value = ddlReport.options[ddlReport.selectedIndex].value;
    return Value;
}

function CheckAll(cb, uniqueId) {


    var ctrls = document.getElementsByTagName('input');
    for (var i = 0; i < ctrls.length; i++) {
        var cbox = ctrls[i];
        if (cbox.type == "checkbox" && cbox.name.indexOf(uniqueId) != -1) {
            cbox.checked = cb.checked;
        }
    }
} 


function clearRadioButtonList(id) {


    var elementRef = document.getElementById(id);
    var inputElementArray = elementRef.getElementsByTagName('input');

    for (var i = 0; i < inputElementArray.length; i++) {
        var inputElement = inputElementArray[i];

        inputElement.checked = false;
    }
    return false;
}


function ScrollTo(clientid) {
    var el = document.getElementById(clientid);
    if (el != null) {
        el.scrollIntoView();
        el.focus();
    }
}

function messageIfEqual(selectedIndex, compareIdx, msg) {
    if (selectedIndex == compareIdx) {
        alert(msg);
        
    }
    
}



/* Global variables ********************************************************/

var winConfirm = null;
var winShow = null;
/* This function shows the confirm box *************************************/



function showMessage(title, htmlmessage)
{
  var windowWidth = 650;
  var windowHeight = 600;
  var locX = ( screen.width - windowWidth ) / 2;
  var locY = ( screen.height - windowHeight ) / 2;
  var windowFeatures = "width=" + windowWidth
                     + ",height=" + windowHeight
                     + ",screenX=" + locX
                     + ",screenY=" + locY
                     + ",left=" + locX
                     + ",top=" + locY;

  /* Close window first to make sure that our window has */
  /* the desired features */

  if ( ( winShow != null )
    && !winShow.closed )
  {
    winShow.close();
  }

  /* Open the new confirm */
  winShow = open( "", "winShow" );

  /* Write to the confirm box */
  var theHTML = '<HEAD><TITLE>'  + title + '</TITLE></HEAD>'
              + '<BODY>'
              + htmlmessage
              + '</BODY>';

  winShow.document.writeln( theHTML );
}



function showConfirm()
{
  var windowWidth = 250;
  var windowHeight = 100;
  var locX = ( screen.width - windowWidth ) / 2;
  var locY = ( screen.height - windowHeight ) / 2;
  var windowFeatures = "width=" + windowWidth
                     + ",height=" + windowHeight
                     + ",screenX=" + locX
                     + ",screenY=" + locY
                     + ",left=" + locX
                     + ",top=" + locY;

  /* Close window first to make sure that our window has */
  /* the desired features */

  if ( ( winConfirm != null )
    && !winConfirm.closed )
  {
    winConfirm.close();
  }

  /* Open the new confirm */
  winConfirm = open( "", "winConfirm", windowFeatures );

  /* Write to the confirm box */
  var theHTML = '<HEAD><TITLE>Please choose...</TITLE></HEAD>'
              + '<BODY BGCOLOR="#FFFFFF">'
              + '<CENTER><B>'
              + 'Click on YES, NO or CANCEL'
              + '</B><FORM NAME="buttonForm">'
              + '<INPUT TYPE="button" VALUE=" YES  "'
              + ' ONCLICK="opener.buttonClicked(0);self.close();">'
              + '&nbsp;'
              + '<INPUT TYPE="button" VALUE="  NO  "'
              + ' ONCLICK="opener.buttonClicked(1);self.close();">'
              + '&nbsp;'
              + '<INPUT TYPE="button" VALUE="CANCEL"'
              + ' ONCLICK="opener.buttonClicked(2);self.close();">'
              + '</FORM></BODY>';

  winConfirm.document.writeln( theHTML );
}

/* This function is called by the buttons on the confirm box ***************/

function buttonClicked( buttonChoice )
{
  /* Put in this function the result of the user's choice   */
  /* (in this case, write the user's choice in a textfield) */

  switch( buttonChoice )
  {
    case 0:
      document.myForm.showResult.value = "YES";
      break;
    case 1:
      document.myForm.showResult.value = "NO";
      break;
    case 2:
      document.myForm.showResult.value = "CANCEL";
      break;
    default:
      document.myForm.showResult.value = "(void)";
  }
}




/* test */


function enableElement(element) {


    
    id = document.getElementById(element);

    alert( element );
}



  function hide(element) {
      document.getElementById(element).style.display = "none";
      
  }

  function show(element) {
      document.getElementById(element).style.display = "block";
      

}


function showhideDiv(divName, box) {
    var showOrHide = (box.checked) ? "block" : "none";
    document.getElementById(divName).style.display = showOrHide;
}


function Copy(divelement) {
    var div = document.getElementById(divelement);
    div.contentEditable = 'true';
    var controlRange;
    if (document.body.createControlRange) {
        controlRange = document.body.createControlRange();
        controlRange.addElement(div);
        controlRange.execCommand('Copy');
    }
    div.contentEditable = 'false';
}


function toggle_visibility(id) {
    var e = document.getElementById(id);
    if (e != null) {
        if (e.style.display == 'block')
            e.style.display = 'none';
        else
            e.style.display = 'block';
     
    }    
}



function CopyDivGridView() {
    Copy('divGridView');
}



function copyToClipboard(s)
{
	if( window.clipboardData && clipboardData.setData )
	{
		clipboardData.setData("Text", s);
	}
	else
	{
		// You have to sign the code to enable this or allow the action in about:config by changing
		user_pref("signed.applets.codebase_principal_support", true);
		netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

		var clip;  
		Components.classes['@mozilla.org/widget/clipboard;[[[[1]]]]'].createInstance(Components.interfaces.nsIClipboard);
		if (!clip) return;

		// create a transferable
		var trans = Components.classes['@mozilla.org/widget/transferable;[[[[1]]]]'].createInstance(Components.interfaces.nsITransferable);
		if (!trans) return;

		// specify the data we wish to handle. Plaintext in this case.
		trans.addDataFlavor('text/unicode');

		// To get the data from the transferable we need two new objects
		var str = new Object();
		var len = new Object();

		var str = Components.classes["@mozilla.org/supports-string;[[[[1]]]]"].createInstance(Components.interfaces.nsISupportsString);

		var copytext=meintext;

		str.data=copytext;

		trans.setTransferData("text/unicode",str,copytext.length*[[[[2]]]]);

		var clipid=Components.interfaces.nsIClipboard;

		if (!clip) return false;

		clip.setData(trans,null,clipid.kGlobalClipboard);	   
	}
}


