//***************************************
// File:     misc.js
// Author:   Pankaj Patel
// Email:    pankaj.patel@vis.co.uk
// Date:     14/10/2003
// Version:  1.0
// Copyright Copyright © 2000-2003, VIS Communications Ltd. All Rights Reserved.
// Comments:
//****************************************


	function PopUpWin(dFileName,WinName)

	{

			props=window.open(dFileName,WinName,"toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=470,height=410, left = 409.5, top = 381.5");
			<!--props=window.open(dFileName,WinName,"toolbar=" +bToolbar + ",location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=470,height=110, left = 409.5, top = 381.5");-->
	}



	function ChkBoxAll(iindex, chkarray, Allbox) {

		var box = "";
		var stbox = eval("document.forms[" + iindex + "]." + Allbox);

		for (var i=0; i<chkarray.length; i++) {
			box = eval("document.forms[" + iindex + "]." + chkarray[i]);
			if (stbox.checked == true) {
				box.checked = true;
			} else {
				box.checked = false;
			}
		}
	}

	function ChkBoxAll2(iindex, chkarray, Allbox) {

		var box = "";
		var stbox = eval("document.forms[" + iindex + "]." + Allbox);
		box = eval("document.forms[" + iindex + "]." + chkarray);
		chkarray = box;

		for (var i=0; i<chkarray.length; i++) {

			if (stbox.checked == true) {
				box[i].checked = true;
			} else {
				box[i].checked = false;
			}
		}

	}

	function check(form) {
		searchqry = form.searchqry.value;

		if (searchqry == "" || searchqry == " ")  {
			alert ("\nSearch Failed.")
			return false;
		} else {
			return true;
		}
	}



	function confirm_delete(url) {

		if (confirm("Are you sure you want to delete this item ?")) {
		window.location = url;
		}
	}



	function confirm_delete2(url,rid) {

	if(document.forms[0].f.length){

		isChecked = eval("document.forms[0].f["+rid+"].checked");

	}else{

		isChecked = eval("document.forms[0].f.checked");

	}

	if(isChecked){

		if (confirm("Are you sure you want to delete this item ?")) {
		window.location = url;
		}


	}else{
		alert("please select the radio button beside the item you want to delete");
	}

	}






	function toggle(n) {

		if (navigator.appName.indexOf("Microsoft Internet Explorer") != -1 && navigator.appVersion.charAt(0)) { // MSIE 4 detected

			if (document.all) {

				if (document.all('id' + n).style.display == '') {
				document.all('id' + n).style.display = 'none';
				}
				else {
				document.all('id' + n).style.display = '';
				}
			}
		}
		else { // assume MSIE 4+ found

			if (document.getElementById) {					// getElementById is found in IE5+ and NS6+

				if (document.getElementById('id' + n).style.display == '') {
				document.getElementById('id' + n).style.display = 'none';
				}
				else {
				document.getElementById('id' + n).style.display = '';
				}
			}
		}

	} // -- ef


	function closeMenus(total_ids) {						// total_ids in navigation menu
		i = 1;								// number of the first id
		while (i <= total_ids) {						// number of ids in navigation

			if (navigator.appName.indexOf("Microsoft Internet Explorer") != -1 && navigator.appVersion.charAt(0)) { // MSIE 4 detected
			document.all('id' + i).style.display = "none";			// close each menu loop
			}
			else {
			document.getElementById('id' + i).style.display = "none";		// close each menu loop
			}
		i++;								// increment counter
		}
	}


	function openMenu(menu_id) {						// menu_id is filled in by PHP from the $menu querystring variable
		if (menu_id) {

			if (navigator.appName.indexOf("Microsoft Internet Explorer") != -1 && navigator.appVersion.charAt(0)) { // MSIE 4 detected
			document.all('id' + menu_id).style.display = "";			// close each menu loop
			}
			else {
			document.getElementById('id' + menu_id).style.display = '';	// open menu_id
			}
		}
	}
	function toggle_symbol() {

		// check if old skool dom
		if (document.all) {

			if (document.all.symbol.innerHTML == '+') {
			document.all.symbol.innerHTML = '–';
			}
			else {
			document.all.symbol.innerHTML = '+';
			}

		}
		// must be a new style dom
		else {

			if (document.getElementById('symbol').innerHTML == '+') {
			document.getElementById('symbol').innerHTML = '–';
			}
			else {
			document.getElementById('symbol').innerHTML = '+';
			}
		}

	} // -- ts


	function cPopUpWin(dFileName,WinName)
	{
		props=window.open(dFileName,WinName,"toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=210, left = 150, top = 250");
	}


	function hlight(what){
		what.bgColor = '#FBC78C'
	}

	function llight(what){
		what.bgColor = '#ffffff'
}


function help(topic){
	props=window.open('help_popup.asp#'+topic,'help',"toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=250,height=300, left = 150, top = 250");

}





	function placeFocus() {
	if (document.forms.length > 0) {
	var field = document.forms[0];
	for (i = 0; i < field.length; i++) {
	if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s")) {
	document.forms[0].elements[i].focus();
	break;
	         }
	      }
	   }
	}
