// JavaScript Document
function SetAllCheckBoxes(FormName, FieldName, fromI, toI, CheckValue)
{
	if(!document.forms[FormName])
		return;
	for(var i = fromI; i <= toI; i++) {
		var objCheckBoxes = document.forms[FormName].elements[FieldName+i];
		if(!objCheckBoxes)
			return;
		var countCheckBoxes = objCheckBoxes.length;
		if(!countCheckBoxes)
			objCheckBoxes.checked = CheckValue;
		else
			// set the check value for all check boxes
			for(var j = 0; j < countCheckBoxes; j++)
				objCheckBoxes[j].checked = CheckValue;
	}
}

function confirmAction(msg) {

	var answer = confirm(msg);    
	
	/* Question icon, Yes/No button. */
	/* 0 = error, 1 = OK, 2 = Cancel, 3 = No, 4 = Yes */
	
	if (answer)
	   return true;
	else
	   return false;	
}

function showHideObj(obj) {
	if(document.getElementById(obj).style.display=="none") {
		document.getElementById(obj).style.display="";
	} else {
		document.getElementById(obj).style.display="none";
	}
}
function showObj(obj) {
	
	if (document.getElementById(obj)) {
		document.getElementById(obj).style.display="";
	}
}
function HideObj(obj) {
	
	if (document.getElementById(obj)) {
		document.getElementById(obj).style.display="none";
	}
}
function confirmDelete(delUrl) {
  if (confirm("Are you sure you want to delete this item? The change will NOT be undoable!")) {
    document.location = delUrl;
  }
}
function confirmURL(Url,msg) {
  if (confirm(msg)) {
    document.location = Url;
  }
}
function HideTab(obj) {
	if (document.getElementById(obj)) {
		document.getElementById(obj).bgColor='#CCCCCC';
	}
}
function showTab(obj) {
	if (document.getElementById(obj)) {
		document.getElementById(obj).bgColor='#EEEEEE'
	}
}
function boldLink(obj) {
	if (document.getElementById(obj)) {
		document.getElementById(obj).style.fontWeight='bold';
	}
}
function unboldLink(obj) {
	if (document.getElementById(obj)) {
		document.getElementById(obj).style.fontWeight='';
	}
}
function browserSize(woh) {
  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;
  }
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
  
  if (woh == "h") {
	  return myHeight;
  } else {
	  return myWidth;
  }
}
function detectBlank(obj) {
	if (obj.value == "") {
		alert("Please delete the spec value by clicking on the X icon (delete) in front of this item. By deleting the value, the default spec will remain in place.");
		return false;
	}
}
function openWindow(url,name,width,height) {
	window.open(url,name,'width='+width+',height='+height+',toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=yes,resizable=yes');	
}

function imgSwap(obj, img) {
	document.getElementById(obj).src = img;	
}