var selectedImg;
var channel;
var onChannel;
var page;
var openerURL = "";
var bgus_prodselector = "includes/updateProductReco.jsp";
var popup;
<!-- These two are very important variables and should always be set to 'N' unless there is a urgent news to be published and then either of  these should be changed to 'Y' depending on type if its link, popup or both -->

var showurgentnews_link="N";
var showurgentnews_popup="N";
////////////////////////////////////////////////////////
function openSweepstakesPopup() {
    var popup = window.open('http://www.ucanwin.com/beinggirl.nsf/contestentry?openform&src=BOLT','newWin','location=no,toolbar=no,resizable=yes,menubar=no,scrollbars=yes',width='750',height='450');
}

////////////////////////////////////////////////////////
function openNewsWindow() {
   window.open ('/urgentnews/urgentnews.html','urgentnews','scrollbars=yes,resizable=yes,width=620,height=400');
}

////////////////////////////////////////////////////////////////////////
function ReadCookie (CookieName) {
  var CookieString = document.cookie;
  var CookieSet = CookieString.split (';');
  var SetSize = CookieSet.length;
  var CookiePieces
  var ReturnValue = "";
  var x = 0;

  for (x = 0; ((x < SetSize) && (ReturnValue == "")); x++) {

    CookiePieces = CookieSet[x].split ('=');

    if (CookiePieces[0].substring (0,1) == ' ') {
		CookiePieces[0] = CookiePieces[0].substring (1, CookiePieces[0].length);
		ReturnValue="";
    }

    if (CookiePieces[0] == CookieName) {
		ReturnValue = CookiePieces[1];
    }
  }
  return ReturnValue;
}

////////////////////////////////////////////////////////////////////////
function WriteCookie (cookieName, cookieValue, expiry)
{
	var cookieExpireDate = new Date();
	var timeSinceEpoch = cookieExpireDate.getTime();
	if(!isNaN(expiry)){
		expiry = parseInt(expiry);
	}
	if(expiry) {
		expiry += timeSinceEpoch;
	}else{
		expiry = timeSinceEpoch;
	}
	cookieExpireDate.setTime(expiry);
	document.cookie = cookieName + "=" + escape (cookieValue) + "; expires=" + cookieExpireDate.toGMTString() + "; path=/";
}

////////////////////////////////////////////////////////////////////////
function checkYear(form) {    
	varyear=form.bdate_year.options[form.bdate_year.options.selectedIndex].value;
   if (varyear=="0") {
      alert("Please select birth year");
      form.bdate_year.focus();
      return false;
   }
   else {
      form.submit();
   }
}

////////////////////////////////////////////////////////////////////////
function linkTo(name) {
   if (onChannel != name )
      document.location.href = channel + "_" + name + ".jhtml";
   else
     return;
}

////////////////////////////////////////////////////////////////////////

function switchToOld(page) {
   document.location.href = page;
}
////////////////////////////////////////////////////////////////////////
function switchToYoung(page) {
   document.location.href = page;
}
////////////////////////////////////////////////////////////////////////
// image rollover functions
////////////////////////////////////////////////////////////////////////

function preLoadImages(ary) {
   var imgAry = new Array();

   for(var i=0; i<ary.length; i++) {
      imgAry[i] = new Image;
      imgAry[i].src = "../images/" + ary[i] + "_over.gif";
   }
}

///////////////////////////////////////////////////////
function mover(name) {

   if (document.images) {
      if (name != selectedImg) document.images[name].src = "../images/" + name + "_over.gif";
   }
}

///////////////////////////////////////////////////////
function mout(name) {
   if (document.images) {
      if (name != selectedImg) document.images[name].src = "../images/" + name + ".gif";
   }
}


///////////////////////////////////////////////////////
function selectDefaultImage(name) {
   if (document.images) {
      document.images[name].src = "../images/" + name + "_sel.gif";
   }

}

///////////////////////////////////////////////////////
/*
 * selectDefaultFooterImage()
 * - Update footer image using either page name or 'hash'
 *   name passed by 'selImg'.
 *
 */

function selectDefaultFooterImage(selImg) {

   var fProps = new Array();

// Create hash (object) of pages to images

   var fProps = {y_bios:     new fNavObj('aboutus'),
            y_sitemap:  new fNavObj('sitemap'),
            y_glossary: new fNavObj('glossary'),
            y_tss:      new fNavObj('TSS') };

   function fNavObj(imgName){
      this.imgName = imgName;
      this.overImg = new Image();
      this.overImg.src = "../images/y_bottombar_" + this.imgName + "_over.gif";
   }

// If name passed, use that.  Otherwise, use the name of the current doc.

   var fPageName;

   if (selImg){
     fPageName = selImg;
   } else {
     fPageName = document.location.pathname;
     fPageName = fPageName.substr(fPageName.lastIndexOf('/') + 1);
     fPageName = fPageName.substr(0, fPageName.lastIndexOf('.'));
        }

// Extra precaution against JS errors or bad function calls.

   if (fProps[fPageName] && document[fProps[fPageName].imgName])
     document[fProps[fPageName].imgName].src = fProps[fPageName].overImg.src;
}

///////////////////////////////////////////////////////
// Used for the maps in the products sections that cause an unrelated image to change
function swap_image(imgName, imgIn) {
   if (document.images) {
                var imgInSrc = "../images/" + imgIn + "_over.gif";
                if (document.images[imgName].src != imgInSrc) {
                        document.images[imgName].src = imgInSrc;
                }
   }
}


////////////////////////////////////////////////////////
function popupWindow(page, width, height) {
    var popup = window.open(page,'newWin','dependent,toolbar=no,location=no,resizable=no,menubar=no,scrollbars=0,width='+width+',height='+height);
}

////////////////////////////////////////////////////////
function resizablePopupWindow(page, width, height) {
    var popup = window.open(page,'newWin','dependent,location=no,toolbar=no,resizable=yes,menubar=no,scrollbars=yes,width='+width+',height='+height);
}

////////////////////////////////////////////////////////
function scrollablePopupWindow(page, width, height) {
    var popup = window.open(page,'newWin','dependent,location=no,toolbar=no,resizable=no,menubar=no,scrollbars=yes,width='+width+',height='+height);
}

////////////////////////////////////////////////////////
function openBannerPopup(width, height) {
    var popup = window.open('#','bannerPopup','dependent,location=no,toolbar=no,resizable=yes,menubar=no,scrollbars=yes,width='+width+',height='+height);
	
}

////////////////////////////////////////////////////////
function privacyStmt() {
   var url = "http://www.pg.com:/privacy.htm?" + document.location.href;
   if (window.opener) {
   window.open(url, 'privacy', 'dependent,toolbar=yes,location=yes,resizable=yes,menubar=yes,scrollbars=yes,status=yes');
   }
   else {
   document.location.href=url;
   return ;
   }
}
////////////////////////////////////////////////////////
function privacyStmtOld() {
   var url = "http://www.pg.com:/privacy.htm?http://www.beinggirl.com/"
   window.open(url, 'privacy', 'dependent,toolbar=yes,location=yes,resizable=yes,menubar=yes,scrollbars=yes,status=yes');
}

////////////////////////////////////////////////////////
function redirectTo(url) {
   var mesg = "You are leaving the site and you are no longer covered under P&G's Privacy and Legal Statement.";
   alert(mesg)
   document.location.href = url;
}

function redirectNewWin(url) {
   var mesg = "You are leaving the site and you are no longer covered under P&G's Privacy and Legal Statement.";
   alert(mesg);
   var popupwin = window.open(url, 'external', 'toolbar=yes,location=yes,resizable=yes,menubar=yes,scrollbars=yes,status=yes')
}

/////////////////////////////////////////////////////////
// Cookie getters and setters
function getCookie (name) {
   var dcookie = document.cookie;
   var cname = name + "=";
   var clen = dcookie.length;
   var cbegin = 0;

   while (cbegin < clen) {
      var vbegin = cbegin + cname.length;
      if (dcookie.substring(cbegin, vbegin) == cname) {
         var vend = dcookie.indexOf (";", vbegin);
         if (vend == -1) vend = clen;
            return unescape(dcookie.substring(vbegin, vend));
         }
      cbegin = dcookie.indexOf(" ", cbegin) + 1;
      if (cbegin == 0) break;
   }
   return null;
}

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




//////////////////////////////////////////////
// VALIDATION
// to validate:
// <input type="text" name="id">
// <input type="text" name="birthday">
// make:
// <input type="hidden" name="id_check" value="required:Your user id">
// <input type="hidden" name="birthday_check" value="age:Your Birthday">
// <input type="button" value="Click" onClick="validationCheckForm(this.form)">

// Go through a form, checking any field that has a xxxxx_check field.
// Builds up an alert message and displays it on error
// Submits form on success
function validationCheckForm(form) {
   var errorMessage = "";

   // Normal Fields
   for (var i = 0; i<form.elements.length; i++) {
      var nameCheck = form.elements[i].name+"_check";
      if(form.elements[nameCheck]) {
         errorMessage = errorMessage+validationCheckFormElement(form.elements[i], form.elements[nameCheck].value);
    }
  }

  if(errorMessage != "") {
    alert("Please check the following:\n\n" + errorMessage);
    return;
  } else {
    form.submit();
  }
}

// Check an individual element of a form
// Supports: required, agecheck
function validationCheckFormElement(elt, type)
{
   if(  (elt.value == "") && ((type.indexOf("required") == 0) || (type.indexOf("agecheck")==0)) ) {
      return(type.replace(/(required|agecheck):/, "") + " is required.\n");
   }

   if(type.indexOf("agecheck") == 0) {
      var birthday = elt.value.replace(/-/g, "/");        // Netscape compatibility
      var message = validationTestValidDate(birthday);
      if(message != "") { return message; }
      if(!validationIsOldEnough(birthday)) { return("You must be at least 13 to use this site.\n"); }
   }

   return "";  // Success for this element
}


// Tests if a user is older than 13
// Can accept text "June 1, 1977", slashes "6/1/77" but because of Netscape, no dashes
function validationIsOldEnough(dateString) {
   var minYears = 13;
   today = new Date();
   birthday = new Date(dateString)
   ageMseconds = (today.getTime() - birthday.getTime());
   msPerYear = 365.2422 * 24 * 60 * 60 * 1000 ;
   ageYears = (ageMseconds/msPerYear);
   return(ageYears>=minYears);
}
function validationIsOldEnoughDropdown(month, day, year) {
   return validationIsOldEnough(month+"/"+day+"/"+year);
}

// Checks for the following valid date formats:
// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY
function validationTestValidDate(dateStr) {
   var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;

   var matchArray = dateStr.match(datePat);
   if (matchArray == null) {
      return("Date is not valid. Try MM/DD/YYYY.\n")
   }

   month = matchArray[1];
   day = matchArray[3];
   year = matchArray[4];
   if (month < 1 || month > 12) {
      return("Birthday month must be between 1 and 12.\n");
   }
   if (day < 1 || day > 31) {
      return("Birthday day must be between 1 and 31.\n");
   }
   if ((month==4 || month==6 || month==9 || month==11) && day==31) {
      return("Birthday month "+month+" doesn't have 31 days!")
   }
   if (month == 2) { // Leapyear
      var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
      if (day>29 || (day==29 && !isleap)) {
         return("February " + year + " doesn't have " + day + " days.");
   }
   }
   return "";
}

// This is to verify ages
// to be used where date is input from drop down menus

function ValidateYearforAge(formObj)
{
   if (formObj.birthMonth == null) {
      var selectedMonthIndx = formObj.bdate_month.selectedIndex;
      var selectedMonth = formObj.bdate_month.options[selectedMonthIndx].value;
   } else {
      var selectedMonthIndx = formObj.birthMonth.selectedIndex;
      var selectedMonth = formObj.birthMonth.options[selectedMonthIndx].value;
   }

   if (formObj.birthDay == null) {
      var selectedDayIndx = formObj.bdate_day.selectedIndex;
      var selectedDay = formObj.bdate_day.options[selectedDayIndx].value;
   } else {
      var selectedDayIndx = formObj.birthDay.selectedIndex;
      var selectedDay = formObj.birthDay.options[selectedDayIndx].value;
   }

   if (formObj.birthYear == null) {
      var selectedYearIndx = formObj.bdate_year.selectedIndex;
      var selectedYear = formObj.bdate_year.options[selectedYearIndx].value;
   } else {
      var selectedYearIndx = formObj.birthYear.selectedIndex;
      var selectedYear = formObj.birthYear.options[selectedYearIndx].value;
   }

   var dToday = new Date();

   var tdMonth = dToday.getMonth() + 1;
   var tdDay = dToday.getDate();
   var tdYear = dToday.getFullYear();

   var iage = tdYear - selectedYear;

   if (tdMonth < selectedMonth)
      iage -= 1;
   else if (tdMonth == selectedMonth) {
      if (tdDay < selectedDay)
         iage -= 1;
   }


   if (iage < 13) {
      alert("Sorry, but you have to be 13 or older to register! (It's not our rule!)");
//    formObj.birthMonth.focus();

      document.location.href = "y_home.jhtml";
   }

}


// Used by BGcreateuser.jhtml
function BoolValidateYearforAge(formObj)
{
   if (formObj.birthMonth == null) {
      var selectedMonthIndx = formObj.bdate_month.selectedIndex;
      var selectedMonth = formObj.bdate_month.options[selectedMonthIndx].value;
   } else {
      var selectedMonthIndx = formObj.birthMonth.selectedIndex;
      var selectedMonth = formObj.birthMonth.options[selectedMonthIndx].value;
   }

   if (formObj.birthDay == null) {
      var selectedDayIndx = formObj.bdate_day.selectedIndex;
      var selectedDay = formObj.bdate_day.options[selectedDayIndx].value;
   } else {
      var selectedDayIndx = formObj.birthDay.selectedIndex;
      var selectedDay = formObj.birthDay.options[selectedDayIndx].value;
   }

   if (formObj.birthYear == null) {
      var selectedYearIndx = formObj.bdate_year.selectedIndex;
      var selectedYear = formObj.bdate_year.options[selectedYearIndx].value;
   } else {
      var selectedYearIndx = formObj.birthYear.selectedIndex;
      var selectedYear = formObj.birthYear.options[selectedYearIndx].value;
   }

   var dToday = new Date();

   var tdMonth = dToday.getMonth() + 1;
   var tdDay = dToday.getDate();
   var tdYear = dToday.getFullYear();

   var iage = tdYear - selectedYear;

   if (tdMonth < selectedMonth)
      iage -= 1;
   else if (tdMonth == selectedMonth) {
      if (tdDay < selectedDay)
         iage -= 1;
   }


   if (iage < 13)
      return "0";
   else
      return "1";
}
// END VALIDATION CODE
///////////////////////////////////////////

// code to redirect  to proper page depending upon usertype
 function enterGuest(box,olderPage,youngerPage){
      var userType = box.options[box.options.selectedIndex].value;
      if(userType.indexOf('older') != -1){
         location.href=olderPage;
      }
      else {
         location.href=youngerPage;
      }
   }

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function ctrySelect() {

   var form=document.CtrySelect;
   selIndex=form.ctryList.options.selectedIndex;
   var ctryname=form.ctryList.options[selIndex].text;
   var ctryurl=form.ctryList.options[selIndex].value;
   if (selIndex==0) {
      alert("Please select a country");
      return;
   }
   window.location.href=ctryurl;
}


///////////////////////////////////////////
// Form "double submit" code.
// Makes sure forms are only submitted once.

var clickFlag = 0;

function checkDup(){
  if (clickFlag){
    return false;
  } else {
    clickFlag = true;
    return true;
  }
}
// Function to open Always product selector

function launchalwaysps() {
popup = window.open('http://www.beinggirl.ca/en_CA/tools/product_selectors/always/selector.php','BG_PSWin','dependent=no,toolbar=no,location=no,resizable=yes,menubar=no,scrollbars=yes,width=510,height=600');
//popup = window.open('http://alwayscanada.com/ca_en/always-product-selector.php','BG_PSWin','dependent=no,toolbar=no,location=no,resizable=yes,menubar=no,scrollbars=yes,width=834,height=690');
//popup = window.open('http://www.always.com/en_us/bg_ps/pages/ps_main.shtml?pageid=ps0001&SITE=BG_US','BG_PSWin','dependent=no,toolbar=no,location=no,resizable=yes,menubar=no,scrollbars=yes,width=496,height=650');
//popup = window.open('../includes/Test _PD.html');
popup.focus();
}

// NEW function to open tampax product selector
// 2010-02-04
function launchTampaxTool() {
	popup = window.open('http://www.beinggirl.ca/en_CA/tools/product_selectors/tampax/selector.php','BG_PSWin','dependent=no,toolbar=no,location=no,resizable=yes,menubar=no,scrollbars=yes,width=510,height=600');
	popup.focus();
}

// Function to open tampax product selector
function launchtampaxps(source)
{
if (source==null) {
   tampaxps =  window.open('http://www.tampax.com/en_us/beinggirl_us_ps/pages/ps_main.shtml?pageid=ps0001','PSWin','dependent=yes,toolbar=no,location=no,resizable=yes,menubar=no,scrollbars=yes,width=496,height=500');
}
else if (source=='CYT') {
   tampaxps =  window.open('http://www.tampax.com/en_us/beinggirl_us_ps/pages/ps_main.shtml?pageid=ps0001&extlink=1','PSWin','dependent=yes,toolbar=no,location=no,resizable=yes,menubar=no,scrollbars=yes,width=496,height=500');
}
else if (source=='GI') {
   tampaxps =  window.open('http://www.tampax.com/en_us/beinggirl_us_ps/pages/ps_main.shtml?pageid=ps0001&extlink=2','PSWin','dependent=yes,toolbar=no,location=no,resizable=yes,menubar=no,scrollbars=yes,width=496,height=500');
}
else if (source=='ROTBAN') {
   tampaxps =  window.open('http://www.tampax.com/en_us/beinggirl_us_ps/pages/ps_main.shtml?pageid=ps0001&extlink=3','PSWin','dependent=yes,toolbar=no,location=no,resizable=yes,menubar=no,scrollbars=yes,width=496,height=500');
}
tampaxps.focus()
}

function showAgain(cookieName,maxCount) {

   var thisYear = new Date();

   var cookieCount = ReadCookie(cookieName + "Count");

   var nCookieCount = 0;

   if (cookieCount == null || cookieCount == "" || isNaN(cookieCount)) {
      nCookieCount = 1;
   }
   else {
      nCookieCount = parseInt(cookieCount) + 1;
   }

   thisYear.setFullYear(thisYear.getFullYear() + 1);

   if (ReadCookie("show" + cookieName) == null || ReadCookie("show" + cookieName).indexOf("n") == -1) {
      setCookie(cookieName + "Count",nCookieCount,thisYear,"/","","");
      return true;
   }

   if (nCookieCount >= maxCount && ReadCookie("show" + cookieName).indexOf("n") == -1) {
      setCookie("show" + cookieName,"n",thisYear,"/","","");
   }

   return false;
}

////////////////////////////////////////////////////////
function linkBanner(bannerId, launchAction, target_url, title) 
{
   	var windowWidth = 400;
   	var windowHeight = 400;
   	if(bannerId == "BAN1") 
   	{
   		var lc="click.php?bannerid="+bannerId;
		document.images.bannerpixel.src=lc;
   		//var popup = target_url
      		var popup = window.open('http://alwayscanada.com/ca_en/always-product-selector.php','BG_PSWin','dependent=no,toolbar=no,location=no,resizable=yes,menubar=no,scrollbars=yes,width=496,height=650');
      		return;
   	}else 
   	{
   		switch(launchAction)
   		{
   		case 1:  		
      			document.location.href=target_url;
   			var lc="click.php?bannerid="+bannerId;
			document.images.bannerpixel.src=lc; 			
      			break;
   		case 2:
      			var popup = window.open(target_url,'bannerPopup');
      		   	var lc="click.php?bannerid="+bannerId;
			document.images.bannerpixel.src=lc;	
      			break;
   		case 3:
      			var popup = window.open(target_url,'bannerPopup','dependent,location=no,toolbar=no,resizable=yes,menubar=no,scrollbars=yes,width='+windowWidth+',height='+windowHeight);
      		   	var lc="click.php?bannerid="+bannerId;
			document.images.bannerpixel.src=lc;	
      			break;
   		}
   	}
}

//***************************************************
// This Function is used by ContactUs page
// Developed by Ajay Singh
// Date: 01-04-2005
//***************************************************
  var eachElem = 0;
  var eachTemp = 0;
  function validateFrmElement(frm)
  {
   //var frm = document.contactus;
   var errFlag = 0;

   var emailReg = /^[a-zA-Z0-9]+([\w.-]?[a-zA-Z0-9]+)*\@[a-zA-Z0-9]+([\w-]*\.[\w-]*[a-zA-Z0-9]+)+$/

     for(eachElem=0;eachElem<frm.elements.length; eachElem++)
     {
      if(frm.elements[eachElem].type!="hidden")
      {
        if(frm.elements[eachElem].type=="radio"){
          if(validateCheckBox(frm)){
            errFlag = 1;
            alert("Creative Expression, Embarrassing Moment or Slumber Party cannot be empty");
            frm.elements[eachElem].focus();
            break;
          }
        }
        else if(frm.elements[eachElem].type == "select-one" && frm.elements[eachElem].value==""){
             errFlag = 1;
         alert("Please select " + frm.elements[eachElem].title );
         frm.elements[eachElem].focus();
         break;
        }
        else if(frm.elements[eachElem].value=="" && !frm.elements[eachElem].name.match("address|city|state") ){
         errFlag = 1;
         alert(frm.elements[eachElem].title + " cannot be empty");
         frm.elements[eachElem].focus();
         break;
        }else if ((frm.elements[eachElem].name=="email") && !emailReg.test(frm.elements[eachElem].value))
         {
            errFlag = 1;
            alert(frm.elements[eachElem].title + " is not valid")
            frm.elements[eachElem].focus();
           break;
         }else if ((frm.elements[eachElem].name=="friendEmail" || frm.elements[eachElem].name=="senderEmail") && !emailReg.test(frm.elements[eachElem].value))
         {
            errFlag = 1;
            alert(frm.elements[eachElem].title + " is not valid")
            frm.elements[eachElem].focus();
           break;
         }
      }
     }

   if (errFlag == 0)
   {
      frm.submit();
   }
  }

  function validateCheckBox(frm)
  {
  var  checkFlag = 1;
  var tempCheck = 0;
     for(;eachElem<frm.elements.length; eachElem++)
     {
      if(frm.elements[eachElem].type=="radio"){
//       alert(frm.elements[eachElem].type + " " + frm.elements[eachElem].name);
          if(frm.elements[eachElem].checked){
            checkFlag=0;
            tempCheck = eachElem;
          }else{
             tempCheck = eachElem;
          }
      }
     }
   eachElem = tempCheck;
   return checkFlag;
     //eachElem = frmObj.length - 1; // to start form next element noit from the radio or check box array element.
  }

//***************************************************
// This Function is used by ContactUs page
// Developed by Ajay Singh
// Date: 01-04-2005
//***************************************************

function searchAgain(spelling_suggestion) {
   spelling_suggestion = spelling_suggestion.replace('<b>', '');
   spelling_suggestion = spelling_suggestion.replace('<i>', '');
   spelling_suggestion = spelling_suggestion.replace('<\/b>', '');
   spelling_suggestion = spelling_suggestion.replace('<\/i>', '');
   document.formSearchAgain[0].searchText.value=spelling_suggestion;
   document.formSearchAgain[0].submit();
}



/*
  function validateFrmElement(frm)
  {
   //var frm = document.expression;
   var errFlag = 0;
   var checkFlag = 1;
   var eachElem = 0;

     for(eachElem=0;eachElem<frm.elements.length; eachElem++)
     {
      if(frm.elements[eachElem].type!="hidden")
      {
        if(frm.elements[eachElem].type=="radio"){
          checkFlag = validateCheckBox(frm.elements[eachElem], checkFlag)
        }
        else if(frm.elements[eachElem].value=="" && frm.elements[eachElem].name=="title"){
         errFlag = 1;
         alert("Title cannot be empty");
        }
        else if(frm.elements[eachElem].value==""  && frm.elements[eachElem].name=="shortDesc" ){
         errFlag = 1;
         alert("Short Description cannot be empty");
        }
        else if(frm.elements[eachElem].value=="" && frm.elements[eachElem].name=="contentBody"){
         errFlag = 1;
         alert("Story cannot be empty");
        }
      }

      if(errFlag)
         break;
     }
   if(checkFlag){
      errFlag = 1;
      alert("Expression cannot be empty");
   }
   if (errFlag == 0)
   {
      frm.submit();
   }
  }
*/
function preloadImages() {
    if (document.images) {

      image_1_over = new Image();
      image_1_over.src = "../images/shell/btn_prod_ultrathin_on.gif";

      image_2_over = new Image();
      image_2_over.src = " ../images/shell/btn_prod_ultrathinwings_on.gif";

     image_3_over = new Image();
      image_3_over.src = " ../images/shell/btn_prod_maxi_on.gif";

     image_4_over = new Image();
      image_4_over.src = " ../images/shell/btn_prod_maxiwings_on.gif";

     image_5_over = new Image();
      image_5_over.src = " ../images/shell/co_prod_pt_ultrathin.gif";

     image_6_over = new Image();
      image_6_over.src = " ../images/shell/co_prod_pt_ultrathinwings.gif";

     image_7_over = new Image();
      image_7_over.src = " ../images/shell/co_prod_pt_maxi.gif";

     image_8_over = new Image();
      image_8_over.src = " ../images/shell/co_prod_pt_maxiwings.gif";
    }
  }

  image_1 = new Image();
  image_2 = new Image();
  imageSwapped = 0;

  function swapImage(swapOne, swapTwo, swapWithOne, swapWithTwo){
    if (imageSwapped){
      document[image_1_name].src = image_1.src;
      document[image_2_name].src = image_2.src;

      imageSwapped = 0;
    }
    else {

      image_1.src = document[swapOne].src;
      image_2.src = document[swapTwo].src;

      image_1_name = swapOne;
      image_2_name = swapTwo;

      document[swapOne].src = swapWithOne;
      document[swapTwo].src = swapWithTwo;

      imageSwapped = 1;
    }
  }
  function openVideo()

 {
   var win  = window.open('../pages/insert.php','','width=350,height=325,toolbar=0,resizable=1');
 }

function  showProduct(pid){

   var obj = document.getElementById(pid);

// for(i=0; )
   obj.style.display='';
   document.getElementById("spacer").style.display="none";

/*
   if(obj.firstChild)
   {
      //alert('in first');
      if ( obj.style.display == 'none')
      obj.style.display='';
   }if(obj.nextSibling){
      obj.previousSibling.style.display='none';
      //alert('in next');
   }if(obj.previousSibling){
      obj.previousSibling.style.display='none';
   }
   if(obj.lastChild){
      obj.previousSibling.style.display='none';
      obj.nextSibling.style.display='none';
   }
   */
  }

function  hideProduct(pid){
   document.getElementById(pid).style.display="none";
   document.getElementById("spacer").style.display="";
}


//used by left_nav
function submitLink(type, page, neww)
{
//  var frm=document.left_nav;
  //frm.cpage.value=type;
  //frm.action=page;
  //frm.submit();
  if(!neww)
  {
  	document.location=page;
  }else{
	window.open(page);  
  }
}


  function selectLeftNav(itemToSelect){
     alert(itemToSelect);
    var getParentIDs= itemToSelect.split(/d/);

    alert("after"+getParentIDs);
      var styleObj = document.getElementsByName(itemToSelect);
      alert(styleObj.length)
    //var styleObj = document.getElementById(itemToSelect);
    if(styleObj){
       for(i=0; i<styleObj.length; i++)
          styleObj[i].style.display="";
      }
  }


/*********************************************************************
   Function Name :popupNewWindow()
   Purpose       :
   Input         :
   Output        :
   Description   :

**********************************************************************/
function popupNewWindow(winName,page, width, height, isResize,isScroll)
{
   var resize,toolbar,menubar,loc,scroll,top,left;
   var name = 'newWin';
   scroll = 'yes';

   top = screen.availHeight/2 - height/2;
   left =  screen.availWidth/2 - width/2;
   //alert("Top , left"+top+","+left);
   var imgFilename;

   if (winName == '')
   {
      name = 'popWin';
   }
   else
   {
      name = winName;
   }
   var reg = /\?(.*)&(.*)$/;
   imgFilename  = reg.exec(page);

   if (!imgFilename)
   {
      imgFilename = new Array();
      imgFilename[0]= '';
      imgFilename[1]= '';
   }

   if ( isResize )
   {
     resize = 'yes';
     toolbar = 'yes';
     menubar = 'yes'
     loc = 'yes'
    }
    else
    {
       resize = 'no';
       toolbar = 'no';
       menubar = 'no'
       loc = 'no'

    }
    if (isScroll)
    {
        scroll = 'no';
    }
    //var _params = "width="+width+",height="+height+",resizable=no,status=yes";
    var _params = 'dependent,toolbar='+ toolbar +',location=' + loc +',resizable='+ resize + ',menubar='+ menubar+',scrollbars='+ scroll +',width='+width+',height='+height+', top='+top+', left='+left ;

    closePopup();

   //alert(page);

//return;

//End of the change

    popup = window.open(page, name, _params);


/*
   //popup.resizeTo(width+10,height);
   if ( popup!=null && !(IE && bVer<5) )
      popup.focus(); // MSIE4 DOESN'T FOCUS WINDOWS
*/

}

/*********************************************************************
   Function Name :closePopup()
   Purpose       :To close the popup if already open
   Input         : None
   Output        : None
   Description   :

**********************************************************************/
function closePopup()
{
   if ( popup )                     // If popup is already created
   {
         popup.close();             // Close the popup
   }
}

/***************************************************************/
//Used by Poll
/**************************************************************/

var optionchecked="N";
var alertmsg="N";	
function validate(pollForm){		
	for(i=0; i < pollForm.R1.length; i++){
		if(pollForm.R1[i].checked){
			optionchecked="Y";
			var a = "../includes/pollresults_update.jsp?update=y";
		}
	}
  if (optionchecked=="N") {
	alert("Please select a option");
	alertmsg="Y";
	return false;
  }
  return true;
}
/////////////////////////////

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}