
function setValue(theID, theValue){
	document.getElementById(theID).value = theValue;	
}


function setHTML(theID, theHTML){
	document.getElementById(theID).innerHTML = theHTML;
}


function showDiv(divID){
	theDiv = document.getElementById(divID);
	theDiv.style.visibility = 'visible';	
	theDiv.style.display = 'block';
}


function hideTr(trID){
	document.getElementById(trID).style.display = 'none';
}

function showTr(trID){
	theTr = document.getElementById(trID);
	theTr.style.visibility = 'visible';	
	if (navigator.appName == "Microsoft Internet Explorer") {
		theTr.style.display = 'block';
	}else{
		theTr.style.display = 'table-row';	
	}
}


function hideDiv(divID){
	document.getElementById(divID).style.display = 'none';
}
function delayHideDiv(divID){
	setTimeout("hideDiv('"+divID+"')",250);	
}


function disableDiv(divID){
	document.getElementById(divID).disabled = 'disabled';
}

function enableDiv(divID){
	theDiv = document.getElementById(divID).disabled = '';
}


function noReadDiv(divID){
	document.getElementById(divID).readOnly = 'readonly';
}

function readDiv(divID){
	theDiv = document.getElementById(divID).readOnly = '';
}

function switchClass(ID, theClass){
	theDiv = document.getElementById(ID).className = theClass;	
}


function checkLength(txtBox, maxLength){
	if(txtBox.value.length > maxLength){
		alert('You have reached the '+maxLength+' character limit!');
		txtBox.value = txtBox.value.substr(0,maxLength-1);
	}
}


function print_view(contentId){
	printDiv = document.getElementById(contentId);
	popup = window.open('', 'popup');
	popup.document.open();
	popup.document.write("<html><head><link href='includes/main.css' rel='stylesheet' type='text/css' /></head><body><div style='padding:10px;'>");
	popup.document.write(printDiv.innerHTML);
	popup.document.write("</div></body></html>");
	popup.document.close();	
}


function admin_print_view(contentId){
	printDiv = document.getElementById(contentId);
	popup = window.open('', 'popup');
	popup.document.open();
	popup.document.write("<html><head><link href='../includes/main.css' rel='stylesheet' type='text/css' /></head><body><div style='padding:10px;'>");
	popup.document.write(printDiv.innerHTML);
	popup.document.write("</div></body></html>");
	popup.document.close();	
}



function check_all_from_box(checked, theDiv){
	if(checked == true){
		check_all_boxes(theDiv, 1);
	}else{
		check_all_boxes(theDiv, 0);
	}
}
	
function check_all_boxes(table_name, on){
	
	var rows = document.getElementById(table_name).getElementsByTagName('tr');
    var unique_id;
    var checkbox;
	
	if(on == null){
		on = 1;	
	}
	
    for ( var i = 0; i < rows.length; i++ ) {
        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' ) {
            unique_id = checkbox.name + checkbox.value;
            if ( on == 1 ) {
                checkbox.checked = true;
            }else{
				checkbox.checked = false;	
			}
        }
    }
	
}//end function


function checkBoxesInDiv(wrapperID, on){
	theElements = document.getElementById(wrapperID).getElementsByTagName('input');
	
	for(var i = 0; i < theElements.length; i++){
		//checkbox = theElements[i].getElementsByTagName( 'input' )[0];
		checkbox = theElements[i];

        if ( checkbox && checkbox.type == 'checkbox' ) {
            unique_id = checkbox.name + checkbox.value;
            if ( on == 1 ) {
                checkbox.checked = true;
            }else{
				checkbox.checked = false;	
			}
        }
	}
}


function showElementsByTag(wrapperID, tag){
	theElements = document.getElementById(wrapperID).getElementsByTagName(tag);
	
	for(var i = 0; i < theElements.length; i++){
		theElements[i].style.display = 'block';	
	}
}


function hideElementsByTag(wrapperID, tag){
	theElements = document.getElementById(wrapperID).getElementsByTagName(tag);
	
	for(var i = 0; i < theElements.length; i++){
		theElements[i].style.display = 'none';	
	}
}

// open browser window
function openPopUp(url, windowName, w, h, scrollbar) {

   var winl = (screen.width - w) / 2;
   var wint = (screen.height - h) / 2;
   winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scrollbar ;
   win = window.open(url, windowName, winprops);
   if (parseInt(navigator.appVersion) >= 4) { 
		win.window.focus(); 
   } 
}


/***********************************************
* Drop Down/ Overlapping Content- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function getposOffset(overlay, offsettype){
	var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
	var parentEl=overlay.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}

function overlayDiv(curobj, divID, opt_position){
	if (document.getElementById){
		var subobj=document.getElementById(divID);
		subobj.style.display=(subobj.style.display!="block")? "block" : "none";
		subobj.style.zIndex = 0;
		
		var xpos = (document.body.clientWidth/2) - (subobj.offsetWidth/2);
		var ypos = ((iecompattest().clientHeight/2 + iecompattest().scrollTop)) - (subobj.offsetHeight/2);
		
		subobj.style.left=xpos+"px";
		subobj.style.top=ypos+"px";
		return false;
	}else{
		return true;
	}
}


function overlayclose(subobj){
	theDiv = document.getElementById(subobj)
	theDiv.style.display="none";
}
