// JavaScript Document
function _getElement(eName) {
	if (document.all) return(eval("document.all['" + eName + "']"));
	else return(document.getElementById(eName));
}

function isBlank(s) {
	for(var i=0; i<s.length; i++){
		var c=s.charAt(i);
		if((c != ' ') && (c != '\n') && (c!= '\t')) return false;
	}
	return true;
}

function verify(f){
	var msg;
	var empty_fields ="";
	var errors="";
	for(var i=0; i<f.length; i++){
		var e=f.elements[i];
		if(((e.type=="text") || (e.type=="textarea") || (e.type=="password")) && !e.optional){
			if((e.value==null) || (e.value=="") || isBlank(e.value)){
				empty_fields += "\n	" + e.name;
				continue;
				}
			}
		}

	if(!empty_fields && !errors) return true;
	msg = "---------------------------------------------------------------------------\n\n";
	msg += "The form was not submitted because of the following error(s).\n";
	msg += "Please correct these error(s) and re-submit.\n";
	msg += "--------------------------------------------------------------------------\n\n";
	if(empty_fields){
		var re = new RegExp ('_', 'gi') ;
		var newstr = empty_fields.replace(re, ' ') ;

		msg += "- The following required field(s) are empty:" + newstr + "\n";
		if(errors) msg += "\n";
		}
	msg += errors;
	alert(msg);
	return false;
}

if (document.getElementById){ 
	document.write('<style type="text/css">\n')
	document.write('.submenu{display: none;}\n')
	document.write('.abstsubmenu{display: none;}\n')
	document.write('</style>\n')
}

//Sheetal: Kept this function exclusively for DOPPS Research Slides Page.So that we can easily add remove the categories and thus add remove from this fucntion.

function SwitchMenu(obj){
	if(document.getElementById){

// make all titles font weight normal.
	var other_hd = document.getElementById("heading_c1");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c2");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c3");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c4");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c5");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c6");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c7");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c8");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c9");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c10");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c11");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c12");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c13");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c14");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c15");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c16");
	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_c17");
//	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_c18");
//	other_hd.style.fontWeight = 'normal';
	

	var el = document.getElementById(obj);
 	var hd = document.getElementById("heading_" + obj);
	var ar = document.getElementById("main_container").getElementsByTagName("span"); 
		if(el.style.display != "block"){
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu") {
				ar[i].style.display = "none";
				document.getElementById("img_" + ar[i].id).src = "img/plus.gif";
			    }
			}
			document.getElementById("img_" + obj).src = "img/minus.gif";
			el.style.display = "block";
			hd.style.fontWeight = 'bold';
		}else{
		    document.getElementById("img_" + obj).src = "img/plus.gif";
			el.style.display = "none";
			hd.style.fontWeight = 'normal';
		}
	}
}

//Sheetal: 2008.09.22 Function for ISHCOF Page. Its Better to have new function for different pages.

function SwitchISHCOFMenu(obj){
	if(document.getElementById){

// make all titles font weight normal.
	var other_hd = document.getElementById("heading_c1");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c2");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c3");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c4");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c5");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c6");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c7");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c8");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c9");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c10");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c11");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c12");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c13");
	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_c14");
//	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_c15");
//	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_c16");
//	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_c17");
//	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_c18");
//	other_hd.style.fontWeight = 'normal';
	

	var el = document.getElementById(obj);
 	var hd = document.getElementById("heading_" + obj);
	var ar = document.getElementById("main_container").getElementsByTagName("span"); 
		if(el.style.display != "block"){
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu") {
				ar[i].style.display = "none";
				document.getElementById("img_" + ar[i].id).src = "img/plus.gif";
			    }
			}
			document.getElementById("img_" + obj).src = "img/minus.gif";
			el.style.display = "block";
			hd.style.fontWeight = 'bold';
		}else{
		    document.getElementById("img_" + obj).src = "img/plus.gif";
			el.style.display = "none";
			hd.style.fontWeight = 'normal';
		}
	}
}

//Sheetal: 2008.09.22 Function for Country Reports Page. Its Better to have new function for different pages.

function SwitchCountryRptMenu(obj){
	if(document.getElementById){

// make all titles font weight normal.
	var other_hd = document.getElementById("heading_c1");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c2");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c3");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c4");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c5");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c6");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c7");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c8");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c9");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c10");
	other_hd.style.fontWeight = 'normal';
	other_hd = document.getElementById("heading_c11");
	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_c12");
//	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_c13");
//	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_c14");
//	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_c15");
//	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_c16");
//	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_c17");
//	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_c18");
//	other_hd.style.fontWeight = 'normal';
	

	var el = document.getElementById(obj);
 	var hd = document.getElementById("heading_" + obj);
	var ar = document.getElementById("main_container").getElementsByTagName("span"); 
		if(el.style.display != "block"){
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu") {
				ar[i].style.display = "none";
				document.getElementById("img_" + ar[i].id).src = "img/plus.gif";
			    }
			}
			document.getElementById("img_" + obj).src = "img/minus.gif";
			el.style.display = "block";
			hd.style.fontWeight = 'bold';
		}else{
		    document.getElementById("img_" + obj).src = "img/plus.gif";
			el.style.display = "none";
			hd.style.fontWeight = 'normal';
		}
	}
}



function isBlank(s) {
	for(var i=0; i<s.length; i++){
		var c=s.charAt(i);
		if((c != ' ') && (c != '\n') && (c!= '\t')) return false;
	}
	return true;
}

function verify(f){
	var msg;
	var empty_fields ="";
	var errors="";
	for(var i=0; i<f.length; i++){
		var e=f.elements[i];
		if(((e.type=="text") || (e.type=="textarea") || (e.type=="password")) && !e.optional){
			if((e.value==null) || (e.value=="") || isBlank(e.value)){
				empty_fields += "\n	" + e.name;
				continue;
				}
			}
		}

	if(!empty_fields && !errors) return true;
	msg = "---------------------------------------------------------------------------\n\n";
	msg += "The form was not submitted because of the following error(s).\n";
	msg += "Please correct these error(s) and re-submit.\n";
	msg += "--------------------------------------------------------------------------\n\n";
	if(empty_fields){
		var re = new RegExp ('_', 'gi') ;
		var newstr = empty_fields.replace(re, ' ') ;

		msg += "- The following required field(s) are empty:" + newstr + "\n";
		if(errors) msg += "\n";
		}
	msg += errors;
	alert(msg);
	return false;
}

if (document.getElementById){ 
	document.write('<style type="text/css">\n')
	document.write('.submenu{display: none;}\n')
	document.write('</style>\n')
}


//Sheetal: 2008.08.27 added new function for Abstract pull out menus.

function SwitchAbstMenu(obj, isISHCOF){
	if(document.getElementById){

// make all titles font weight normal.
	var other_hd = document.getElementById("heading_d1");
	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_d2");
//	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_d3");
//	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_d4");
//	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_d5");
//	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_d6");
//	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_d7");
//	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_d8");
//	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_d9");
//	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_d10");
//	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_d11");
//	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_d12");
//	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_d13");
//	other_hd.style.fontWeight = 'normal';
	if (!isISHCOF) {
	other_hd = document.getElementById("heading_d1");
	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_d15");
//	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_d16");
//	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_d17");
//	other_hd.style.fontWeight = 'normal';
//	other_hd = document.getElementById("heading_d18");
//	other_hd.style.fontWeight = 'normal';
    }

	var el = document.getElementById(obj);
 	var hd = document.getElementById("heading_" + obj);
	var ar = document.getElementById("main_container").getElementsByTagName("span"); 
		if(el.style.display != "block"){
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="abstsubmenu") 
				ar[i].style.display = "none";
			}
			el.style.display = "block";
			hd.style.fontWeight = 'bold';
		}else{
			el.style.display = "none";
			hd.style.fontWeight = 'normal';
		}
	}
}


function _getElement(eName) {
	if (document.all) return(eval("document.all['" + eName + "']"));
	else return(document.getElementById(eName));
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}


function showDiv(whichDiv, divShutOff) {
	if(whichDiv == divShutOff) { return false; }
	var aObj = _getElement(whichDiv);
	var menu = _getElement("useTick" + whichDiv);
	var x = findPosX(menu);
      	aObj.style.left = x + 9 + "px";
	if (aObj!=null) {
		aObj.style.visibility = "visible";
	}
}
function hideDiv(i) {
	var aObj = _getElement(i);
	if(aObj!=null) {
		aObj.style.visibility = "hidden";
	}
}
