/*
 JavaScript file for Portfolio Host
 Copyright Rapid Ascent, Inc. 2000 ALL RIGHTS RESERVED
*/

	function totalCharge(){
	
		
		var inputs = document.getElementsByTagName("input");
		
		var temp = 0.0;
		var total = 0.0;
		
		for(var i = 0; i < inputs.length; i++){
			if(inputs[i].name.match(/^charge_/)){
				temp = parseFloat(inputs[i].value);
				if(!isNaN(temp)){
					total += temp;
				}
			}
		}
		
		var total_input = document.getElementById("totalc");
		total_input.value = total;
		
		setTimeout("totalCharge()", 250);
	}

	
	function updateCharge(id){
	
		var cframe = document.getElementById("cframe");
		var ivalue = document.getElementById("charge_"+id);
		var value = 0.0;
		
		if(isNaN(parseFloat(ivalue.value))){
			value = '';
			
		}else{
			value = ivalue.value;
		}
		
		cframe.src = "admin.php?tab=overall&subtab=users&act=charge&id=" + id + "&value=" + value;
		
	}

	function viewNotes(noteid){
		window.name = 'note_parent';
		var loc = 'admin.php?tab=overall&subtab=users&act=notes&id=' + noteid;
		var notewin = window.open(loc, 'notewin', 'scrollbars=yes,resizable=yes,height=300,width=350,menubar=no');
		notewin.focus();
	}


// HELP FUNCTIONS
	function quickHelp(helpid)
	{
		var loc = 'help.php?helpid=' + helpid;
		var helpwin = 
	window.open(loc,'helpwin','scrollbars=yes,resizable=yes,height=300,width=250,menubar=no');
		helpwin.focus();
	}

// HELP EDITOR FUNCTIONS
	function editHelp(id,topic){
		var editURL = "admin.php?tab=$tab&subtab=$subtab&act=edit&helpid=" + id + '&helptopic=' + escape(topic);
		var editwin = open(editURL,"editwin","scrollbars=no,resizable=yes,height=460,width=480");
		editwin.focus();
	}
	
	function confirmHelpDelete(id,title){
		if(confirm("Are you sure you want to permanently delete the help record\r" + title)){
			location = "admin.php?tab=$tab&subtab=$subtab&act=delete&helpid=" + id;
		}
	}
	
	function confirmHelpClose(){
		with (document.editform){
			//alert(oldtext.value + '|' + helptext.value);
			if(oldtext.value == helptext.value && oldtitle.value == helptitle.value){
				window.close();
			}else{
				var gosave = confirm("You have edited the help record. Click OK to save your changes.");
				if(gosave){
					submit();
				}else{
					window.close();
				}
			}
		}
	}
	
	// Add a new help topic
	function newHelpTopic(){
		var new_topic = document.editform.newtopic.value;
		//alert(oldtext.value + '|' + helptext.value);
		if(new_topic != ""){
			var editURL = "admin.php?tab=$tab&subtab=$subtab&act=addtopic&helptopic=" + escape(new_topic);
			var editwin = open(editURL,"editwin","scrollbars=no,resizable=yes,height=460,width=480");
			editwin.focus();
		}else{
			alert("Please enter new help topic and then click Add Topic");
		}
	}

	
	
	