var isID = 0;
var isAll = 0;
var isLayers = 0;
var isTrans = 0;
var isFp = 0;
var lb = 0;

// browser identification
if (document.getElementById){isID=1;}
if (document.layers){isLayers=1;}
if (document.all){isAll=1;}


function pageWidth() {return window.innerWidth != null? window.innerWidth: document.body != null? document.body.clientWidth:null;}
function pageHeight() {return window.innerHeight != null? window.innerHeight: document.body != null? document.body.clientHeight:null;}



////////////////////////////////////////////////////////////////////
// Menu object constructors and methods
////////////////////////////////////////////////////////////////////

function menuCollection(descStr){		// menuCollection object constructor

		this.description = descStr;		// description string, not currently used
		this.menuCount = 0;				// counter to aid iteration through menus
		this.addMenu = addMenuFunc;		// method linked to additional function

}

function menuObj(shortTextStr,textStr,menuHref){		// menu object constructor

		this.ref = shortTextStr;			// shorten version of text (without spaces) to be used as reference
		this.text = textStr;			// text shown at top of menu
		this.href = menuHref;			// href for text
		this.itemCount = 0;				// counter to aid iteration through menu items
		this.addItem = addMenuItemFunc;	// method linked to additional function

}

function menuItemObj(textStr,itemHref,isHr,isEx){	// menuItem object constructor

		this.text = textStr;			// text shown in menu
		this.href = itemHref;			// href for text
		this.hrFollows = isHr;			// whether menu item is followed by <hr> spacer
		this.isExternal = isEx;         // whether link is open and 
		this.subMenuExists = 0;			// does menu item have a submenu
		this.addSubMenu = addSubMenuFunc;	// method linked to additional function
		this.subRef = "";				// reference name for sub menu

}


function addMenuFunc(shortTextStr,textStr,menuHref){			// constructor method

		this.menuCount++;				// increase menuCount
		this["menu" + this.menuCount] = new menuObj(shortTextStr,textStr,menuHref);	// create menu object using menuCount to create iterative name
		
}

function addMenuItemFunc(textStr,itemHref,isHr,isEx){	// constructor method

		this.itemCount++;				// increase itemCount
		this["menuItem" + this.itemCount] = new menuItemObj(textStr,itemHref,isHr,isEx);	// create menuitem object using itemCount to create iterative name

}

function addSubMenuFunc(subRef){				// constructor method

		this.subMenuExists = 1;			// set that there is a sub menu for a particular menuItem
		this.subRef = subRef;
		this.subMenu = new menuObj("",""); // create menu object below a particular menuItem
		
}




////////////////////////////////////////////////////////////////////
// Functions to draw menus dynamically from configuration file
////////////////////////////////////////////////////////////////////

function drawMainMenu(){		// function iterates through menu Collection


	htmlStr = "";
	
	htmlStr += "<div id=\"menu\">\n";
	htmlStr += "<table cellspacing=\"0\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">\n";
	htmlStr += "<tr>\n";
	htmlStr += "<td width=\"10\" align=\"center\">&nbsp;</td>\n";
	
		for (i=1; i <= topMenu.menuCount; i++){
		
			thisMenu = topMenu['menu' + i];
		
			htmlStr += "<td id=\"" + thisMenu.ref + "MenuTitle\" ";
			htmlStr += "onmouseover=\"showMenu('" + thisMenu.ref + "Menu','main')\" ";
			htmlStr += "onmouseout=\"menuTimer()\"><span style=\"cursor:default;\" class=\"menuTitle\">&nbsp;" + thisMenu.text + "&nbsp;</span></td>\n";
			//htmlStr += "<a class=\"menuTitle\" href=\"" + thisMenu.href + "\" ";
			//htmlStr += "<a class=\"menuTitle\" href=\"\" ";
			
			
			if (i < topMenu.menuCount){
				htmlStr += "<td width=\"20\" align=center>|</td>\n";
			}
		
		}
			
	//htmlStr += "<td width=\"25\" align=center>&nbsp;</td>\n"
	htmlStr += "</tr></table></div>";
	
	document.write (htmlStr);

}


function drawHorizontalMenus(){		// function iterates through menu and then horizontal menu items

	var htmlStr = "";
	var subHtmlStr = "";
	
	for (i=1; i <= topMenu.menuCount; i++){
	
		thisMenu = topMenu['menu' + i];
	
		htmlStr += "\n<div id=\"" + thisMenu.ref + "Menu\">\n";
		htmlStr += "<table border=\"0\" bgcolor=\"#ffffff\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td bgcolor=\"#9999cc\" ></td><td>\n";
		htmlStr += "<table border=\"0\" bgcolor=\"#9999cc\" cellpadding=\"4\" cellspacing=\"0\">\n<tr>";
		
		for (j=1; j <= thisMenu.itemCount; j++){
		
			thisItem = thisMenu['menuItem' +j];
		

				
				if (thisItem.subMenuExists){
					htmlStr += "<td style='padding-top:0px;' onmouseout=\"menuOut();subTimer()";
					htmlStr += "\" onmouseover=\"menuOver();";
					htmlStr += "showMenu('" + thisItem.subRef + "','sub')\">";
				    htmlStr += "<span class=\"menuItemNoLink\">&nbsp;" + thisItem.text + "</span> ";
				    htmlStr += "<img src=\"/images/structure/bullet-tri-menu2.gif\">";
				    htmlStr += "</td>\n";
				}
				else{
					htmlStr += "<td style='padding-top:0px;' colspan=\"2\" onmouseout=\"menuOut();";
					htmlStr += "\" onmouseover=\"menuOver();";
					htmlStr += "\"><a class=\"menuItem\" href=\"" + thisItem.href + "\">&nbsp;";
				    htmlStr += thisItem.text + "</a> ";
				    htmlStr += "</td>\n";
				}
				
					
				if (j < thisMenu.itemCount){
					htmlStr += "<td class=\"menuItem\">&nbsp;-&nbsp;</td>";
				}
				
		
			
			if(thisItem.subMenuExists){		// if menuItem has submenu call function and return code to temp string
			
				subHtmlStr += drawSubMenu(thisItem);
			
			}
		
		}
		
		htmlStr += "<td style='padding:0px;' bgcolor='#9999cc' valign='bottom'><img src='/images/structure/menu_curve.gif'></td>";
		htmlStr += "</tr></table>\n";
		htmlStr += "</td></tr></table>\n";
		htmlStr += "</div>\n\n";
	}
	
	document.write(htmlStr);		// output the menu html
	document.write(subHtmlStr);	// output the submenu html
	
}



function drawSubMenu(menuItemObj){	// iterates through submenu items

	var tempStr = "";
	var subSubHtmlStr = "";

	tempStr += "<div id=\"" + menuItemObj.subRef + "\">\n";
	tempStr += "<table border=\"0\" bgcolor=\"#000000\" cellpadding=\"1\" cellspacing=\"0\"><tr><td>\n";
	tempStr += "<table border=\"0\" bgcolor=\"#dedeff\" cellpadding=\"2\" cellspacing=\"0\">\n";

	subMenu = menuItemObj.subMenu;

	for (k=1; k <= subMenu.itemCount; k++){
	
		subItem = subMenu['menuItem' + k];
	
		tempStr += "<tr>\n";
		
		if (subItem.subMenuExists){
		
		    tempStr += "<td  onmouseout=\"subOut();subSubTimer()\" onmouseover=\"subOver();";
		    tempStr += "showMenu('" + subItem.subRef + "','subSub')";
		    tempStr += "\" style=\"border-bottom:1px solid #9999cc;padding:3px 2px 3px 2px;\">"
		    tempStr += "<span class=\"subMenuItemNoLink\">&nbsp;" + subItem.text + "&nbsp;</span>";
		    if (subItem.hrFollows){ 
			    tempStr += "<hr>";
		    }
		    tempStr += "</td><td style=\"border-bottom:1px solid #9999cc\"><img src=\"/images/structure/bullet-tri-menu.gif\"></td>\n";
		    
		} else{
		
		    tempStr += "<td colspan=\"2\"  onmouseout=\"subOut()\" onmouseover=\"subOver()\"  style=\"border-bottom:1px solid #9999cc;padding:3px 10px 3px 2px;\">";
		    tempStr += "<a class=\"subMenuItem\" href=\"" + subItem.href + "\"";
		    if (subItem.isExternal){
			    tempStr += " target=\"external\" ";  
		    }
		    tempStr += ">&nbsp;";
		    tempStr += subItem.text + "&nbsp;</a>";
		    if (subItem.hrFollows){ 
			    tempStr += "<hr>";
		    }
		    tempStr += "</td>\n";
		}
				
		
		

		
		

		
		tempStr += "</tr>\n";
		
		
		if(subItem.subMenuExists){		// if menuItem has submenu call function and return code to temp string
			
			
				subSubHtmlStr += drawSubSubMenu(subItem);
			
		}
		
	}

	tempStr += "</table>\n";
	tempStr += "</td></tr></table>\n";
	tempStr += "</div>\n\n";

return tempStr + subSubHtmlStr;
	
}

function drawSubSubMenu(menuItemObj){	// iterates through submenu items
	var tempStr = "";

	tempStr += "<div id=\"" + menuItemObj.subRef + "\">\n";
	tempStr += "<table border=\"0\" bgcolor=\"#000000\" cellpadding=\"1\" cellspacing=\"0\"><tr><td>\n";
	tempStr += "<table border=\"0\" bgcolor=\"#e8e8ff\" cellspacing=\"0\">\n";

	subSubMenu = menuItemObj.subMenu;

	for (m=1; m <= subSubMenu.itemCount; m++){
	
		subItem = subSubMenu['menuItem' + m];
	
		tempStr += "<tr>\n";
		
		tempStr += "<td  onmouseout=\"subSubOut()\" onmouseover=\"subSubOver()\" style=\"padding:3px 30px 3px 2px;border-bottom:1px solid #c8c8ff\">";
		tempStr += "<a class=\"subMenuItem\" href=\"" + subItem.href + "\"";
		if (subItem.isExternal){
			tempStr += " target=\"external\" ";  
		}

		tempStr += ">&nbsp;";
		tempStr += subItem.text + "&nbsp;</a>";
		if (subItem.hrFollows){ 
			tempStr += "<hr>";
		}
		tempStr += "</td>\n";

		
		tempStr += "</tr>\n";
		
		
	}

	tempStr += "</table>\n";
	tempStr += "</td></tr></table>\n";
	tempStr += "</div>\n\n";

return tempStr;

	
}

function drawTopCorner(){	// draw the topCorner2 i.e. curve, picture and small menu
	
	document.write ("<div id=\"topCorner\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">");
	document.write ("<tr><td rowspan=\"2\">");
	document.write ("<img src=\"/images/structure/topcorner1.gif\" alt=\"\" width=\"116\" height=\"115\" border=\"0\">");
	document.write ("</td>");
	document.write ("<td>");
	document.write ("<a href=\"/news/fullarticle.asp?id=900\"><img src=\"/images/structure/topcorner2.gif\" alt=\"\" width=\"64\" height=\"89\" border=\"0\"></a>");
	document.write ("</td>");
	document.write ("<td>");
	document.write ("<a href=\"/news/fullarticle.asp?id=900\"><img src=\"/images/structure/topcorner3.jpg\" alt=\"\" width=\"180\" height=\"89\" border=\"0\"></a>");
	document.write ("</td>");
	document.write ("</tr>");
	
	document.write ("<tr>");
	document.write ("<td height=\"26\" colspan=\"2\" align=\"center\">");
	document.write ("<table cellpadding=\"3\" cellspacing=\"0\" border=\"0\"><tr>");
	
	if (lb == 1 || lb == 4){
		document.write ("<td><a href=\"javascript:showLogin(0);\">" + logoutName + "</a></td>");
		document.write ("<td>|</td>");
		document.write ("<td><a href=\"" + profileUrl + "\">" + profileName + "</a></td>");
	}
	else {
		document.write ("<td><a href=\"javascript:showLogin(0);\">" + loginName + "</a></td>");
		document.write ("<td>|</td>");
		document.write ("<td><a href=\"" + registerUrl + "\">" + registerName + "</a></td>");
	}

	
	document.write ("<td>|</td>");
	document.write ("<td><a href=\""+ contactUrl + "\">" + contactName + "</a></td>");
	document.write ("<td>|</td>");
	document.write ("<td><a href=\""+ searchUrl + "\">" + searchName + "</a></td>");
	document.write ("</table></td></tr>");
	document.write ("</tr>");
	document.write ("</table></div>");

}



function drawTopBar(hasBackground){		// master function to draw topbar, calling other functions to draw key parts
	
	document.write ("<div id=\"topBar\"><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">");
	document.write ("<tr>");
	document.write ("<td bgcolor=\"#133878\">");
	document.write ("<a href=\"/\">");
	document.write ("<img src=\"/images/structure/logo.gif\" alt=\"Wallingford Software\" width=\"336\" height=\"81\" border=\"0\">");
	document.write ("</a></td>");
	document.write ("<td rowspan=\"2\" width=\"360\" bgcolor=\"#133878\">");
			drawTopCorner();
	document.write ("</td></tr>");
	document.write ("<tr>");
	
		if (isAll || isLayers){
			document.write ("<td valign=\"bottom\" bgcolor=\"#314c8e\" height=\"24\">");
		} else {
			document.write ("<td valign=\"bottom\" bgcolor=\"#314c8e\" height=\"26\">");
		}
	
		drawMainMenu();
	document.write ("</td></tr>");
	document.write ("<tr><td bgcolor=\"#9999cc\" colspan=\"2\">");
	document.write ("<img src=\"/images/structure/transparent.gif\" alt=\"\" width=\"1\" height=\"2\" border=\"0\">");
	document.write ("</td>");
	document.write ("</tr>");
	document.write ("</table>");
		
	document.write ("</div>");
	
	
		drawHorizontalMenus();
		
		if (hasBackground){
			drawBackgroundLine();
		}

		switch (lb) {
			case 1:
				drawLogin("logout","");
				break;
			case 2:
				drawLogin("login","none");
				break;
			case 3:
				drawLogin("login","many");
				break;
			case 4:
				drawLogin("logout","");
				break;
			default:
				drawLogin("login","");
				break;
		}	
		
		
		if (lb == 2 || lb == 3){
			setVisibility('loginBox','visible');
		}
		
		var queryString = location.search.substring(1);		// QueryString section of URL
		if (queryString.indexOf('prt=1') != -1){			// if print window then 
			printStyle();									// call printStyle function
		}
}


function drawBackgroundLine(){

	document.write("<style type=\"text/css\">");
	document.write("body {background-image: url(/images/structure/background3.gif);}");
	document.write("#main {width:1000px;margin: 10px;}");
	document.write("</style>");

}

function footer(){
	
		if (window.name != "printWindow"){
			document.write("<div id=\"footer\" style=\"width:965px;clear:both;margin-left:25px;margin-top:25px;border-top:solid 2px #DEE9F5;text-align:center;padding:5px 0px;\">");
				var today = new Date();
			document.write("<span class=\"smallText\">Copyright &copy; " + today.getFullYear() + " Wallingford Software Ltd. All rights reserved.</span> ");
			document.write("<br /><a href=\"/info/terms\"><span class=\"smallText\">Terms and Conditions</span></a>");
			document.write("</div>");
		} else
		{
			document.write("<div id=\"footer\" style=\"width:90%;clear:both;margin-left:25px;margin-top:10px;border-top:solid 2px #DEE9F5;text-align:center;padding:5px 0px;\">");
			document.write("<p align=\"center\" class=\"normalTitle\" style=\"margin-top:0px;\">Contact: <a href=\"mailto:sales@wallingfordsoftware.com\">sales@wallingfordsoftware.com</a></p><br/>");
			document.write("</div>");
		}

}

////////////////////////////////////////////////////////////////////
// Functions to control dynamic menus
////////////////////////////////////////////////////////////////////


var menuActive = 0;
var subActive = 0;
var subSubActive = 0;
var onMenu;
var onSub;
var onSubSub;
var timeOn = null;
var timeSub = null;
var timeSubSub = null;



// SHOW MENU
function showMenu(menuName,menuType){

	// Reset menu timeouts
	if (menuType=="sub"){
		if (timeSub != null) {
			clearTimeout(timeSub);
			hideSub(onSub);
		}
	}
	else if (menuType=="subSub"){
	    if (timeSubSub != null) {
			clearTimeout(timeSubSub);
			hideSubSub(onSubSub);
		}
	}
	else{
		if (timeOn != null) {
			clearTimeout(timeOn);
			hideMenu(onMenu);
		}
	}

	// Change menu style to visible
	setVisibility(menuName,'visible');
	if (menuType!="sub" && menuType!="subSub"){
		setBackground(menuName+'Title','#9999cc');
	}
	
	// Change current menu string	
	if (menuType=="sub"){
		onSub = menuName;
	}
	else if (menuType=="subSub"){
	    onSubSub = menuName;
	}
	 else {
		onMenu = menuName;
	}
}


// TIMER FOR BUTTON MOUSE OUT
function menuTimer() {
 timeOn = setTimeout("btnOut()",600);
}

// BUTTON MOUSE OUT
function btnOut() {
	if (menuActive == 0) {
		hideMenu(onMenu);
	}
}

// SET MENU VISIBILITY STATE
function setVisibility(menuName,state){

	if (isID){
		document.getElementById(menuName).style.visibility = state;
	}
	else if (isLayers){
		document.layers[menuName].visibility = state;
	}
	else {
		document.all[menuName].style.visibility = state;
	}
}


 // HIDE MENU
function hideMenu(menuName){
 	if (menuActive == 0) {
		setVisibility(menuName,'hidden');
		setBackground(menuName+'Title','#314c8e');

		if (onSub){
			hideSub(onSub);
		}
		if (onSubSub){
			hideSubSub(onSubSub);
		}
 	}
}


// HIDE SUB MENU
function hideSub(menuName){
 	if (subActive == 0) {
		setVisibility(menuName,'hidden');
 	}
 	if (onSubSub){
		hideSubSub(onSubSub);
	}
}

// HIDE SUB SUB MENU
function hideSubSub(menuName){
 	if (subSubActive == 0) {
		setVisibility(menuName,'hidden');
 	}
}


// MENU MOUSE OVER 
function menuOver() {
		if (timeSub != null) {
			clearTimeout(timeSub);
			hideSub(onSub);
		}
		clearTimeout(timeOn);
		menuActive = 1;
}

// SUB MOUSE OVER 
function subOver() {
        if (timeSubSub != null){
            clearTimeout(timeSubSub);
			hideSub(onSubSub);
        }
		subActive = 1;
		clearTimeout(timeSub);
		clearTimeout(timeOn);
		menuActive = 0;
				
}

// SUB MOUSE OVER 
function subSubOver() {
		subSubActive = 1;
		clearTimeout(timeSubSub);
		clearTimeout(timeSub);
		clearTimeout(timeOn);
		menuActive = 0;
		subActive = 0;
				
}

// MENU MOUSE OUT 
function menuOut() {
		menuActive = 0;
		timeOn = setTimeout("hideMenu(onMenu)", 600);
}

// SUB MOUSE OUT 
function subOut() {
		subActive = 0;
		timeSub = setTimeout("hideSub(onSub)", 400);
		timeOn = setTimeout("hideMenu(onMenu)", 400);
		
}

// SUB MOUSE OUT 
function subSubOut() {
		subSubActive = 0;
		timeSubSub = setTimeout("hideSubSub(onSubSub)", 400);
		timeSub = setTimeout("hideSub(onSub)", 400);
		timeOn = setTimeout("hideMenu(onMenu)", 400);
}


// TIMER FOR SUB MENU OUT
function subTimer(){
	timeSub = setTimeout("menuItemOut()",400);
}

// TIMER FOR SUBSUB MENU OUT
function subSubTimer(){
	timeSubSub = setTimeout("subMenuItemOut()",400);
}


// MENU ITEM OUT
function menuItemOut(){
	if (subActive == 0) {
		hideSub(onSub);
	}
}


// MENU ITEM OUT
function subMenuItemOut(){
	if (subSubActive == 0) {
		hideSubSub(onSubSub);
	}
}


// returns dom.style object
function domStyle(objName){

	if (isID){
		return document.getElementById(objName).style;
	}
	else if (isLayers){
		return document.layers[objName];
	}
	else {
		return document.all[objName].style;
	}

}

function setBackground(thePageObj,theColor){
	if (isID){
		document.getElementById(thePageObj).style.backgroundColor = theColor;
	}
	else if (isLayers){
		document.layers[thePageObj].backgroundColor = theColor;
	}
	else {
		document.all[thePageObj].style.backgroundColor = theColor;
	}
}

function menuHoverOut(theObj){

	theObj.style.backgroundColor = "#314c8e";
}

// Shows or hides login box
function showLogin(localLocation){
    if (document.getElementById){
        if (document.getElementById("loginBox").style.visibility == 'visible'){
            document.getElementById("loginBox").style.visibility = 'hidden';
        }else{
            if (localLocation==0){ //make sure login box is in reset position
                document.getElementById("loginBox").style.top  =  "118px";
	            document.getElementById("loginBox").style.left  =  ((pageWidth() - 280).toString() + "px");
            }
	        document.getElementById("loginBox").style.visibility = 'visible';
	        document.getElementById("emailField").focus();
        }
    } else { 
        window.location.href = "/user/login/"; // if old browser send user to login page
    }
}


function localLoginClick(e){
    if (document.getElementById){
	    var posx = 0;
	    var posy = 0;
	
	    if (!e) e = window.event;
	    if (e.clientX || e.clientY){
		    posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
		    posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	        
		    document.getElementById("loginBox").style.top  =  ((posy+20).toString() + "px")
		    document.getElementById("loginBox").style.left  =  ((posx+20).toString() + "px"); 			     
	    }
    }
    showLogin(1); // Show login box using above position, not reset position
}



// Draws hidden login box for login/logout and for error messages
function drawLogin(contentType,errorType) {

	document.write ("<div id=\"loginBox\" style=\"width:250px;border:1px solid #000000;background-color:#ccd2e2;padding:10px;\">");
	document.write ("<form action=\"/user/login/index.aspx\" method=\"post\" name=\"loginForm\" style=\"margin-bottom:0px;\">");
	document.write ("<table style=\"width:235px\" cellspacing=\"0\" cellpadding=\"3\">");


	if (contentType == "login") {
		
		document.write ("<tr><td>E-mail:</td>");
		document.write ("<td><input type=\"Text\" name=\"email\" style=\"width:150px;\" maxlength=\"50\" id=\"emailField\">");
		document.write ("</td></tr>");
		document.write ("<tr><td>Password:</td>");
		document.write ("<td><input type=\"Password\" name=\"password\" style=\"width:150px;\" maxlength=\"20\">");
		document.write ("</td></tr>");
		document.write ("<tr><td colspan=\"2\" align=\"center\">");
		document.write ("<input type=\"Submit\" value=\"Login\" class=\"blueButton\"> &nbsp;");
		document.write ("<input type=\"Button\" value=\"Cancel\" class=\"blueButton\" onmouseup=\"showLogin(0);\" >");
		document.write ("</td></tr>");
		document.write ("<tr><td colspan=\"2\" align=\"center\">");
		document.write ("<span class=\"smallText\"><a href=\"/user/login/?f=y\">Forgotten password?</a></span>");
		document.write ("</td></tr>");
	
	}
	else if (contentType == "logout") {
	
		document.write ("<tr><td align=\"center\">Please confirm that you wish to logout.</td></tr>");
		document.write ("<tr><td align=\"center\">");
		document.write ("<input type=\"Hidden\" name=\"email\" value=\"logout\">");
		document.write ("<input type=\"Submit\" value=\"Logout\" class=\"blueButton\"> &nbsp;");
		document.write ("<input type=\"Button\" value=\"Cancel\" class=\"blueButton\" onmouseup=\"showLogin(0);\" >");
		document.write ("</td></tr>");
	}


	document.write ("</table>");
	document.write ("</form>");
	document.write ("</div>	");


}


function drawRegion(){
	document.write("<div id=\"region\">");
	document.write("<table width=\"300\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\">");
	document.write("<tr><td bgcolor=\"#000080\">Region</td></tr></table>");
	document.write("</div>");
}
	

function sideBarTitle(theText){
	
	document.write ("<table cellpadding=\"10\" cellspacing=\"0\" border=\"0\" width=\"200\">");
	document.write ("<tr><th colspan=\"3\">");
	document.write (theText);
	document.write ("</th></tr>");
	document.write ("</table>");

}	

function regionSideBar(){

	document.write ("<table cellpadding=\"10\" cellspacing=\"0\" border=\"0\" width=\"200\">");
	document.write ("<tr><th colspan=\"3\">");
	document.write ("Region/Language");
	document.write ("</th></tr>");
	document.write ("</table>");
	sideBarContentStart();
	document.write ("North America/English");
	sideBarContentFinish();
}
			

function sideBarContentStart(){

	document.write ("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"200\">");
	document.write ("<tr>");
	document.write ("<td width=\"2\" bgcolor=\"#dee9f5\"><img src=\"/images/structure/transparent.gif\" width=\"2\" height=\"1\" border=\"0\"></td>");
	document.write ("<td>");
	document.write ("<table cellpadding=\"10\" cellspacing=\"0\" border=\"0\">");
	document.write ("<tr><td>");

}			
	

function sideBarContentFinish(){

	document.write ("</td></tr></table>");
	document.write ("</td>");
	document.write ("<td width=\"2\" bgcolor=\"#dee9f5\"><img src=\"/images/structure/transparent.gif\" width=\"2\" height=\"1\" border=\"0\"></td>");
	document.write ("</tr>");
	document.write ("<tr>");
	document.write ("<td colspan=\"3\" bgcolor=\"#dee9f5\"><img src=\"/images/structure/transparent.gif\" width=\"2\" height=\"2\" border=\"0\"></td>");
	document.write ("</tr></table>");

}	

function printStyle(){

	document.write ("<style type=\"text/css\">");
	document.write ("body {background-image:none;}");
	document.write ("#sideBar {display:none;}");
	document.write ("#topCorner {display:none;}");
	document.write ("#topBar {display:none;}");
	document.write ("#menu {display:none;}");
	//document.write ("#footer {display:none;}");
	document.write ("#main {width:100%;}");
	document.write ("#content {position:absolute;left:0px;top:10px;width:100%;}");
	document.write ("#maintext {position:relative;left:10px;top:0px;}");
	document.write ("</style>");

}

function printWin(){
	var printWindow;
	var pageUrl = window.location.href;
	
	if (pageUrl.indexOf("?") == -1){
		pageUrl = pageUrl + "?prt=1";
	} 
	else {
		pageUrl = pageUrl + "&prt=1";
	}
	
		 printWindow =  window.open(pageUrl,"printWindow","resizable,width=795,height=500,top=100,left=100,scrollbars,toolbar,menubar");
		printWindow.focus();
	
}

function printOption(){

	if (window.name != "printWindow"){
		document.write("<a href=\"javascript:printWin();\"><img src=\"/images/icons/print_16.gif\" alt=\"Printer Friendly Version\" width=\"16\" height=\"16\" border=\"0\" align=\"absmiddle\"> <span class=\"smallText\">Printer Friendly Version</span></a>");
	}
	else {
	
	document.write("<img src=\"/images/structure/print_logo.gif\" alt=\"Wallingford Software\" width=\"300\" height=\"68\" border=\"0\"><hr>");
	
	}
	
}				

function customerList(){
	var customerWin;
	customerWin =  window.open("/products/infoworks/customers.html","printWindow","resizable,width=400,height=198,top=200,left=200");
	customerWin.focus();
}			
		
function infonetList(){
	var customerWin;
	customerWin =  window.open("/products/infonet/customers.html","printWindow","resizable,width=400,height=198,top=200,left=200");
	customerWin.focus();
}		
	
function drawRegionBar(){

	document.write("<tr><td><table cellpadding=\"1\" cellspacing=\"0\"><tr><td bgcolor=\"#133878\">");
	document.write("<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr><td bgcolor=\"#cecedc\" valign=\"top\">");
	document.write("&nbsp; <a href=\"\" class=\"menuItem\">Region: North America (English)</a> &nbsp;");
	document.write("</td><td bgcolor=\"cecedc\"><img src=\"/images/structure/small_down_arrow.gif\"  border=\"0\">");
	document.write("</td></tr></table>");
	document.write("</td></tr></table></td></tr>");

}
		
		
function screenshot(imageRef){
	var customerWin;
	screenWin =  window.open("/images/products2/"+imageRef,"screen_shot","resizable,width=625,height=475,top=100,left=100");
	screenWin.focus();
}				
				
function pp(imageRef){
	var popWin;
	popWin =  window.open("/products/enlarge.asp?ref="+imageRef,"screen_shot","scrollbars=no,resizable,width=625,height=525,top=100,left=100");
	popWin.focus();
}				
			
			
function imgBox(imageRef){

	refArray = imageRef.split(",");
	
	document.write ("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"80%\"><tr><td align=\"center\">");
	
	document.write ("<div align=\"center\" class=\"imgBox\">");
	document.write ("<a href=\"javascript:pp('" + refArray[0] + "')\"><img src=\"/images/products/thumbs/" + refArray[0] + ".jpg\" border=\"0\" alt=\"Enlarge\"></a> ");
	document.write ("<span class=\"smallText\"><a href=\"javascript:pp('" + refArray[0] + "')\">Enlarge</a></span> ");
	document.write ("<a href=\"javascript:pp('" + refArray[0] + "')\"><img src=\"/images/icons/magnify.gif\" alt=\"Enlarge\" align=\"middle\" border=\"0\"></a>");
	document.write ("</div>");
	
	// handle a possible second image at this point
	if (refArray.length > 1){
	
		document.write ("</td><td>");
		document.write ("<div align=\"center\" class=\"imgBox\">");
		document.write ("<a href=\"javascript:pp('" + refArray[1] + "')\"><img src=\"/images/products/thumbs/" + refArray[1] + ".jpg\" border=\"0\" alt=\"Enlarge\"></a> ");
		document.write ("<span class=\"smallText\"><a href=\"javascript:pp('" + refArray[1] + "')\">Enlarge</a></span> ");
		document.write ("<a href=\"javascript:pp('" + refArray[1] + "')\"><img src=\"/images/icons/magnify.gif\" alt=\"Enlarge\" align=\"middle\" border=\"0\"></a>");
		document.write ("</div>");
	
	}
	
	document.write ("</td></tr></table>");

}

////////////////////////////////////////////////////////////////////
// sideMenu object constructors and methods
////////////////////////////////////////////////////////////////////

function sideMenuCollection(descStr){		// menuCollection object constructor

		this.description = descStr;		// description string, not currently used
		this.menuCount = 0;				// counter to aid iteration through menus
		this.addSideMenu = addSideMenuFunc;		// method linked to additional function

}

function sideMenuObj(shortTextStr,textStr,menuHref){		// menu object constructor

		this.ref = shortTextStr;		// shorten version of text (without spaces) to be used as reference
		this.text = textStr;			// text shown at top of menu
		this.href = menuHref;			// href for text
		this.linkCount = 0;				// counter to aid iteration through menu items
		this.addItem = addSideMenuLink;	// method linked to additional function

}

function sideMenuLink(textStr,itemHref,newWin){	// menuItem object constructor

		this.text = textStr;			// text shown in menu
		this.href = itemHref;			// href for text
		this.tarWin = newWin;			//is the link launched in new window

}

function addSideMenuFunc(shortTextStr,textStr,menuHref){			// constructor method

		this.menuCount++;				// increase menuCount
		this[shortTextStr] = new sideMenuObj(shortTextStr,textStr,menuHref);	// create menu object using menuCount to create iterative name
		
}

function addSideMenuLink(textStr,itemHref,newWin){	// constructor method

		this.linkCount++;				// increase itemCount
		this["link" + this.linkCount] = new sideMenuLink(textStr,itemHref,newWin);	// create menuitem object using itemCount to create iterative name

}
			
////////////////////////////////////////////////////////////////////
// Function to draw language specific product side menus
////////////////////////////////////////////////////////////////////

function drawSideMenuLinks(sectionName) {

	htmlStr = "";
	var thePattern = /http:\/\/[\w\.-]+\/{1}/i;
	var theServer = document.location.href.match(thePattern)[0];
	thisSideMenu = sideMenus[sectionName];
	
	for (i=1; i <= thisSideMenu.linkCount; i++){
		thisPage = theServer.substr(0,(theServer.length-1))+thisSideMenu['link'+i].href;
		
		htmlStr = htmlStr + "<img src=\"/images/structure/bullet-tri.gif\" width=\"15\" height=\"12\" border=\"0\">\n";
		
		if (thisPage == document.location.href){
			htmlStr = htmlStr + "<strong>" + thisSideMenu['link'+i].text + "</strong><br /><br />\n\n";
		} else {
			htmlStr = htmlStr + "<a href=\"" + thisSideMenu['link'+i].href + "\"";;
			if (thisSideMenu['link'+i].tarWin==1){
				htmlStr = htmlStr + " target=\"_blank\" ";
			}
			htmlStr = htmlStr + ">";
			htmlStr = htmlStr + thisSideMenu['link'+i].text + "</a><br /><br />\n\n";
		}
		
	}
	document.write (htmlStr);

}		

function languageBar(){

	checkTrans();

	document.write ("<form name=\"langForm\"action=\"/language.asp\" method=\"post\" ><input type=\"Hidden\" name=\"lg\"><input type=\"Hidden\" name=\"pgTrans\"><input type=\"Hidden\" name=\"oldLg\" value=\"" + lang + "\"></form>");
	document.write ("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">");
	document.write ("<tr>");
	document.write ("	<td bgcolor=\"#314C8E\"><img src=\"/images/structure/lang_left.gif\"></td>");
	document.write ("	<td bgcolor=\"#314C8E\"><img src=\"/images/structure/transparent.gif\"></td>");
	document.write ("	<td><img src=\"/images/structure/lang_right.gif\"></td>");
	document.write ("</tr>");
	document.write ("<tr>");
	document.write ("	<td bgcolor=\"#314C8E\"><img src=\"/images/structure/transparent.gif\"></td>");
	document.write ("	<td bgcolor=\"#314C8E\" valign=\"top\">&nbsp;&nbsp;<a href=\"javascript:displaySection('languageMenu');\" style=\"color:#ffffff\">Language: " + langDisplay(lang) + "</a> &nbsp;&nbsp;</td>");
	document.write ("	<td bgcolor=\"#314C8E\"><img src=\"/images/structure/transparent.gif\"></td>");
	document.write ("</tr>");
	document.write ("<tr>");
	document.write ("	<td colspan=\"3\" bgcolor=\"#314C8E\"><img src=\"/images/structure/transparent.gif\" height=\"3\"></td>");
	document.write ("</tr>");
	document.write ("</table>");
	
	document.write ("<div id=\"languageMenu\" style=\"margin:0px;\">");
	document.write ("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"200\">");
	document.write ("<tr><td colspan=\"4\" bgcolor=\"#314C8E\"><img src=\"/images/structure/transparent.gif\" height=\"3\"></td></tr>");
	document.write ("<tr>");
	document.write ("	<td bgcolor=\"#314C8E\"><img src=\"/images/structure/transparent.gif\"></td>");
	document.write ("	<td bgcolor=\"#314C8E\" valign=\"top\">&nbsp;&nbsp;<a href=\"javascript:langSet('en');\" style=\"color:#ffffff\"><img src=\"/images/structure/flags/us.gif\" alt=\"English\" width=\"20\" height=\"13\" border=\"0\" align=\"absmiddle\"> - English (US)</td>");
	document.write ("	<td bgcolor=\"#314C8E\" valign=\"top\">&nbsp;&nbsp;<a href=\"javascript:langSet('uk');\" style=\"color:#ffffff\"><img src=\"/images/structure/flags/en.gif\" alt=\"English (UK)\" width=\"20\" height=\"13\" border=\"0\" align=\"absmiddle\"> - English (UK)</td>");
	document.write ("	<td bgcolor=\"#314C8E\"><img src=\"/images/structure/transparent.gif\"></td>");
	document.write ("</tr>");
	
	document.write ("<tr><td colspan=\"4\" bgcolor=\"#314C8E\"><img src=\"/images/structure/transparent.gif\" height=\"5\"></td></tr>");

	document.write ("<tr>");
	document.write ("	<td bgcolor=\"#314C8E\"><img src=\"/images/structure/transparent.gif\"></td>");
	document.write ("	<td bgcolor=\"#314C8E\" valign=\"top\">&nbsp;&nbsp;<a href=\"javascript:langSet('pt');\" style=\"color:#ffffff\"><img src=\"/images/structure/flags/pt.gif\" alt=\"Portugu&ecirc;s\" width=\"20\" height=\"13\" border=\"0\" align=\"absmiddle\"> - Portugu&ecirc;s</td>");
	document.write ("	<td bgcolor=\"#314C8E\" valign=\"top\">&nbsp;&nbsp;<a href=\"javascript:langSet('ja');\" style=\"color:#ffffff\"><img src=\"/images/structure/flags/ja.gif\" alt=\"Japanese\" width=\"20\" height=\"13\" border=\"0\" align=\"absmiddle\"> - <img src=\"/images/structure/flags/ja_txt.gif\" alt=\"Japanese\" width=\"39\" height=\"11\" border=\"0\" align=\"absmiddle\"></td>");
	document.write ("	<td bgcolor=\"#314C8E\"><img src=\"/images/structure/transparent.gif\"></td>");
	document.write ("</tr>");
	
	document.write ("<tr><td colspan=\"4\" bgcolor=\"#314C8E\"><img src=\"/images/structure/transparent.gif\" height=\"5\"></td></tr>");

	document.write ("<tr>");
	document.write ("	<td bgcolor=\"#314C8E\"><img src=\"/images/structure/transparent.gif\"></td>");
	document.write ("	<td bgcolor=\"#314C8E\" valign=\"top\">&nbsp;&nbsp;<a href=\"javascript:langSet('it');\" style=\"color:#ffffff\"><img src=\"/images/structure/flags/it.gif\" alt=\"Italiano\" width=\"20\" height=\"13\" border=\"0\" align=\"absmiddle\"> - Italiano</td>");
	document.write ("	<td bgcolor=\"#314C8E\" valign=\"top\">&nbsp;&nbsp;<a href=\"javascript:langSet('es');\" style=\"color:#ffffff\"><img src=\"/images/structure/flags/es.gif\" alt=\"Espa&ntilde;ol\" width=\"20\" height=\"13\" border=\"0\" align=\"absmiddle\"> - Espa&ntilde;ol</td>");
	document.write ("	<td bgcolor=\"#314C8E\"><img src=\"/images/structure/transparent.gif\"></td>");
	document.write ("</tr>");
	document.write ("<tr>");
	
	document.write ("	<td colspan=\"4\" bgcolor=\"#314C8E\"><img src=\"/images/structure/transparent.gif\" height=\"3\"></td>");
	document.write ("</tr>");
	document.write ("</table></div>");
	
}
	
function displaySection(theObjectStr){

	if (isID){
		if (document.getElementById(theObjectStr).style.display == 'block'){
			document.getElementById(theObjectStr).style.display = 'none';
		}
		else{
			document.getElementById(theObjectStr).style.display = 'block';
		}
	}
	else if (isLayers){
		if (document.layers[theObjectStr].display == 'block'){
			document.layers[theObjectStr].display = 'none';
		}
		else{
			document.layers[theObjectStr].display = 'block';
		}
	}
	else {
		if (document.all[theObjectStr].style.display == 'block'){
			document.all[theObjectStr].style.display = 'none';
		}
		else{
			document.all[theObjectStr].style.display = 'block';
		}
	}
}		

function langSet(newLang){
	if (isTrans){
		document.forms.langForm.pgTrans.value = isTrans;
	}
	document.forms.langForm.lg.value = newLang;
	document.forms.langForm.submit();
}

function langDisplay(langStr){
	langStr = langStr.toUpperCase();
	if (langStr == "EN"){
		returnStr = "EN (US)";
	} 
	else if (langStr == "UK"){
		returnStr = "EN (UK)";
	}
	else {
		returnStr = langStr;
	}
	
	return returnStr;
}		
			
function checkTrans(){
		languageDir = "/" + lang + "/";
		if ((isTrans) && (document.location.href.indexOf(languageDir) == -1) && (lang != "en") && (window.location.search.substring(1).search(/tx/)==-1)){
			targetStr = "/language.asp?tr=1&ref=" + window.location.href.replace(/&/g,"%26");
			window.location.href = targetStr;
		}
}			


function openEnlargeWin(theForm){

	var popWin;
	popWin =  window.open("about:blank","enlargeWin","scrollbars=no,resizable,width=625,height=525,top=100,left=100");
	document.forms[theForm].submit();
	popWin.focus();
}

function enlargeImage(theName,smUrl,lrgUrl,theDesc,theFloat){

	document.write("<div class=\"imgBox\" style=\"width:auto;float:" + theFloat + ";\">");
	document.write("<form action=\"/misc/enlarge_img.asp\" target=\"enlargeWin\" method=\"post\" name=\"" + theName + "\" style=\"margin:5px;\">");
	document.write("<input type=\"Hidden\" name=\"lrgUrl\" value=\"/images/articles/" + lrgUrl + "\">");
	document.write("<input type=\"Hidden\" name=\"comment\" value=\"" + theDesc + "\">");
	document.write("<a href=\"javascript:openEnlargeWin('" + theName + "')\"><img src=\"/images/articles/" + smUrl + "\" style=\"border:1px #000000 solid;\"></a></form>");
	document.write("<span class=\"smallText\"><a href=\"javascript:openEnlargeWin('" + theName + "')\">Enlarge</a></span>");
	document.write("<a href=\"javascript:openEnlargeWin('" + theName + "')\"><img src=\"/images/icons/magnify.gif\" alt=\"Enlarge\" align=\"middle\" border=\"0\"></a></div>");
	
}			
			
function footerHeight(){
	if (isID){
		if (document.getElementById('sideBar')){
			sidebarLength = document.getElementById('sideBar').offsetHeight;}
		else {sidebarLength = 0;}
		if (document.getElementById('content')){
			contentLength = document.getElementById('content').offsetHeight;}
		else {contentLength = 0;}
		if (document.getElementById('rightBar')){
			rightbarLength = document.getElementById('rightBar').offsetHeight;}
		else {rightbarLength = 0;}
		
		if (contentLength != 0){		
			if (contentLength > sidebarLength){ footerHeight = contentLength +135;} 
			else {footerHeight = sidebarLength +135;}
		}
			
		if (document.getElementById('footer')){
			document.getElementById('footer').style.top = footerHeight;
			document.getElementById('footer').style.visibility = 'visible';
		}
	}
}

function showSection(theObjectStr){
        if (isID){document.getElementById(theObjectStr).style.display = 'block';
        }else if (isLayers){document.layers[theObjectStr].display = 'block';
        }else {document.all[theObjectStr].style.display = 'block';}
}
    
function hideSection(theObjectStr){
        if (isID){document.getElementById(theObjectStr).style.display = 'none';
        }else if (isLayers){document.layers[theObjectStr].display = 'none';
        }else {document.all[theObjectStr].style.display = 'none';}
}		
    	
function newsletterPop(){
	var newsPopWin;
	newsPopWin =  window.open("/support/newsletters/archive/","newsletterArchive","scrollbars=no,resizable,width=830,height=760,top=100,left=100");
	newsPopWin.focus();
}

function mail(theName){
	window.location.href = "mailto:" + theName + "@wallingfordsoftware.com";
}

function sendto(theName){
	window.location.href = "mailto:" + theName + "@mwhsoft.com";
}

function maillink(theName){
	document.write("<a href=\"javascript:mail('" + theName + "');\">" + theName +"&#64;&#119;allingfordsoftware&#46;com</a>");
}		

function mailto(theName){
	document.write("<a href=\"javascript:sendto('" + theName + "');\">" + theName +"&#64;m&#119;hsoft&#46;com</a>");
}
