// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = 9;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 28;
// -----------------------------------------------------------------------------

function initnav(obj,tabOn) {

	//set the style of the tab that's been selected
	if(tabOn) {
		document.getElementById(tabOn).className = "mainnavon";
	}
	
	if (document.getElementById && document.getElementById(obj)) {
		navRoot = document.getElementById(obj);
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			// make sure drop downs don't extend past 990
			if (node.offsetLeft > 775) {
				var adjust = 775-node.offsetLeft;
				for (var j=0; j<node.childNodes.length; j++) {
					if (node.childNodes[j].nodeName.toUpperCase() == 'UL') {
						node.childNodes[j].style.left = adjust+'px';
					}
				}
			}
			
			node.onmouseover = function() {			
				if (this.className.indexOf('mainnav') != -1) {
					this.className = 'hi';
				}
			}
			
			node.onmouseout = function() {
				//set the style of the tab that's been selected
				if(tabOn) {
					document.getElementById(tabOn).className = "mainnavon";
				}

				if (this.className.indexOf('hi') != -1) {
					this.className = 'mainnav'
				}
			}
		}
	}
}

function hideLayer(d) {
	document.getElementById(d).style.visibility = "hidden";
}

function showLayer(d) {
	document.getElementById(d).style.visibility = "visible";
}	

var spotlightProductsDefault = "<span class='header_lg'>Tideworks Solutions</span><p>Moving" +
	" more cargo quickly, safely, and profitably...that's what your business is" +
	" all about.</p><p> Today, terminal operators, stevedores, and logistics providers" +
	" are leveraging the proven technology and industry expertise of Tideworks" +
	" Technology&reg; to gain and maintain a profitable competitive advantage.</p>";
	
var spotlightServicesDefault = "<span class='header_lg'>More than Just Great Software</span><p>From" +
	" initial customer engagement through ongoing, long-term support, our team" +
	" provides a level of professionalism, skill and dedication unmatched in the industry.</p>" +
	"<p>We're here for the long haul, committed to your terminal's success.</p>";
	
var spotlightSolutionsDefault = "<span class='header_lg'>Tideworks Solutions</span><p>Tideworks leverages proven technology and industry practices to help operators of marine terminals, multipurpose facilities and intermodal terminals achieve more - more operational productivity, better communication with customers and partners and faster turn times.</p><p>Our industry leading software gives you the reliability and flexibility to manage your business proactively and cost-effectively. Coupled with our unmatched support and comprehensive professional services, Tideworks' solutions deliver results and a rapid return on investment.</p>";

function changeBackgroundOn(area,id) {
	if(id != null) {
		document.getElementById(id).style.backgroundColor = "#cfe2fe";
		//document.getElementById("learnmore_" + id).style.display = "block";
	}

	switch(id) {
		case "mainsail":
			spotlightTxt = "<span class='header_lg'>Mainsail®</span><p>Mainsail® is an intuitive terminal operating system that fortifies operations with real-time inventory management, flexible workflow tools, and comprehensive integration with other business-critical systems and partners.</p><p>The system gives terminal operations complete visibility and control of cargo at the gate, in the yard, and on vessels or rail cars. The result is faster, more efficient cargo processing.</p><p>Mainsail Online provides your customers and partners with access to selected terminal data through an intuitive Web interface for enhanced, instantaneous communication.</p>";
			break;    
		case "spinnaker":
  			spotlightTxt = "<span class='header_lg'>Spinnaker Planning Management System®</span><p>Spinnaker Planning Management System® fully integrates vessel, berth, yard, intermodal and rail planning tools in one workspace to give terminal operators the ability to increase cargo volume and reduce vessel turn time.</p><p>Spinnaker has the most intuitive user interface on the market and eliminates the guesswork from planning while maximizing efficiency throughout terminal operations.</p>";
			break;
		case "trafficcontrol":
  			spotlightTxt = "<span class='header_lg'>Traffic Control™</span><p>Traffic Control™ is an advanced module of the Spinnaker Planning Management System®. It provides dynamic control of your terminal's container handling equipment, and replaces radio communication and paper instructions with accurate, real-time, electronic dispatching of work instructions to operators.</p><p>Seamless integration with Spinnaker Planning Management System insures that your operational plans are executed flawlessly every time.</p>";
			break;
		case "forecast":
  			spotlightTxt = "<span class='header_lg'>Forecast®</span><p>Forecast uses the internet to help terminals communicate faster and easier with trucking companies, shippers, consignees, brokers, and other interested parties. The system provides real-time information before truckers arrive at the terminal, so that once they arrive, processing is faster and trouble-free. </p><p>The result for the terminal is faster gate turn times, reduced customer service costs, and an increased competitive advantage. For the shipping community, Forecast enables improved planning and resource management, hassle free gate transactions, and fewer calls to the terminal.</p>";
			break;
		case "genoa":
  			spotlightTxt = "<span class='header_lg'>Genoa Breakbulk Management System®</span><p>Genoa Breakbulk Management System® is a suite of systems that will help you effectively manage all aspects of your multipurpose terminal business and deliver on customers' expectations. Genoa supports terminals that handle all cargo types - break-bulk, bulk, ro-ro, and containers - and can operate as a standalone system, in dedicated or multipurpose terminal environments.</p><p>The system was developed from the ground up with extensive input from terminal operations staff, cargo carriers, manufacturers, and shippers. The result is a flexible system that precisely controls your cargo operations and keeps pace with changing operational needs.</p>";
			break;
		case "gatevision":
  			spotlightTxt = "<span class='header_lg'>GateVision®</span><p>GateVision is a combination of software and hardware that effectively integrates all key components of the gate transaction into one user interface. It provides a platform to accelerate gate activity, minimize truck processing time, and maximize user productivity.</p><p>GateVision enables terminal operators to increase gate processing speed and reduce operating costs by providing an adaptable, modular gate system that can grow and adjust to changes in the operation.</p>";
			break;
		case "digitalbridge":
  			spotlightTxt = "<span class='header_lg'>Digital Bridge™</span><p>Digital Bridge™ is a dashboard tool that displays a real-time Key Performance Indicators (KPI's) and highlights issues before they become problems.</p><p>The comprehensive library of metrics for gate, yard, vessel, and rail activities provides increased visibility into your terminal's operations while decreasing the response time needed to address hot issues and giving terminal personnel the power to make truly informed business decisions.</p>";
			break;
		case "implementation":
			spotlightTxt = "<span class='header_lg'>Implementation Services</span><p>Tideworks ensures that each solution, whether a new system implementation or legacy system conversion, is well accepted by its users and meets the objectives of terminal management. Our expert implementation services include:<ul><li class='spotlightBullet'>Project Management</li><li class='spotlightBullet'>Operational Consulting</li><li class='spotlightBullet'>Technical Consulting</li><li class='spotlightBullet'>Hardware Procurement Assistance</li><li class='spotlightBullet'>Gate Automation Services</li><li class='spotlightBullet'>Software Customization</li><li class='spotlightBullet'>Data Conversion</li><li class='spotlightBullet'>User and Technical Training</li><li class='spotlightBullet'>On-site Go-live Support</li></ul></p>";
			break;
		case "integration":
			spotlightTxt = "<span class='header_lg'>Integration Services</span><p>Sophisticated terminal operating systems depend on integration of the core TOS with other key systems. Tideworks acts as systems integrator, delivering seamless integration with the following systems:<ul><li class='spotlightBullet'>Gate and Crane OCR (Optical Character Recognition) Systems</li><li class='spotlightBullet'>LPR (License Plate Recognition) Systems</li><li class='spotlightBullet'>RTLS (Real-Time Location Systems)</li><li class='spotlightBullet'>DGPS (Differential Global Positioning Systems)</li><li class='spotlightBullet'>Financial and Accounting Systems</li><li class='spotlightBullet'>ERP Systems</li><li class='spotlightBullet'>Gate Camera and Scale Systems</li><li class='spotlightBullet'>Customer Proprietary Systems</li></ul></p>";
			break;
		case "management":
			spotlightTxt = "<span class='header_lg'>System Management &amp; ASP Services</span><p>Outsourcing systems management means seasoned professionals are here around the clock to guarantee uptime while lowering your overhead.  You focus on your operation while Tideworks handles the technical details, including any or all of the following services:<ul><li class='spotlightBullet'>Server Hosting</li><li class='spotlightBullet'>Server Administration</li><li class='spotlightBullet'>Database Administration</li><li class='spotlightBullet'>Application Monitoring</li><li class='spotlightBullet'>Website Hosting</li><li class='spotlightBullet'>Software Upgrades</li><li class='spotlightBullet'>EDI Support</li><li class='spotlightBullet'>Application Disaster Recovery</li></ul></p>";
			break;
		case "support":
			spotlightTxt = "<span class='header_lg'>Platinum Support Services</span><p>Tideworks provides unmatched technical support that is based on 24/7 availability. This \"Platinum\" level of service is the standard that we deliver to all customers, large and small. Platinum Support includes:<ul><li class='spotlightBullet'>All software upgrades at no additional cost</li><li class='spotlightBullet'>24/7 technical support via Tideworks' Service Center</li><li class='spotlightBullet'>Three-tier support approach for quick escalation and resolution</li><li class='spotlightBullet'>Regional field support personnel</li><li class='spotlightBullet'>Tracking of all support requests using Remedy Action/Request System</li><li class='spotlightBullet'>Support for third-party technologies under service level agreement</li></ul></p>";
			break;
		case "container":
			spotlightTxt = "<span class='header_lg'>Container Terminal Solutions</span><p>Tideworks' container terminal management solutions help you maximize productivity with a host of innovative tools:<ul><li class='spotlightBullet'>Inventory management, reporting and customer service tools in Mainsail®</li><li class='spotlightBullet'>Vessel, berth, yard and rail planning tools in Spinnaker Planning Management System®</li><li class='spotlightBullet'>Gate centralization and automation tools in GateVision®</li><li class='spotlightBullet'>Work instruction dispatch tools for container handling equipment operators in Traffic Control™</li><li class='spotlightBullet'>Terminal productivity monitoring tools in Digital Bridge™</li><li class='spotlightBullet'>Web-based customer service tools for trucking companies, shippers and other parties in Forecast®</li></ul></p>";
			break;
		case "multipurpose":
			spotlightTxt = "<span class='header_lg'>Multipurpose Terminal Solutions</span><p>Tideworks' multipurpose terminal operating systems minimize costs with flexible tools for the entire operation:<ul><li class='spotlightBullet'>Inventory management, customer service and receiving and delivery tools in Genoa Breakbulk Management System®</li><li class='spotlightBullet'>Vessel, berth, yard and rail planning tools in Spinnaker Planning Management System®</li></ul></p>";
			break;
		case "intermodal":
			spotlightTxt = "<span class='header_lg'>Intermodal Terminal Solutions</span><p>Tideworks' intermodal terminal management solutions manage your entire terminal network more efficiently with the following tools:<ul><li class='spotlightBullet'>Rail and yard planning tools in Intermodal Pro™</li><li class='spotlightBullet'>Work instruction dispatch tools for container handling equipment operators in Traffic Control™</li><li class='spotlightBullet'>Gate centralization and automation tools in GateVision®</li><li class='spotlightBullet'>Terminal productivity monitoring tools in Digital Bridge™</li></ul></p>";
			break;
		default:
			if(area=="services") {
				spotlightTxt = spotlightServicesDefault;
			} else if(area=="solutions") {
				spotlightTxt = spotlightSolutionsDefault;
			} else {
				spotlightTxt = spotlightProductsDefault;
			}
			break;
	} 
	
	document.getElementById("spotlight").innerHTML = spotlightTxt;
}

function changeBackgroundOff(area,id) {
	if(id != null) {
		document.getElementById(id).style.backgroundColor = "#ffffff";
		//document.getElementById("learnmore_" + id).style.display = "none";
	}
	
	if(area=="services") {
		spotlightTxt = spotlightServicesDefault;
	} else {
		spotlightTxt = spotlightProductsDefault;
	}

	document.getElementById("spotlight").innerHTML = spotlightTxt;
}

function showFaq(id) {
	if(document.getElementById(id).style.display == "block") {
		document.getElementById(id).style.display = "none";
	} else {
		document.getElementById(id).style.display = "block";
	}
}

function showRelatedProducts(id) {
	var productTxt = "";
	switch(id) {
		case "0": //container terminal operator
			productTxt = "<p><a href='mainsail/' class='standard'>Mainsail</a></p><p><a href='spinnaker/' class='standard'>Spinnaker Planning Management System</a></p><p><a href='forecast/' class='standard'>Forecast</a></p><p><a href='trafficcontrol/' class='standard'>Traffic Control</a></p><p><a href='gatevision/' class='standard'>GateVision</a></p><p><a href='digitalbridge/' class='standard'>Digital Bridge</a></p>";
			break;    
		case "1": //multipurpose terminal operator
  			productTxt = "<p><a href='genoa/' class='standard'>Genoa Breakbulk Management System</a></p><p><a href='spinnaker/' class='standard'>Spinnaker Planning Management System</a></p>";
			break;
		case "2": //shipping line/agency
  			productTxt = "<p><a href='mainsail/' class='standard'>Mainsail</a></p><p><a href='mainsail/' class='standard'>Mainsail Online</a></p>";
			break;
		case "3": //trucking company
  			productTxt = "<p><a href='forecast/' class='standard'>Forecast</a></p>";
			break;
		case "4": //importer/exporter
  			productTxt = "<p><a href='forecast/' class='standard'>Forecast</a></p>";
			break;
		case "5": //warehousing
  			productTxt = "<p><a href='genoa/' class='standard'>Genoa Breakbulk Management System</a></p>";
			break;
		case "6": //container freight station
  			productTxt = "<p><a href='genoa/' class='standard'>Genoa Breakbulk Management System</a></p><p><a href='mainsail/' class='standard'>Mainsail</a></p>";
			break;
		case "7": //rail terminal operator
  			productTxt = "<p><a href='intermodalpro/' class='standard'>Intermodal Pro</a></p><p><a href='trafficccontrol/' class='standard'>Traffic Control</a></p><p><a href='gatevision/' class='standard'>GateVision</a></p><p><a href='digitalbridge/' class='standard'>Digital Bridge</a></p>";
			break;
		default:
			productTxt = "";
			break;
	} 
	
	if(productTxt != "") {
		document.getElementById("theRelatedProducts").innerHTML = "<p>Based on the information you have provided, we have identified the following Tideworks solutions for you. Select a link to find out more.</p>" + productTxt;
	} else {
		document.getElementById("theRelatedProducts").innerHTML = "";
	}
}

function showClients(region) {
	if(region != "") {
		document.getElementById("clientRegion").innerHTML = document.getElementById(region).innerHTML;
	}
	
	document.getElementById("clientRegion").style.backgroundColor = "#F5F5F5"
	
	var regions = new Array("northwest","southwest","eastcoast","gulfcoast","centralamerica","southamerica","europe","asia","allclients");

	for (i=0; i < regions.length; i++) {
		document.getElementById("div_" + regions[i]).style.backgroundColor = "#FFFFFF";
	}

	document.getElementById("div_" + region).style.backgroundColor = "#F5F5F5";
}


function showClients1(region) {
	if(document.getElementById("clientRegion") != null)
	{
		if(region != "") {
			document.getElementById("clientRegion").innerHTML = document.getElementById(region).innerHTML;
		}
	
		//document.getElementById("clientRegion").style.backgroundColor = "#F5F5F5"
	}
	//var regions = new Array("northwest","southwest","eastcoast","gulfcoast","centralamerica","southamerica","europe","asia","allclients");

	//for (i=0; i < regions.length; i++) {
		//document.getElementById("div_" + regions[i]).style.backgroundColor = "#FFFFFF";
	//}

	//document.getElementById("div_" + region).style.backgroundColor = "#F5F5F5";
}

var qsParm = new Array();
function checkQS() {
	var query = window.location.search.substring(1);
	if(query !="") {
		var parms = query.split('&');
		for (var i=0; i<parms.length; i++) {
			var pos = parms[i].indexOf('=');
			if (pos > 0) {
				var key = parms[i].substring(0,pos);
				var val = parms[i].substring(pos+1);
				qsParm[key] = val;
			}
		}
		//showClients1(qsParm['clients']);
	}
}

function validateSalesForm(formref) {

	//if checkbox is not checked then set the value to null
	if(!formref.elements["00N40000001mVwh"].checked) {
		formref.elements["00N40000001mVwh"].value = null;
	}
	
	var forgot = "";
	if(formref.first_name.value==0)	{forgot = forgot + " First Name\n"}
	if(formref.last_name.value==0)	{forgot = forgot + " Last Name\n"}
	if(formref.email.value==0)		{forgot = forgot + " Email Address\n"}
	if(formref.company.value==0)	{forgot = forgot + " Company Name\n"}
	
	//loop through the products to see if we have a value
	var chosenProduct = false;
	for (var i=0; i<formref.elements["00N40000001mVwr"].length; i++) {
		if(formref.elements["00N40000001mVwr"][i].checked) {
			chosenProduct=true;	
		}
	}
	
	if(!chosenProduct) {forgot = forgot + " Product(s) Interest\n"}
	
	if(forgot != "") {
		alert("Please fill in the following fields before submitting:\n--------------------------------------------------------------\n" + forgot+"--------------------------------------------------------------");
		return false;
	} else {
		return true;
	}
}

function validateNewsletterForm(formref) {
	var forgot = "";
	if(formref.first_name.value==0)	{forgot = forgot + " First Name\n"}
	if(formref.last_name.value==0)	{forgot = forgot + " Last Name\n"}
	if(formref.email.value==0)		{forgot = forgot + " Email Address\n"}
	if(formref.company.value==0)	{forgot = forgot + " Company Name\n"}
	if(formref.elements["00N40000001Xkhi"].value==0)	{forgot = forgot + " Operation Type\n"}
	
	if(forgot != "") {
		alert("Please fill in the following fields before submitting:\n--------------------------------------------------------------\n" + forgot+"--------------------------------------------------------------");
		return false;
	} else {
		return true;
	}
}

// JQuery code from here down ----------------------------------------------------------------------------------------
// to use the rollover, set the class name to any image to "ro". Alternate image needs the same name + "_o".

IMAGE = {};

IMAGE.rollover =
	{
	init: function()
		{
		this.preload();
     
      $(".ro").hover(
         function () { $(this).attr( 'src', IMAGE.rollover.newimage($(this).attr('src')) ); },
         function () { $(this).attr( 'src', IMAGE.rollover.oldimage($(this).attr('src')) ); }
      );
   },

   preload: function()
   {
      $(window).bind('load', function() {
         $('.ro').each( function( key, elm ) { $('<img>').attr( 'src', IMAGE.rollover.newimage( $(this).attr('src') ) ); });
      });
   },
   
   newimage: function(src)
   {
      return src.substring( 0, src.search(/(\.[a-z]+)$/) ) + '_o' + src.match(/(\.[a-z]+)$/)[0];
   },

   oldimage: function(src)
   {
      return src.replace(/_o\./, '.');
   }
};


function newWindow(sLink,w,h) {
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers) var xMax = window.outerWidth, yMax = window.outerHeight;
        else var xMax = 640, yMax=480;
    var xOffset = (xMax - h)/2, yOffset = (yMax - w)/2;
	newWin = open(sLink,"newWin","scrollbars=no,resizable=yes,status=no,height="+w+",width="+h+",toolbar=no,menubar=no,screenX="+xOffset+",screenY="+yOffset+",top="+yOffset+",left="+xOffset+"'"); 
	newWin.focus();
}