function navOver(imgTag)
{        
	var theImage = imgTag;	
	if(theImage.src.indexOf("_off.") != -1)	
	{
		theImage.src = theImage.src.replace("_off.","_on.");		
	}
	else	
	{
		theImage.src = theImage.src.replace("_on.","_off.");	
	}
}

window.onload = function()
{
	createSwftype(".swfHeading1", "flash/SwfFrutiger.swf", "css/swftype.css", 615, 18, false, "all", false);
	createSwftype(".swfHeading1a", "flash/SwfFrutiger.swf", "css/swftype.css", 500, 18, false, "height", false);
	createSwftype(".swfHeading1b", "flash/SwfFrutiger.swf", "css/swftype.css", 250, 18, false, "width", false);
	createSwftype(".swfHeading1c", "flash/SwfFrutiger.swf", "css/swftype.css", 200, 18, false, "width", false);
	createSwftype(".swfHeading2", "flash/SwfFrutiger.swf", "css/swftype.css", 580, 18, false, "all", false);
	createSwftype(".swfHeading3", "flash/SwfFrutiger.swf", "css/swftype.css", 280, 18, false, "all", false);
	createSwftype(".swfHeading3a", "flash/SwfFrutiger.swf", "css/swftype.css", 280, 18, false, "all", false);
	createSwftype(".swfHeading4", "flash/SwfFrutiger.swf", "css/swftype.css", 250, 18, false, "all", false);
	createSwftype(".swfHeading5", "flash/SwfFrutiger.swf", "css/swftype.css", 580, 18, false, "all", false);
	createSwftype(".swfHeading6", "flash/SwfFrutiger.swf", "css/swftype.css", 250, 18, false, "all", false);
	createSwftype(".subNavSwfOn", "flash/SwfFrutiger.swf", "css/swfNav.css", 250, 16, false, "all", false);
	createSwftype(".subNavSwfOff", "flash/SwfFrutiger.swf", "css/swfNav.css", 250, 16, false, "all", false);
}

function GetXmlHttpObject(){var xmlHttp = null;	try {xmlHttp = new XMLHttpRequest();} catch (e) {try{xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");}}return xmlHttp;}

function navOver(imgTag)
{        
	var theImage = imgTag;	
	if(theImage.src.indexOf("_off.") != -1)	
	{
		theImage.src = theImage.src.replace("_off.","_on.");		
	}
	else	
	{
		theImage.src = theImage.src.replace("_on.","_off.");	
	}
}

var EmailAFriend = {
	SenderName: null,
	SenderEmail: null,
	FriendName: null,
	FriendEmail: null,
	Message: null,
	PageUrl: null,
	Valid: true,
	Request: function(el)
	{
		xhr = GetXmlHttpObject();				
		url = "/email-a-friend.aspx";
		var query = "&status=new";
		

		xhr.onreadystatechange = EmailAFriend.RequestStatus;	
		xhr.open("POST",url,true);	
		xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr.setRequestHeader("Content-length", query.length);
		xhr.setRequestHeader("Connection", "close");
		xhr.send(query);	
	},
	Validate: function()
	{
		SenderName = document.getElementById('txtName');
		SenderEmail = document.getElementById('txtEmail');
		FriendName = document.getElementById('txtFriendName');
		FriendEmail = document.getElementById('txtFriendEmail');
		Message = document.getElementById('message');
		
		if(SenderName.value == "")
		{
			Valid = false;
			SenderName.className += ' formError';
		}
		else
		{
			Valid = true;
			SenderName.className = 'textBox';
		}
		
		if(SenderEmail.value == "")
		{
			Valid = false;
			SenderEmail.className += ' formError';
		}
		else if (SenderEmail.value != "")
		{			
			var supEmail = SenderEmail.value;
			var emLen = supEmail.length;
			var posAt = supEmail.indexOf('@')
			var posDot = supEmail.lastIndexOf('.')
			if((emLen < 7) || (posAt < 1) || (posDot <= (posAt + 1)) || (posDot >= (emLen - 1)))
			{
				Valid = false;
				SenderEmail.className += " formError";
			}
			else
			{
				Valid = true;
				SenderEmail.className = "textBox";
			}
		} 
		else
		{
			Valid = true;
			SenderEmail.className = 'textBox';
		}
		
		if(FriendName.value == "")
		{
			Valid = false;
			FriendName.className += ' formError';
		}
		else
		{
			Valid = true;
			FriendName.className = 'textBox';
		}
		
		if(FriendEmail.value == "")
		{
			Valid = false;
			FriendEmail.className += ' formError';
		}
		else if (FriendEmail.value != "")
		{			
			var supEmail = FriendEmail.value;
			var emLen = supEmail.length;
			var posAt = supEmail.indexOf('@')
			var posDot = supEmail.lastIndexOf('.')
			if((emLen < 7) || (posAt < 1) || (posDot <= (posAt + 1)) || (posDot >= (emLen - 1)))
			{
				Valid = false;
				FriendEmail.className += " formError";
			}
			else
			{
				Valid = true;
				FriendEmail.className = "textBox";
			}
		} 
		else
		{
			FriendEmail.className = 'textBox';
		}
		
		
		if(Valid == true)
		{		
			var query = "&status=submit";
			query += "&friendsName=" + FriendName.value;
			query += "&friendsEmail=" + FriendEmail.value;
			query += "&yourName=" + SenderName.value;
			query += "&yourEmail=" + SenderEmail.value;
			query += "&yourMessage=" + Message.value;			
			query += "&pageUrl=" + document.location;
		
			xhr.onreadystatechange = EmailAFriend.RequestStatus;	
			xhr.open("POST",url,true);	
			xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			xhr.setRequestHeader("Content-length", query.length);
			xhr.setRequestHeader("Connection", "close");
			xhr.send(query);
		}
	},
	RequestStatus: function()
	{
		var emailAFriendContainer = document.getElementById('emailAFriendContainer');
		if (xhr.readyState == 4)
		{						
			emailAFriendContainer.innerHTML = xhr.responseText;														
		} else {			
			emailAFriendContainer.innerHTML = "<img src='/media/build/ajax-loader.gif' alt='' />";			
		}	
	}
}
