/*
 * jQuery hashchange event - v1.3 - 7/21/2010
 * http://benalman.com/projects/jquery-hashchange-plugin/
 * 
 * Copyright (c) 2010 "Cowboy" Ben Alman
 * Dual licensed under the MIT and GPL licenses.
 * http://benalman.com/about/license/
 */
(function($,e,b){var c="hashchange",h=document,f,g=$.event.special,i=h.documentMode,d="on"+c in e&&(i===b||i>7);function a(j){j=j||location.href;return"#"+j.replace(/^[^#]*#?(.*)$/,"$1")}$.fn[c]=function(j){return j?this.bind(c,j):this.trigger(c)};$.fn[c].delay=50;g[c]=$.extend(g[c],{setup:function(){if(d){return false}$(f.start)},teardown:function(){if(d){return false}$(f.stop)}});f=(function(){var j={},p,m=a(),k=function(q){return q},l=k,o=k;j.start=function(){p||n()};j.stop=function(){p&&clearTimeout(p);p=b};function n(){var r=a(),q=o(m);if(r!==m){l(m=r,q);$(e).trigger(c)}else{if(q!==m){location.href=location.href.replace(/#.*/,"")+q}}p=setTimeout(n,$.fn[c].delay)}$.browser.msie&&!d&&(function(){var q,r;j.start=function(){if(!q){r=$.fn[c].src;r=r&&r+a();q=$('<iframe tabindex="-1" title="empty"/>').hide().one("load",function(){r||l(a());n()}).attr("src",r||"javascript:0").insertAfter("body")[0].contentWindow;h.onpropertychange=function(){try{if(event.propertyName==="title"){q.document.title=h.title}}catch(s){}}}};j.stop=k;o=function(){return a(q.location.href)};l=function(v,s){var u=q.document,t=$.fn[c].domain;if(v!==s){u.title=h.title;u.open();t&&u.write('<script>document.domain="'+t+'"<\/script>');u.close();q.location.hash=v}}})();return j})()})(jQuery,this);


/********************************************
* Tab plugin
*
********************************************/
(function($, undefined) {
	var defaultTabConfig = {
			tabClass : "services-tab",
			tabContainerId : "TabbedPanelsContentGroup",
			defaultTab : "",  ///Loads the first tab by default, else mention the id
			onBeforeTabLoad: function(fn) {
				$(".services-tab").bind("tabBeforeLoad", fn);
			},  //// will also be available as $.fn.onBeforeTabLoad
			onTabLoad : function(fn) {
				$(".services-tab").bind("tabLoadComplete", fn);
			}, //// will also be available as $.fn.onTabLoad
			tabLoaderClass : 'loader'
		};
		
	
	$.fn.tabs = function(configurations) {
		var config = {};
		$.extend(true, config, configurations, defaultTabConfig);
		var tabCls = "." + config.tabClass, tabContId = "#" + config.tabContainerId,
		     parent = this;
			$.fn.extend(config); 
			
			
	    /// Tab click behaviour
		$(tabCls, parent).click(function(e) {
			var tabContentClass = $(this).attr("id").replace("#", ''),
			     tabContentEl = $("." + tabContentClass), 
				 tabContent = $(tabContentEl).text(),
				 url = $(this).find('a').attr('href'),
				 tabEl = this; ///selected tab element
			if(!tabContentEl.length > 0) return;  ///quit if no tabContentHolder found
			// remove class 'selected' from any tab if present and add to selected tab.
			$(tabCls, parent).removeClass('current');
			$(tabEl).addClass('current');
			//hide all other tabs
			$(tabContId + " > li").hide();

			/// Load tab content else show cached content
			$(tabEl).trigger("tabBeforeLoad"); /// trigger tab before load
			$(tabContentEl).show();
		    if(tabContent.length > 0 ) {  
				$(tabEl).trigger("tabLoadComplete");  /// tab content is cached so tigger tabOnload
			}else {   /// fire Ajax 
				$(tabContentEl).ajaxStart(function() {
					$(this).addClass($.fn.tabLoaderClass);
				});
				$(tabContentEl).load(url, function(responseText) {
					if($(this).hasClass("services-soa-pricing")) {
						this.innerHTML = responseText; ///hack for bypassing IE issue for SOA pricing Tab(ToDo: change)
					}
					$(tabEl).trigger("tabLoadComplete");   ////trigger onload event after tab is complete
				});
				$(tabContentEl).ajaxStop(function() {
					$(this).removeClass($.fn.tabLoaderClass);
				});
			}
			
			if(e.target.href || e.target.srcElement || location.hash.indexOf("#")==-1){
				var rel = $("a", this).attr("rel").replace("!","");
				document.location.hash = "!"+rel;//adding ! for SEO
			}

 			if( e.target.href || e.target.srcElement || location.hash !== "#!how-it-works" ){
			$('.pads-t2 .pads-t2-screen,.pads-t2 .pads-t2-bullet').slideUp('slow');
			}
				
			return false;
		});	
	};
	$.fn.extend({
		loadTab : function(id) {
			var selector = "", $elem = null;
			if(id && id.indexOf("#") === 0) {   ///when "#id"
				selector = "#\\" + id;
			}else if(id.indexOf("#") < 0) { ///when "id"
				selector = "#\\#" + id;
			}else {
				selector = null;
			}
			$elem = $(selector);
			
			if(id && selector && $elem.length > 0) {  //// #tabid but not jumplink
			   if(!$elem.is('.current')) {  /// dont fire a click if the tab is already open
					$elem.click();
			   }
			} else {
				$("." + $.fn.tabClass).filter(":first").click();
			}
		}
	});
	

 })(jQuery);


/********************************************
* Left Nav plugin
*
********************************************/
(function($, undefined) {
	var defaultLeftNavConfig = {
			leftNavHeaderClass : "awsSideNavHeader",
			leftNavMenuClass : "awsSideNavMenu",
			navLinkContainerClass: "LeftBox",
			onLeftNavLoad : function(fn) {
				$("." + defaultLeftNavConfig.leftNavHeaderClass).bind("loadComplete", fn);
			} ,//// will also be available as $.fn.onLeftNavLoad
			onNavClick : function(fn) {
				$("." + defaultLeftNavConfig.navLinkContainerClass + " a").bind("navigate", fn);
			}//// will also be available as $.fn.onNavClick
	};
	
	$.fn.leftNav = function(configurations) {
		var config = {};
		$.extend(true, config, configurations, defaultLeftNavConfig);
		$.fn.extend(config);
		///left nav click behaviour
		$("." + defaultLeftNavConfig.leftNavHeaderClass, this).click(function() {
			var navHeader = this, navMenu = $(navHeader).next();
			//toggle
			if($(navHeader).hasClass("active")) {
				///slideup all  and remove class 'active'
				$("." + defaultLeftNavConfig.leftNavHeaderClass).removeClass('active').next().slideUp('fast');
			}else {
				///slideup all  and remove class 'active'
				$("." + defaultLeftNavConfig.leftNavHeaderClass).removeClass('active').next().slideUp('fast');
				$(navHeader).addClass('active');
				$(navMenu).slideDown('fast', function() {
					$(this).prev().trigger("loadComplete");
				});
			}
		});
		
		$("." + config.navLinkContainerClass + " a", this).click(function(e) {
			//var tabid = "#" + $(this).parent().attr('id').replace("_sidebar", '');
			var tabclass = "." + $(this).parent().attr('id').replace("_sidebar", '');
			var hash=e.target.href;		
			
			$(this).trigger("navigate");		
			if($(tabclass).length > 0 ) { /// assuming tab present, need to use better logic
			
				if(hash.indexOf("#")!=-1){
						$('.pads-t2 .pads-t2-screen,.pads-t2 .pads-t2-bullet').slideUp('slow');
						var urlhash=hash.substr(1, hash.length).split("#")[1];
						urlhash = urlhash.replace("!","");
						document.location.hash = "!"+urlhash;/*adding ! for SEO */
				}			
				return false  ;
			}
			return true;
		});
	}
 })(jQuery);



/**************************************
* URL Route for opening tabs [Global]
**************************************/
/* Route URL hash */
		var RouteManager = function() {
			//private
			//Public
			return {
				init : function() {
					var urlHash = document.location.hash, tabId = "", hm="", jumpLink = "", hashOnHash = [];
					/*Code for avoiding XSS issue*/
					var hrefRegEx = /^[A-Za-z0-9-!]+$/;
					if(!hrefRegEx.test(urlHash.substr(1))){	
							$("#services-tab").loadTab("");
							return true;
					}	
					/*End of code for avoiding XSS issue*/
					if(urlHash) {
					
						
						///bad workaround for PADS #terhash75 need to use better logic
						if(urlHash.indexOf("termhash75") >= 0) {
							urlHash = "#pay-per-click-pricing#termhash75";	
							
						}
						if(urlHash.indexOf("shoppers-see") >= 0) {
							urlHash = "#how-it-works#shoppers-see";	
						}						
						
						hashOnHash = urlHash.substr(1, urlHash.length).split("#");
						if(hashOnHash.length > 1) {
							urlHash = "#" + hashOnHash[0];
							jumpLink = hashOnHash[1];
						}
						
							
						
							tabId = RouteManager.findTabIdFromHash(urlHash);
							
						
					} else {
						hm = getQueryVariable("id"); //getQueryVariable from lead.js
						tabId = RouteManager.findTabIdFromQueryParam(hm);
						
					}
					
					$.fn.onTabLoad(function() {
						if(jumpLink) {
						//	document.location.hash = jumpLink;
							$(".image-btn a").trigger("focus");	
							jumpLink = "";
						}
					});
					
					if(tabId) {
						
						$("#services-tab").loadTab(tabId); /// loads the tabid passed as param else 1st tab
						return false;
					}
					$("#services-tab").loadTab("");  ///load default tab
				},
				findTabIdFromQueryParam : function(hm) {  /// accept id=HM1 type of params
					hm = hm || "hm1";
					var tabs = [], index =  hm.match(/\d+/)[0], id = "";
					index = +index || 1;
					$("#services-tab .services-tab").each(function() {
						tabs.push(this);
					});
					if(index > 0 && tabs.length > 0) {
						id = $(tabs[index-1]).attr("id");
					}
					return id;
				},
				findTabIdFromHash : function(hash) {  //// map <a rel="xyz"> to tab id
					var rel = hash.substr(1, hash.length), id = "";
					rel = rel.replace("!","");//for removing ! added for SEO
					id = $("#services-tab a[rel = " + rel + "]").parent().attr("id") || false;
					return id;
				}
			};
		}();  //route manager end
//jQuery.fn.hashchange.delay = 5; //for IE6 & IE7

$(window).hashchange(function() {
	RouteManager.init();
});   ///handle tab history


/********************************************
* Left Nav and Tab implementation using plugins
*
********************************************/
(function($, undefined) {
	///on document load
	$(function() {
		///load tabs
		var tabConfig = {
			tabClass : "services-tab",
			tabContainerId : "TabbedPanelsContentGroup",
			defaultTab : "",  ///Loads the first tab by default, else mention the id
			tabLoaderClass : 'loader'
		};
		///init tabs
		$("#services-tab").tabs(tabConfig);
		///check if url has hash
		$.fn.onTabLoad(function() {
			var sidenavLink = null,
				tabId = $(this).attr('id'),
				temp = tabId.replace("#", ''),
				tabCont = $("." + temp),
			sidenavId = "#" + temp + "_sidebar";
			sidenavLink = $(sidenavId);
			if($(sidenavLink).is(":hidden")) {
				$(sidenavLink).parents(".awsSideNavMenu").prev().click();
			}
			$(sidenavLink).parent().find('a').removeClass('leftTabActive');
			$(sidenavLink).find('a').addClass('leftTabActive');
			
			///call sanitizer on link
			 UrlSanitizer.init(tabCont);

		});
		
	
	///load left nav
		var navConfig = {
			leftNavHeaderClass : "awsSideNavHeader",
			leftNavMenuClass : "awsSideNavMenu",
			navLinkContainerClass: "LeftBox"
		};
		
		///init left nav
		$("#awsSideNav").leftNav(navConfig);
		$.fn.onNavClick(function() {
			var hashId = "";
			var tabId = $(this).parent("li.left-nav-service").attr('id');
			hashId = "#" + tabId.replace(/_sidebar$/, '');
			tabId = "#\\#" + tabId.replace(/_sidebar$/, '');
			tab = $(tabId);
			if(tab.length > 0) {
				$.fn.loadTab(hashId);
			}
			//$('.pads-t2 .pads-t2-screen,.pads-t2 .pads-t2-bullet').slideUp('slow');
			//$('.signup-box').fadeIn();
			
		});
		
		/*$('.left-nav-service a').click(function(event) {
			event.preventDefault();
		});*/
		if(location.href.indexOf("product-ads-associates")!=-1){
			$("#services-pads-associates_sidebar_sidebar a").addClass("leftTabActive");
		}

		RouteManager.init();  /// open tab based on url
		

	});
 })(jQuery);







/*Home page*/
//Facebook page iframe injection
jQuery(function() {
	$(".facebook-social-strip iframe").attr("allowTransparency", "true");
});

/*Common to services page*/
jQuery(function(){
	$('.QnA_Question').live('click', function(){
		    var el = $(this).next();
			if($(el).is(":visible")) {
				expandCollapse(el, false); //collapse
			} else {
				expandCollapse(el, true); //expand
			}
  });
  
  
  
  jQuery('.QnA-right-text-header').live('click', function(){
		var txt= $.trim(jQuery(this).text()), els = $(this).parent().next().find('div.QnA_Answer');
	
		if(txt.toLowerCase() == "expand all") {
			$(els).each(function() {
				expandCollapse(this, true);
			});
			$(this).text("Collapse All");
		}else {
			$(els).each(function() {
				expandCollapse(this, false);
			});
			$(this).text("Expand All");
		}
	});
	
	
	function expandCollapse(el, bool) {
		if(bool) {
			$(el).slideDown(function() { 
				$(el).prev('.QnA_Question').find('img').attr('src', "http://g-ecx.images-amazon.com/images/G/01/AmznServices/en_US/images/icon/AS_Ominus._V184426707_.gif");
			});
		}else {
			$(el).slideUp(function() { 
				$(el).prev('.QnA_Question').find('img').attr('src', "http://g-ecx.images-amazon.com/images/G/01/AmznServices/en_US/images/icon/AS_Oplus.gif");	
			});
		}
	}
});



 

//SOA page
//js for soa-freepromo-sem
$(function(){
	
	/* makes show/hide media links, tooltip working for tabload or without tabload */
	function pricingLinks(){
	
		$('.available-categories').click(function(){
			$(this).next().toggle();
		});

		$('.toolbox').hover(function(){
			$(this).show();
		}, 
		function(){
			$(this).hide();
		});
	
		$('#soa-pricing').delegate('#ViewElidible3','mouseover',function(){
							$(this).next().find('.toolbox').show();
			});

		$('#soa-pricing').delegate('.soa .toolbox','mouseover mouseout',function(e){
			if(e.type=='mouseover')
			{
				$(this).show();
			}
			else if(e.type=='mouseout')
			{
				$(this).hide();
			}
	});

	$("#showMedialink").live('click', function() {
		toggleExamples.call(this, "showMedia");
	});
	
	$("#showOtherlink").live('click', function() {
		toggleExamples.call(this, "showOther");
	});
	
	//SOA guidelines above tabbed pannel
	$('.sell-guideline a').click(function(){
			$(this).closest('.sell-guideline').next().toggle();
			return false;
		});
	$(".guidelines .close").click(function(){
		$('.guidelines').hide();
	});
	
	}
	
	pricingLinks();
	


$.fn.onTabLoad(function() {
	pricingLinks();
});

	function toggleExamples(example_div_id) {
		var txt = $(this).text().toLowerCase() == "more examples"? "Hide examples" : "More examples";
		$("#" + example_div_id).toggle();
		$(this).text(txt)
	}

 //code for readmore links and category combo box
        $.fn.onTabLoad(function() {
			$('.common-short-note-shown').click(function(){
					$(this).text("");
					$(this).parent().next().toggle();
			});
				
			jQuery('span.common-short-note-hidden-link').click(function(){
				$(this).parent().parent().parent().toggle();
				$(this).parent().parent().parent().prev().find('.common-short-note-shown').html('Read More<br clear="all">');
			});

			jQuery('div.common-select-list').html('<select style="font-size: 11px;"  id="ungatingWidgetChoice"><option selected="selected" value="http://s3.amazonaws.com/merchant-facing/StyleGuides/ApparelStyleGuide.pdf">-- Choose your category---</option><option value="http://s3.amazonaws.com/merchant-facing/StyleGuides/BabyStyleGuide.pdf">Baby</option><option value="http://s3.amazonaws.com/merchant-facing/StyleGuides/BeautyStyleGuide.pdf">Beauty                                </option><option value="http://s3.amazonaws.com/merchant-facing/StyleGuides/ApparelStyleGuide.pdf">Clothing &amp; Accessories</option><option value="http://s3.amazonaws.com/merchant-facing/StyleGuides/GroceryStyleGuide.pdf">Grocery &amp; Gourmet Food</option><option value="http://s3.amazonaws.com/merchant-facing/StyleGuides/HPCStyleGuide.pdf">Health &amp; Personal Care</option><option value="http://g-ecx.images-amazon.com/images/G/01/rainier/help/Home_and_Garden-Style_Guide.pdf">Home</option><option value="http://s3.amazonaws.com/merchant-facing/StyleGuides/ToolsStyleGuide.pdf">Home Improvement (Tools)</option><option value="http://s3.amazonaws.com/merchant-facing/StyleGuides/SoftwareStyleGuide.pdf">Software &amp; Video Games</option><option value="http://s3.amazonaws.com/merchant-facing/StyleGuides/ShoesStyleGuide.pdf">Shoes*</option><option value="http://s3.amazonaws.com/merchant-facing/StyleGuides/SportingGoodsStyleGuide.pdf">Sports &amp; Outdoors</option><option value="http://s3.amazonaws.com/merchant-facing/StyleGuides/ToysStyleGuide.pdf">Toys</option><option value="http://s3.amazonaws.com/merchant-facing/StyleGuides/WatchesStyleGuide.pdf">Watches</option></select>');
								
			jQuery('#ungatingWidgetChoice').change(function(){
						window.open(document.getElementById('ungatingWidgetChoice').value)
			});
		});
		
});

function showExample(id) {
	//$("#" + id).toggle();
}
function read(o) {
	if (document.getElementById(o).style.display=='none') {
		document.getElementById(o).style.display='block';
		document.getElementById(o+'link').innerHTML='Hide';
	}
	else {
		document.getElementById(o).style.display='none';
		document.getElementById(o+'link').innerHTML='Read More';
	} 
}

function showTooltip(o){
	hideTooltip();
   document.getElementById(o).style.display='block'; 
   window.location.hash=o+"Hash";                                          
}
function hideTooltip(){
   document.getElementById('ship1').style.display='none';
   document.getElementById('ship2').style.display='none';
}

///SOA videos and guides --Naman
browserName = navigator.appName; browserVer = parseInt(navigator.appVersion); condition = !(( (browserName.indexOf("Explorer") >=0 ) && (browserVer < 4) ) || ((browserName.indexOf("Netscape") >=0 ) && (browserVer < 2) ) ) ; if (condition == true ) CanAnimate = true; else CanAnimate = false; function openchild(thisurl){ if ( CanAnimate ){ msgWindow=window.open( '' ,'subwindow','background-Color=#FFFFCC,toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,menubar=no,resizable=yes,width=900,height=700'); msgWindow.focus(); msgWindow.location.href = thisurl; } else { msgWindow=window.open( thisurl,'subwindow','background-Color=#FFFFCC,toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,menubar=no,resizable=yes,width=900,height=700'); } }

/****************JS for SOA guide******************/

function embedSOAGuideHowItWorks(w, h){

	var attributes = {
		id : "media",
		name : "media",
		align : "center"
	};
	var URL = "http://g-ecx.images-amazon.com/images/G/01/AmznServices/en_US/merchant/SOAHowItWorks/SOAHowItWorks_controller.swf";
	var width = w || '400';
	var height = h ||'400';
	
	
	setTimeout(function() {
		swfobject.embedSWF(URL, "flashVideo",width,height,'9.0.115',"",{csConfigFile : 'http://g-ecx.images-amazon.com/images/G/01/AmznServices/en_US/merchant/SOAHowItWorks/SOAHowItWorks_config.xml',csColor : 'FFFFFF',csPreloader : 'http://g-ecx.images-amazon.com/images/G/01/AmznServices/en_US/merchant/SOAHowItWorks/SOAHowItWorks_preload.swf',csFilesetBookmark : '0'},{quality : 'best', bgcolor : 'FFFFFF', allowscriptaccess : 'always'},attributes);
	}, 1000);
}
	
jQuery(function(){
$.fn.onTabLoad(function() {
			var selector =  "", el ={}, width = "", height = "";
                if($('div.flash-player-video').length > 0) {
                                selector = "div.flash-player-video";
								width = "400";
								height = "400";
								el = $(selector).html('<div id="flashVideo"></div>');
								embedSOAGuideHowItWorks(width, height);
								
                } 
				
				if($(".how-it-works-video-t4").length > 0)
				{
					$(".how-it-works-video-t4").html('<object width="461" height="285"> <param name="wmode" value="transparent"></param><param name="movie" value="http://fpdownload.adobe.com/strobe/FlashMediaPlayback_101.swf"></param><param name="flashvars" value="src=http://g-ecx.images-amazon.com/images/G/01/AmznServices/en_US/merchant/SOAHowItWorks/Amazon_SOA_FL9_Widescreen_960x540._V161938183_.flv&poster=http%3A%2F%2Fg-ecx.images-amazon.com%2Fimages%2FG%2F01%2FAmznServices%2Fen_US%2Fimages%2Ficon%2Fas-video._V166567053_.png&bufferingOverlay=false"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://fpdownload.adobe.com/strobe/FlashMediaPlayback_101.swf" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="461" height="285" flashvars="src=http://g-ecx.images-amazon.com/images/G/01/AmznServices/en_US/merchant/SOAHowItWorks/Amazon_SOA_FL9_Widescreen_960x540._V161938183_.flv&poster=http%3A%2F%2Fg-ecx.images-amazon.com%2Fimages%2FG%2F01%2FAmznServices%2Fen_US%2Fimages%2Ficon%2Fas-video._V166567053_.png&bufferingOverlay=false" wmode="transparent"></embed></object>');
					$(".how-it-works-video-t4").css({'position' : 'relative', 'z-index' : '0'});
				}
				if($(".how-it-works-promo").length > 0)
				{
					$(".how-it-works-promo").html('<object width="461" height="285"> <param name="wmode" value="transparent"></param><param name="movie" value="http://fpdownload.adobe.com/strobe/FlashMediaPlayback_101.swf"></param><param name="flashvars" value="src=http://g-ecx.images-amazon.com/images/G/01/AmznServices/en_US/merchant/SOAHowItWorks/Amazon_MASTER_Short_FL9_Widescreen_960x540._V161295438_.flv&poster=http%3A%2F%2Fg-ecx.images-amazon.com%2Fimages%2FG%2F01%2FAmznServices%2Fen_US%2Fimages%2Ficon%2Fas-video._V166567053_.png&bufferingOverlay=false"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://fpdownload.adobe.com/strobe/FlashMediaPlayback_101.swf" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="461" height="285" flashvars="src=http://g-ecx.images-amazon.com/images/G/01/AmznServices/en_US/merchant/SOAHowItWorks/Amazon_MASTER_Short_FL9_Widescreen_960x540._V161295438_.flv&poster=http%3A%2F%2Fg-ecx.images-amazon.com%2Fimages%2FG%2F01%2FAmznServices%2Fen_US%2Fimages%2Ficon%2Fas-video._V166567053_.png&bufferingOverlay=false" wmode="transparent"></embed></object>');
					$(".how-it-works-promo").css({'position' : 'relative', 'z-index' : '0'});
				}
				
			 	$(".how-it-works-video").click(function(){
								$(this).css('background','none');
					            width = "460";
								height = "285";
								el = $(this).html('<div id="flashVideo"></div>');
								embedSOAGuideHowItWorks(width, height);
                }); 
                

});

});
/*FBA ************************/

$(function(){
	$('.popup').live('click', function(){
		$('.tooltipGroup').css('z-index','0');
		$(this).next().toggle();
		$(this).parent('.tooltipGroup').css('z-index','202');
	});
	$('.close').live('click', function(){
		$(this).parent('.tooltip-content').hide();
	});
	
	//fba top image changes with tab changes
	$('.fba .services-tab').bind('tabLoadComplete', function() {
		var imageId = "#image-" + $(this).attr("id").replace("#", '');
		$(".tab-image").removeClass('visuallyhidden').hide();
		$(imageId).fadeIn();
		
	})
});

/*Pads pricing table*/

$(function() {
	$("td.expandable").live('click', expandCollapse);
	
	$("td.pads-table-style2").live('click', expandCollapse);
	
	function expandCollapse() {
		var tr = $(this).parent('tr').next().toggle();	
		if($(tr).is(":visible")) {
			$("img", this).attr("src", "http://g-ecx.images-amazon.com/images/G/01/AmznServices/en_US/images/icons/AS_minus._V183805782_.gif");	
		}else {
			$("img", this).attr("src", "http://g-ecx.images-amazon.com/images/G/01/AmznServices/en_US/images/icons/AS_plus._V183805780_.gif");
		}
	}
     //P-ADS view categories
			 $(".pads .tooltipgroup img").hover(function() {
				 $(this).next().show();
				 $(this).parent().css('zIndex', 3000); //hack for IE7 and below
			 }, function() {
				 $(this).next().hide();
				  $(this).parent().css('zIndex', 1);  //hack for IE7 and below
			 });
	 
	 	   $('.pads-thumb').click(function(){
		   		$(this).next().show();
		   });
		   $('.close-btn').click(function(){
			    $(this).parent().hide();
		   });
  
		  $('.pads-details').hover(function(){
		   		$(this).next().show();
		   },
		   function(){
		   		$(this).next().hide();      
		   });
			
		   $(".TooltipMouseOut").mouseover(function(event) {
				$(this).parent().hide();
		   });           

	 
      //PADS  tracking pixel
$.fn.onTabLoad(function(){
		if($('#wrapper.pads').length > 0){
		    var tag = getQueryVariable('tag');
			if(tag && tag != null){
				var preRegRegex = new RegExp('signup\.htm',"i");
				$('a').each(function() {
					var href = $.trim($(this).attr('href'));
					if(href.match(preRegRegex) && href.indexOf('tag=') < 0) {
						if(href.indexOf('?') > 0) {
							//href += '%26tag='+ tag;
							href += '&tag=' + tag;
						} else {
							href += '?tag=' + tag;
						}
						$(this).attr('href', href);
					}
				});
				
		     }	
	     }	
	});  
	function sendPadsTracking() {
		var tag = getQueryVariable('tag'), 
			iframe = document.createElement('iframe'),
                        url = "http://product-ads-portal.amazon.com/gp/tracking/tracker.html?tag=" + tag;
		if(!tag) return;
		iframe.style.display = "none"
		iframe.setAttribute('src', url);
		document.body.appendChild(iframe);
	}
	if($("#wrapper.pads").length || $("#wrapper.pads-decision-tree").length || $(".pads-3dcart").length) {
		sendPadsTracking();
	}
//end P-Ads tracking pixel
	$.fn.onTabLoad(function(){
		
			$('.services-pads-pricing').delegate('.restricted-tooltip-link','mouseover',function(){

                     $(this).next().show();
             });

		$('.services-pads-pricing').delegate('.pads-pricing-table .toolbox','mouseover mouseout',function(e){
				if(e.type=='mouseover')
				{
					$(this).show();
				}
				else if(e.type=='mouseout')
				{
					$(this).hide();
				}
		});		

});
});



/* Script for adding List of Testimonials */

var cs = {"clientData": [
	 { "name":"Asp Doors","link":"asp-doors.htm"},
     { "name":"Geroy Family","link":"geroys.htm"},
	 { "name":"Go Vacuum","link":"go-vacuum.htm"},
     { "name":"Star Bright","link":"starbright.htm"},
     { "name":"Urban Boundaries","link":"urban_boundaries.htm"},
     { "name":"Thrift Recycling","link":"thriftrecycling.htm"},
     { "name":"SoftwareHouse","link":"softwarehouse.htm"},
     { "name":"Reiss Innovations","link":"reiss_innovations.htm"},
     { "name":"Redtag Sale","link":"redtagsale.htm"},
     { "name":"Fantasies-Costume","link":"first_fantasies_costume_cuzzins.htm"},
     { "name":"Samsonite","link":"samsonite.htm"},
     { "name":"Art of Appreciation","link":"artofappreciation.htm"},
     { "name":"SmartPractice","link":"smart-gloves.htm"},
	 { "name":"ABC Pharmacy","link":"abc_pharmacy.htm"},
	 { "name":"As Seen on TV Guys","link":"as-seen-on-tv-guys.htm"},	 
     { "name":"BabyBecause","link":"babybecause.htm"},
     { "name":"Before the Stores","link":"beforethestores.htm"},	 
     { "name":"BP Medical","link":"bpmed.htm"},
     { "name":"Central Chef","link":"centralchef.htm"},
     { "name":"HandStands","link":"handstands.htm"},
     { "name":"Bella Sara","link":"bella-sara.htm"},
     { "name":"Timex","link":"timex.htm"},
     { "name":"TextbooksRus","link":"textbooksrus.htm"},
     { "name":"CrazyonDigital","link":"case_studies_crazyon_digital.htm"},
     { "name":"No Thyme","link":"case_studies_no_thyme.htm"},
     { "name":"QuickAutoHouse","link":"case_studies_quick_auto_house.htm"},
     { "name":"Element Jewelry","link":"case_studies_element_jewerly.htm"},
     { "name":"Uber Shop","link":"case_studies_ubershop.htm"},
     { "name":"HSN","link":"case_studies_hsn.htm"},
     { "name":"Toy Burg","link":"case_studies_toyburg.htm"},
     { "name":"Big T","link":"case_studies_t_case.htm"},
	 { "name":"Mow Town","link":"case_studies_mowtown.htm"}
]
};

$(document).ready(function() {                              
                  var newarr=[],template="<ul class='amzn_casestudy_box'>",
                                                URL = window.location.pathname,
												pagelastindex=URL.search(/\.htm/),
                                                PageName = URL.slice(9,pagelastindex+4); 

                                newarr = jQuery.grep(cs.clientData, function(obj) {
                                                return obj.link != PageName;
                                });  
								
                  $.each(newarr,function(i,val){
												template+="<li><a href='/content/"+val.link+"'>" + val.name + "</a></li>";
															
                  });

				  $('.testimonial-list').html("").append(template+"</ul>").append("<div style='clear:both'></div>");
				
				$('.case-study-inner-box').find('.headline').click(function(){
					$('.testimonial-list').slideToggle();
					$(this).toggleClass('active');
					return false;
				});
	  
				  

  });
  
  /* Script for Services-title page */
  $(function() {
	  	var services = {};
		var selectBox = $("<select class='mm_selectbox'><option value=''> -- Make your choice -- </option></select>").appendTo(".services-title-top .services-title-options");
		$(selectBox).before("<span>How can I help you?&nbsp;&nbsp;&nbsp;&nbsp;</span>");
		$(".services-title-top .services-title-showhide").text("Expand All Services");
		// get all services and dump in array
		
		$(".services-titlepage-table-row .mm_greybox").each(function() {
			var serviceClass = $.trim(this.className.replace('mm_greybox', ''));
			var serviceName = $(".title" , this).text();
			services[serviceClass] = serviceName;
		});
		
		//populate selectbox
		$.each(services, function(indx, val) {
			$("<option value='" + indx +"'>" + val + "</option>").appendTo(selectBox);			
		});
		
		//Showhide methods
		function expandCollapse(el, bool) {
			if(bool) { //expand
				$(el).slideDown('slow', function() {
					$(this).prev(".mm_greybox").find('.showhide img').attr('src', "http://g-ecx.images-amazon.com/images/G/01/AmznServices/en_US/images/icon/AS_mm_up.gif");
				});
			}else {
				$(el).slideUp('slow', function() {
					$(this).prev(".mm_greybox").find('.showhide img').attr('src', "http://g-ecx.images-amazon.com/images/G/01/AmznServices/en_US/images/icon/AS_mm_down.gif");
				});
			}
		}
		
		function hideAll() {
			$(".services-titlepage-table .mm_description").each(function() {
				expandCollapse(this, false);
			})
		}
		
		function showAll() {
			$(".services-titlepage-table .mm_description").each(function() {
				expandCollapse(this, true);
			})
		}
		
		
		//attach listeners
		$(selectBox).change(function() {
			var value = $(this).val(), el;
			
			hideAll();
			if(value) {
				el = $("." + value).next('.mm_description');
				expandCollapse(el, true);
			}
		});
		
			$(".services-title-top .services-title-showhide").click(function(){
                                                
		if($(this).text()=='Expand All Services'){                
					showAll();
					$(this).text("Collapse All Services");
					}
					else if($(this).text()=='Collapse All Services'){
					hideAll();
					$(this).text("Expand All Services");
					}              
                                
		});
		
		$(".mm_greybox").click(function() {
			var el = $(this).next('.mm_description');
			if($(el).is(":visible")) {
				expandCollapse(el, false);
			}else {
				expandCollapse(el, true);
			}
		})
  });
  



//js for fba-tour-video single-col

$(function(){
	$('.singn-up-now-box').mouseover(function(){
		$('.register-box').show();
	});

	$('.register-box').mouseout(function(){
		$(this).hide();
	});
});

//JS for seller-success stories

$(function() {
	var selectBox = null;
	$('.success-story:first').before("<div class='bluebar'><div class='select-cont'>Sort by product&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='showAll'><a href='#'>Show All</a></div></div>");
	//Create the select box
	selectBox = $("<select id='storySelect'><option value=''>-- Make Your Choice --</option><option value='soa-stories'>Sell on Amazon</option><option value='fba-stories'>Fulfillment by Amazon</option><option value='pads-stories'>Amazon Product Ads</option><option value='wba-stories'>Amazon WebStore</option></select>").appendTo(".bluebar .select-cont");
	
	function showAll() {
		$(".success-story").show();
		$("#storySelect option").attr("selected", "");
		$(selectBox).filter("option:first").attr("selected", "selected");
		$(".bluebar .showAll").hide();
	}
	
	function hideAll() {
		$(".success-story").hide();
		$(".bluebar .showAll").show();
	}
	
	///attach handlers
	$("#storySelect").change(function() {
		var value = $(this).val();
		if(value){
			hideAll();
			$("." + value).show();
		}else {
			showAll();
		}
	});
	
	$(".bluebar .showAll").click(showAll);
	
});
 
 
/******************
* FBA Reg not launched
**********************/
$(function() {
	$(".show-all").click(function(){
			$(".reversecolumncheck img").attr("src","http://g-ecx.images-amazon.com/images/G/01/AmznServices/en_US/images/icon/Collapse.gif");
			$('.topic-detail').show();
	});
	
	$(".hide-all").click(function(){
			$(".reversecolumncheck img").attr("src","http://g-ecx.images-amazon.com/images/G/01/AmznServices/en_US/images/icon/Expand.gif");
			$('.topic-detail').hide();
	});
	
	$(".reversecolumncheck a").click(function(){
			if($(this).parent(".reversecolumncheck").next().css("display") == "none") {
				   $(this).find('img').attr("src","http://g-ecx.images-amazon.com/images/G/01/AmznServices/en_US/images/icon/Collapse.gif");
			}else {
				   $(this).find('img').attr("src","http://g-ecx.images-amazon.com/images/G/01/AmznServices/en_US/images/icon/Expand.gif");
			}
			$(this).parent(".reversecolumncheck").next().toggle();
			return false;
	});
	
	$(".get_started,.Sidebar1 a,.topic-detail a").click(function(){
			var link=$(this).attr("href");
			window.open(link, '_blank', 'status=0, toolbar=0, location=0, menubar=0, directories=0, resizable=0, scrollbars=0, height=550, width=850');
			return false;
	});
})

/******************
Scripts for product-ads-associates.htm
********************/
$(function() {
	$(".q-bar").click(function() {
		$(".q-text", this).toggleClass("close");
		$(this).next().toggle();	
	});

	$(".sub-bar").click(function() {
		$(this).toggleClass("close");
		$(this).next().toggle();	
	});
	
	$(".expand-all").click(function() {
		var text = $.trim($(this).text());
		if(text === "Expand All") {
				$(this).text("Collapse All");
				$(".q-text").addClass("close");
				$(".q-bar").next().show();
		}else {
				$(this).text("Expand All");
				$(".q-text").removeClass("close");
				$(".q-bar").next().hide();
		}
	});
	
	///load left nav
	//$(".pads-associates #services-pads-pricing_sidebar").parents(".awsSideNavMenu").prev().click();
	$("#services-pads-pricing_sidebar").parents(".awsSideNavMenu").prev().click();

});

$('div.pads-associates').find('span.linked-text').hover(function(){
                $('.popup').show();
},function(){

                $('.popup').hide();
});
$('div.pads-associates').find('.popup').hover(function(){
$(this).show();
},
function(){
$(this).hide();
});

/************************************
	JS for pads interstitial page
***********************************/

$(document).ready(function() {

         var steps = $('.step1, .step2, .step3');  //cache elements
		//hide all but first step
         
		//$('.dt-rec, .step2, .step3').hide();
		hideNextSteps(1);
		$("input", this).attr("checked", "");

		//a radio has been clicked

		$('.dt-radio').click(function() {

			if($('input[name="dt-what"]',this).length) {

				//$('.dt-rec, .step2, .step3').hide() ;
				hideNextSteps(1);
			}

			if($('input[name="dt-are"]', this).length) {

				//$('.dt-rec, .step3').hide();
				hideNextSteps(2);
			}

			if($('input[name="dt-types"]', this).length) {

				hideNextSteps(3);

			}
			$("input", this).attr("checked", "checked");
            
			var next = "." + $("input", this).attr("value");

			$(next).show("slide", function() {
				if(this.style.removeAttribute) {
					this.style.removeAttribute("filter");  /// fix for IE7 and IE8 compatibiity moode force rendering of fonts in clearType.
					}
			});

		});
		
		
		function hideNextSteps(iCurStep) { 
			//iCurStep = iCurStep - 1;
			while(iCurStep <= steps.length) {
				$('.dt-rec').hide();
				$(steps[iCurStep]).hide().find("input").attr("checked", '');
				iCurStep++;
			}
		}
	});
	

/*******************************
scripts for Unsubscribe page
*******************************/
$(function() {
	
	var mktoPreFillFields = {};
	var profiling = {};
	if($(".unsubscribe").length) {
		 mktoPreFillFields = {"Email":null,"Unsubscribed":false,"AmazonPayments":false,"AmazonProductAds":false,"AmazonWebstoreopt-out":false,"FulfillmentbyAmazonopt-out":false,"SellingonAmazonopt-out":false};
		 profiling = {
			isEnabled: false,
			numberOfProfilingFields: 3,
			alwaysShowFields: [ 'mktDummyEntry']
		};	
		
		$("input[name='submitButton']").click(function() {
			formSubmit(document.getElementById("mktForm_22"));
			return false;
		});
	}
	
});

	function formSubmit(elt) {
		return Mkto.formSubmit(elt);
	}
	function formReset(elt) {
		return Mkto.formReset(elt);
	}
	function fieldValidate(field) {
	  /* call Mkto.setError(field, message) and return false to mark a field value invalid */
	  /* return 'skip' to bypass the built-in validations */
	  if($(field).attr('name') === "Email") {
		  return validateEmailCustom(field);
	  }
	  return true;
	}
	function getRequiredFieldMessage(domElement, label) {
	  return "This field is required";
	}
	function getTelephoneInvalidMessage(domElement, label) {
	  return "Please enter a valid telephone number";
	}
	function getEmailInvalidMessage(domElement, label) {
	  return "Please enter a valid e-mail address";
	}
	function mktoGetForm() {
		var frm1 = document.getElementById('mktForm_22');
		if(frm1) { return frm1;};
	}
	
	//cannot use Marketo's default email validation procedure since 
	//adding class to 'input' is not allowed in ContactUs widget
	function validateEmailCustom(field) {
		 var emailRE =  /^[a-zA-Z0-9_!&=`~#%'\/\$\^\|\+\?\{\}-]+(\.[a-zA-Z0-9_!&=`~#%'\/\$\^\|\+\?\{\}-]+)*@[a-zA-Z0-9]([a-zA-Z0-9_-])*(\.[a-zA-Z0-9][a-zA-Z0-9_-]*)+$/,
	  		val = $(field).val(),
		   isEmpty = val.length > 0 ? false : true,
		   isValidEmail = !isEmpty && emailRE.test(val) ? true : false;
		   if(!isValidEmail) {
			    Mkto.setError(field, "Please enter a valid Email address");
	  			return false;
		   }
		   return true;
	}
	
	/********************
	* Fix for connect with us widget (temp)
	**********************/
	function formSubmit(elt) {
		var ret = Mkto.formSubmit(elt);
		if(ret) {
			$("#leadcapture-form-cont, #leadcapture-thankyou-msg").toggle();
			return true;
		}else {
			return false;
		} 
	}
	
/**************************
* Display-Ads 
**************************/


$(function() {
	 	   $('.display-ads-thumb').click(function(){
		   		$(this).next().show();
		   });
		   $('.display-ads-details').hover(function(){
		   		$(this).next().show();
		   },
		   function(){
		   		$(this).next().hide();      
		   });
});


/******************************
* Pre-load images for P-ads and Display-ads thumbs
*******************************/
 $(function() {
	  
	 $('.pads-thumb').next().each(function() {
	    var src = $(this).css('background-image');
		preloadImg(src);
	});

	 
	 $('.display-ads-thumb').next().each(function() {
	    var src = $(this).css('background-image');
		preloadImg(src);
	});


   function preloadImg(src) {
	   (new Image()).src = src;
   }

 });
 
 /******************************
* sell-on-amazon-freepromo-1.htm
*******************************/
jQuery(function(){
var timeout = null;	
	
	
$('#wrapper').delegate('.case-study-navigator .next','click',function(){
    var curr = getCurrent(),
	    next = getNext();
	if(next) {
		$(curr).removeClass("current").fadeOut();
		$(next).addClass("current").fadeIn();
	}
	//showHideButtons();

});

$('#wrapper').delegate('.case-study-navigator .prev','click',function(){

    var curr = getCurrent(),
        prev = getPrevious();


	if(prev) {
		$(curr).removeClass("current").fadeOut();
		$(prev).addClass("current").fadeIn();
	}
	//showHideButtons();
});




function showHideButtons() {
    var prev = getPrevious(),
	    next = getNext();
	if(prev && prev.length > 0) {
		$(".prev").show();
	}else {
		$(".prev").hide();
	}
	if(next && next.length > 0) {
		$(".next").show();
	}else {
		$(".next").hide();
	}
}

function getCurrent() {
     var $el = $(".case-study.current");
	return $el.length > 0 ? $el : $(".case-study:first");
}
function getPrevious() {
  var curr = getCurrent(),
      prev = $(curr).prev();
  return prev.length > 0 ? $(curr).prev() : null;
}

function getNext() {
  var curr = getCurrent(),
      next =  $(curr).next();
  return next.length > 0 ? next : null;
}

$("#TabbedPanelsContentGroup").delegate(".col1 img", "hover", function(event) {
	var position = $(this).position();
	//$(this).parent().css('position', 'relative');
	$(this).parent().prev().css({"position" : "absolute", "left" : position.left + 20, "top" : position.top + 10}).toggle(event.type === "mouseenter");
});

});
/******************************
* PADS pop-ups
*******************************/



	 
jQuery(function(){


$.fn.onTabLoad(function() {

 function resizePop(nWidth, nHeight) {
	
	var scrolledY = document.body.scrollTop || document.documentElement.scrollTop || self.pageYOffset;
	var ptop = (scrolledY) ? scrolledY + 100 : 100;
	
	$(".pads-popup-container").css({left: ($(window).width() - nWidth) / 2, top:ptop, display: "block", opacity: 1}).animate({ opacity: 1 }, 500, "swing");
	
	$(".pads-popup-body").css({width: nWidth, height: nHeight});
	
 }

 
$('#wrapper').delegate('.pads-placement > a','click',function(event) {

	event.preventDefault();
	$('.pads-popup-container').appendTo(document.body);		
	var linkName = $(this).parent().parent().attr('class');
	var popup = linkName.substr(5);
	
	$('.pads-popup-content').html($('.' + popup).html());
	
	if($('.' + popup + " .detail-img:first").length) {
		resizePop($('.' + popup + " .detail-img:first").width(), $('.' + popup + " .detail-img:first").height() + 50);
	} else {
		resizePop(740, 520);
	}
	

});

 function closePop() {						
	$('.pads-popup-container').animate({ opacity: 0 }, 1000, "swing", function() {
			$('.pads-popup-container').css({display:"none"});
	});
	$('.pads-popup-content').html("&nbsp;");
 }

 	$('.pads-popup-content').find('.close-btn').live('click',function(event) {
			event.preventDefault();
			closePop();
    });
	
 $('.awsSideNavQuick a[href*="wmv"]').click(function(){
		$('.pads-popup-content').html($('.webinar').html());
		$('.pads-popup-container').appendTo(document.body);
		resizePop(740, 520);
		return false;
    });

	 
$('.where-will-shoppers').click(function(event) {

			location.hash="shoppers-see";
			// $('html, body').animate({scrollTop: $(".shoppers-see-your").offset().top}, 0);
			$('.shoppers-see-your').css({ backgroundColor: "#CCE0FF" });
			return false;	
		});
		
$('.termhash75').live('click',function(){
location.hash="!termhash75";
return false;
});	
});	
});	 

/* script for pads shopify page*/
$(window).load(function()
{
	if($(".pads-shopify").length > 0)
	{
		document.title = "Increase Shopify Sales with Amazon Product Ads";
		var footerLinks = ["shp_pricing","shp_how","shp_wps","shp_tq","shp_et"];
		var tabIds = ["!pay-per-click-pricing","!how-it-works","!what-people-say","!top-questions","!events-tutorials"];//adding ! for SEO optimization
		for(var i = 0;i<footerLinks.length;i++)
		{
			var linkHref = $("."+footerLinks[i]+" a").attr("href");
			var newHref = linkHref+"#"+tabIds[i];
			$("."+footerLinks[i]+" a").attr("href",newHref);			
		}
		 $(".receive75 a").attr("href",$(".receive75 a").attr("href")+"#!termhash75");//adding ! for SEO optimization
		 $(".restrict_apply a").attr("href",$(".restrict_apply a").attr("href")+"#!termhash75");//adding ! for SEO optimization	
	}

}
);

$(document).ready(function(){
	if($(".all-services").length > 0){
		var $this=$(".all-services");
		$this.find('ul:first').addClass('topnav');
		$this.find('ul').eq(1).addClass('subnav');
	}
	$(".all-services").hover(function(){
		var $this=$(this);					
		$this.find(".topnav").addClass('topborder');
		$(this).find('.subnav').show();
		return true;
	},
	function(){		
		var $this=$(this);
		$this.find('.subnav').hide();
		$this.find(".topnav").removeClass('topborder');
	});
});

/*Script for go button in main page*/

function validateEmail(elementValue) {
    var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
    return emailPattern.test(elementValue);
}

function submit_form(){
    var frm = $("#mktForm_27")[0];
    var ret = Mkto.formSubmit(frm);
	var gc_email_status = $(".email-wrapper");
    if (ret) {
		gc_email_status.html("<div class='success'>Thank you for subscribing!</div>");
        return true;
    } else {
        return false;
    }
}

$('.home-page #lead-gobutton').click(function () {		
		var gc_email_fld = $('#lead-email');
		var gc_email_status = $(".email_status_msg");
        if (gc_email_fld.val() == '') {
            gc_email_fld.addClass("error");		
			gc_email_status.html(">> Please enter valid email");
        } else if (!validateEmail(gc_email_fld.val())) {
            gc_email_fld.addClass("error");
			gc_email_status.html(">> Please enter valid email");
        } else {
            $('#Email').val(gc_email_fld.val());
            gc_email_fld.removeClass("error");
			gc_email_status.html("");
            submit_form();
        }
});
//for treatment2
jQuery(function() {
jQuery('.pads-t2-bullet').hover(
function () {
jQuery(this).find('.pads-t2-hover').fadeIn('fast');
},
function () {
jQuery(this).find('.pads-t2-hover').fadeOut('fast');
}
);
}); 

/*script for home page country drop down*/
$(document).ready(function(){
	$(".header-links ul li").eq(0).find("a").addClass("country_anc");
	$(".country-link a").mouseover(function(){$(".header-links ul").show().focus();});
	$(".header-links ul").mouseleave(function(){$(this).hide();});	
});
/*end of script for home page country drop down*/
jQuery(function(){
		$("#nav-pads").live('click',function(){
		if($(".pads-t2-banner").hasClass('treatment-2')){
					$('.pads-t2 .pads-t2-screen,.pads-t2 .pads-t2-bullet').slideUp('slow');
					return false;
			}
		});
});

/*code for showing generic pop up*/
$(document).ready(function(){
	if($(".webstore_tutorial").length > 0){
		$(".webstore_tutorial").html('<object width="865" height="540"><param name="wmode" value="transparent"></param><param name="movie" value="http://fpdownload.adobe.com/strobe/FlashMediaPlayback_101.swf"></param><param name="flashvars" value="src=https://s3.amazonaws.com/AmazonWebstoreUS/New Intro to Webstore Webinar/2011-11-17 12.00 Introduction to Amazon Webstore.flv&poster=http%3A%2F%2Fg-ecx.images-amazon.com%2Fimages%2FG%2F01%2FAmznServices%2Fen_US%2Fimages%2Fbanner%2Fnew_webstore_into._V161822678_.png&bufferingOverlay=true"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://fpdownload.adobe.com/strobe/FlashMediaPlayback_101.swf" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="865" height="540" flashvars="src=https://s3.amazonaws.com/AmazonWebstoreUS/New Intro to Webstore Webinar/2011-11-17 12.00 Introduction to Amazon Webstore.flv&poster=http%3A%2F%2Fg-ecx.images-amazon.com%2Fimages%2FG%2F01%2FAmznServices%2Fen_US%2Fimages%2Fbanner%2Fnew_webstore_into._V161822678_.png&bufferingOverlay=true" wmode="transparent"></embed></object>');	
	}	
});
 function showVideoPop(nWidth, nHeight) {	
	var scrolledY = document.body.scrollTop || document.documentElement.scrollTop || self.pageYOffset;
	var ptop = (scrolledY) ? scrolledY + 100 : 100;	
	$(".video-popup-container").css({left: ($(window).width() - nWidth) / 2, top:ptop, display: "block", opacity: 1}).animate({ opacity: 1 }, 500, "swing");	
	$(".video-popup-body").css({width: nWidth, height: nHeight});	
 }

$('#wrapper').delegate('.video-placement > a','click',function(event) {
	event.preventDefault();
	$('.video-popup-container').appendTo(document.body);		
	var linkName = $(this).parent().parent().attr('class');
	var popup = linkName.substr(5);	
	$('.video-popup-content').html($('.' + popup).html());	
	if($('.' + popup + " .detail-img:first").length) {
		showVideoPop($('.' + popup + " .detail-img:first").width(), $('.' + popup + " .detail-img:first").height() + 50);
	} else {
		showVideoPop(740, 520);
	}
});
 function closeVideoPop() {						
	$('.video-popup-container').animate({ opacity: 0 }, 1000, "swing", function() {
			$('.video-popup-container').css({display:"none"});
	});
	$('.video-popup-content').html("&nbsp;");
 }
 $('.video-popup-content').find('.video-close-btn a').live('click',function(event) {
			event.preventDefault();
			closeVideoPop();
});	
 $('.services-intext_head2 a[href*="flv"]').click(function(){
		$('.video-popup-content').html($('.webinar').html());
		$('.video-popup-container').appendTo(document.body);
		showVideoPop(865, 580);
		return false;
});
/*end of code for showing generic pop up*/
