var expdate = new Date();
expdate.setTime(expdate.getTime() + (360 * 24 * 60 * 60 * 1000));

function checkElem(theForm) {
	theElemObj = eval("document." + theForm + ".element");
	theElem = theElemObj.value;
	if (theElem == '') {
		alert("Please select a personal element before purchasing this product");
		theElemObj.focus();
		return false;
	 // block sales of out-of-stock items
	} else if (document.elemselect.newid.value == 'fscpsmetal') {
		alert("Soft Metal is not available on CASSETTE.  Please choose the CD or MP3 version or select a different element.");
		theElemObj.focus();
		return false;
	} else if (document.elemselect.newid.value == 'fscphmetal') {
		alert("Hard Metal is not available on CASSETTE.  Please choose the CD or MP3 version or select a different element.");
		theElemObj.focus();
		return false;
	} else {
		// alert(document.elemselect.newid.value);
		return true;
	}
	return false;
}

function checkElem2(theForm) {
        theElemObj = eval("document." + theForm + ".element1");
        theElem = theElemObj.value;
        if (theElem == '') {
                alert("Please select a personal element before purchasing this product");
                theElemObj.focus();
                return false;
         // block sales of out-of-stock items
        } else if (document.elemselect.newid.value == 'fscpsmetal') {
                alert("Soft Metal is not available on CASSETTE.  Please choose the CD or MP3 version or select a different element.");
                theElemObj.focus();
                return false;
        } else if (document.elemselect.newid.value == 'fscphmetal') {
                alert("Hard Metal is not available on CASSETTE.  Please choose the CD or MP3 version or select a different element.");
                theElemObj.focus();
                return false;
        } else {
                // alert(document.elemselect.newid.value);
                return true;
        }
        return false;
}


function setElem(theForm,thePrefix,theType) {
	theElemObj = eval("document." + theForm + ".element");
	theElem = theElemObj.value;
	theNewObj = eval("document." + theForm + ".newid");
	theNewObj.value = thePrefix + theElem + theType;
	// alert(document.elemselect.newid.value);
}


function checkQuiz()
{
	form = document.quiz;
	for (i=0;i<form.elements.length;i++)
	{
		if (form.elements[i].value=="")
		{
			alert('You have left a required field blank. Please fill in all required fields.');
		form.elements[i].focus();
		return false;
		}
	}
	birthYear = form.year.value;
	if (birthYear.length<4)
	{
		alert('You have not entered a 4-digit number for the birth year. Please enter a 4-digit birth year (e.g. "1967")');
		form.year.focus();
		return false;
	}
	return true;
}


function leaveSite()
{
	if(!GetCookie("fspopno"))
	{
		if(leaving) {
			 // window.open('pop-up.html','newWin','resizable=no, scrollbars=no, location=no, status=yes, history=no, width=350, height=350');
		}
	}
}


function openWind(url) {
	var viewer = window.open(url,'newWin','resizable=yes, scrollbars=yes, width=400, height=300');
	viewer.focus();
}


function showLevel(elementName) {
	if (document.getElementbyId)
		theElement = document.getElementbyId(elementName);
	else if (document.all)
		theElement = document.all[elementName];
	if (theElement.style.display == 'none' || theElement.style.display == '')
			theElement.style.display = 'block';
	else
			theElement.style.display = 'none';
}


function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}


function FixCookieDate (date) {
  var base = new Date(0);
  var skew = base.getTime(); // dawn of (Unix) time - should be 0
  if (skew > 0)  // Except on the Mac - ahead of its time
    date.setTime (date.getTime() - skew);
}


function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
	i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}


function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}


function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

