  function NewWindow(mypage, myname, w, h, scroll) { 
  var winl = (screen.width - w) / 2; 
  var wint = (screen.height - h) / 2; 
  winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no' 
  win = window.open(mypage, myname, winprops) 
  if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); } 
  } 


function openPopUpWin(a1, a2, a3, a4) {

	var aWnd = window.open("tellafriend-popup.html?a1=" + escape(a1) + "&a2=" + escape(a2) + "&a3=" + escape(a3) + "&a4=" + escape(a4),
	                       "WNDEMAILTOFRIEND",
	                       "status=no,border=no,menu=no,height=300,width=400");
	aWnd.focus();
}

function ValidateEmail() {
       emailEntered = document.forms[0].email_address.value;
       isValid = true;
       if (emailEntered.indexOf("@") < 1)
               isValid = false;
       else if (emailEntered.indexOf(".") < 1)
               isValid = false;
       else if (emailEntered.indexOf("@") > emailEntered.indexOf("."))
               isValid = false;
       else if (emailEntered.length < 7)
               isValid = false;
       
       if (!isValid)
               alert("Please enter a valid email address!");
       else
               document.forms[0].submit();
}
var AdditionalImages = new Array();
var CurrentMainImage = "";

function ShowAdditionalImage(id, idx)
{
  if (AdditionalImages[id] && AdditionalImages[id].length > 0)
  {
    if (document.images['img_' + id])
    {
        if (CurrentMainImage == "")
            CurrentMainImage = document.images['img_' + id].src;
        document.images['img_' + id].src = AdditionalImages[id][idx];
    }
  }
}

function RestoreMainImage(id)
{
    if (CurrentMainImage != "" && document.images['img_' + id])
    {
      document.images['img_' + id].src = CurrentMainImage;
      CurrentMainImage = "";
    }
}

function UpdateOptions(sel, idx) 
{
	if (document.getElementById) 
	{ 
		var OptDiv = document.getElementById("Options" + idx); 
		if (OptDiv) 
		{
			// remove all nodes
			while (OptDiv.firstChild)
			{
				var x = OptDiv.removeChild(OptDiv.firstChild);
				x = null;
			} 
			
			// generate drop-downs
			var ID = sel.options[sel.selectedIndex].value.toUpperCase();
			if (SelectOptions[ID])
			{
				for (i = 0; i < SelectOptions[ID].length; i++)
				{
					OptParts = SelectOptions[ID][i].split("|");
					var OptName = "vwattr" + idx + "_" + OptParts[0];
					var SelectElem = document.createElement('select');
					
					if (OptParts[0] == "Select Main Color")
					{
						SelectElem.onchange = new Function("ChangeTrims('" + ID + "',this)");
					}
					SelectElem.name = OptName;
					for (j = 0; j < OptParts.length; j++)
					{
						var OneOpt = new Option(OptParts[j], j == 0 ? "#" : OptParts[j]);
						SelectElem.options[SelectElem.options.length] = OneOpt;
					}
					OptDiv.appendChild(SelectElem);
				}
			}
		} 
	} 
}