function navOver(imgTag)
{        
	var theImage = imgTag;	
	if(theImage.src.indexOf("_off.") != -1)	
		theImage.src = theImage.src.replace("_off.","_over.");		
	else	
		theImage.src = theImage.src.replace("_over.","_off.");	
}

function addLoadEvent(func) 
{ 
	var oldonload = window.onload; 
	if (typeof window.onload != 'function') 
	{ 
		window.onload = func; 
	} 
	else 
	{ 
		window.onload = function() 
		{ 
			if (oldonload) 
			{ 
				oldonload(); 
			} 
			func(); 
		} 
	} 
} 

function CurrencyConverter(){	
	var mainDiv = document.getElementById("price_in_other_currency");
	
	if(mainDiv == null) return; 
	
	var us = document.getElementById("us_dollar");
	var pound = document.getElementById("pound");
	var euro = document.getElementById("euro");
	var yen = document.getElementById("yen");	
	
	us.getElementsByTagName("p")[0].className = "hasJs";
	pound.getElementsByTagName("p")[0].className = "hasJs";
	euro.getElementsByTagName("p")[0].className = "hasJs";
	yen.getElementsByTagName("p")[0].className = "hasJs";
	
	us.getElementsByTagName("a")[0].onmouseover = function(){			
		us.getElementsByTagName("p")[0].style.display = 'block';
	}
	
	us.getElementsByTagName("a")[0].onmouseout = function(){	
		us.getElementsByTagName("p")[0].style.display = 'none';
	}
	
	pound.getElementsByTagName("a")[0].onmouseover = function(){	
		pound.getElementsByTagName("p")[0].style.display = 'block';	
	}
	
	pound.getElementsByTagName("a")[0].onmouseout = function(){
		pound.getElementsByTagName("p")[0].style.display = 'none';
	}
	
	euro.getElementsByTagName("a")[0].onmouseover = function(){	
		euro.getElementsByTagName("p")[0].style.display = 'block';	
	}
	
	euro.getElementsByTagName("a")[0].onmouseout = function(){
		euro.getElementsByTagName("p")[0].style.display = 'none';
	}

	yen.getElementsByTagName("a")[0].onmouseover = function(){	
		yen.getElementsByTagName("p")[0].style.display = 'block';	
	}
	
	yen.getElementsByTagName("a")[0].onmouseout = function(){
		yen.getElementsByTagName("p")[0].style.display = 'none';
	}
	
}

var SendToAFriend = {
	Init: function()
	{
		var btnEl = document.getElementById("btnSendToAFriend");
		if(btnEl == null) return;
		btnEl.onclick = function()
		{
			SendToAFriend.Call();
		};		
	},
	
	Call: function()
	{	
		var body = document.getElementsByTagName("body")[0];			
		var sizeatt = getPageSize();
		var scrollatt = getPageScroll();
		
		var bodyOverlay = document.createElement("div");
		bodyOverlay.id = "friend_bodyOverlay";
		bodyOverlay.style.height = sizeatt[1] + "px";
		
		if(navigator.userAgent.indexOf("MSIE") != -1)			
			bodyOverlay.style.width = (sizeatt[0]) + "px";					
		else		
			bodyOverlay.style.width = (sizeatt[0] - 17) + "px";	
			
		body.appendChild(bodyOverlay);
	
		var contentOverlay = document.createElement("div");
		contentOverlay.id = "friend_contentOverlay";		
		contentOverlay.style.top = scrollatt[1] + "px";
		
		var contentHolder = document.createElement("div");		
		contentHolder.id  = "friend_contentHolder";				
				
		var title = document.createElement("h3");		
		title.appendChild(document.createTextNode("Send to a friend"));
		
		var paragraph = document.createElement("p");
		paragraph.appendChild(document.createTextNode("Tell you friends about Aestivaal - just enter their details below..."));
		
		/* friends first name column */
		var friendName = document.createElement("div");
		friendName.className = "col1";
		friendName.appendChild(document.createTextNode("Your friend's first name:*"));				
		var friendNameInput = document.createElement("input");
		friendNameInput.setAttribute("type","text");
		friendNameInput.id = "txtFriendsFirstName";		
		friendName.appendChild(friendNameInput);
		
		/* friends email address column */
		var friendEmail = document.createElement("div");
		friendEmail.className = "col2";
		friendEmail.appendChild(document.createTextNode("Your friend's email address:*"));				
		var friendEmailInput = document.createElement("input");
		friendEmailInput.setAttribute("type","text");
		friendEmailInput.id = "txtFriendsEmail";		
		friendEmail.appendChild(friendEmailInput);
				
		/* your first name column */
		var yourName = document.createElement("div");
		yourName.className = "col1";
		yourName.appendChild(document.createTextNode("Your first name:*"));				
		var yourNameInput = document.createElement("input");
		yourNameInput.setAttribute("type","text");
		yourNameInput.id = "txtYourFirstName";		
		yourName.appendChild(yourNameInput);
		
		/* your email address column */
		var yourEmail = document.createElement("div");
		yourEmail.className = "col2";
		yourEmail.appendChild(document.createTextNode("Your email address:*"));				
		var yourEmailInput = document.createElement("input");
		yourEmailInput.setAttribute("type","text");
		yourEmailInput.id = "txtYourEmail";		
		yourEmail.appendChild(yourEmailInput);
				
		/* message column */
		var yourMessage = document.createElement("div");
		yourMessage.className = "col3";
		yourMessage.appendChild(document.createTextNode("Message:*"));				
		var yourMessageInput = document.createElement("textarea");		
		yourMessageInput.id = "txtEmailAFriendMessage";		
		yourMessage.appendChild(yourMessageInput);
		
		/* disclaimer and button */
		var sendDiv = document.createElement("div");
		sendDiv.className = "col4";
		var floatLeft = document.createElement("span");
		floatLeft.className = "floatLeft";
		floatLeft.appendChild(document.createTextNode("*These fields are required"));
		sendDiv.appendChild(floatLeft);
		
		var sendBtn = document.createElement("a");
		sendBtn.className = "btnSendIt";
		sendBtn.onclick = function()
		{
			SendToAFriend.Validate();
		};
		sendBtn.appendChild(document.createTextNode("Send >"));		
		sendDiv.appendChild(sendBtn);
		
		var btnClose = document.createElement("a");
		btnClose.appendChild(document.createTextNode("Close"));
		btnClose.className = "btnCloseIt";
		btnClose.onclick = function()
		{
			SendToAFriend.Close();
		};
		
		contentOverlay.appendChild(title);
		contentHolder.appendChild(paragraph);
		contentHolder.appendChild(friendName);
		contentHolder.appendChild(friendEmail);
		contentHolder.appendChild(yourName);
		contentHolder.appendChild(yourEmail);
		contentHolder.appendChild(yourMessage);		
		contentHolder.appendChild(sendDiv);				
		contentOverlay.appendChild(contentHolder);		
		contentOverlay.appendChild(btnClose);		
		body.appendChild(contentOverlay);		
	},
	Close: function()	
	{
		var body = document.getElementsByTagName("body")[0];
		var overlayToRemove = document.getElementById("friend_bodyOverlay");
		var contentToRemove = document.getElementById("friend_contentOverlay"); 
		body.removeChild(overlayToRemove);
		body.removeChild(contentToRemove);
	},
	Validate: function()
	{
		var valid = true;
		var senderName = document.getElementById("txtFriendsFirstName");
		var senderEmail = document.getElementById("txtFriendsEmail");
		var friendName = document.getElementById("txtYourFirstName");
		var friendEmail = document.getElementById("txtYourEmail");
		var theMessage = document.getElementById("txtEmailAFriendMessage");
						
		if(senderName.value == ""){
			valid = false;
			senderName.className += " error";
		} else {
			senderName.className = "";
		}
	
		if(senderEmail.value == ""){
			valid = false;
			senderEmail.className += " error";
		} 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 += " error";
			}
		} else {
			senderEmail.className = "";	
		}
		
		
		if(friendName.value == ""){
			valid = false;
			friendName.className += " error";
		} else {
			friendName.className = "";
		}
		
		if(friendEmail.value == ""){
			valid = false;
			friendEmail.className += " error";
		} 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 += " error";
			}
		} else {
			friendEmail.className = "";	
		}
		
		if(theMessage.value == ""){
			valid = false;
			theMessage.className += " error";
		} else {
			theMessage.className = "";
		}
				
		if(valid == true){	
			SendToAFriend.Submit()
		}		
	},
	Submit: function()
	{
		xmlHttp = GetXmlHttpObject();				
		var postData;
		var pageTitle = document.title;
		var pageUrl = location.href;
		var url = "/send-to-a-friend.aspx";				
		var senderName = document.getElementById("txtYourFirstName");
		var senderEmail = document.getElementById("txtYourEmail");
		var friendName = document.getElementById("txtFriendsFirstName");
		var friendEmail = document.getElementById("txtFriendsEmail");			
		var theMessage = document.getElementById("txtEmailAFriendMessage");
		
		postData += "&pageTitle=" + pageTitle;
		postData += "&pageUrl=" + pageUrl;
		postData += "&senderName=" + senderName.value;
		postData += "&senderEmail=" + senderEmail.value;
		postData += "&friendName=" + friendName.value;
		postData += "&friendEmail=" + friendEmail.value;
		postData += "&theMessage=" + theMessage.value;
		
		xmlHttp.onreadystatechange = SendToAFriend.CheckStatus;	
		xmlHttp.open("POST",url,true);	
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", postData.length);
		xmlHttp.setRequestHeader("Connection", "close");		
		xmlHttp.send(postData);		
	},
	CheckStatus: function()
	{			
		var holder = document.getElementById("friend_contentHolder");	
		if (xmlHttp.readyState == 4)
		{			
			holder.innerHTML = "<p>" + xmlHttp.responseText + "</p>";														
		} else {			
			holder.innerHTML = "<div class='col3'><img style='padding:30px 0 30px 200px' src='/media/build/ajax-loader.gif' width='32' height='32' /></div>";			
		}			
	}
}

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 hideDdls()
{
	for(i=0;i<document.getElementsByTagName("select").length;i++)
		document.getElementsByTagName("select")[i].style.visibility = "hidden";
}

function showDdls()
{
	for(i=0;i<document.getElementsByTagName("select").length;i++)
		document.getElementsByTagName("select")[i].style.visibility = "visible";
}

function hideObject()
{	
	for(i=0;i<document.getElementsByTagName("object").length;i++)
		document.getElementsByTagName("object")[i].style.visibility = "hidden";
}

function showObject()
{	
	for(i=0;i<document.getElementsByTagName("object").length;i++)
		document.getElementsByTagName("object")[i].style.visibility = "visible";
}	

function newsletterSignUp()
{	
	var validSignUp = true;
	var nameId = document.getElementById("txtNewsletterName");
	var emailId = document.getElementById("txtNewsletterEmail");
	
	if((nameId.value == "") || (nameId.value == "Enter first name"))
	{
		validSignUp = false;
		nameId.className = " error";
	}
	else
	{
		nameId.className = "";
	}
	
	if(emailId.value == "")
	{
		validSignUp = false;
		emailId.className = " error";
	} 
	else if(emailId.value != "")
	{			
		var supEmail = emailId.value;
		var emLen = supEmail.length;
		var posAt = supEmail.indexOf('@')
		var posDot = supEmail.lastIndexOf('.')
		if((emLen < 7) || (posAt < 1) || (posDot <= (posAt + 1)) || (posDot >= (emLen - 1)))
		{
			validSignUp = false;
			emailId.className = " error";
		}
		else
		{
			emailId.className = "";	
		}	
	} 
	else 
	{
		emailId.className = "";	
	}
	
	if(validSignUp == true)
	{	
		xmlHttp = GetXmlHttpObject();				
		var url = "/newsletter-signup.aspx";
			
		var signUpQuery = "";
			
		signUpQuery += "&txtSignUpName="+nameId.value + "&txtSignUpEmail=" + emailId.value;
		xmlHttp.open("POST",url,true);	
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", signUpQuery.length);
		xmlHttp.setRequestHeader("Connection", "close");
		
		xmlHttp.send(signUpQuery);		
		
		nameId.value = "Enter first name";
		emailId.value = "Enter email address";
		nameId.className = "";
		emailId.className = "";
		newsletterThanks();
	}		
}

function newsletterThanks()
{
	var body = document.getElementsByTagName("body")[0];			
	var sizeatt = getPageSize();
	var scrollatt = getPageScroll();
	
	var bodyOverlay = document.createElement("div");
	bodyOverlay.id = "friend_bodyOverlay";
	bodyOverlay.style.height = sizeatt[1] + "px";
	if(navigator.userAgent.indexOf("MSIE") != -1)			
		bodyOverlay.style.width = (sizeatt[0]) + "px";					
	else		
		bodyOverlay.style.width = (sizeatt[0] - 17) + "px";	
		
	body.appendChild(bodyOverlay);

	var contentOverlay = document.createElement("div");
	contentOverlay.id = "friend_contentOverlay";		
	contentOverlay.style.top = scrollatt[1] + "px";
	
	var contentHolder = document.createElement("div");		
	contentHolder.id  = "friend_contentHolder";				
			
	var title = document.createElement("h3");		
	title.appendChild(document.createTextNode("Aestivaal Newsletter"));
	
	var paragraph = document.createElement("p");
	paragraph.appendChild(document.createTextNode("Thank you for signing up to the Aestivaal's newsletter. You can stay up to date with the latest promotions and what's hot right now."));
	
	var btnClose = document.createElement("a");
	btnClose.appendChild(document.createTextNode("Close"));
	btnClose.className = "btnCloseIt";
	btnClose.onclick = function()
	{
		SendToAFriend.Close();
	};
	
	contentOverlay.appendChild(title);
	contentHolder.appendChild(paragraph);		
	contentOverlay.appendChild(contentHolder);		
	contentOverlay.appendChild(btnClose);		
	body.appendChild(contentOverlay);
}

function getPageScroll()
{
	var yScroll;
	if (self.pageYOffset) 
	{
		yScroll = self.pageYOffset;
	} 
	else if (document.documentElement && document.documentElement.scrollTop)
	{
		yScroll = document.documentElement.scrollTop;
	} 
	else if (document.body) 
	{
		yScroll = document.body.scrollTop;
	}
	arrayPageScroll = new Array('',yScroll); 
	return arrayPageScroll;
}

function getPageSize()
{
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) 
	{	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	}
	else if (document.body.scrollHeight > document.body.offsetHeight)
	{
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	}
	else 
	{ 
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) 
	{
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} 
	else if (document.documentElement && document.documentElement.clientHeight) 
	{
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} 
	else if (document.body) 
	{
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	
	if(yScroll < windowHeight)
	{
		pageHeight = windowHeight;
	} 
	else 
	{ 
		pageHeight = yScroll;
	}
	
	if(xScroll < windowWidth)
	{	
		pageWidth = windowWidth;
	} 
	else 
	{
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight); 
	return arrayPageSize;
}