function popGlossary(gTerm, w, h) {
  window.open("../glossary.aspx?gTerm="+gTerm,  
  "_blank", 
  "width="+w+",height="+h+",scrollbars=yes");
  
  return false;
}
function popGlossaryApp(gTerm, w, h) {
  window.open("glossary.aspx?gTerm="+gTerm,  
  "_blank", 
  "width="+w+",height="+h+",scrollbars=yes");
  
  return false;
}

// JavaScript Document
var intImage = 2;
var intSave = 2;
//i = 1;

var save1 = "template_images/SaveYourWORK.gif"
var save2 = "template_images/SaveYourWORK_hoover.gif"
var str = {};
str['starthelp'] ="<p>This is a help text document. Following the instruction, the user will find it is easy to fill in the electronic application form. </p><p>Every principal of your business or organization, including yourself, will be listed in this section. </p><p>Clicking on 'add a director' brings up a screen where you provide information about yourself and the partners, directors or officers associated with this business or organization.</p>"
str['determinationhelp'] = "<p>THIS IS A PLAIN TEXT HELP DOCUMENT, Following the instruction, the user will find it is easy to fill in the electronic application form. </p><p>Every principal of your business or organization, including yourself, will be listed in this section. </p><p>Clicking on 'add a director' brings up a screen where you provide information about yourself and the partners, directors or officers associated with this business or organization.</p>"

var empty = 'something else'

var aryImages = new Array(3);
aryImages[0] = "template_images/Help%2B.gif"
aryImages[1] = "template_images/Help%2BHover.gif"

aryImages[2] = "template_images/Help-.gif"
aryImages[3] = "template_images/Help-Hover.gif"

aryImages[4] = "template_images/spacer.gif"

aryImages[5] = "%2B.gif"
aryImages[6] = "_.gif"

aryImages[7] = "template_images/LogOUT.gif"
aryImages[8] = "template_images/LogOUT_hoover.gif"

/* swap help+.gif and help-.gif*/
function swap(param, num){
	var imgS = param+'s';
	var imgP = param+'p';
	if (num == 0){
		document[imgS].src = aryImages[2];
		document[imgS].style.visibility = "visible"; //aryImages[2];
		document[imgP].style.visibility = "hidden";//aryImages[4];
	} else if (num == 1){
		document[imgS].style.visibility = "hidden";	//aryImages[4];
		document[imgP].src = aryImages[0];
		document[imgP].style.visibility = "visible";//aryImages[0];
		
	}
}

/* swap rollover image */
function swapImage(param, id) {

var ele = document.getElementById(param);

if ( id == "helpp"){
/*	if (document["helpp"].src == "http://melmer/npass/template_images/spacer.gif"){}
	else {
*/
		document[param].src = aryImages[0]
//	}
}
if ( id == "helpph"){
/*	if (document["helpp"].src == "http://melmer/npass/template_images/spacer.gif"){}
	else {
 */
 		document[param].src = aryImages[1]
//	}
}

if (id == "helps") {
	document[param].src = aryImages[2]
}
if (id == "helpsh") {
	document[param].src = aryImages[3]
}
if (id == "save"){
	save.src = save1
}
if (id == "saveh"){
	save.src = save2
}
if (id =="logouth"){
	ele.src = aryImages[8]
}
if (id == "logout"){
	ele.src = aryImages[7]
}

if (id == "sign"){
var s = splitPath(param);
//var s = new Array();
//s = document[param].src.split('/');
//alert(s);
//alert(document[param].src);
	if(s == aryImages[5])
	{
		document[param].src = "../template_images/"+aryImages[6];
	} else{
		document[param].src = "../template_images/"+aryImages[5];
	}
}

return(false);
}
function splitPath(param){
	var str = new Array();
	str = document[param].src.split("/");
	return str[str.length-1];
}

function displaySub(param, id){
	var sub = document.getElementById(id);
	var check = splitPath(param);
	if (check == aryImages[6]){
		sub.style.display = "inline";
	}else {
		sub.style.display = "none";
	}
}

/* display text */
function helpdoc(param,index){
	var helptext = document.getElementById(param);
		if (index == 1){
/*			helptext.innerHTML = str[param];
*/
			helptext.style.display = "block";
		}else {
			helptext.style.display = "none"
		}
//	}
}

/*function flipImage(){
	if ( img1 == "template_images/Help%2B.gif"){
	 img1 = "template_images/Help-.gif"
	 img2 = "template_images/Help-Hover.gif"
	} else{
	 img1 = "template_images/Help%2B.gif"
	 img2 = "template_images/Help%2BHover.gif"
	}
	intImage = 2;
 	swapImage('help');
		if (index == 1){
			showText();
			index = 2;
		}else {
			hideText();
			index = 1;
		}
}
*/
function showText(param){
		var helptext=document.getElementById("helptext");
		helptext.innerHTML = str;
		helptext.style.display="block";
}
function hideText(param){
		var helptext=document.getElementById("helptext");
		helptext.innerHTML = empty;
		helptext.style.display="none";
}
	function nameVal(name){
		if (name == ""){
			name= "N/A";
		}
		return name;
	}

	function phoneVal(phone){
		if (phone != ""){
			if (phone.length==3){
				phone = "("+phone+")";
			}else{
				phone=phone.replace(/\D/g,"");
				var sub1 = phone.substr(0,3,  phone);
				var sub2 = phone.substr(3,phone );
				phone = sub1 +"-"+sub2;
			}
		} 
		
		return phone;
	}
function popup(url){
  window.open(url, "_blank", "top=10, left=10, width=640, height=480, menubar=no, scrollbars=yes, resizable=no");
  return false;
}