<!--// 

/*

ATTENTION: Update these comments with your information immediately after any changes, thank you!

Last edited by: Jim Goldbloom
Last edited on: 3/13/06
Note: This is a LEGACY Javascript file - it's for CF Apps and PHP scripts prior to phase 5.4.0 (3/13/06)

Comments:
The code in this script is only used for legacy portal apps written prior to phase 5.4.0 and also
for Cold Fusion apps that might call this file.  If you are adding/modifying Javascript for the portal
front end or the CMT, then DO NOT update this file.

Instead, edit: /skins/default/templates/javascript.js 

If you're developing Cold Fusion, I'd apprecoate it if you used your own JavaScript file in /apps somewhere
and not edit this file.  But if you do, leave copius comments explaining what the function or variable does
and where it's used.  Thank you.  

- Jim Goldbloom

*/

/* GLOBAL SETTINGS BELOW THIS LINE */

var myWidth = 0, myHeight = 0;

/* PUT ALL JAVASCRIPT FUNCTIONS BELOW THIS LINE */

function ChangeDivText (id,text) {

// By: Jim Goldbloom for MBDA.gov 9/27/04
// Function to alter text inside any div tag.
// Pass the div ID name and text to change to as arguments.
// NS4 compatibility requires different HTML body code - see comments for isLayer/Netscape4 below...

        isLayer = document.layers?true:false;
        isIE = navigator.appName.indexOf("Microsoft") != -1
        isByID = !isIE && document.getElementById?true:false;

        if (isIE || isByID) {
                // MSIE 4 or later and any browser not requiring layers
                document.getElementById(id).innerHTML = text;
        }

        if (isLayer) {
            // Netscape 4 only - hardcode your source like this...
                // <ilayer name="ilayer_name"><layer name="layer_name">Original Text</layer></ilayer>
                document.ilayer_name.document.layer_name.document.write(text);
                document.ilayer_name.document.layer_name.document.close();
        }

} // end function

function checkEverything(form_name,checked) {
	// Pass name of form and true/false - this will check/uncheck all checkboxes in the form
	var adjust = document.getElementById(form_name);
	var input, i = 0, inputs = adjust.getElementsByTagName('input');
	while (input = inputs.item(i++)) {
		if (input.getAttribute('type') == 'checkbox' && input.getAttribute('disabled')==false && checked==true) {input.checked=true;}
		if (input.getAttribute('type') == 'checkbox' && input.getAttribute('disabled')==false && checked==false) {input.checked=false;}
	 }
}

function NSresize()
{
	if(navigator.appName=="Netscape")
	{
		location.reload();
	}
}
document.WM = new Object();
document.WM.menu = new Object();
document.WM.menu.dropdown = new Array();

function WM_initializeToolbar(){
	var i;
    if ((document.all)&&(document.all('container')))
	{
		for(i = 0; i < document.all('container').all.length; i++)
		{
		    if ((document.all('container').all[i].className == 'header') ||(document.all('container').all[i].className == 'links'))
			{
				document.WM.menu.dropdown[document.WM.menu.dropdown.length] = document.all('container').all[i];
	    	}
		}
    }else if ((document.getElementsByTagName && document.getElementById)&&(document.getElementById('container')))
	{
		var contained = document.getElementById('container').getElementsByTagName('div');
		for(i = 0; i < contained.length; i++)
		{
			if ((contained[i].getAttribute('class') == 'header') || (contained[i].getAttribute('class') == 'links'))
			{
				document.WM.menu.dropdown[document.WM.menu.dropdown.length] = contained[i];
			}
		}
    }
}
function WM_collapse(item,bucket_id){
	if(navigator.appName=="Netscape"){
		//alert(bucket_id);
		window.location.href='/templates/collection.php?collect_bucket=' + bucket_id + '&site_id=1';
	}

    if(document.WM.menu.dropdown.length){
	//alert(document.WM.menu.dropdown[item + 1].style.display)
		if (document.WM.menu.dropdown[item].style.display == 'none'){
		    document.WM.menu.dropdown[item].style.display = '';
		   	document.images[document.WM.menu.dropdown[item - 1].id + 'images'].src = '/images/folder_open.gif';
		}
		else {
	    	document.WM.menu.dropdown[item].style.display = 'none';
		    document.images[document.WM.menu.dropdown[item - 1].id + 'images'].src = '/images/folder_closed.gif';
		}
    }
	}

function expandit(hideThis,curobj,images){
	if(images){
		var temp = curobj.src.split("/");
		//alert();
		if(temp[temp.length-1] == 'folder_open.gif')
			curobj.src = '/images/folder_closed.gif';
		else
			curobj.src = '/images/folder_open.gif';
	}

	if (document.all)
		folder=document.all[hideThis].style;
	else
		folder=document.layers[hideThis];


 if (folder.display=="")
  folder.display="none"
 else
  folder.display=""

}

function GetBrowserSize() {
  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;
  }
  
}


function openApp(pageToLoad) {
	
	GetBrowserSize(); // Creates global variables myHeight and myWidth

	var winName = "_blank";
	var width=myWidth-50;
	var height=myHeight-50;
	var center=true;
	
	// Safety catches
	if (width<600) {width=750;}
	if (height<100) {height=550;}

    var xposition=0; 
	var yposition=50;
    
	if ((parseInt(navigator.appVersion) >= 4 ) && (center)){
        xposition = (screen.width - width) / 2;
    }
    
	var args = "width=" + width + ","
    + "height=" + height + ","
    + "location=0,"
    + "menubar=1,"
    + "resizable=1,"
    + "scrollbars=1,"
    + "status=1,"
    + "titlebar=1,"
    + "toolbar=1,"
    + "hotkeys=0,"
    + "screenx=" + xposition + ","  //NN Only
    + "screeny=" + yposition + ","  //NN Only
    + "left=" + xposition + ","     //IE Only
    + "top=" + yposition;           //IE Only

    window.open( pageToLoad,winName,args );
	return false;

}

function NotAllSpace(A_Str)
{
	Len = A_Str.value.length;

	for (i = 0; i < Len; i++)
	{
		if (A_Str.value.charAt(i) != " ")
		return true;	//runs throught the string, if it hits something other than a space it returns TRUE
	}
	return false;
}

function validate(form)
{
	var msg="";
	if (!namevalid(form.username)) msg += "  *  Username\n";
	if (!namevalid(form.password)) msg += "  *  Password\n";

	if (msg == "")
    { return true; }
	else
	{
		alert("The following fields had errors:\n" + msg);
		return false;
	}
}

function validateForm(form)
{
  var msg = "";
  var len = form.elements.length;

  for (var i = 0; i < len; i++)
  {
    var field_value = form.elements[i].value;
    if (field_value == null || field_value == "")
    {
      var field_name = form.elements[i].name;
      msg += field_name + "\n";
    }
  }

	if (msg == "")
  {
    return true;
  }
	else
	{
		alert("The following required fields were not completed:\n\n" + msg);
		return false;
	}
}

function checkAll(value, form_name, checkbox_name)
{
  var form = document.forms[form_name];

  for (i = 0; i < form.length; i++)
  {
    if (form.elements[i].type == "checkbox" && form.elements[i].disabled==false && form.elements[i].name == checkbox_name)
    {
      form.elements[i].checked = value;
    }
  }
}

function namevalid(name)
{
	if (name.value.length != 0 && NotAllSpace(name))
		return true;
	return false;
}

function popwindow(window_url) {location=window_url;}

/* CONTINUE ANY OTHER FUNCTIONS BELOW THIS LINE */

//-->