function getBaseUrl(){
	url=window.location.href; 
	var args=url.split('/');
	var first=args[2].split('.')[0];  
	if( parseInt(first)==first){ 
		 page_url='http://'+args[2]+'/'+args[3]+'/';  //http://192.168.0.32/wholesalej/
	} else{
		 page_url='http://'+args[2]+'/';   //http://www.wholesalej.com/
	}
	//alert(page_url);
	return page_url;
}

var baseURL = getBaseUrl();
 


(function($){

$(document).ready(function(){
	
	 $.ajax({
		  type:"POST",
		  url:baseURL+"index.php?main_page=ajax_cart",
		  success:function(data){
		      $('#head_login').html(  $(data).filter("#head_login").html() );
			  $("#shopping_cart_count").html( $(data).filter("#shopping_cart_count").html()  );
			  }
		  })
	
		  
		  
	 //bof products
	 $.ajax({
		type:"post",
		url:baseURL+"index.php?main_page=ajax_index",
	    success:function(data){  
		 
			featured_len_s=data.indexOf('<div id="featured"><ul>');
			featured_len_e=data.indexOf('</ul></div><div id="featured_end"></div>');
			featured_len=data.substring(featured_len_s,featured_len_e+11  );  
			$("#mFeaturedProducts .product-list-items").append(featured_len);
			 
			
			
			
			new_len_s=data.indexOf('<div id="products_new"><ul>');
			new_len_e=data.indexOf('</ul></div><div id="products_new_end"></div>');
			new_len=data.substring(new_len_s,new_len_e+11  );
			$("#NewProducts .product-list-items").append(new_len);
			 

//			popu_len_s=data.indexOf('<div id="popular_search">');
//			popu_len_e=data.indexOf('</div><div id="popular_search_end"></div>');
//			popu_len=data.substring(popu_len_s,popu_len_e+11  );  
//			$("#popular_wrap").append(popu_len);
			
			
			rec_order_len_s=data.indexOf('<div id="rec_order"><ul id="recentlyorder">');
			rec_order_len_e=data.indexOf('</ul></div> <div id="rec_order_end"></div>');
			rec_order_len=data.substring(rec_order_len_s+43,rec_order_len_e  );
			$("#recentlyorder").html(rec_order_len);
			
			
			specials_len_s=data.indexOf('<div id="specials"><ul>');
			specials_len_e=data.indexOf('</ul></div><div id="specials_end"></div>');
			specials_len=data.substring(specials_len_s,specials_len_e+5);
			$("#SpecialsProducts .product-list-items").append(specials_len);
			
		  } 
	  });
	 

 
	 
});
})(jQuery)
// search keywords
function getkeywords(id,type){
		 //alert(type+'__'+id);
	 
			jQuery.ajax({
					type:"get",
					url:baseURL+"index.php?main_page=ajax_popular_search&type="+type+"&id="+id,
				    success:function(data){	
					   popu_len_s=data.indexOf('<div id="popular_search">');
					   popu_len_e=data.indexOf('</div><div id="popular_search_end"></div>');
					   popu_len=data.substring(popu_len_s,popu_len_e+11  );  
					   //alert(popu_len);
					   $("#popular_wrap").append(popu_len);
			        } 
			  });
			
	 
}
		
 // $(document).ready(ktc(78));
	 

//bof products
	var Cart={
			Add: function(pid){
					jQuery.ajax({
						type:"get",
						url:baseURL+"index.php?main_page=index&action=buy_now&products_id="+pid,
						//data:"main_page=product_info&action=buy_now&products_id="+pid,
						success:function(data){
						jQuery("#product-item-message-"+pid).html('<span style="line-height: 20px; color: rgb(198, 56, 24); font-weight: bold; font-size: 11px;">Add to Cart success</span>');
							jQuery.ajax({
								type:"POST",
								url:"index.php?main_page=ajax_cart",
								success:function(data){
								     //alert(data);
								jQuery("#buyerCartCountNumber").html( jQuery(data).filter("#shopping_cart_count").html()  );
								}
							})
						}
					})
				}
			}

	
 



