





/***********************************************
* Slashdot Menu script- By DimX
* Submitted to Dynamic Drive DHTML code library: http://www.dynamicdrive.com
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
/* configured for dept of veterans affairs by Victor Chan (vwc@ca.ibm.com) */

function SDMenu(id) {
	if (!document.getElementById || !document.getElementsByTagName)
		return false;
	this.menu = document.getElementById(id);
	this.submenus = this.menu.getElementsByTagName("div");
	this.speed = 3;
	this.markCurrent = true;
	this.oneSmOnly = true;
}
SDMenu.prototype.init = function() {
	var mainInstance = this;
	for (var i = 0; i < this.submenus.length; i++)
		this.submenus[i].getElementsByTagName("span")[0].onclick = function() {
			mainInstance.toggleMenu(this.parentNode);
		};
	if (this.markCurrent) {
		var links = this.menu.getElementsByTagName("a");
		for (var i = 0; i < links.length; i++)
			if (links[i].href == document.location.href) {
				links[i].className = "current";
				break;
			}
	}
};
SDMenu.prototype.toggleMenu = function(submenu) {
	if (submenu.className == "collapsed")
		this.expandMenu(submenu);
	else
		this.collapseMenu(submenu);
};
SDMenu.prototype.expandMenu = function(submenu) {
	var fullHeight = submenu.getElementsByTagName("span")[0].offsetHeight;
	var links = submenu.getElementsByTagName("a");
	for (var i = 0; i < links.length; i++)
		fullHeight += links[i].offsetHeight;
	var moveBy = Math.round(this.speed * links.length);
	
	var mainInstance = this;
	var intId = setInterval(function() {
		var curHeight = submenu.offsetHeight;
		var newHeight = curHeight + moveBy;
		if (newHeight < fullHeight)
			submenu.style.height = newHeight + "px";
		else {
			clearInterval(intId);
			submenu.style.height = "";
			submenu.className = "";
		}
	}, 30);
	this.collapseOthers(submenu);
};
SDMenu.prototype.collapseMenu = function(submenu) {
	var minHeight = submenu.getElementsByTagName("span")[0].offsetHeight;
	var moveBy = Math.round(this.speed * submenu.getElementsByTagName("a").length);
	var mainInstance = this;
	var intId = setInterval(function() {
		var curHeight = submenu.offsetHeight;
		var newHeight = curHeight - moveBy;
		if (newHeight > minHeight)
			submenu.style.height = newHeight + "px";
		else {
			clearInterval(intId);
			submenu.style.height = "";
			submenu.className = "collapsed";
		}
	}, 30);
};
SDMenu.prototype.collapseOthers = function(submenu) {
	if (this.oneSmOnly) {
		for (var i = 0; i < this.submenus.length; i++)
			if (this.submenus[i] != submenu && this.submenus[i].className != "collapsed")
				this.collapseMenu(this.submenus[i]);
	}
};
SDMenu.prototype.expandAll = function() {
	var oldOneSmOnly = this.oneSmOnly;
	this.oneSmOnly = false;
	for (var i = 0; i < this.submenus.length; i++)
		if (this.submenus[i].className == "collapsed")
			this.expandMenu(this.submenus[i]);
	this.oneSmOnly = oldOneSmOnly;
};
SDMenu.prototype.collapseAll = function() {
	for (var i = 0; i < this.submenus.length; i++)
		if (this.submenus[i].className != "collapsed")
			this.collapseMenu(this.submenus[i]);
};

// functions for setting text size for accessibility, and storing value of text size for during of session

// predetermined set of 5 font sizes
var sizesArray = new Array('10px', '11px', '12px','14px','18px');
var lineheightArray = new Array('13px','14px','15px', '18px', '22px');

var contentResizeArray = new Array ('main_portlet','full_portletblue','full_portletorange','full_portletgreen','full_portlet','leftcolumn','rightcolumn','leftcolumn','leftcolumn','leftcolumn','leftcolumn','leftcolumn','leftcolumn','leftcolumn','leftcolumn');

// get the current value of the font size from session cookie and set the text
function onloadresizetext() {
	var currentSize=parseInt(lookupvalue());
	
	for (var i = 0; i < contentResizeArray.length; i++ )
	{
		document.getElementById(contentResizeArray[i]).style.fontSize = sizesArray[currentSize];
		document.getElementById(contentResizeArray[i]).style.lineHeight = lineheightArray[currentSize];
	}
}

// change the current value of the font size and store in cookie
function resizetext(sizeChange) {
	var currentSize=parseInt(lookupvalue());

	currentSize = currentSize + sizeChange;

	if ( currentSize < 0 ) {
	  currentSize = 0;
	}

	if ( currentSize > 4 ) {
	  currentSize = 4;
	}

	//session cookie
	//document.cookie="textsize="+currentSize;

	//persistent cookie
	writePersistentCookie('textsize',currentSize,'days',1);
	
	for (var i = 0; i < contentResizeArray.length ; i++)
	{
		
		if(document.getElementById(contentResizeArray[i])!=null){
			
		document.getElementById(contentResizeArray[i]).style.fontSize = sizesArray[currentSize];
		document.getElementById(contentResizeArray[i]).style.lineHeight = lineheightArray[currentSize];
		}else{
			
		}
		
	}
}

//lookup current value of the text size, if the cookie doesnt exist create it and set the text size to 0
function lookupvalue() {
  
  var currentSize = getCookieValue("textsize");
  
  if (currentSize=="") {
    currentSize=1;
    //session cookie
    //document.cookie="textsize=0";

    //persistent cookie
    writePersistentCookie('textsize',currentSize,'days',1);
  } 
  return currentSize;	
}

function writePersistentCookie (CookieName, CookieValue, periodType, offset) {

  var expireDate = new Date ();
  offset = offset / 1;
  
  var myPeriodType = periodType;
  switch (myPeriodType.toLowerCase()) {
    case "years":
      expireDate.setYear(expireDate.getFullYear()+offset);
      break;
    case "months":
      expireDate.setMonth(expireDate.getMonth()+offset);
      break;
    case "days":
      expireDate.setDate(expireDate.getDate()+offset);
      break;
    case "hours":
      expireDate.setHours(expireDate.getHours()+offset);
      break;
    case "minutes":
      expireDate.setMinutes(expireDate.getMinutes()+offset);
      break;
    default:
      alert ("Invalid periodType parameter for writePersistentCookie()");
      break;
  } 
  
  document.cookie = escape(CookieName ) + "=" + escape(CookieValue) + "; expires=" + expireDate.toGMTString() + "; path=/";
}  

function getCookieValue (cookieName) {
  var exp = new RegExp (escape(cookieName) + "=([^;]+)");
  if (exp.test (document.cookie + ";")) {
    exp.exec (document.cookie + ";");
    return unescape(RegExp.$1);
  }
  else return "";
}

function feedbackURL(){
	var url='/gortt/portal/ttconnect/feedback?SourcePageID='+window.location.href;
	window.location=url;
}

function emailURL(){
	var url='/gortt/portal/ttconnect/email?SourcePageID='+window.location.href;
	window.location=url;
}

function printPage(){
	var printDiv= document.getElementById('printdiv');
	printDiv.style.display= 'none'
	window.print();
}

function printerFriendlyURL(){
	var tmpurl=window.location.toString();
	var first_index=tmpurl.indexOf("WCM_GLOBAL_CONTEXT");
	var burlindex=tmpurl.indexOf("/gortt/portal/ttconnect/");
	var burl=tmpurl.substring(0,burlindex);
	var last_index=tmpurl.length;
	tmpurl=tmpurl.substring(first_index,last_index);
	var spurl='/gortt/portal/ttconnect/printFriendly?'+tmpurl;
	var finalurl=burl+spurl;
	//myRef = window.open(self.location,'T&TPortal','width=100px,height=100px,toolbar=1,resizable=0');
	myRef=window.open(finalurl,'printpage','width=900,height=900,resizable=1,scrollbars=1');
	myRef.focus();
}



function addToFavorites(url,title){
	var surl=window.location.href;


	if (window.sidebar) { // Mozilla Firefox Bookmark
		//window.sidebar.addPanel(title, surl,"");
		alert("Please use 'Ctrl + D' to bookmark this page with this Browser");
	} else if( window.external ) { // IE Favorite
		window.external.addFavorite( surl, title); 
		}
	else if(window.opera && window.print) { // Opera Hotlist
		return true; 
	}

}


var EGov = {
    Version: 'v1.1'
}

EGov.FontSizer = {
    tags: ['div','a','h1','h2','h3','h4','th','ul','ol','li','dt','dd','tr'],
	ids:['more'],
    initSize: 1,
    changeFontSize: function(size, container){
		var currentSize=parseInt(lookupvalue());
		
		currentSize=currentSize+size;
		if ( currentSize < 0 ) {
					  currentSize = 0;
		}
		if ( currentSize > 4 ) {
					  currentSize = 4;
		}

		if(document.getElementById("leftcolumn").style.fontSize==''){
			if(size==1)	currentSize=3;
			else if(size==-1)currentSize=1;
		}
		
		writePersistentCookie('textsize',currentSize,'days',1);
        getBody = document.getElementById(container);
        for (i = 0 ; i <  this.tags.length ; i++ ){
	        getallTags = getBody.getElementsByTagName(this.tags[i]);
		
		if(getallTags!=null){
           		for (k = 0 ; k < getallTags.length ; k++){
					

						if(getallTags[k].nodeName == "H3"){
	                			getallTags[k].style.fontSize = lineheightArray[currentSize];
	            		}else if(getallTags[k].nodeName == "TR" && getallTags[k].style.fontSize!=''){
							getallTags[k].style.fontSize = sizesArray[currentSize];
							getallTags[k].style.lineHeight = lineheightArray[currentSize];
						}else if(getallTags[k].nodeName == "A" && getallTags[k].className == "more"){
							
							getallTags[k].style.fontSize = sizesArray[currentSize-1];

						}else if((getallTags[k].nodeName == "DIV") && (getallTags[k].id == "subheader_orange" || getallTags[k].id =="subheader_blue"||getallTags[k].id =="subheader_green")){
							
							if(currentSize==4){
								getallTags[k].style.height='133px';
							}else if(currentSize==3){
								getallTags[k].style.height='98px';
							}else{
								getallTags[k].style.height='91px';
							}

				}else{
							getallTags[k].style.fontSize = sizesArray[currentSize];
							getallTags[k].style.lineHeight = lineheightArray[currentSize];
						}

	        	}
		}
	    }
		
    }
}


function toggleSearch(targetId) {

    if (document.getElementById(targetId)) {
        target = document.getElementById(targetId);
        targetList = target.getElementsByTagName("li");
        for (i = 0; i < targetList.length; i++) {
            if (targetList[i].style.display == "none") {
                targetList[i].style.display = "block";
            } else {
                targetList[i].style.display = "none";
            }
        }
    }
}



function switchSearch(id, type, txtBox) {
    var txtElement = document.getElementById(txtBox);

      switch (type) {
        case "a":
            if (txtElement.value = "Search Citizen" || txtElement.value == "Search Business" || txtElement.value == "Search Non-Resident" || txtElement.value == "") {
                txtElement.value = "Search Entire Site";
            }
            document.getElementById("all").className = "selected";
            document.getElementById("citizen").className = "";
            document.getElementById("business").className = "";
            document.getElementById("non_national").className = "";
            document.getElementById(id).value = "all";
            break;
            
        case "c":
            if (txtElement.value = "Search Entire Site" || txtElement.value == "Business" || txtElement.value == "Non-Resident" || txtElement.value == "") {
                txtElement.value = "Search Citizen";
            }
            document.getElementById("all").className = "";
            document.getElementById("citizen").className = "selected";
            document.getElementById("business").className = "";
            document.getElementById("non_national").className = "";
            document.getElementById(id).value = "citizen";
            break;
        
        case "b":
            if(txtElement.value = "Search Entire Site" || txtElement.value == "Citizen" || txtElement.value == "Non-Resident" || txtElement.value == "") {
               txtElement.value = "Search Business";
            }
            document.getElementById("all").className = "";
            document.getElementById("citizen").className = "";
            document.getElementById("business").className = "selected";
            document.getElementById("non_national").className = "";
            document.getElementById(id).value = "business";
            break;
            
        case "n":
            if(txtElement.value = "Search Entire Site" || txtElement.value == "Citizen" || txtElement.value == "Business" || txtElement.value == "") {
               txtElement.value = "Search Non-Resident";
            }
            document.getElementById("all").className = "";
            document.getElementById("citizen").className = "";
            document.getElementById("business").className = "";
            document.getElementById("non_national").className = "selected";
            document.getElementById(id).value = "nonnational";
            break;
    }

}

function fieldClear(id) {
    if (document.getElementById(id).value == "Search Entire Site" ||
        document.getElementById(id).value == "Search Citizen" ||
        document.getElementById(id).value == "Search Business" ||
        document.getElementById(id).value == "Search Non-Resident")  {
            document.getElementById(id).value = "";
    } else {
        selectText(id);
    }
}







