/* /== NetReach Copyright Block ==\
   Copyright 2004, Bastnet, Inc.
   All of the information contained herein is the intellectual property of Bastnet, Inc.  
   No portion of the tools, routines, subroutines and other programs, data and/or materials 
   may be used by any other organization without the express written consent of NetReach, 
   Inc.  Any organization that attempts to reuse any portion of these materials without 
   consent will be prosecuted to the fullest extent allowed by law. 
   This Application includes a licensed copy of telerik r.a.d.editor, copyright 2003 telerik.  
   All rights reserved.  Use of telerik r.a.d.editor outside of this Application is a 
   violation of the Bulgarian and International Copyright Laws and other applicable laws.
   \== NetReach Copyright Block ==/ */

// +----------------------------------------------------------------------------------------------
// |                                      ~~ nr_common.js ~~                                      
// +----------------------------------------------------------------------------------------------
// | Modified: 2003/04/09 [sballard]
// |           Added functions for popup menus
// |
// | Modified: 12.11.2002 [derek]                                                            
// | Notes: this is a common javascript file for use solely with the portstore admin              
// +----------------------------------------------------------------------------------------------


    function popupMenu(level, item) {
		closePopups(level);
		activePopups[level] = item;
		item.style.visibility = 'visible';
        document.onclick = function() {closePopups(0)};
    }
    function closePopups(level) {
		for (var i = 0; i < activePopups.length; i++) {
			if (activePopups[i] != null) {
				activePopups[i].style.visibility = (i < level) ? 'visible' : 'hidden';
			}
		}
    }
    var activePopups = new Array();
    
	// define the colors of active and inactive tabs, intTabs will be overwritten as needed
	// on the page level - it's not really necessary to assign it a value here
	var srtActiveLink = "#000000";
	var strInactiveLink = "#f5f5f5";
	var strActiveTab = "#ffffff";
	var strInactiveTab = "#a9a9a9";

	// preload the tab images for use in the admin..
	if (document.images){
		tabLeftOff  = new Image(7,20); tabLeftOff.src  = "/admin/images/tab-left_deselected.gif";
		tabLeftOn   = new Image(7,20); tabLeftOn.src   = "/admin/images/tab-left_selected.gif";
		tabRightOff = new Image(7,20); tabRightOff.src = "/admin/images/tab-right_deselected.gif";
		tabRightOn  = new Image(7,20); tabRightOn.src  = "/admin/images/tab-right_selected.gif";
	}

	// function responsible for hiding and showing tab content DIVs and swapping tab images
	function tab(intSelectedTab,strElementName,intShowElement){
		if (document.getElementById){
			for (i=1; i<(intTabs+1); i++){
				document.getElementById('tabContent'+i).style.display = 'none';
				document.getElementById('tab'+i).style.background = strInactiveTab;
				document.getElementById('tab'+i).style.color = strInactiveLink;
				document['tabLeft' + i].src = tabLeftOff.src;
				document['tabRight' + i].src = tabRightOff.src;
			}
			try {
				document.getElementById('tabContent'+intSelectedTab).style.display = 'table-row';
			} catch (e) {
				document.getElementById('tabContent'+intSelectedTab).style.display = 'block';
			}
			document.getElementById('tab' + intSelectedTab).style.background = strActiveTab;
			document.getElementById('tab' + intSelectedTab).style.color = srtActiveLink;
			document['tabLeft' + intSelectedTab].src = tabLeftOn.src;
			document['tabRight' + intSelectedTab].src = tabRightOn.src;
			if(intShowElement == 0){
				document.getElementById(strElementName).style.visibility = 'hidden';
			}
			else{
				//alert(strElementName); //debug
				document.getElementById(strElementName).style.visibility = 'visible';
			}
		}
	}

	// function to swap items from one select box to another. automatically sorts by alpha..
	function moveSelect(fbox,tbox){
		var arrFbox = new Array();
		var arrTbox = new Array();
		var arrLookup = new Array();
		var i;
		for (i = 0; i < tbox.options.length; i++){
			arrLookup[tbox.options[i].text] = tbox.options[i].value;
			arrTbox[i] = tbox.options[i].text;
		}
		var fLength = 0;
		var tLength = arrTbox.length;
		for(i = 0; i < fbox.options.length; i++){
			arrLookup[fbox.options[i].text] = fbox.options[i].value;
			if (fbox.options[i].selected && fbox.options[i].value != ""){
				arrTbox[tLength] = fbox.options[i].text;
				tLength++;
			}
			else {
				arrFbox[fLength] = fbox.options[i].text;
				fLength++;
			}
		}
		arrFbox.sort();
		arrTbox.sort();
		fbox.length = 0;
		tbox.length = 0;
		var c;
		for(c = 0; c < arrFbox.length; c++){
			var no = new Option();
			no.value = arrLookup[arrFbox[c]];
			no.text = arrFbox[c];
			fbox[c] = no;
		}
		for(c = 0; c < arrTbox.length; c++){
			var no = new Option();
			no.value = arrLookup[arrTbox[c]];
			no.text = arrTbox[c];
			tbox[c] = no;
		}
	}
	
