ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false

function show(id) {
	if (ns4) document.layers[id].visibility = "show"
	else if (ie4) document.all[id].style.visibility = "visible"
	else document.getElementById(id).style.visibility = "visible"
}

function hide(id) {
	if (ns4) document.layers[id].visibility = "hide"
	else if (ie4) document.all[id].style.visibility = "hidden"
	else document.getElementById(id).style.visibility = "hidden"
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		ram_home4_o = newImage("/images/ram_home4_o.gif");
		ram_home5_o = newImage("/images/ram_home5_o.gif");
		ram_home6_o = newImage("/images/ram_home6_o.gif");
		ram_home7_o = newImage("/images/ram_home7_o.gif");
		ram_home8_o = newImage("/images/ram_home8_o.gif");
		ram_home16_o = newImage("/images/ram_home16_o.gif");
		ram_home17_o = newImage("/images/ram_home17_o.gif");
		ram_home17_o026 = newImage("/images/ram_home17_o-26.gif");
		ram_home18_o = newImage("/images/ram_home18_o.gif");
		
		ram_looknav5_o = newImage("/images/ram_looknav5_o.gif");
		ram_looknav7_o = newImage("/images/ram_looknav7_o.gif");
		ram_looknav9_o = newImage("/images/ram_looknav9_o.gif");
		ram_looknav11_o = newImage("/images/ram_looknav11_o.gif");

		ram_thinknav6_o = newImage("/images/ram_thinknav6_o.gif");
		ram_thinknav9_o = newImage("/images/ram_thinknav9_o.gif");
		ram_thinknav10_o = newImage("/images/ram_thinknav10_o.gif");

		preloadFlag = true;
	}
}




//-------------------------------------------------------------------------------
// shareAPagePopUp()
//-------------------------------------------------------------------------------
// Purpose:
//   Create share a page popup
//
// Parameters:
//
//------------------------------------------------------------------------------
function shareAPagePopUp(page, pagetitle) {
        url = "/sharethispage.asp?sPage=" + page + "&sPageTitle=" + pagetitle;
	sharePop = window.open(url,'window','height=620,width=398,scrollbars=no,resizable=no,status=no,menubar=no,toolbar=no,location=no');
}

//-------------------------------------------------------------------------------
// productPopUp()
//-------------------------------------------------------------------------------
// Purpose:
//   Create product popup
//
// Parameters:
//   name of the page to open
//
//------------------------------------------------------------------------------
function productPopUp(pagename) {
	productPop = window.open(pagename,'window','height=500,width=600,scrollbars=no,resizable=no,status=no,menubar=no,toolbar=no,location=no');
}

//-------------------------------------------------------------------------------
// openDermLocator()
//-------------------------------------------------------------------------------
// Purpose:
//   open derm locator window
//
// Parameters:
//
//------------------------------------------------------------------------------
function openDermLocator() {
	outlinkWin = window.open('/outlinkmssg.asp?copy=We+are+now+directing+you+to+the+American+Academy+of+Dermatology\'s+Web+site+where+Retin-A+Micro\'s+Privacy+Policy+does+not+apply.&link=http://www.aad.org/public/searchderm.html','outlink','width=270,height=180,scrollbars=yes,resizable=yes,status=no,menubar=no,toolbar=no');
}

//-------------------------------------------------------------------------------
// openAcrobatDownload()
//-------------------------------------------------------------------------------
// Purpose:
//   open Acrobat Download window
//
// Parameters:
//
//------------------------------------------------------------------------------
function openAcrobatDownload() {
	outlinkWin = window.open('/outlinkmssg.asp?copy=This+link+will+take+you+to+a+website+to+which+our+Privacy+Policy+does+not+apply.+You+are+solely+responsible+for+your+interactions+with+such+websites.&link=http://www.adobe.com/products/acrobat/readstep.html','outlink','width=260,height=180,scrollbars=yes,resizable=yes,status=no,menubar=no,toolbar=no');
}

//-------------------------------------------------------------------------------
// openAboutOurCompany()
//-------------------------------------------------------------------------------
// Purpose:
//   open Acrobat Download window
//
// Parameters:
//
//------------------------------------------------------------------------------
function openAboutOurCompany() {
	outlinkWin = window.open('/outlinkmssg.asp?copy=This+link+will+take+you+to+a+website+to+which+our+Privacy+Policy+does+not+apply.+You+are+solely+responsible+for+your+interactions+with+such+websites.&link=http://orthoneutrogena.com','outlink','width=260,height=180,scrollbars=yes,resizable=yes,status=yes,menubar=yes,toolbar=yes');
}

//-------------------------------------------------------------------------------
// CheckAge()
//-------------------------------------------------------------------------------
// Purpose:
//   On Ask form, check if age is valid
//
// Parameters:
//	 submit bit
//
//-------------------------------------------------------------------------------
function CheckAge(submit){

	var sErrMessage;
	var iAge;
	var Err;
	sErrMessage = "We're sorry, but Neutrogena.com does not collect personally identifiable information from children under age 13. \n\n We encourage you to visit the areas of our site that do not require personally identifiable information. \n\n Clicking OK will take you to the Neutrogena.com home page.";
	validInput = /^[1-9]([0-9]*)$/
	
	iAge = document.forms[0].sAge.value;

	if (document.forms[0].VerifyAge.value == 1) {
		fMon = document.forms[0].iMonth.options[document.forms[0].iMonth.selectedIndex].value;
		fDay =  document.forms[0].iDay.options[document.forms[0].iDay.selectedIndex].text;
		fYr = document.forms[0].lYear.value;

		if (fMon != "" && fDay != "" && fYr != "") {
//alert("a0");
			mydate = new Date();
			mon = mydate.getMonth() + 1;
			day = mydate.getDate();
			yr = mydate.getFullYear();

			if ((yr - fYr < 13 || fYr > yr || !validInput.test(fYr)))  {
			    Err = 1
//alert("a1");
			} else if (yr - fYr == 13) {
				if (mon < fMon) {
//alert("b1");
					Err = 1
				} else if (mon == fMon && fDay > day) {
//alert("c1");
					Err = 1
				}
			}
		}
	}

	if (!validInput.test(iAge) && iAge != "") {
		document.forms[0].sAge.value = "";
		document.forms[0].sAge.text = "";
	} else {

		if (iAge <= 12 && iAge != ""){
			Err = 1
//alert("a");
		} else if (submit == "2") {
		document.forms[0].submit();
		} else if (submit == "1") {
//alert("b");

          mydate = new Date();
		  mon = mydate.getMonth() + 1;
		  day = mydate.getDate();
		  yr = mydate.getFullYear();
		  nAge = 0;

          
          if (fMon > mon) {
                nAge = -1;
          }
          if (fMon == mon) {
               if (fDay > day) {
                 nAge = -1;
               }
          } 
          userAge = yr - fYr;
          userAge = userAge + nAge;
          if (userAge != iAge) {
             alert("Your Age and Date of Birth do not match.  Please provide the correct information and re-submit the form.");
          } else {
             document.forms[0].submit();
          }
		
		}
	}

	if (Err == 1) {
		alert(sErrMessage);
		document.forms[0].sAge.value = "";
		document.forms[0].sAge.text = "";
			
		//Redirect them to an intermediate page where the under 13 cookie will be set
		window.location.href = "/AgeRedirect.asp";
		document.forms[0].VerifyAge.value = 0
	}	
}


function coppaPopup() {
	passwordWin = window.open('/RetinamicroCOPPA.asp','window','width=300,height=225,scrollbars=no,resizable=yes,status=yes,menubar=no,toolbar=no'); passwordWin.focus();
}
