jQuery(document).ready(function() {
	
	jQuery('#bottom-2 .product').eq(4).css('border-right', 'none');
	jQuery('#bottom-2 .product').eq(jQuery('#bottom-2 .product').size()-1).css('border-right', 'none');
	jQuery('div.com-amazon-webstore-MiniCart-2 .staticMiniCart').corner("tl tr");
	jQuery('body.cart#pageId100 #rightColumn').corner();
	jQuery('body.cart#pageId101 #rightColumn').corner();
	jQuery('#center-18 h2.widgetTitle').addClass('active');
 	
	jQuery('h2.widgetTitle').live('click', function(){
		if(jQuery(this).hasClass('active'))
		{
		}
		else
		{
			
			jQuery(this).parents('div.productListWidget').find('div.carousel').css('width','688px');
			jQuery(this).parents('div.productListWidget').find('div.carousel').children('div.carouselWindow').css('width','688px');
		 jQuery('#center-20 .carousel, #center-19 .carousel, #center-18 .carousel').hide();
		 jQuery('#center-20 h2.widgetTitle, #center-19 h2.widgetTitle, #center-18 h2.widgetTitle').removeClass('active');
		 jQuery(this).addClass('active'); 
		 jQuery(this).siblings('.carousel').css('display','block');	
		 jQuery(this).siblings('.carousel').show();		 
		}
	});
	/* PDP Page functions Start*/
	/* Facebook initiation code start */
	jQuery('a.facebook_icon').click(function() {
		u=location.href;
		t=document.title;
		window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
		return false;
	});	
	/* Facebook initiation code end */
	/* Twitter initiation code start */
	jQuery('a.twitter_icon').click(function() {
		var url = window.location;
		var Title = jQuery('div#rightColumn').find('div#right-1').children('div.com-amazon-webstore-ProductTitleDetail-2').find('h2.productTitle').text();
		window.open('http://twitter.com/home?status='+Title,'sharer','toolbar=0,status=0,width=626,height=436');
		return false;
	});	
	/* Twitter initiation code end */
	/*
	var RItem_Count = jQuery('#right-14').find('.productListWidget').children('.productList').find('li.product').length;
	if(RItem_Count >= 1)
	{
		var RHeight = jQuery('#right-14').find('.target-amazon-com-target-pagelets-IncaNewReleasesWidgetPagelet-1').height();
		RHeight = RHeight+35;
		jQuery('#right-15').find('.starter-amazon-com-ImageWidget-1-latest').css('top',RHeight);
	
		
		jQuery('#right-14').find('.productListWidget').children('.productList').find('li.product').eq(RItem_Count-1).css('border','none');		
	}
	else
	{
		jQuery('#right-15').find('.starter-amazon-com-ImageWidget-1-latest').css('top','0px');
	}
	*/
	var PDPHeight = jQuery('body.detail').find('div#columns').children('#center-right-wrapper').find('#rightColumn').height();
	if(PDPHeight <= 400)
	{
		jQuery('body.detail').find('#right-9').children('div.com-amazon-webstore-ProductBuyBox-3').find('fieldset').children('ol.formFields').css('margin-left','-48px');
	}
	else if ( (jQuery.browser.msie) && (jQuery.browser.version >= '7.0') ){
		jQuery('body.detail').find('#right-9').children('div.com-amazon-webstore-ProductBuyBox-3').find('fieldset').children('ol.formFields').css('margin-left','-48px');
	}
	
	
	jQuery('body.detail div').click(function(){
		var CartHref = jQuery('body.detail').find('div#header-7').children('div.com-amazon-webstore-MiniCart-2').find('div.miniCart').children('div.dynamicMiniCart').find('div.miniCartActions').children('form').attr('action');		
		if(CartHref == "/cartPreview")
		{
			jQuery('body.detail').find('div#header-7').children('div.com-amazon-webstore-MiniCart-2').find('div.miniCart').children('div.dynamicMiniCart').find('div.miniCartActions').children('form').attr('action','/cart');
		}
	});		
	
	var CView_Count = jQuery('#bottom-5').find('.productListWidget').children('.productList').find('li.product').length;
	if(CView_Count>=5)
	{
		var CView_Loop = Math.round(CView_Count/5);
		var CEQ = -1;
		for(i=0;i<CView_Loop;i++)
		{
			CEQ = CEQ+5;
			jQuery('#bottom-5').find('.productListWidget').children('.productList').find('li.product').eq(CEQ).css('border','none');
		}
	}
	
	var RView_Count = jQuery('#bottom-6').find('.productListWidget').children('.productList').find('li.product').length;
	if(RView_Count>=5)
	{
		var RView_Loop = Math.round(RView_Count/5);
		var EQ = -1;
		for(i=0;i<RView_Loop;i++)
		{
			EQ = EQ+5;
			jQuery('#bottom-6').find('.productListWidget').children('.productList').find('li.product').eq(EQ).css('border','none');
		}
	}
	
	var RMore = jQuery('#center-right-span-3').find('.com-amazon-webstore-ProductCustomerReviews-1').children('.communityReviews').find('div.rating').length;
	for(k=0;k<RMore;k++)
	{
		jQuery('#center-right-span-3').find('.com-amazon-webstore-ProductCustomerReviews-1').children('.communityReviews').find('div.rating').eq(k).find('div').eq(2).find('a').css('color','#0078FF');
	}
	var Sales = jQuery.trim(jQuery('#right-5').find('.productDetailPrice').children('dl.attributeList').find('dt.salePrice').html());
	if(Sales == "Sale&nbsp;")
	{
		jQuery('#right-5').find('.productDetailPrice').children('dl.attributeList').find('dt.salePrice').html('Our Price&nbsp;');
	}
	var RPrice = jQuery.trim(jQuery('#right-5').find('.productDetailPrice').children('dl.attributeList').find('dt.listPrice').text());
	if(RPrice == "Our price:")
	{
		jQuery('#right-5').find('.productDetailPrice').children('dl.attributeList').find('dt.listPrice').html('Regular Price:');
	}
	
	/* PDP Page functions end */
	/* Search items confirmation popup start in SWB Ctegory 13oct11*/
	function isContains(source,findData)
	{
		var matchRes = "N";			
		for(j=0;j<source.length;j++)
		{
			if(source[j] == findData)
			{
				matchRes = "Y";				
			}
			/*else if(source[j].contains(findData))
			{
				matchRes = "Y";
			}
			else if(findData.contains(source[j]))
			{
				matchRes = "Y";
			}*/
		}		
		return matchRes;
	}
	
	function validate()
	{
		var Res = true;		
		var KeyWord = new Array("adult","adult games","massager","sex","sexy","sexual","enhancer","stimulate","condoms","condom","lubricants","vibrating","stimulators","all lubricants","penis pumps","anal toys","g-spot","all vibrators","sensual","latex condoms","adult games","sexy accessories","female contraceptives","dildos","Dildos","kegel","female-supplements","anal toys & prostate massagers","desensitizers","masturbators","male-supplements","vibrating & couples rings","cleansing & deodorant","personal grooming for her","Sexual-Supplements","Sensual & Romance","sensual gift sets","pheromones","positional furniture","Personal Messagers","vagina","Vagina","dildo","Dildo","vibrator","Vibrator","vibrators","Vibrators","penis","Penis","anal","Anal","lube","Lube","lubricant","Lubricant","masturbate","Masturbate","masturbator","Masturbator","pheromone","Pheromone","pheromones","Pheromones","forplay","Forplay","foreplay","Foreplay","cyberskin","Cyberskin","sex tarts","Sex tarts","climax","Climax","stroke","Stroke","stroker","Stroker","clit","Clit","clitoral","Clitoral","clitoris","Clitoris","k-y","K-Y","bullet","Bullet","bj","Bj","bondage","Bondage","cuffs","Cuffs","handcuffs","Handcuffs","restraint","Restraint","restraints","Restraints","aphrodisiac","Aphrodisiac","pump","Pump","dolphin","Dolphin","beads","Beads","bead","Bead","rabbit","Rabbit","bunny","Bunny","penis ring","Penis ring","cockring","Cockring","vibe","Vibe","jelly","Jelly","butt","Butt","butt plug","Butt plug","plug","Plug","gspot","G-spot","tickler","Tickler","erection","Erection","silicone","Silicone","oral sex","Oral sex","strap","Strap","Strapon","Strap on","Toys","toys","toy","Toy");
		
		
		var Search_Key = jQuery('#searchKeywords').val();
		var SplitKey = Search_Key.split(" ");
		var caseKey = "";
		var isMatch = "N";
		for(i=0;i<SplitKey.length;i++)
		{
			caseKey = jQuery.trim(SplitKey[i].toLowerCase());			
			isMatch = isContains(KeyWord,caseKey);			
			//if(isMatch == "Y")
			if(isMatch != "N")
			{
				
				var HREF = jQuery('div.com-amazon-webstore-SearchNav-2').find('div.miniSearchForm').children('form#searchForm').attr("action")+"?searchKeywords="+Search_Key+"&Action=submit";
				var RPopup = "<div class='confirmationPopup'></div><div class='contentpane'><p>You are about to view sexually explicit materials.  If you do not wish to proceed, simply click the <strong>back</strong> button on your browser.</p><p>I acknowledge that I am at least 18 years of age.</p><input type='checkbox' name='isA' class='isA' id='isA' value='"+HREF+"' /><button value='I Accept' name='age' id='age' class='primaryAction' type='submit'><span>I Accept</span></button><button value='Decline' name='decline' id='decline' class='primaryAction' type='submit'><span>Decline</span></button></div>";
				
				jQuery("body").append(RPopup);
				
				jQuery("div.contentpane .primaryAction").unbind('click').click(submitFunction);
				jQuery("div.contentpane .isA").unbind('click').click(submitCheckFunction);
				jQuery("div.contentpane #decline").unbind('click').click(gotohomeFunction);
			//	var BHeight = jQuery('body').height();
				var BWidth = jQuery('body').width();
			//	var PHeight = jQuery('div.contentpane').height();
				var PWidth = jQuery('div.contentpane').width();
				
			//	var Top = (BHeight/2)-(PHeight/2);
				var Left = (BWidth/2)-(PWidth/2);
				
				jQuery('div.contentpane').css({'left':Left});
				
				
				Res = false;
				break;
			}
		}
		return Res;
	}
	jQuery('div.com-amazon-webstore-SearchNav-2').find('div.miniSearchForm').children('form#searchForm').attr('onSubmit','return validate(this);');
	jQuery('div.com-amazon-webstore-SearchNav-2').find('div.miniSearchForm').children('form#searchForm').submit(validate);
	/* Search items confirmation popup end */
	/* Review Page functions Start*/
	var RItem_Counts = jQuery('#right-1').find('.productListWidget').children('.productList').find('li.product').length;
	
	if(RItem_Counts >= 1)
	{
		var RHeight = jQuery('#right-1').find('.target-amazon-com-target-pagelets-IncaNewReleasesWidgetPagelet-1').height();
		RHeights = RHeights+35;
		/*jQuery('#right-1').find('.starter-amazon-com-ImageWidget-1-latest').css('top',RHeights);*/
		jQuery('#right-1').find('.productListWidget').children('.productList').find('li.product').eq(RItem_Counts-1).css('border','none');	
	
	}	

	var subCat_Count = jQuery('body.browse').children('div#wrapper').find('div#left-2').children('div.com-amazon-webstore-BrowseLeftNavBin-2').find('ul.linkList').length;
	if(subCat_Count > 0)
	{
		jQuery('body.browse').children('div#wrapper').find('div#left-2').children('div.com-amazon-webstore-BrowseLeftNavBin-2').find('ul.linkList').children('li.lessBinValue').find('a').text('Hide All');
	}
	var cat_Count = jQuery('body.browse').children('div#wrapper').find('div#left-1').children('div.com-amazon-webstore-LeftNavBrowse-2').find('ul.linkList.browseLadder').children('li').length;	
	if(cat_Count > 0)
	{
		if(cat_Count > 5)
		{
			for(i=6;i<cat_Count;i++)
			{
				jQuery('body.browse').children('div#wrapper').find('div#left-1').children('div.com-amazon-webstore-LeftNavBrowse-2').find('ul.linkList.browseLadder').children('li').eq(i).hide();
			}			
			CatList = "<li id='moreCatVal' class='moreCatVal'><a>View All</a>&nbsp;<img src='/media/Site Files/Merchandising Files/downarrow.png'></li>"+"<li id='minCatVal' class='minCatVal'><a>Hide All</a>&nbsp;<img src='/media/Site Files/Merchandising Files/up_arrow.jpg'></li>";
			
			jQuery('body.browse').children('div#wrapper').find('div#left-1').children('div.com-amazon-webstore-LeftNavBrowse-2').find('ul.linkList.browseLadder').eq(1).append(CatList);
			jQuery('body.browse').children('div#wrapper').find('div#left-1').children('div.com-amazon-webstore-LeftNavBrowse-2').find('ul.linkList.browseLadder').children('li:last').hide();
		}
	}
	jQuery('li#moreCatVal').live('click', function() {		
		jQuery('body.browse').children('div#wrapper').find('div#left-1').children('div.com-amazon-webstore-LeftNavBrowse-2').find('ul.linkList.browseLadder').children('li').slideDown(600);
		jQuery(this).parents('ul.linkList.browseLadder').find('li#minCatVal').show();
		jQuery(this).hide();
	});
	jQuery('li#minCatVal').live('click', function() {		
		var cat_Count = jQuery('body.browse').children('div#wrapper').find('div#left-1').children('div.com-amazon-webstore-LeftNavBrowse-2').find('ul.linkList.browseLadder').children('li').length;
		for(i=cat_Count;i>=6;i--)
		{
			jQuery('body.browse').children('div#wrapper').find('div#left-1').children('div.com-amazon-webstore-LeftNavBrowse-2').find('ul.linkList.browseLadder').children('li').eq(i).slideUp(600);
		}		
		jQuery(this).parents('ul.linkList.browseLadder').find('li#moreCatVal').show();
		jQuery(this).hide();
	});
	/*start sub category product search height*/
	var subCat_ProHeight = jQuery('body.browse').find('div#columns').children('div#centerColumn').find('div#center-6').children('div.com-amazon-webstore-SearchResults-4').height();
	
	var BreadLen = 	jQuery('body.browse').find('div#mainContentWrapper').children('div#top-10').find('div.com-amazon-webstore-BreadcrumbBrowse-2').children('ol.breadcrumbs.browseBreadcrumbs').find('li').length;	
	if ( jQuery.browser.msie && (jQuery.browser.version >= 7) && (BreadLen >= 3) && (subCat_ProHeight > 1000 )) {
		subCat_ProHeight = subCat_ProHeight+250;
		jQuery('body.browse').find('div#columns').css("height",subCat_ProHeight);		
}
	/*start edit 27sep11*/
	
	/*
	if(jQuery('body').is('.browse') && (BreadLen >= 3))
	{
		var Pages = [ "pageId3068147011", "pageId3068172011", "pageId3068183011", "pageId3070501011", "pageId3070525011", "pageId3070529011", "pageId3070238011", "pageId3070239011", "pageId3070247011", "pageId3068415011", "pageId3068430011"];
		var Images = { "pageId3068147011":"/media/Site Files/Merchandising Files/allergy_sinus.jpg", "pageId3068172011":"/media/Site Files/Merchandising Files/healthcare_for_children.jpg", "pageId3068183011":"/media/Site Files/Merchandising Files/cold-cough-flu.jpg", "pageId3070501011":"/media/Site Files/Merchandising Files/all_supplements.jpg", "pageId3070525011":"/media/Site Files/Merchandising Files/bone_joint .jpg", "pageId3070529011":"/media/Site Files/Merchandising Files/by_condition.jpg",  "pageId3070238011":"/media/Site Files/Merchandising Files/bath_spa.jpg", "pageId3070239011":"/media/Site Files/Merchandising Files/fragrance.jpg", "pageId3070247011":"/media/Site Files/Merchandising Files/gift_sets.jpg", "pageId3068415011":"/media/Site Files/Merchandising Files/acne_care.jpg", "pageId3068430011":"/media/Site Files/Merchandising Files/antiperspirants_deodorants.jpg"};
		
		var bodyID = jQuery('body').attr('id');		
		if(jQuery.inArray(bodyID, Pages) >= 0)
		{
			jQuery("#center-2 .imageWidget a img").attr("src",Images[bodyID]);
		}
	}
	*/
		/*end edit 27sep11*/
		/*start edit 30sep11*/
		/*
		if(jQuery('body').is('.browse') && (BreadLen >= 3))
		{
		jQuery("body.browse #center-2 .imageWidget a img").hide();
		var PName = jQuery('body.browse').find('div#mainContentWrapper').children('div#top-10').find('div.com-amazon-webstore-BreadcrumbBrowse-2').children('ol.breadcrumbs.browseBreadcrumbs').find('li.last').text();
		
		var PName = jQuery.trim(PName).replace('&','');
		var RName = jQuery.trim(PName.toLowerCase()).replace(/ /g,'_')+".jpg";
		
		var RName = jQuery.trim(RName).replace('__','_');
		
		RName = "/media/Site Files/Merchandising Files/"+RName;
		
		jQuery("#center-2 .imageWidget a img").attr("src",RName);
		jQuery("#center-2 .imageWidget a img").show(100, function() {
			ImgWidth = jQuery("#center-2 .imageWidget a img").width();
			
		});
	}
		/*end edit 31sep11*/
		
	
	/*1dec11 subcategory contextual banners start*/
			var PName = jQuery('body.browse').find('div#mainContentWrapper').children('div#top-10').find('div.com-amazon-webstore-BreadcrumbBrowse-2').children('ol.breadcrumbs.browseBreadcrumbs').find('li a').eq(1).text();
	if(jQuery('body').is('.browse') && (BreadLen >= 3))
	{
		var Images = {"Medicine & Health":"/media/Site Files/Merchandising Files/MedHealth_CSH.jpg","Vitamins":"/media/Site Files/Merchandising Files/Vitamins_CSH.jpg","Beauty":"/media/Site Files/Merchandising Files/Beauty_CSH.jpg","Baby & Mom":"/media/Site Files/Merchandising Files/BabyMom_CSH.jpg","Personal Care":"/media/Site Files/Merchandising Files/Personal_CSH.jpg","Household":"/media/Site Files/Merchandising Files/Household_CSH.jpg","Sexual Well-Being":"/media/Site Files/Merchandising Files/Sexualwellbeing_CSH.jpg","Diet & Fitness":"/media/Site Files/Merchandising Files/DietFitness_CSH.jpg","Rite Aid Brand Store":"/media/Site Files/Merchandising Files/RiteAidBrand_CSH.jpg"};
		
		var Reflink ={"Medicine & Health":"/Medicine-Health/b/3003326011","Vitamins":"/Vitamins/b/3068768011","Beauty":"/Beauty/b/3068746011","Baby & Mom":"/Baby-Mom/b/3068767011","Personal Care":"/Personal-Care/b/3015700011","Household":"/Household/b/3003322011","Sexual Well-Being":"/Sexual-WellBeing/b/3068770011","Diet & Fitness":"/Diet-Fitness/b/3068769011","Rite Aid Brand Store":"/Rite-Aid-Brand-Store-Products/b/3172241011"};
		
		var bodyID = jQuery('body').attr('class');

		jQuery("#center-2 .imageWidget a img").attr("src",Images[PName]);
		jQuery("#center-2 .imageWidget a").attr("href",Reflink[PName]);
		
	}
	/*1dec11 subcategory contextual banners end*/
	
	/*end sub category product search height*/	
	/*start hack for saleprice*/
	var SalePriceCount = jQuery('body.browse').children('div#wrapper').find('div#searchResultsContainer').children('ol.searchResultsList.itemList').find('li.product.largeProduct').length;	
	if((SalePriceCount > 0) && (jQuery.browser.msie) && (jQuery.browser.version >= 7))
	{		
		for(i=0;i<SalePriceCount;i++)
		{			
			SalePrices = jQuery.trim(jQuery('body.browse').children('div#wrapper').find('div#searchResultsContainer').children('ol.searchResultsList.itemList').find('li.product.largeProduct').eq(i).children('div.productDetails').find('dl.attributeList.priceBlock').children('dd.salePrice').html());
			SalePrices = SalePrices+"<span style='color:#FFF'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>";
			
			jQuery('body.browse').children('div#wrapper').find('div#searchResultsContainer').children('ol.searchResultsList.itemList').find('li.product.largeProduct').eq(i).children('div.productDetails').find('dl.attributeList.priceBlock').children('dd.salePrice').html(SalePrices);
		}
	}
	var SalePriceHack = jQuery('body.search').children('div#wrapper').find('div#searchResultsContainer').children('ol.searchResultsList.itemList').find('li.product.largeProduct').length;	
	if((SalePriceHack > 0) && (jQuery.browser.msie) && (jQuery.browser.version >= 7))
	{		
		for(i=0;i<SalePriceHack;i++)
		{			
			SalePricesHack = jQuery.trim(jQuery('body.search').children('div#wrapper').find('div#searchResultsContainer').children('ol.searchResultsList.itemList').find('li.product.largeProduct').eq(i).children('div.productDetails').find('dl.attributeList.priceBlock').children('dd.salePrice').html());
			SalePricesHack = SalePricesHack+"<span style='color:#FFF'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>";
			
			jQuery('body.search').children('div#wrapper').find('div#searchResultsContainer').children('ol.searchResultsList.itemList').find('li.product.largeProduct').eq(i).children('div.productDetails').find('dl.attributeList.priceBlock').children('dd.salePrice').html(SalePricesHack);
		}
	}	
	
/*end hack for saleprice*/
	
	var PreImg = jQuery.trim(jQuery('body.browse').children('div#wrapper').find('div.searchPagination').children('ul.linkList.paginationLinks').find('li.previousPage').children('a').eq(0).text());
	var NextImg = jQuery.trim(jQuery('body.browse').children('div#wrapper').find('div.searchPagination').children('ul.linkList.paginationLinks').find('li.nextPage').children('a').eq(0).text());
	if(PreImg == "Back")
	{
		jQuery('body.browse').children('div#wrapper').find('div.searchPagination').children('ul.linkList.paginationLinks').find('li.previousPage').children('a').html("<img class='preBtn' src='/media/Site Files/Merchandising Files/pagination_leftarrow.png'>");		
	}
	if(NextImg == "Next")
	{
		jQuery('body.browse').children('div#wrapper').find('div.searchPagination').children('ul.linkList.paginationLinks').find('li.nextPage').children('a').html("<img class='nxtBtn' src='/media/Site Files/Merchandising Files/pagination_rigtarrow.png'>");
	}
	/* Sub Category Page functions End*/
	/* No search result start */	
	var SCount = jQuery('body.search').find('div#columns').children('div#leftColumn').find('div.com-amazon-webstore-SearchLeftNavBin-3').children('div.navigationLinks.browseRefinements').find('ul.linkList').length;
	if(SCount >= 1)
	{
		jQuery('body.search').find('div#columns').children('div#leftColumn').find('div.com-amazon-webstore-SearchLeftNavBin-3').children('div.navigationLinks.browseRefinements').find('ul.linkList').children('li.lessBinValue').find('a').text('Hide All');
	}
	var SRes = jQuery.trim(jQuery('body.search').find('div#columns').children('div#centerColumn').find('div#center-2').children('div.com-amazon-webstore-PaginationTopSearch-2').find('p.searchCount').html());
	if(SRes != "")
	{		
		var ESRes = SRes.replace("We're sorry, we didn't find any items matching","0 Results were found for ");
		jQuery('body.search').find('div#columns').children('div#centerColumn').find('div#center-2').children('div.com-amazon-webstore-PaginationTopSearch-2').find('p.searchCount').html(ESRes);
	}
	
	var serahTitle = jQuery.trim(jQuery('body.search').find('div#columns').children('div#centerColumn').find('div#center-3').children('div.com-amazon-webstore-SearchResults-4').find('div.searchAgain').children('form.searchForm').find('li.formField').children('label').html());
	if(serahTitle == "Would you like to try another search?")
	{
		jQuery.trim(jQuery('body.search').find('div#columns').children('div#centerColumn').find('div#center-3').children('div.com-amazon-webstore-SearchResults-4').find('div.searchAgain').children('form.searchForm').find('li.formField').children('label').html('<b>SEARCH MORE :</b>'));
	}	
	
	var SPreImg = jQuery.trim(jQuery('body.search').children('div#wrapper').find('div.searchPagination').children('ul.linkList.paginationLinks').find('li.previousPage').children('a').eq(0).text());
	var SNextImg = jQuery.trim(jQuery('body.search').children('div#wrapper').find('div.searchPagination').children('ul.linkList.paginationLinks').find('li.nextPage').children('a').eq(0).text());
	if(SPreImg == "Back")
	{
		jQuery('body.search').children('div#wrapper').find('div.searchPagination').children('ul.linkList.paginationLinks').find('li.previousPage').children('a').html("<img class='preBtn' src='/media/Site Files/Merchandising Files/pagination_leftarrow.png'>");		
	}
	if(SNextImg == "Next")
	{
		jQuery('body.search').children('div#wrapper').find('div.searchPagination').children('ul.linkList.paginationLinks').find('li.nextPage').children('a').html("<img class='nxtBtn' src='/media/Site Files/Merchandising Files/pagination_rigtarrow.png'>");
	}
		
	/* No search result end */
	/* Cart page function start */	
	var CartProduct_Count = jQuery('body.cart').find('div#center-4').children('div.com-amazon-webstore-ActiveCartItems-3').find('fieldset.shoppingCart').children('ol.formFields.productList').find('li.formField.product').length;
	if(CartProduct_Count >= 1)
	{		
		jQuery('body.cart').find('div#center-4').children('div.com-amazon-webstore-ActiveCartItems-3').find('fieldset.shoppingCart').children('ol.formFields.productList').find('li.formField.product').children('div.productDetails').find('ul.buttonGroup.cartItemActions').children('li.delete').find('span').text('Remove');
	}	
	/* Cart page function end */
	/* Home page function start */
	var MPCount = jQuery('body.browse').find('div#mainContentWrapper').children('div#bottom-2').find('div.productListWidget').children('ul.productList').find('li.product').length;
	if(MPCount > 5)
	{
		for(i=5;i<MPCount;i++)
		{
			jQuery('body.browse').find('div#mainContentWrapper').children('div#bottom-2').find('div.productListWidget').children('ul.productList').find('li.product').eq(i).css('border-bottom','none');
		}
	}
	/* Home page function end */
	/* js function for restrict the page of Sexual Well-Being start */
	function clickFunction(e) {	
		e.preventDefault();
	}
	function submitFunction() {
		var isChecked = jQuery('input[id=isA]').attr('checked','checked');
		window.location.href = jQuery('input[id=isA]').attr('value');
		/*if(isChecked == true)
		{			
			window.location.href = jQuery('input[id=isA]').attr('value');
		}
		else
		{		
			window.location.href = "http://www.riteaidonlinestore.com";
		}*/
	}
	function submitCheckFunction() {
		var isChecked = jQuery('input[id=isA]').attr('checked');
		if(isChecked == true)
		{			
			window.location.href = jQuery('input[id=isA]').attr('value');
		}
	}
	function gotohomeFunction() {		
		window.location.href = "http://www.riteaidonlinestore.com";		
	}
	jQuery("ul#globalNav li#globalNavItem7 a.mainNode").unbind('click').click(clickFunction);
	jQuery('ul#globalNav li#globalNavItem7').click(function() {		
		var Popup = jQuery("div.popup").text();			
		if(Popup == "")
		{
			var HREF = jQuery("li#globalNavItem7").find("a.mainNode").attr("href");
			var RPopup = "<div class='confirmationPopup'></div><div class='contentpane'><p>You are about to view sexually explicit materials.  If you do not wish to proceed, simply click the <strong>back</strong> button on your browser.</p><p>I acknowledge that I am at least 18 years of age.</p><input type='checkbox' name='isA' class='isA' id='isA' value='"+HREF+"' /><button value='I Accept' name='age' id='age' class='primaryAction' type='submit'><span>I Accept</span></button><button value='Decline' name='decline' id='decline' class='primaryAction' type='submit'><span>Decline</span></button></div>";
			jQuery("body").append(RPopup);
			jQuery("ul#globalNav li#globalNavItem7 a.mainNode").unbind('click').click(clickFunction);
			jQuery("div.contentpane .primaryAction").unbind('click').click(submitFunction);
			jQuery("div.contentpane .isA").unbind('click').click(submitCheckFunction);
			jQuery("div.contentpane #decline").unbind('click').click(gotohomeFunction);
		//	var BHeight = jQuery('body').height();
			var BWidth = jQuery('body').width();
		//	var PHeight = jQuery('div.contentpane').height();
			var PWidth = jQuery('div.contentpane').width();
			
		//	var Top = (BHeight/2)-(PHeight/2);
			var Left = (BWidth/2)-(PWidth/2);
			
			jQuery('div.contentpane').css({'left':Left});
			
		}
	});
	/* js function for restrict the page of Sexual Well-Being end */
	
	/*start home page slider*/
	jQuery(".paging").show();
	jQuery(".paging a:first").addClass("active");
		
	//Get size of images, how many there are, then determin the size of the image reel.
	var imageWidth = jQuery(".window").width();
	var imageSum = jQuery(".image_reel img").size();
	var imageReelWidth = imageWidth * imageSum;
	
	
	//Adjust the image reel to its new size
	jQuery(".image_reel").css({'width' : imageReelWidth});
	
	//Paging + Slider Function
	rotate = function(){	
		var triggerID = jQueryactive.attr("rel") - 1; //Get number of times to slide
		var image_reelPosition = triggerID * imageWidth; //Determines the distance the image reel needs to slide

		jQuery(".paging a").removeClass('active'); //Remove all active class
		jQueryactive.addClass('active'); //Add active class (the jQueryactive is declared in the rotateSwitch function)
		
		//Slider Animation
		jQuery(".image_reel").animate({ 
			left: -image_reelPosition
		}, 500 );
		
	}; 
	
	//Rotation + Timing Event
	rotateSwitch = function(){		
		play = setInterval(function(){ //Set timer - this will repeat itself every 3 seconds
			jQueryactive = jQuery('.paging a.active').next();
			if ( jQueryactive.length === 0) { //If paging reaches the end...
				jQueryactive = jQuery('.paging a:first'); //go back to first
			}
			rotate(); //Trigger the paging and slider function
		}, 7000); //Timer speed in milliseconds (3 seconds)
	};
	
	rotateSwitch(); //Run function on launch
	
	//On Hover
	jQuery(".image_reel a").hover(function() {
		clearInterval(play); //Stop the rotation
	}, function() {
		rotateSwitch(); //Resume rotation
	});	
	
	//On Click
	jQuery(".paging a").click(function() {	
		jQueryactive = jQuery(this); //Activate the clicked paging
		//Reset Timer
		clearInterval(play); //Stop the rotation
		rotate(); //Trigger rotation immediately
		rotateSwitch(); // Resume rotation
		return false; //Prevent browser jump to link anchor
	});	
	/*end home page slider*/
});
