// JavaScript Document
function _getElement(eName) {
	if (document.all) return(eval("document.all['" + eName + "']"));
	else return(document.getElementById(eName));
}

function newDiv(div){
        var a = _getElement('slides')
//        var b = _getElement('reference')
//        var c = _getElement('other')
//        var d = _getElement('articles')
        var e = _getElement('default')
//        var f = _getElement('csr')
  	    var g = _getElement('feature')
  	    var s = _getElement('contact')
//  	    var t = _getElement('fastfact')

        var useDiv;
        if(div=='slides') useDiv = a
//        if(div=='reference') useDiv = b
//        if(div=='other') useDiv = c
//        if(div=='articles') useDiv = d
        if(div=='default') useDiv = e
//        if(div=='csr') useDiv = f
	      if(div=='feature') useDiv = g
	      if(div=='contact') useDiv = s
//	      if(div=='fastfact') useDiv = t
	      
        
        a.style.display = "none"
//        b.style.display = "none"
 //       c.style.display = "none"
  //      d.style.display = "none"
        e.style.display = "none"
  //      f.style.display = "none"
	      g.style.display = "none"
	      s.style.display = "none"
	//      t.style.display = "none"
	      
        
        useDiv.style.display = "inline";
}


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')
}
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';
	

	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";
			}
			el.style.display = "block";
			hd.style.fontWeight = 'bold';
		}else{
			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')
}
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';

	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";
			}
			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;
	if (aObj!=null) {
		aObj.style.visibility = "visible";
	}
}
function hideDiv(i) {
	var aObj = _getElement(i);
	if(aObj!=null) {
		aObj.style.visibility = "hidden";
	}
}
