function openTerms()
{
	newwin = window.open("terms.html","terms","width=505,height=400,scrollbars=yes");
}

function openPrivacy()
{
	newwin = window.open("privacy.html","terms","width=505,height=400,scrollbars=yes");
}

function openTerms2()
{
	newwin = window.open("boutique/terms.html","terms","width=505,height=400,scrollbars=yes");
}

function openPrivacy2()
{
	newwin = window.open("boutique/privacy.html","terms","width=505,height=400,scrollbars=yes");
}

function openMap()
{
	newwin = window.open("map.html","terms","width=476,height=479,scrollbars=no");
}

function defineBrowser()
{
	if (navigator.appName.indexOf('Microsoft') != -1)
	{
		browser = "IE";
	}
	
	else if (navigator.appName.indexOf('Netscape') != -1)
	{
		browser = "Netscape";
	}
	
	isMac = (navigator.userAgent.indexOf("Mac") != -1) ? true : false;	 
	InMotion = false;
	toFade = false;
}

defineBrowser();


function importXML()
{	
	if (window.ActiveXObject)
	{
		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async=false;
		xmlDoc.load("brands.xml");
	}
	else if (document.implementation && document.implementation.createDocument)
	{
		xmlDoc=document.implementation.createDocument("","",null);
		xmlDoc.load("brands.xml");
	}
}

importXML();


function navOver(imgName)
{
	var theImage = document.getElementById(imgName);
	if(theImage.src.indexOf("_off.gif") != -1)
	{
		theImage.src = theImage.src.replace("_off.gif","_on.gif");
	}
	else
	{
		theImage.src = theImage.src.replace("_on.gif","_off.gif");
	}
}

function hideOpacity(Id)
{
	var theId = document.getElementById(Id);
	
	// change this to if(!isMac) after texting
	// if (!isMac)	
	
	if(!isMac)
	{
		if(theId.src.indexOf("opacitybg.gif") != -1)
		{
			theId.src = theId.src.replace("opacitybg.gif","clear.gif");
		}
		else
		{
			theId.src = theId.src.replace("clear.gif","opacitybg.gif");
		}
	}
	
	if(isMac)
	{		
		if(theId.src.indexOf("up.png") != -1)
		{
			theId.src = theId.src.replace("up.png","clear.gif");
		}
		else
		{
			theId.src = theId.src.replace("clear.gif","up.png");
		}	
	}	
	
}

function displayImage(Id)
{				
	if(InMotion == false)
	{				
		var theId = document.getElementById(Id);	
		var opacity = Id+"_thumbnail";		
		var getOpacity = document.getElementById(opacity);
							
		if(theId.src.indexOf("clear.gif") != -1)
		{						
			theId.src = "images/thumbborder.gif";
	
			getOpacity.style.opacity = 1;			
			getOpacity.style.filter = 'alpha(opacity=' + 100 + ')';											
			
			for(i=0;i<productList.length;i++)
			{				
				// if this IS the current product 
				if(productList[i] != Id)
	
				{
					var imgId = document.getElementById(productList[i]);				
					var mainImage = document.getElementById(productList[i]+"_mainImage");
								
					
					var comOpacity = productList[i]+"_thumbnail";
					var resetOpacity = document.getElementById(comOpacity);				
					
					if(isMac)
					{
						imgId.src = "images/up.png";
					}
					else
					{					
						imgId.src = "images/opacitybg.gif";
						resetOpacity.style.opacity = 0.6;			
						resetOpacity.style.filter = 'alpha(opacity=' + 60 + ')';																			
					}	
																															;		
				}	
			}	
			
			fadeOption(Id);													
		}				
	}
}	

function fadeOption(productID)
{
	var elementID = document.getElementById(productID+"_mainImage");	

	if(elementID.style.display == "none")	
	{	
		elementID.style.display = "inline";
		elementID.style.opacity = 0;	
		elementID.style.filter = 'alpha(opacity=' + 0 * 100 + ')';			
			
		fadeInImage(productID);		
		InMotion = true;		
	}
}

function fadeInImage(productID) 
{		
	var newImage = document.getElementById(productID+"_mainImage");				
	var currentOpacity = parseFloat(newImage.style.opacity) + 0.1;		
	
	newImage.style.opacity = currentOpacity;	
	newImage.style.filter = 'alpha(opacity=' + currentOpacity * 100 + ')';			

	for(i=0;i<productList.length;i++)
	{
		var theId = productList[i];	
		if(productID != theId)
		{	
			fadeOutImage(productList[i]);					
		}
	}
	
	if(currentOpacity < parseFloat(90/100))
	{			
		InMotion = true;
		setTimeout('fadeInImage("'+productID+'")',40);
	}
	else
	{
		InMotion = false;
	}		
}

function fadeOutImage(productID) 
{
	var theMenu = document.getElementById(productID+"_mainImage");				
	var newOpacity = parseFloat(theMenu.style.opacity) - 0.1;	
	
	theMenu.style.opacity = newOpacity;	
	theMenu.style.filter = 'alpha(opacity=' + newOpacity * 100 + ')';			

	if(newOpacity > parseFloat(20/100))
	{		
		InMotion = true;	
		setTimeout('fadeOutImage("' + productID + '")',40);
	}
	else
	{
		theMenu.style.display = "none";
	}
}

function showImage(productID)
{
	var newImage = document.getElementById(productID+"_mainImage");	
	
	for(i=0;i<productList.length;i++)
	{
		var theId = productList[i];
		if(productID != theId)
		{	
			document.getElementById(productList[i]).style.display = "none";
		}		
	}	
	newImage.style.display = "inline";
}

/* validation*/
function validateForm(theForm)
{

     valid = true;

     message = "Please enter:\n\n";
	 
     if(theForm.elements["title"].value == "")
     {
      message += "Your title\n";
      valid = false;
     }

     if(theForm.elements["firstname"].value == "")
     {
      message += "Your first name\n";
      valid = false;
     }

     if(theForm.elements["surname"].value == "")
     {
      message += "Your surname\n";
      valid = false;
     }
      	  
	if(theForm.elements["email"].value == "")
    {
    	message += "Your email address\n";
    	valid = false;
    }

	if(theForm.elements["email"].value != "")
	{
		 var supEmail = theForm.elements["email"].value;
		 var emLen = supEmail.length;
		 var posAt = supEmail.indexOf('@')
		 var posDot = supEmail.lastIndexOf('.')
		 if((emLen < 7) || (posAt < 1) || (posDot <= (posAt + 1)) || (posDot >= (emLen - 1)))
		 {
		  message += "Valid email address\n";
		  valid = false;
		 }
	}	
		 
     if(valid)
     {
      return true;
     }


     else
     {
      alert(message);
      return false;
     }
}



function changeBorder(id)
{		
	document.getElementById(id).style.borderColor = "#000000";											
	document.getElementById(id).style.backgroundColor = "#f7f7f7";
}
function resetBorder(id)
{		
	document.getElementById(id).style.borderColor = "#7e9eb7";
	document.getElementById(id).style.backgroundColor = "#ffffff";									
}			
