// Add to shopping Bag
function AddInBag(prodid,qty,action,attrib1,attrib2) 
{
		var exurl='';	

///=============================Code For Attribute checking========================
		if($("#"+attrib1))
		{
			exurl=exurl+"&attrib_1= "+ $("#"+attrib1).val();
			if($("#"+attrib1).val()=="")
			{	
				//*alert("Please Select the Attribute.");
				$.modaldialog.warning("Please Select the Attribute.");
				$("#"+attrib1).focus();
				return false;
			}
		}	
		if($("#"+attrib2))
		{
				exurl=exurl+"&attrib_2= "+ $("#"+attrib2).val();
				if($("#"+attrib2).val()=="")
				{	
					//alert("Please Select the Attribute.");
					$.modaldialog.warning("Please Select the Attribute.");
					$("#"+attrib2).focus();
					return false;
				}
		}
// 	=============================End Code For Attribute checking========================	
///alert(qty);return false;
	$.ajax({
		   type: "POST",
		   url: Site_URL+"script/shoppingcart_ajax.php",
		   data: "action=" + action + "&productid=" + prodid +"&quantity= "+ qty + exurl,
		   success: function(msg)
					{
					   var response = msg.split("##");
					   //alert( response[0] );
					  $.modaldialog.success("The item has been added to shopping bag.");
					  document.getElementById('id_totalitem_bag').innerHTML =  response[0]; // Total Items in Bag
					  document.getElementById('id_totalitem_bag1').innerHTML = response[0];
					  
					  document.getElementById('id_subtot_bag').innerHTML =  response[1]; // Total Items in Bag
					 					  
				   }
	});
	
}
// Add to Shopping Bag End Here.

//Clear List From the Bag
function RemoveBagItems(action) 
{
///alert(qty);return false;
	$.ajax({
		   type: "POST",
		   url: Site_URL+"script/shoppingcart_ajax.php",
		   data: "action=" + action ,
		   success: function(msg)
					{
					   var response = msg.split("##");
					   //alert( response[0] );

					 document.getElementById('id_totalitem_bag').innerHTML =  0; // Total Items in Bag
					 document.getElementById('id_totalitem_bag1').innerHTML = 0;
					 document.getElementById('id_subtot_bag').innerHTML =  "$0.00"; // Total Items in Bag
					 document.getElementById('id_cartshow').style.display='none'; //Shopping cart td not show
					 document.getElementById('id_empty').style.display='block'; //No Record message on shopping cart
					 
										 					  
				   }
	});
}
//End Clear List From the Bag

// Add to shopping Bag
function AddInWishList(prodid,action) 
{
//alert(icustomer_id);
	if(icustomer_id=='' || icustomer_id==0)
		{ 
			alert("Please login for add product to your wish list !!");
			return false;
		}
		
	$.ajax({
		   type: "POST",
		   url: Site_URL+"script/shoppingcart_ajax.php",
		   data: "action=" + action + "&productid=" + prodid ,
		   success: function(msg)
					{
					   var response = msg.split("##");

					    //New code for set message in wish list added time :: 04-03-2011///////////////
						if(response[3] == '1')
						{
							//*alert("The item has been added to wishlist.");
							 $.modaldialog.success("The item has been added to wishlist.");
						}
					    else
					    {
							//*alert("The item already added in your wishlist.");
							$.modaldialog.warning("The item already added in your wishlist.");
					    }
						///////////////////////////////////////
						
					   document.getElementById('id_totalwish').innerHTML = response[2]; //Wishlist total item
					 				  
					 					  
				   }
	});
	
}
// Add to Shopping Bag End Here.

//Clear List From the Bag
function RemoveWishItems(action) 
{
	$.ajax({
		   type: "POST",
		   url: Site_URL+"script/shoppingcart_ajax.php",
		   data: "action=" + action ,
		   success: function(msg)
					{
					   var response = msg.split("##");
					   //alert( response[0] );
					   document.getElementById('id_totalwish').innerHTML = 0; //Wishlist total item
					   document.getElementById('id_listshow').style.display='none'; //Wishlist cart td not show
					   document.getElementById('id_msgshow').style.display='block'; //No Record message on Wishlist Page.
										 					  
				   }
	});
}
//End Clear List From the Bag

function LTrim(str) {
   var whitespace = new String(" tnr");
   var s = new String(str);

   if (whitespace.indexOf(s.charAt(0)) != -1) {

      var j=0, i = s.length;

      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;

      s = s.substring(j, i);
   }
   return s;
}

function RTrim(str)	{
   var whitespace = new String(" tnr");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {

      var i = s.length - 1;       

      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;
      s = s.substring(0, i+1);
   }
   return s;
}


function Trim(str)
{
   return RTrim(LTrim(str));
}

