$(document).ready(function(e) {

	var ajaxCache = {};
	/* START : Each Tab Click on widget */
	$("[data-class='widgets_tab']").click(function(){
		
		/* START : tab show-hide script */
		var tabnavid =  $(this).attr('data-tabnavid');
		var widgetID =  $(this).attr('data-widget');
		var currentShowDiv = $(".wdgt-slider-block .tabpane_"+widgetID+"[data-tabid='"+tabnavid+"']");
		$(".wdgt-slider-block .tabpane_"+widgetID+"").hide();
		currentShowDiv.show();
		$(this).closest(".wdgt-tab").find("li a.tab").removeClass('active');
		$(this).addClass('active');
		/* END : tab show-hide script */

		/* START : Ajax call to get the widget tab items */
		var href =  $(this).attr('data-href');
		/* To check whether the Ajax cache has the HTML content . If not ; call Ajax else fetch from the cache variable*/
		if(typeof ajaxCache[href] =='undefined'){
			$.ajax({
				type:"GET",
				url:GLOBAL_BASE_PATH + href,
				beforeSend:function(){	
				},
				success:function(html){
					ajaxCache[href] = html;
					currentShowDiv.html(html);
						
				}
			});
		}else{
			html = ajaxCache[href];
			currentShowDiv.html(html);
			
		}
		/* END : Ajax call to get the widget tab items */
	});
	/* END : Each Tab Click on widget */

	
	/*START : To load the initial widget tab products */
	$(".first_tab").trigger('click');
	/*END : To load the initial widget tab products */

});


