// JScript File

// BazzarVoice script
function ratingsDisplayed(totalReviewsCount, avgRating, ratingsOnlyReviewCount, recommendPercentage, productID)
{
    if (totalReviewsCount == 0) {
        var bvRevCntr = document.getElementById("BVReviewsContainer");
        var bvSVPLink = document.getElementById("BVSVPLinkContainer");
        
        if (bvRevCntr) { bvRevCntr.style.display = "none"; }
        if (bvSVPLink) { bvSVPLink.style.display = "none"; }
    }
    // Other custom items leveraging these values.
    // TODO: insert Web Analytics tracking here
}

//show - hide divs used for sub menus
function ShowHideDiv(div_id,src_id,src_name,src_extn)
{
   
   var ele = document.getElementById(div_id);
   var img = document.getElementById(src_id);
   var img_src = img.src;
   var img_src_arr = img_src.split("/");
   var img_src_arr_len =  img_src_arr.length;
   
   if(img_src_arr[img_src_arr_len-1] == src_name+"_plus."+src_extn)
   {
     ele.style.display = "block";  
     img_src_arr[img_src_arr_len-1] = src_name+"_minus."+src_extn;
     img.src = img_src_arr.join("/");
     img.alt = "Hide Details";
     img.title = "Hide Details";
   }
   else
   if(img_src_arr[img_src_arr_len-1] == src_name+"_minus."+src_extn)
   {
     ele.style.display = "none";
     img_src_arr[img_src_arr_len-1] = src_name+"_plus."+src_extn;
     img.src = img_src_arr.join("/");
     img.alt = "Show Details";
     img.title = "Show Details";
  
     
   }
   
  
    
}

function sortNumber(a, b)
{
 return a - b;
}

function getPeriodDay(clickedDay,startDay)
{
   //alert(clickedDay+','+startDay);
   
   if( clickedDay > startDay )
   {
        value =  clickedDay - startDay + 1;
        
        if( value >  pfrequency)
        {
            value =  value - pfrequency;
        }
        
        return value;
   }
   else
   if( clickedDay == startDay )
   {
      return 1;
   }
   else
   if( clickedDay < startDay )
   {
        if( pfrequency < (startDay - clickedDay) )
        {
                startDay =  startDay - pfrequency;
                
        }
        
           return (pfrequency - (startDay - clickedDay) +1); 
        
   
       
   }
   
}

function show_day_text_one(day)
{
var result = getPeriodDay(day,monthoneDayone);
showWhatToExpect(result);

              
}
            
function show_day_text_two(day)
{
var result = getPeriodDay(day,monthtwoDayone);
showWhatToExpect(result);
                
}
function show_day_text_three(day)
{
var result = getPeriodDay(day,monththreeDayone);
showWhatToExpect(result);


}


function showWhatToExpect( Day ){
	
	
	
	if( Day < 1 || Day > 28 ) return false;
	
	var WhatToExpect = new Array( 
		"Ok, here we go. This is when your period and your cycle starts.<br \/><br \/>Bleeding begins as your womb lining is shed.",
		"Emotionally, you’ll feel more chilled than you have for days as your hormone levels drop.<br \/><br \/>No more PMS for 28 days.<br \/><br \/> Bliss!",
		"You can expect 13 periods each year and 500 in your lifetime.<br \/><br \/>Sounds like a lot? You’ll be ok.",
		"Each period contains up to 90 ml of blood.<br \/><br \/>But remember, you’re unique, so it’s different for every girl.",
		"You may find you get your period at the same time as your mom, sister, or best friend.<br \/><br \/>Somehow we seem to synchronize with women we’re close to.",
		"Periods can last from three to eight days, but five or six days is average.<br \/><br \/>By now your Monthly Gift should be much lighter.",
		"Your period is ending, your hormones are regulating, and you’re feeling more sociable.<br \/><br \/>A good time for a party, or even a hot date.",
		"Soaring energy levels, ahoy!<br \/><br \/>Your body’s preparing to ovulate — in other words to release an egg.<br \/><br \/>Happy days.",
		"You’re at your least hormonal now, the perfect time for serious, level-headed chats.<br \/><br \/>(“Mom, I’ve been thinking...”)",
		"Around this time, levels of the female hormone estrogen begin to rise.<br \/><br \/>This stimulates the growth of an egg within one of your ovaries.",
		"You may notice that your vagina starts to secrete thin, clear mucus.<br \/><br \/>This helps make it easier for sperm to pass into the womb and fertilize an egg.",
		"A rise in estrogen (the female hormone) means you feel flirty and confident.<br \/><br \/>Make the most of it, girl!",
		"Getting slight cramps in the lower abdomen?<br \/><br \/>No worries, this is your body preparing to release an egg.",
		"About now you’ll be ovulating, so you’re very fertile.<br \/><br \/>But you need to use contraception all month round if you’re having sex.",
		"If you’re feeling a tad warmer that’s because your body temperature rises by about one degree centigrade after ovulation. This is another female hormone at work, progesterone.",
		"Don’t fret if you have thicker vaginal discharge that’s yellow or white.<br \/><br \/>It’s totally normal and is easily washed out of your underwear.",
		"Yes, you can have a period without ovulating, especially if you’ve only recently started.<br \/><br \/>But ovulation does occur in most cycles.",
		"Tender breasts alert! It’s because your body is producing more progesterone now. It also makes the lining of your womb thick and spongy.",
		"If the egg isn’t fertilized, your body gradually stops producing estrogen and progesterone.",
		"Uh-oh, PMS. Headaches, bloating, irritability and tearfulness all make their presence felt. But some gals don’t seem to suffer at all. Huh, alright for some.",
		"You may feel a bit edgy and more emotional than usual.",
		"Levels of serotonin, your brain’s ‘happy chemical’ dip around now.<br \/><br \/>Luckily, you can find the same sort of thing in chocolate. God is female!",
		"Hormonal changes may affect your judgment and could make you more upset or angry.<br \/><br \/>Avoid big decisions and lay off any heavy-duty shopping.",
		"At this point in your cycle you’re loads more sensitive to pain.<br \/><br \/>So no leg, eyebrow waxes or Brazilians puleese!",
		"Zits ahoy! You may see more of these blighters before your period.<br \/><br \/>This is due to a change in the level of hormones that affect your skin.",
		"Not sure when your period is due? Write down the date, so it’ll be easier to figure out when the next one’s due.",
		"You won’t always be a once — a-month girl at the beginning.<br \/><br \/>Missing a month when you first start is nothing to worry about.",
		"The day before you come on your ‘period pains’ will start.<br \/><br \/>Aches in your back, tummy, or vagina are signs that your womb is starting to cramp."
	);
	
	var DayNo = document.getElementById('day_no');
	var DayDesc = document.getElementById('day_desc');
	
	DayNo.innerHTML = "<h2 class=\"clsWhtn_15\">Day&nbsp; "+Day+"</h2>";
	DayDesc.innerHTML = WhatToExpect[Day-1];
	
	return true;
}

function isValidDate(day,month,year){
/*
Purpose: return true if the date is valid, false otherwise

Arguments: day integer representing day of month
month integer representing month of year
year integer representing year

Variables: dteDate - date object

*/
var dteDate;

//set up a Date object based on the day, month and year arguments
//javascript months start at 0 (0-11 instead of 1-12)
dteDate=new Date(year,month,day);

/*
Javascript Dates are a little too forgiving and will change the date to a reasonable guess if it's invalid. We'll use this to our advantage by creating the date object and then comparing it to the details we put it. If the Date object is different, then it must have been an invalid date to start with...
*/

return ((day==dteDate.getDate()) && (month==dteDate.getMonth()) && (year==dteDate.getFullYear()));
}


function validate()
{
    var return_val = false;
   
   
   
    curr_period_day_val = document.getElementById(last_period_day).value;
    curr_period_month_val = document.getElementById(last_period_month).value;
    curr_period_year_val = document.getElementById(last_period_year).value;
    period_days_val = document.getElementById(period_duration).value;
    period_frequency_val = document.getElementById(period_frequency).value;
   
   
   if( isNaN(curr_period_day_val) || isNaN(curr_period_month_val) || isNaN(curr_period_year_val) || isNaN(period_days_val) || isNaN(period_frequency_val) )
   {
       alert('Invalid Date'); 
       return   return_val;
   }
   else
   {
        err = "";
        
        if(curr_period_day_val == "0")
        {
           err += "Please select a Day\n"; 
        }
        
        if(curr_period_month_val == "0")
        {
          err += "Please select a Month\n";   
        }
        
        if(curr_period_year_val == "0000")
        {
          err += "Please select a Year\n";     
        }
        
        if(err == "")
        {
             if(!isValidDate(curr_period_day_val,curr_period_month_val-1,curr_period_year_val))
             {
                     err += "Please select valid date\n";  
             }
             
        }
        
        
        if(period_days_val == "0")
        {
          err += "Please select number of days for your period\n";  
        }
        
        if(period_frequency_val == "0")
        {
            err += "Please select number of days from the first day of your last period to the first day of your next period\n";   
        }
        
        
        
        
        if(err == "")
        {
           return_val = true; 
        }
        else
        {
            alert(err);
        }
        
        
   }
    
   return   return_val;
}

function MM_preloadImages() { 
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_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_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')?'block':(v=='hide')?'none':v; }
            
            
            obj.display=v; 
            
            //alert(obj.display);
        }
    }



function stripHTML(){
var re= /<\S[^><]*>/g
for (i=0; i<arguments.length; i++)
{
document.getElementById(arguments[i]).value =   document.getElementById(arguments[i]).value.replace(re, "");
}
}

var selectedLink = '';
var selectedFooterLink = '';

function changeClass(linkID)
{
     
   if ( selectedLink != linkID )
   {
       if( document.getElementById(linkID).className == "pnlTopNavItemsASel" )
       {
           document.getElementById(linkID).className = "pnlTopNavItemsA";
       }
       else
       if( document.getElementById(linkID).className == "pnlTopNavItemsA" )
       {
         document.getElementById(linkID).className = "pnlTopNavItemsASel";
       }
   }
}



function setSelectedSection(HomeID,ProductsID,FirstID,FYIID,CouponsID,AskID)
{
   if( document.getElementById(HomeID).className == "pnlTopNavItemsASel" )
   {
        selectedLink = HomeID;
   }
   else
   if( document.getElementById(ProductsID).className == "pnlTopNavItemsASel" )
   {
        selectedLink = ProductsID;
   }
   else
   if( document.getElementById(FirstID).className == "pnlTopNavItemsASel" )
   {
        selectedLink = FirstID;
   }
   else
   if( document.getElementById(FYIID).className == "pnlTopNavItemsASel" )
   {
        selectedLink = FYIID;
   }
   else
   if( document.getElementById(CouponsID).className == "pnlTopNavItemsASel" )
   {
        selectedLink = CouponsID;
   }
   else
   if( document.getElementById(AskID).className == "pnlTopNavItemsASel" )
   {
        selectedLink = AskID;
   } 
}

function makeProductlinkUnBold(element)
{
      element.style.fontWeight = "normal"; 
       
      
       
}

function makeProductlinkBold(element)
{
       
        element.style.fontWeight = "bold"; 
}


function setSelectedFooterSection(imgMotherNature,lnkMotherNature,imgPeriodCalc,lnkPeriodCalc,imgAdvertising,lnkAdvertising,imgUniquelyGirl,lnkUniquelyGirl,imgPFutures,linkPFutures)
{
   if( document.getElementById(lnkMotherNature).className == "clsWhnbF_35" )
   {
        selectedFooterLink = lnkMotherNature;
   }
   else
   if( document.getElementById(lnkPeriodCalc).className == "clsWhnbF_35" )
   {
        selectedFooterLink = lnkPeriodCalc;
   }
   else
   if( document.getElementById(lnkAdvertising).className == "clsWhnbF_35" )
   {
        selectedFooterLink = lnkAdvertising;
   }
   else
   if( document.getElementById(lnkUniquelyGirl).className == "clsWhnbF_35" )
   {
        selectedFooterLink = lnkUniquelyGirl;
   }
   else
   if( document.getElementById(linkPFutures).className == "clsWhnbF_35" )
   {
        selectedFooterLink = linkPFutures;
   }
   
}


function changeFooterClass(element)
{
  if ( selectedFooterLink != element.id )
   {
      
       if( document.getElementById(element.id).className == "clsWhnbF_35" )
       {
         document.getElementById(element.id).className = "clsWhnbF_23";
        }
       else
       if( document.getElementById(element.id).className == "clsWhnbF_23" )
       {
         document.getElementById(element.id).className = "clsWhnbF_35";
        
       }
       
        var parentDIV = element.parentNode; 
         j = parentDIV.childNodes.length;
        
        var testCond1 = "IMG"; 
        var testCond2 = "img";  
        
       
         
        if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
        { 
            var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
            if (ieversion>=5 && ieversion < 7)
            {
                testCond1 = "SPAN";
                testCond2 = "span";
            }
            
        }
         
       
         
         
         for(i=0;i<j;i++)
         {
            if( parentDIV.childNodes[i].nodeName == testCond1 || parentDIV.childNodes[i].nodeName == testCond2 )
            {
                   
                 if(parentDIV.childNodes[i].className == "displayNone")
                 {
                    parentDIV.childNodes[i].className = "displayBlock"
                 }
                 else
                 if(parentDIV.childNodes[i].className == "displayBlock")
                 {
                    parentDIV.childNodes[i].className = "displayNone"
                 }
            }
         }
       
   }
}

var productDetailDefaultImageSRC = "";
var productDetailDefaultImageALT = "";

function showBubImage(linkElement,imageID,oldImgSRC,oldImgALT)
    {
      
            oldImg = document.getElementById(imageID);
            productDetailDefaultImageSRC = document.getElementById(oldImgSRC).value;
            productDetailDefaultImageALT = document.getElementById(oldImgALT).value;   


            /*var j = linkElement.childNodes.length;
            alink = null;
            
            for(i=0;i<j;i++)
             {
                if( linkElement.childNodes[i].nodeName == "A" || linkElement.childNodes[i].nodeName == "a" )
                {
                        alink = linkElement.childNodes[i];
                }
             }*/
             
             
             
             
            if(oldImg.tagName == "IMG")
            {             
             oldImg.src = linkElement.rel;
            }
            else
            if(oldImg.tagName == "SPAN")
            {
             oldImg.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+linkElement.rel+"', sizingMethod='image')";
            }
             
            
             
            /* if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
                { 
                    
                    var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
                    if (ieversion>=5 && ieversion < 7)
                    {
                        alert('ok');
                    }
                    
                }
              */
             
            
            //alert(productDetailDefaultImageSRC+" -- "+productDetailDefaultImageALT);
      
            
           /*var divwidth = linkElement.offsetWidth;
            
            var j = linkElement.childNodes.length;
            alink = null;
            
            for(i=0;i<j;i++)
             {
                if( linkElement.childNodes[i].nodeName == "A" || linkElement.childNodes[i].nodeName == "a" )
                {
                        alink = linkElement.childNodes[i];
                }
             }
            
            var xy = findPosition_prod(linkElement);
            
           x=parseInt(xy[0]);
           x = x + divwidth;
           
           y = parseInt(xy[1]);
           y = y;
           
           popupdiv = document.getElementById("bubImgDiv");
           popupdiv.innerHTML = "<img src='"+alink.rel+"' />";
           popupdiv.style.display = "block";
           popupdiv.style.top = y+"px";
           popupdiv.style.left = x+"px";*/
           
           
           
            
            
         
    }
    
    function hideBubImage(linkElement,imageID,oldImgSRC,oldImgALT)
    {
      /*popupdiv = document.getElementById("bubImgDiv");
      popupdiv.style.display = "none";*/
      //alert(productDetailDefaultImageSRC+" -- "+productDetailDefaultImageALT);
      
       oldImg = document.getElementById(imageID);
       
       if(oldImg.tagName == "IMG")
       {             
         oldImg.src =   productDetailDefaultImageSRC;
         oldImg.alt =   productDetailDefaultImageALT;
       }
       else
       if(oldImg.tagName == "SPAN")
       {
         oldImg.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+productDetailDefaultImageSRC+"', sizingMethod='image')";
       }
       
        
      
    }
    
     function findPosition_prod( oElement ) 
    {
        if( typeof( oElement.offsetParent ) != 'undefined' ) 
        {
            for( var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent ) 
            {
                posX += oElement.offsetLeft;
                posY += oElement.offsetTop;
            }
            return [ posX, posY ];
        } 
        else 
        {
            return [ oElement.x, oElement.y ];
        }
    }
    
    
function loadPlayer(src)
{
var str = "";
str='<classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="337" height="252">';
str= str+'<param name="movie" value="/en-US/common/videoplayer/video_player_2.swf"/>';
str= str+'<param name="quality" value="high"/>';
str= str+'<param name="wmode" value="transparent"/>';
str= str+'<param name="swliveconnect" value="true"/>';
str= str+'<param name="FlashVars" value="myURL='+src+'"/>';
str= str+'<embed src="../common/videoplayer/video_player_2.swf" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="337" height="252" swliveconnect="true" FlashVars="myURL='+src+'"/>';
str= str+'</OBJECT>';
document.getElementById('video').innerHTML=str;
}

function loadPlayerProducts(src,id)
{
var str = "";
str='<classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="337" height="252">';
str= str+'<param name="movie" value="/en-US/common/videoplayer/video_player_2.swf"/>';
str= str+'<param name="quality" value="high"/>';
str= str+'<param name="wmode" value="transparent"/>';
str= str+'<param name="swliveconnect" value="true"/>';
str= str+'<param name="FlashVars" value="myURL='+src+'"/>';
str= str+'<embed src="../common/videoplayer/video_player_2.swf" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="337" height="252" swliveconnect="true" FlashVars="myURL='+src+'"/>';
str= str+'</OBJECT>';
document.getElementById(id).innerHTML=str;
}

function doNothing()
{
 return false;
}

function validateZIP(sender, args)
{
   var enteredZIP = args.Value;
   var re5digit=/^\d{5}$/
   
   if(enteredZIP.search(re5digit)==-1)
   {
       args.IsValid = false; 
   }
   else
   {
       args.IsValid = true;  
   }
}

function validateEmail(sender, args)
{
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    str = args.Value;
    
   
    
    if(reg.test(str) == true) {
        args.IsValid = true;  
    }else{
   args.IsValid = false; 
    }
   
}

function hideSearchText(defaultText,controlID)
{
   var searchText = document.getElementById(controlID).value.replace(/^\s+|\s+$/g, '');
   
   if( searchText == defaultText )
   {
       document.getElementById(controlID).value = "";
   }
    
}

function showSearchText(defaultText,controlID)
{
    var searchText = document.getElementById(controlID).value.replace(/^\s+|\s+$/g, '');
  
     if( searchText == "" )
     {
             document.getElementById(controlID).value = defaultText;
     }
}

function changeBeingGirlLogo(src,elementID)
{
    var parentElement  = document.getElementById(elementID);
    j = parentElement.childNodes.length;
    
    var testCond1 = "IMG"; 
    var testCond2 = "img"; 
    
    if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
        { 
            var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
            if (ieversion>=5 && ieversion < 7)
            {
                testCond1 = "SPAN";
                testCond2 = "span";
            }
            
        }
        
        
    for(i=0;i<j;i++)
         {
            if( parentElement.childNodes[i].nodeName == testCond1 || parentElement.childNodes[i].nodeName == testCond2 )
            {
                if((testCond1 ==  "SPAN") || (testCond1 ==  "span"))
                {
                    parentElement.childNodes[i].src = src;    
                }  
                else
                {
                    parentElement.childNodes[i].src = src;  
                    
                    
                      
                }
                
                 
                
            }
         }    
     
}


function toggle(object){
	var div1 = document.getElementById(object)
	if (div1.className == 'displayOff') {
		div1.className = 'displayOn'
	} else {
		div1.className = 'displayOff'
	}
}


function set_xy_menu_divs(x,y)
    {
        var home_menu_div = document.getElementById('SubmenuHome');
        var tampax_products = document.getElementById('SubmenuProducts');
        var first_tempon = document.getElementById('SubmenuFirst');
        var fyi = document.getElementById('SubmenuFyi');
        var coupons = document.getElementById('SubmenuCoupons');
        var faq = document.getElementById('SubmenuAsk');
        var postfix = "px";
        
       
        
        y = parseInt(y);
        x = parseInt(x); 
        y = y+35;
        
        
        
        
        home_menu_div.style.top = y+postfix;
        home_menu_div.style.left = (x + 125)+postfix;
        
        tampax_products.style.top = y+postfix;
        tampax_products.style.left = (x + 325)+postfix;
        
        first_tempon.style.top = y+postfix;
        first_tempon.style.left = (x + 300)+postfix;
        
        fyi.style.top = y+postfix;
        fyi.style.left = (x + 540)+postfix;
        
        coupons.style.top = y+postfix;
        coupons.style.left = (x + 500)+postfix;
        
        faq.style.top = y+postfix;
        faq.style.left = (x + 550)+postfix;
       
        
    }
    
    function findPosition( oElement ) 
    {
        if( typeof( oElement.offsetParent ) != 'undefined' ) 
        {
            for( var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent ) 
            {
                posX += oElement.offsetLeft;
                posY += oElement.offsetTop;
            }
            return [ posX, posY ];
        } 
        else 
        {
            return [ oElement.x, oElement.y ];
        }
}

function redirectTo(URL)
{
    window.location=URL;
}