<!--

var CurNewsItemID = 'a051910';	// starting news item id . . .

var mainGrxFlag = true;


String.prototype.trim = function()
{
	return this.replace(/^\s+|\s+$/g,"");
}



function GH_preloadLayers()
{
  	var d=document;

	d.GH_layers = new Array();

	d.GH_layers[0] = "main";
	d.GH_layers[2] = "bd";
	d.GH_layers[3] = "srch";
	d.GH_layers[4] = "res";
	d.GH_layers[5] = "out";
	d.GH_layers[6] = "job";

/*alert('d.GH_layers[1]= ' + d.GH_layers[1]);*/
}


function GH_swapLayer(activeDiv)
{
  	var i, e, d=document;

/*alert('activeDiv= ' + activeDiv);
alert('a= ' + a);*/

	if(a=d.GH_layers)
	{
		for(i=0; i < a.length; i++)
		{
/*			e = d.getElementById(a[i]);*/

			if(e=d.getElementById(a[i] + 'grx'))
			{
/*alert('starting e.className= ' + e.className);*/
/*alert('starting e.style.visibility= ' + e.style.visibility);*/
				if(a[i] != activeDiv)
					e.className = a[i] + 'grx_h';
				else	
					e.className = activeDiv + 'grx';
/*alert('ending e.className= ' + e.className);*/
			}

			if(e=d.getElementById(a[i] + 'Txt'))
			{
/*alert('starting e.className= ' + e.className);*/
/*alert('starting e.style.visibility= ' + e.style.visibility);*/
				if(a[i] != activeDiv)
					e.className = 'layerTxt_h';	/*a[i] + 'grx_h';*/
				else	
					e.className = 'layerTxt';	/*activeDiv + 'grx;*/
/*alert('ending e.className= ' + e.className);*/
			}
		}

		mainGrxFlag = false;
	}
}

function GH_displayDefault()
{
	if(!mainGrxFlag)
	{
		var i, e, d=document;

		if(a=d.GH_layers)
		{
			for(i=0; i < a.length; i++)
			{
				if(e=d.getElementById(a[i] + 'grx'))
				{
					e.className = a[i] + 'grx_h';
				}

				if(e=d.getElementById(a[i] + 'Txt'))
				{
					e.className = 'layerTxt_h';	/*a[i] + 'grx_h';*/
				}
			}
		}

	  	e=d.getElementById("maingrx");
			e.className = "maingrx";

		mainGrxFlag = true;
	}
}


//----

function RequestConsult()
{
	if(validateForm())
	{
		var content = "<div class='demoWaitDisplay'></div>";

		var e = document.getElementById('demoRequest');
			e.innerHTML = content;

		SubmitConsultRequest();
	}
}

function ConsultDisplayThanks()
{
	var f, n, s, fn="", content="";

	if(f=document.demoForm)
	{
		if(n=f.demoName.value)
		{
			if(n.trim().length > 0)
			{
				n=n.trim();

				s=n.indexOf(' ');
					if(s > 0)
					{
						fn=n.substring(0,s);
					}
					else
					{
						fn = n;
					}
			}
		}
	}

	if(fn.length > 0)
		content = fn + ",<br/>";

	content	= content
				+ "<p>Thank you for your interest in <i>Gravitocity</i>.  <br/>A member of our team will contact you shortly.</p>";

	var e = document.getElementById('demoData');
		e.className = 'demoThanks';
		e.innerHTML = content;
}

//----





function demoOnFocus()
{
}

function RequestDemo()
{
	if(validateForm())
	{
		var content = "<div class='demoWaitDisplay'></div>";

		var e = document.getElementById('demoRequest');
			e.innerHTML = content;

		SubmitDemoRequest();
	}
}

function DemoDisplayThanks()
{
	var f, n, s, fn="", content="";

	if(f=document.demoForm)
	{
		if(n=f.demoName.value)
		{
			if(n.trim().length > 0)
			{
				n=n.trim();

				s=n.indexOf(' ');
					if(s > 0)
					{
						fn=n.substring(0,s);
					}
					else
					{
						fn = n;
					}
			}
		}
	}

	if(fn.length > 0)
		content = fn + ",<br/>";

	content	= content
				+ "<p>Thank you for your interest in <i>Gravitocity</i>.  <br/>A member of our team will contact you shortly to schedule a live online demonstration.</p>"
				+ "<p>Please note that, given the breadth and depth of Gravitocity's capabilities, a live demonstration <br/>- <i>including ample time to answer your questions</i> - typically runs for approximately one hour in length.";

	var e = document.getElementById('demoData');
		e.className = 'demoThanks';
		e.innerHTML = content;
}




function validateForm()
{
	var f=document.demoForm;

	if(f.demoName.value.length == 0 )
	{
		alert(' Please first enter your name. ');
		f.demoName.focus();
		return false;
	}
 	if(f.demoTitle.value.length == 0)
	{
		alert(' Please first enter your title. ');
		f.demoTitle.focus();
		return false;
	}
 	if(f.demoCompany.value.length == 0)
	{
		alert(' Please first enter your company - or NA. ');
		f.demoCompany.focus();
		return false;
	}
 	if(f.demoPhone.value.length == 0)
	{
		alert(' Please first enter a phone number. ');
		f.demoPhone.focus();
		return false;
	}
	if(f.demoEmail.value.length == 0)
	{
		alert(' Please first enter an email address. ');
		f.demoEmail.focus();
		return false;
	}
	if(f.demoEmail.value.indexOf('@') == -1)
	{
		alert(' Please first enter a valid email address. ');
		f.demoEmail.focus();
		return false;
	}
	return true;
}


//---

function SubmitConsultRequest()
{
	var f=document.demoForm;

	var n=f.demoName.value, t=f.demoTitle.value, c=f.demoCompany.value, p=f.demoPhone.value, e=f.demoEmail.value;
	try
 	{
 		var theURL = 'http://www.Gravitocity.com/AJAX_RequestConsult?n=' + n + '&t=' + t + '&c=' + c + '&p=' + p + '&e=' + e;

// 		var theURL = 'http://192.168.1.65/AJAX_RequestConsult?n=' + n + '&t=' + t + '&c=' + c + '&p=' + p + '&e=' + e;


//alert('theURL= ' + theURL);

		if (window.XMLHttpRequest)
		{
  			req = new XMLHttpRequest(); 
		} 
		else if (window.ActiveXObject)
		{
  			req = new ActiveXObject("Microsoft.XMLHTTP");
		} 

		req.open("Get",theURL,true); 
		req.onreadystatechange = myConsultCallback;
		req.send(null);
 	}  // try
 	catch(e)
 	{
//alert(e);
 	}
}


function myConsultCallback()
{
	try
	{
//alert('req.readyState= ' + req.readyState);
		if(req.readyState==4)
		{
			ConsultDisplayThanks();	// AJAX_RequestConsult pauses for 1 second; otherwise AJAX too fast to display activity icon . . .
		}
	}  // try
	catch(e)
	{
//alert('callback(): ' + e);
	}
} 


//---



function SubmitDemoRequest()
{
	var f=document.demoForm;

	var n=f.demoName.value, t=f.demoTitle.value, c=f.demoCompany.value, p=f.demoPhone.value, e=f.demoEmail.value;
	try
 	{
 		var theURL = 'http://www.Gravitocity.com/AJAX_RequestDemo?n=' + n + '&t=' + t + '&c=' + c + '&p=' + p + '&e=' + e;

// 		var theURL = 'http://192.168.1.65/AJAX_RequestDemo?n=' + n + '&t=' + t + '&c=' + c + '&p=' + p + '&e=' + e;

//alert('theURL= ' + theURL);

		if (window.XMLHttpRequest)
		{
  			req = new XMLHttpRequest(); 
		} 
		else if (window.ActiveXObject)
		{
  			req = new ActiveXObject("Microsoft.XMLHTTP");
		} 

		req.open("Get",theURL,true); 
		req.onreadystatechange = myDemoCallback;
		req.send(null);
 	}  // try
 	catch(e)
 	{
//alert(e);
 	}
}


function myDemoCallback()
{
	try
	{
//alert('req.readyState= ' + req.readyState);
		if(req.readyState==4)
		{
			DemoDisplayThanks();	// AJAX_RequestDemo pauses for 1 second; otherwise AJAX too fast to display activity icon . . .
		}
	}  // try
	catch(e)
	{
//alert('callback(): ' + e);
	}
} 




function DisplayNewsItem(id)
{
	var e = document.getElementById(id);

		var content = e.innerHTML;

	e = document.getElementById('newsView');
		e.innerHTML = content;


	var prevID = CurNewsItemID;

	CurNewsItemID = 'a' + id;

	e = document.getElementById(CurNewsItemID);
		e.className = 'newsListItemSelected';

	if(prevID)
	{
		e = document.getElementById(prevID);
			e.className = 'newsListItemVisited';
	}
}



