/*
 * newWindow function
 * features:
 *   toolbar
 *   location
 *   directories
 *   status
 *   menubar
 *   resizeable
 *   scrollbars
 * 
 * features are disabled by default, if you wish
 * to turn a feature on, set 'features=yes'
 * For example, feed in 'resizable=no, scrollbars=yes' 
 * to features to disable resizeable and enable
 * scrollbars.
 */

function newWindow(mypage,myname,w,h,features) {
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
  var settings = 'height=' + h + ',';
  settings += 'width=' + w + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += features;
  var win = window.open(mypage,myname,settings);
  win.window.focus();
}

function resizeWindowToPic() { 
  var isNetScape = (navigator.appName.toLowerCase=="netscape")?true:false; 
  var rWidth = isNetScape?window.innerWidth:document.body.clientWidth; 
  var rHeight = isNetScape?window.innerHeight:document.body.clientHeight; 
  rWidth = document.images[0].width - rWidth; 
  rHeight = document.images[0].height - rHeight; 
  window.resizeBy(rWidth, rHeight); 
};

function changeBgColor(obj){
  obj.style.backgroundColor='#78FDFF';
}

function revertBgColor(obj){
  obj.style.backgroundColor='white';
}
function revertBgColorTab(obj){
  obj.style.backgroundColor='ButtonFace';
}

function confirmAndLink(confirmMsg, answerNoURL,answerYesURL){
  result = confirm(confirmMsg);
  if(result == 1){
    if(answerYesURL != 'NULL')
      window.open(answerYesURL,'_self');
  }
  else{
    if(answerNoURL != 'NULL')
      window.open(answerNoURL,'_self');
  }
}

function setVisible(form, visible){
  //alert();
  var formGroup = document.getElementsByName(form);
  var i=0;
  if(formGroup!= null){
    for(i=0; i<formGroup.length; i++){
      if(visible == true){
        formGroup.item(i).style.display='block';
      }
      else{
        formGroup.item(i).style.display='none';
      }
    }
  }
}

/*  add attribute to nodes
 *  specify null to values if not used
 */
function addAttribute(node,typeValue,nameValue,valueValue,classValue, sizeValue){
  if (typeValue != 'null'){
    var attType = document.createAttribute('type');
    attType.value = typeValue;
    node.setAttributeNode(attType);
  }

  if (nameValue != 'null'){
    var attName = document.createAttribute('name');
    attName.value = nameValue;
    node.setAttributeNode(attName);
  }

  if (valueValue != 'null'){
    var attValue = document.createAttribute('value');
    attValue.value = valueValue;
    node.setAttributeNode(attValue);
  }

  if (classValue != 'null'){
    var attClass = document.createAttribute('class');
    attClass.value = classValue;
    node.setAttributeNode(attClass);
  }

  if (sizeValue != 'null'){
    var attSize = document.createAttribute('size');
    attSize.value = sizeValue;
    node.setAttributeNode(attSize);
  }
}

function checkUncheckAll(theElement) {
  var theForm = theElement.form, i = 0;

  while (theForm[i] != null) {
	if(theForm[i].type == 'checkbox' && theForm[i].name != 'checkall')
	  theForm[i].checked = theElement.checked;
    i++;
  }
}

/* Dropdown menu, do not touch! */
sfHover = function() {
	if (document.getElementById("nav_menu"))
	{
	var sfEls = document.getElementById("nav_menu").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
	}
  }
if (window.attachEvent) window.attachEvent("onload", sfHover);

/* Hide status bar message */ 
function hidestatus(){
window.status='';
return true;
}

if (document.layers)
document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
document.onmouseover=hidestatus;
document.onmouseout=hidestatus;
 
/*  REFERENCE 
 <script type="text/javascript"><!--//--><![CDATA[//><!--
 sfHover = function() {
	if (document.getElementById("nav_menu"))
	{
	var sfEls = document.getElementById("nav_menu").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
	}
  }
  if (window.attachEvent) window.attachEvent("onload", sfHover);
  //--><!]]></script>*/ 
  


