function _$(ElementID)
{
	return document.getElementById(ElementID);
}

function OpenInline(ElementID, Width, Height, e)
{
	var element = _$(ElementID);
	var positionLeft = 0;
	var positionTop = 0;
		
	if (Width != null && Height != null)
	{
		positionLeft = ((GetClientWidth() - Width) / 2);
				
		if (arguments.length == 3)
		{			
			positionTop = (((GetClientHeight() - Height) / 2) + 50);
		}
		else if (arguments.length == 4)
		{
			positionTop = GetMousePositionY(e) - 90;
		}		
		
		element.style.top = positionTop.toString() + 'px';
		element.style.left = positionLeft.toString() + 'px';
	}	
	
	element.style.display = '';
}//OpenInline

function ContactUs(BoxID, Company, Name, Email, Phone, Subject, Message)
{	
	var isValid = false;
	var isAsyncronous = false;	
	var queryString = null;


	//Refresh Style
	Name.style.backgroundColor = 'white';
	Name.style.color = 'black';
	
	Email.style.backgroundColor = 'white';
	Email.style.color = 'black';
	
	Email.style.backgroundColor = 'white';
	Email.style.color = 'black';
	
	Subject.style.backgroundColor = 'white';
	Subject.style.color = 'black';
	
	Message.style.backgroundColor = 'white';
	Message.style.color = 'black';
	

	//Validations
	if (BoxID.length == 0)
	{
		return false;
	}	
	else if (Name.value.length == 0)
	{
		Name.style.backgroundColor = 'red';
		Name.style.color = 'white';
		return false;
	}	
	else if (Email.value.length == 0)
	{
		Email.style.backgroundColor = 'red';
		Email.style.color = 'white';
		return false;
	}
	else if (Subject.value.length == 0)
	{
		Subject.style.backgroundColor = 'red';
		Subject.style.color = 'white';
		return false;
	}
	else if (Message.value.length == 0)
	{
		Message.style.backgroundColor = 'red';
		Message.style.color = 'white';
		return false;
	}
	
		
	//set query format
	queryString = 'com=' + Company.value + '&nm=' + Name.value + '&em=' + Email.value + '&ph=' + Phone.value + '&su=' + Subject.value + '&msg=' + Message.value;
	
	//replace spaces
	queryString = queryString.replace(' ', '+');	
	
	WEB_SERVICE_URL = WEB_DOMAIN + '/t/ContactUs.aspx?' + queryString;
				
	//verify xmlHttp existence
	if(syncXmlHttp)
	{				
		syncXmlHttp.open("GET", WEB_SERVICE_URL, isAsyncronous);
		
		syncXmlHttp.setRequestHeader("Content-Type", CONTENT_TYPE_FORM);
		syncXmlHttp.setRequestHeader("Connection", "Close");
		
		syncXmlHttp.onreadystatechange = function()
		{
			if (syncXmlHttp.readyState == READYSTATE_COMPLETE && syncXmlHttp.status == 200)
			{				
				try
				{	
					var xmlDoc = syncXmlHttp.responseXML;
					var responses = xmlDoc.getElementsByTagName("Response");
					var isError = '';
					var status = '';
					
					
					if (responses.length > 0)
					{
						isError = responses[0].attributes[0].value;
						status = responses[0].attributes[1].value;

						if (isError == 'false')
						{
							isValid = true;
							alert(status);
						}
						else
						{
							alert('Server Error: ' + status);
						}
					}									
					
					//kill vars
					xmlDoc = null;
				}
				catch (e)
				{
					isValid = false;
					alert("Error: " + e.description);					
				}//try
			}//if (xmlHttp.readyState == READYSTATE_COMPLETE && xmlHttp.status == 200)
		}//xmlHttp.onreadystatechange 
				
		syncXmlHttp.send(null);
		
	}//if(xmlHttp)	
	
	if (isValid)
		CloseInline(BoxID);

	//prevent postback	
	return false;
	
}//EmailBusiness

function CloseInline(ElementID)
{
	var e = _$(ElementID);

	e.style.display = 'none';
	
}//CloseInline

function SetWindowStatus(status)
{
	window.status = status;
	
}//SetWindowStatus