function buyProduct(prodId, skuId) 
{
    window.scrollTo(0, 0);

    //$('#light').fadeIn();
    $('#fade').show();
    var height=$('body').height();
    $('#fade').css("height",height);

    var postData = {
        'prodId': prodId, 
        'skuId': skuId
    };
    $.ajax({
        url: baseUrl + "index.php/cart/cart/buyCart",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) {
            //$('#light').hide();
            $('#light').html(response.strRespVal);                        
            $('#cartTot').html("("+response.totProduct+")");
            $('#light').slideDown("slow");
        }
    });
}

function addProduct(prodId, skuId) 
{
    var postData = {
        'prodId': prodId, 
        'skuId': skuId
    };
    $.ajax({
        url: baseUrl + "index.php/cart/cart/addToCart",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) {
            if (response.strRespVal == "Added") {
                $('#cartTot').html("("+response.totProduct+")");
                alert('The item has been added to your shopping cart.');
            }
            else if (response.strRespVal == "Exist"){
                alert('This item is already in your shopping cart.');
            }
        }
    });
}

function updateCart(cartId) 
{
    qty = $('#cartQty' + cartId).val();
	
    var postData = {
        'cartId': cartId, 
        'qty': qty
    };
    $.ajax({
        url: baseUrl + "index.php/cart/cart/updateCart",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) {
            $('#light').html('');
            $('#cartTot').html("("+response.totProduct+")");
            $('#light').html(response.strRespVal);
        }
    });
}

function closeShoppingCart() 
{
    $('#light').hide();
    $('#fade').hide();
}

function continueShopping() 
{
    $('#light').hide();
    $('#fade').hide();
}

function deleteItems(cartId) 
{
    $('#light').show();
    $('#fade').show();

    var postData = {
        'cartId': cartId
    };
    $.ajax({
        url: baseUrl+"index.php/cart/cart/deleteProductCart",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) {
            $('#light').html('');
            $('#light').html(response.strRespVal);
            $('#cartTot').html("("+response.totProduct+")");
        }
    });
}

function displayCart() 
{
    $('#light').show();
    $('#fade').show();
    var height=$('body').height();
    $('#fade').css("height",height);

    $.ajax({
        url: baseUrl+"index.php/cart/cart/displayCart",
        type: "POST",
        cache: false,
        dataType: 'json',
        success: function(response, status, XHR) {
            $('#light').html('');
            $('#light').html(response.strRespVal);
        }
    });
}

function placeOrder(cartMasterId) 
{
    var postData = {
        'cartMasterId': cartMasterId
    };
    $.ajax({
        url: baseUrl + "index.php/cart/cart/addProductsOrder",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) {
            var randomNumber = Math.floor(Math.random()*1001);
            location.href = baseUrl + "index.php/order";
        }
    });
}
function product_pagination_sort(baseUrl,cnt,page_no,cat_id,brand_id,sortPrice,pageSize)
{
	
    $('#category_right_comman').html('<div align="center"><img src="'+baseUrl+'assets/images/loading.gif"/></div>');
    var attributes_val=document.getElementsByName("attributes_val");
    var attributes_val_array=[];
    var j=0;
    for(var i=0;i<attributes_val.length;i++)
    {
        if(attributes_val[i].checked==true)
        {
            attributes_val_array[j]=attributes_val[i].value;
            j++;
        }
    }
    var min_value=$slider.slider("values", 0);
    var max_value=$slider.slider("values", 1);
    var postData = {
        'cnt': cnt, 
        'page_no': page_no, 
        'cat_id': cat_id, 
        'brand_id': brand_id, 
        'attributes': attributes_val_array, 
        'min_value': min_value, 
        'max_value': max_value, 
        'sortPrice': sortPrice, 
        'pageSize': pageSize
    };
    $.ajax({
        url: baseUrl + "index.php/products/search/index_sort",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) {

            $('#category_right_comman').html(response.product_list_page);
        }
    });
}

function product_pagination(baseUrl,cnt,page_no,cat_id,brand_id,sortPrice,pageSize)
{
    $('#category_right_comman').html('<div align="center"><img src="'+baseUrl+'assets/images/loading.gif"/></div>');
    var attributes_val=document.getElementsByName("attributes_val");
    var attributes_val_array=[];
    var j=0;
    for(var i=0;i<attributes_val.length;i++)
    {
        if(attributes_val[i].checked==true)
        {
            attributes_val_array[j]=attributes_val[i].value;
            j++;
        }
    }
    //var sortPrice= $('#sortByPrice').val();
    //alert(sortPrice);
    var min_value=$slider.slider("values", 0);
    var max_value=$slider.slider("values", 1);
    var postData = {
        'cnt': cnt, 
        'page_no': page_no, 
        'cat_id': cat_id, 
        'brand_id': brand_id, 
        'attributes': attributes_val_array, 
        'min_value': min_value, 
        'max_value': max_value, 
        'sortPrice': sortPrice, 
        'pageSize': pageSize
    };
    $.ajax({
        url: baseUrl + "index.php/products/search/index_page",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) {

            $('#category_right_comman').html(response.product_list_page);
        }
    });
}



function terms_conditions()
{
    var url;
    url = baseUrl + "index.php/common/termsandconditions";
    var strWinFeatures = "dependent=no,resizable=yes,scrollbars=yes,titlebar=yes,left=100,top=25,height=800px,width=900px";
    var popupWindow = window.open(url, 'popUpResequence', strWinFeatures);
}



function sendInvitation() 
{
    var email = $('#conEmail').val();
    if( email=='' ) {
        alert('Please enter your mail');
    }
    else if( !isValidEmailAddress( email ) ) 
    {
        alert('Please enter valid email address');
    }
    else {
        var postData = {
            'email': email
        };
        $.ajax({
            url: baseUrl + "index.php/user/congratulation/sendInvitaion",
            type: "POST",
            cache: false,
            dataType: 'json',
            data: postData,
            success: function(response, status, XHR) {
                alert("Thanks for your interest. Our team will process ASAP. Expect your invite soon.");

            }
        });
    }
}

function closeCongrats() 
{
    $('#indexlight').hide();
    $('#indexfade').hide();
}

function isValidEmailAddress(emailAddress) 
{
    var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
    return pattern.test(emailAddress);
}

function dispPromoCode() 
{
    $('#indexlight').show();
    $('#indexfade').show();

    $.ajax({
        url: baseUrl + "index.php/user/congratulation/diplayPromo",
        type: "POST",
        cache: false,
        dataType: 'json',
        success: function(response, status, XHR) {
            $('#indexlight').html('');
            $('#indexlight').html(response.strRespVal);
        }
    });
}

function checkPromo() 
{
    var promoCode = $('#promoCode').val();
    var postData = {
        'promoCode': promoCode
    };
    $.ajax({
        url: baseUrl + "index.php/user/congratulation/checkPromo",
        type: "POST",
        cache: false,
        dataType: 'json',
        data: postData,
        success: function(response, status, XHR) {
            if(response.strRespVal != "OK"){
                alert("Please Enter proper Promo code.");
            }
            else{
                $('#indexlight').hide();
                $('#indexfade').hide();
            }
        }
    });
}

function attribute_search(att_name_id,att_id,baseUrl,cat_id)
{
    $('#category_right_comman').html('<div align="center"><img src="'+baseUrl+'assets/images/loading.gif"/></div>');
    var attributes_val=document.getElementsByName("attributes_val");
    var attributes_val_array=[];
    var brand_id=$('#brands').val();
	
    var attributes_val_droplist=$('#attributes_val_droplist').val();
	
    if(attributes_val_droplist!='')
        attributes_val_array[attributes_val_array.length]=attributes_val_droplist;
	
    var j=0;
    for(var i=0;i<attributes_val.length;i++)
    {
        if(attributes_val[i].checked==true)
        {
            attributes_val_array[j]=attributes_val[i].value;
            j++;
        }
    }
    var sortPrice= $('#sortByPrice').val();
    var min_value=$slider.slider("values", 0);
    var max_value=$slider.slider("values", 1);
    var postData = {
        'attributes': attributes_val_array, 
        'cat_id': cat_id, 
        'brand_id': brand_id, 
        'min_value': min_value, 
        'max_value': max_value, 
        'sortPrice': sortPrice
    };
    $.ajax({
        url: baseUrl + "index.php/products/search/index_page",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) {
            //alert(response.product_list_page);
            $('#category_right_comman').html(response.product_list_page);
        }
    });
}
function attribute_search_image(att_name_id,att_id,baseUrl,cat_id)
{
    $('#category_right_comman').html('<div align="center"><img src="'+baseUrl+'assets/images/loading.gif"/></div>');
    var attributes_val=document.getElementsByName("attributes_val");
    var attributes_val_array=[];
    var brand_id=$('#brands').val();
	
    var attributes_val_droplist=$('#attributes_val_droplist').val();
	
    if(attributes_val_droplist && attributes_val_droplist!='')
        attributes_val_array[attributes_val_array.length]=attributes_val_droplist;
	
    var j=0;
    for(var i=0;i<attributes_val.length;i++)
    {
        if(attributes_val[i].checked==true)
        {
            attributes_val_array[j]=attributes_val[i].value;
            j++;
        }
    }
    attributes_val_array[attributes_val_array.length]=att_id;
    var sortPrice= $('#sortByPrice').val();
    var min_value=$slider.slider("values", 0);
    var max_value=$slider.slider("values", 1);
    var postData = {
        'attributes': attributes_val_array, 
        'cat_id': cat_id, 
        'brand_id': brand_id, 
        'min_value': min_value, 
        'max_value': max_value, 
        'sortPrice': sortPrice
    };
    $.ajax({
        url: baseUrl + "index.php/products/search/index_page",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) {
            //alert(response.product_list_page);
            $('#category_right_comman').html(response.product_list_page);
        }
    });
}
function attribute_search_droplist(att_name_id,att_id,baseUrl,cat_id)
{
    $('#category_right_comman').html('<div align="center"><img src="'+baseUrl+'assets/images/loading.gif"/></div>');
    var attributes_val=document.getElementsByName("attributes_val");
    var attributes_val_array=[];
    var brand_id=$('#brands').val();
    var j=0;
    for(var i=0;i<attributes_val.length;i++)
    {
        if(attributes_val[i].checked==true)
        {
            attributes_val_array[j]=attributes_val[i].value;
            j++;
        }
    }
    if(att_id!='')
        attributes_val_array[attributes_val_array.length]=att_id;
	
    var sortPrice= $('#sortByPrice').val();
    var min_value=$slider.slider("values", 0);
    var max_value=$slider.slider("values", 1);
    var postData = {
        'attributes': attributes_val_array, 
        'cat_id': cat_id, 
        'brand_id': brand_id, 
        'min_value': min_value, 
        'max_value': max_value, 
        'sortPrice': sortPrice
    };
    $.ajax({
        url: baseUrl + "index.php/products/search/index_page",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) {
            //alert(response.product_list_page);
            $('#category_right_comman').html(response.product_list_page);
        }
    });
}

function colorSelector(attributeId,chk)
{
    var shap_body=$('#shap_body').val();
    if(chk==2) {
        attributeId='';		
    }
    var postData = {
        'attributeId': attributeId, 
        'shap_body': shap_body
    };
    $.ajax({
        url: baseUrl + "index.php/home/styleMyProductColorSelect",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) {
            //alert(response.product_list_page);
            $('.home_3products_inside').html(response.styleMyProductPage);
        }
    });
}
function whatSuitMe()
{
	
	
    var suitForVal=document.getElementsByName("chkForWhom");
    var suitForValArray=[];
	
    var j=0;
    for(var i=0;i<suitForVal.length;i++)
    {
        if(suitForVal[i].checked==true)
        {
            suitForValArray[j]=suitForVal[i].value;
            j++;
        }
    }
	
	
    if($("#forSenior:checked").length==1) {
        forSenior=	$("#forSenior").val();
    }
    if($("#forStudent:checked").length==1) {
        forStudent=	$("#forStudent").val();
    }
    if($("#forBusiness:checked").length==1) {
        forBusiness=	$("#forBusiness").val();
    }
    var postData = {
        'chkForWhom': suitForValArray
    };
    $.ajax({
        url: baseUrl + "index.php/home/whatSuitMeMostSelect",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) {
            //alert(response.product_list_page);
            $('.home_3products_inside').html(response.whatSuitMeMostPage);
        }
    });
	
}

function popCategory()
{
    var catId = new Array();
    $('.categoryCheckbox:checked').each(function() {
        catId.push($(this).val());
    });
    
    var postData = {
        'catId': catId
    };
    $.ajax({
        url: baseUrl + "index.php/home/getPopularCategory",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) {
            //alert(response.popularCategories.length);
            var popularCategories = response.popularCategories;
            var length = popularCategories.length;
            if(length > 6)
            {
                length = 6;
            }
            var htmlLi = '';
            for(var i = 0; i < length; i++)
            {
                var popCatName = popularCategories[i]['cat_name'];
                if(popCatName.length > 18){
                    popCatName = popCatName.substring(0, 18) + '..';
                }
                htmlLi += '<li><input type="checkbox" value="'+popularCategories[i]['cat_pk_id']+'" id="popCategory'+popularCategories[i]['cat_pk_id']+'" name="popCategory" onclick="return wowJqueryAjax(1);" class="popCategoryCheckbox">';
                htmlLi +=' <label for="popCategory'+popularCategories[i]['cat_pk_id']+'" style="cursor:pointer;">'+ popCatName +'</label></li>';
            }
            $('ul.popularCategory').html(htmlLi);
        }
    });
                
}
function brandCategory()
{
    var catId = new Array();
    //alert("hi");
    $('.categoryCheckbox:checked').each(function() {
        catId.push($(this).val());
    });
    
	
    var postData = {
        'catId': catId
    };
    $.ajax({
        url: baseUrl + "index.php/home/getBrandCategory",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) {
            //alert(response.resp);
            var brandCategories = response.resp;
            var length = brandCategories.length;
            //alert(length);
            var htmlLi = '';
					
            htmlLi +='<li>Please Select<div style="float:right; padding-right:2px;"><img src="'+baseUrl+'assets/images2.0/DownArrow.gif"/></div></li>';
            for(var i = 0; i < length; i++)
            {
                  
                /*	htmlLi += '<option value="'+brandCategories[i]['brd_pk_id']+'" id="brandCategory'+brandCategories[i]['brd_pk_id']+'"  onclick="wowJqueryAjax(1);featuresCat();" class="brandsCheckbox" >';
                       	    htmlLi +=' <label for="brands'+brandCategories[i]['brd_pk_id']+'" style="cursor:pointer;">'+brandCategories[i]['brd_name']+'</label> </option>';
                       */
                htmlLi +='<li><input type="checkbox" name="brands" onclick="wowJqueryAjax(1);featuresCat();" id="brands'+brandCategories[i]['brd_pk_id']+'" class="brandsCheckbox" value="'+brandCategories[i]['brd_pk_id']+'" /> <label style="cursor:pointer;" for="brands'+brandCategories[i]['brd_pk_id']+'">'+brandCategories[i]['brd_name']+'</label><span style="display:none;">'+brandCategories[i]['brd_pk_id']+'</span></li>';
            }
					

                                            
            $('ul.homeWowULbrand').html(htmlLi);
            $(".homeWowULbrand li").css("display", "none");
            $(".homeWowULbrand li:eq(0)").css("display", "block");
        }
    });

    $(".homeWowULbrand").mouseenter(function(){        
        $(".homeWowULbrand li").css("display", "block");
        $(".homeWowULbrand li:eq(0)").css("display", "block");
    });        
    $(".homeWowULshape").mouseenter(function(){        
        $(".homeWowULshape li").css("display", "block");
        $(".homeWowULshape li:eq(0)").css("display", "block");
    });  

}
function featuresCat() {
    var catId = new Array();
    $('.categoryCheckbox:checked').each(function() {
        //alert(catId.push($(this).val()));
        catId.push($(this).val());
    });
	 
    var brandId = new Array();
    $('.brandsCheckbox:checked').each(function() {
        // alert(brandId.push($(this).val()));
        brandId.push($(this).val());
	   
    });
    var postData = {
        'catId': catId ,
        'brandId': brandId
    };
    //  alert(brandId);
    $.ajax({
        url: baseUrl + "index.php/home/getFeaturesCategory",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) {
            //	alert(response.respo);
            var featureCategories = response.respo;
            var length = featureCategories.length;
            var htmlLi = '';
            /*   if(length==0){
						 htmlLi += ' <li> <label style="cursor:pointer;" for="features0">No Features</label></li>';  
					   }*/
            /*htmlLi +='<tr><td><div align="right"><b>Features</b></div></td><td>&nbsp;</td>';
                               htmlLi +=' <td><div class="shapeDropDiv">      <ul class="homeWowULshape">'; */
            htmlLi +='<li>Please Select<div style="float:right; padding-right:2px;"><img src="'+baseUrl+'assets/images2.0/DownArrow.gif"/></div></li>';
            for(var i = 0; i < length; i++)
            {
                htmlLi += ' <li><input type="checkbox" name="features" onclick="return wowJqueryAjax(1);" id="features'+featureCategories[i]['atv_pk_id']+'" class="featuresCheckbox" value= "'+featureCategories[i]['atv_pk_id']+'" /> <label style="cursor:pointer;" for="features'+featureCategories[i]['atv_pk_id']+'">'+featureCategories[i]['atv_value']+'</label></li>';
            }
                                          
            /*  htmlLi +=   '<select class="homeWowULbrand" name="features" multiple="multiple" onmouseover=shoall('+length+')><option>Please Select<div style="float:right; padding-right:2px;"><img src="'+baseUrl+'assets/images2.0/DownArrow.gif"/></div></option>';
					for(var i = 0; i < length; i++)
                        {
                  
						htmlLi += '<option value="'+featureCategories[i]['atl_pk_id']+'" id="features'+featureCategories[i]['atl_pk_id']+'"  name="features" onclick="return wowJqueryAjax(1);" class="featuresCheckbox" >';
                       	    htmlLi +=' <label for="features'+featureCategories[i]['atl_pk_id']+'" style="cursor:pointer;">'+featureCategories[i]['atl_name']+'</label> </option>';
                       
						   }
						    htmlLi +='</ul>  </div></td> </tr>';*/

                                            
            $('ul.homeWowULshape').html(htmlLi);
            $(".homeWowULshape li").css("display", "none");
            $(".homeWowULshape li:eq(0)").css("display", "block");
        }
    });
}
function wowJqueryAjax( pageNo, prodCount )
{
    var min_value = $('#minV').html();
    var max_value = $('#maxV').html();
    var catId = new Array();
    $('.categoryCheckbox:checked').each(function() {
        catId.push($(this).val());
    });
	 
    var brandId = new Array();
    $('.brandsCheckbox:checked').each(function() {
        // alert(brandId.push($(this).val()));
        brandId.push($(this).val());
	   
    });
    var featureId = new Array();
    $('.featuresCheckbox:checked').each(function() {
        // alert(featureId.push($(this).val()));
        featureId.push($(this).val());
	   
    });
	 
    var popCatId = new Array();
    $('.popCategoryCheckbox:checked').each(function() {
        //	alert(popCatId.push($(this).val()));
        popCatId.push($(this).val());
    });
	 
    //alert(catId.length);
    //var brandId = $('#brand_id').val();
    //        if($('.homeWowULbrand li:eq(0) span').html() != null)
    //        var brandId = $('.homeWowULbrand li:eq(0) span').html();
    //        else
    //        var brandId = '';
    
    var pageSize = 4;
    var endLimit = pageSize * pageNo;
    var startLimit = pageSize * (pageNo - 1);
	
    var liWidth = 185;
		
	
    var marginLeft = (pageNo - 1) * (-(liWidth * pageSize) );
	
    $('div.cate_3products ul').animate({
        "marginLeft": marginLeft
    }, "slow");
	
    if( prodCount > pageSize)
    {
        var width = (liWidth * prodCount);
        $('div.cate_3products ul').css('width', width);
    }
	
	
	
    for( var i = startLimit; i < endLimit; i++)
    {
        $('div.cate_3products ul li:eq('+i+')').html('<div class="imgLoader" align="center"><img src="'+baseUrl+'assets/images2.0/ajax-loader-small.gif" /></div>');	
    }
	
    var postData = {
        'pageNo': pageNo, 
        'catId': catId, 
        'brandId': brandId, 
        'min_value': min_value, 
        'max_value': max_value, 
        'popCatId': popCatId, 
        'featureId': featureId
    };
    //alert(brandId);
    $.ajax({
        url: baseUrl + "index.php/products/search/homeWowSearchPagination",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) {
			
            var products = response.allProducts;	
            var totalProdCount =	response.totalProdCount;
            //alert(totalProdCount);
            for( var i = 0; i < products.length; i++ )
            {				
                var sku_mrpFixed=formatNumber(products[i].sku_mrp,0,'','','','','-','');
                var sku_gvpriceFixed=formatNumber(products[i].sku_gvprice,0,'','','','','-','');
				
                var liNo = i + ( (pageNo - 1) * pageSize);
                                
                var perc = Math.round(((products[i].sku_mrp - products[i].sku_gvprice) / products[i].sku_mrp) * 100);
				
                var htmlLi = '<a href="'+baseUrl+'index.php/details/'+products[i].pro_pk_id+ '/' +products[i].pro_seopath+'">';
                if( products[i].chkImage == 'Yes' )
                {
                    htmlLi += '<img src="'+imageUrl+'assets/img/'+products[i].pro_image+'"  height="127" />';
                }
                else
                {
                    htmlLi += '<img src="'+baseUrl+'assets/images2.0/noImage.jpg"  height="127" />';   
                }
                htmlLi += '</a><br />';
                htmlLi+='<div class="fixedHeight"><a href="'+baseUrl+'index.php/details/'+products[i].pro_pk_id+ '/' +products[i].pro_seopath+'">'+products[i].pro_name+'</a></div>';
                htmlLi+='<div class="cate_price"> <span class="cate_left">Rs. '+sku_mrpFixed+'</span>';
                if(perc > 1)
                {
                    htmlLi+='<br/>';
                }
                htmlLi+='<span class="cate_right">Rs. '+sku_gvpriceFixed+' </span></div>';
                if(perc > 1)
                {
                    htmlLi += '<div class="discountImage"><div class="discountText"> '+perc+'%</div></div>';
                }
                htmlLi+='<div class="cate_btns">';
                htmlLi+='<img width="72" height="22" src="'+baseUrl+'assets/images2.0/add_cart_btn.jpg" onclick="return addProduct('+products[i].pro_pk_id+', '+products[i].sku_pk_id+');" style="cursor:pointer;" >';
                htmlLi+='<img width="72" height="22" src="'+baseUrl+'assets/images2.0/buy_nw_btn.jpg" onclick="return buyProduct('+products[i].pro_pk_id+', '+products[i].sku_pk_id+');" style="cursor:pointer;"></div>';
				
                $('div.cate_3products ul li:eq('+liNo+')').html(htmlLi);
                                
                if(perc > 1)
                {
                }
                else
                {
                    $('div.cate_3products ul li:eq('+liNo+') div.cate_price').css("width", "161px");
                    $('div.cate_3products ul li:eq('+liNo+') div.cate_price span.cate_right').css("textAlign", "right");   
                }
				
            }
            var htmlImage='';
            if( pageNo > 1 )
            {
                htmlImage='<img src="'+baseUrl+'assets/images2.0/ButtPrev_normal.gif" width="15" height="19" title="Previous"';
                htmlImage+='style="cursor:pointer;" onclick="return wowJqueryAjax('+(pageNo-1)+', '+prodCount+');"  />&nbsp;';
            }
            else
            {
                htmlImage='<img width="15" height="19" title="Previous"';
                htmlImage+='src="'+baseUrl+'assets/images2.0/ButtPrev_hover.gif">&nbsp;';
            }
				
            if( totalProdCount > (pageNo*pageSize) )
            {
                htmlImage+='<img width="15" height="19" onclick="return wowJqueryAjax('+(pageNo+1)+', '+prodCount+');" style="cursor:pointer;"';
                htmlImage+='title="Next" src="'+baseUrl+'assets/images2.0/ButtNext_hover.gif">';
            }
            else
            {
                htmlImage+='<img src="'+baseUrl+'assets/images2.0/ButtNext_normal.gif" width="15" height="19" title="Next"   />';
            }
            $('div.left_right_arrow').html(htmlImage);
            for( var j = totalProdCount; j < endLimit; j++ )	
            {
                $('div.cate_3products ul li:eq('+j+')').html('');
            }
        }
    });
	
	
}

function formatNumber(num,dec,thou,pnt,curr1,curr2,n1,n2) {
    var x = Math.round(num * Math.pow(10,dec));
    if (x >= 0) n1=n2='';
    var y = (''+Math.abs(x)).split('');
    var z = y.length - dec;
    if (z<0) z--;
    for(var i = z; i < 0; i++) y.unshift('0');
    if (z<0) z = 1;
    y.splice(z, 0, pnt);
    if(y[0] == pnt) y.unshift('0');
    while (z > 3) {
        z-=3;
        y.splice(z,0,thou);
    }
    var r = curr1+n1+y.join('')+n2+curr2;
    return r;
}

function bestSellingProducts ( pageNo, prodCount )
{
   
    var pageSize = 4;
    var htmlLi;
    var htmlImage;
    var endLimit = pageSize * pageNo;
    var startLimit = pageSize * (pageNo - 1);
        
    var liWidth = 184;	
    var marginLeft = (pageNo - 1) * (-(liWidth * pageSize) );
	
    $('div.cate_4products ul').animate({
        "marginLeft": marginLeft
    }, "slow");
        
    for(var i = startLimit; i < endLimit; i++)
    {
        $('div.cate_4products ul li:eq('+i+')').html('<div class="imgLoader" align="center">'+
            '<img src="'+baseUrl+'assets/images2.0/ajax-loader-small.gif" /></div>');	
    }
        
    if( prodCount > pageSize)
    {
        var width = (liWidth * prodCount);
        $('div.cate_4products ul').css('width', width);
    }
				
    var postData = {
        'count': pageSize, 
        'pageNo': pageNo
    };
    $.ajax({
        url: baseUrl + "index.php/home/bestSellingProducts",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) 
        {
            var products = response.allProducts;	
            var totalProdCount =	response.totalProdCount;
            for( i = 0; i < products.length; i++)
            {
                var sku_mrpFixed=formatNumber(products[i].sku_mrp,0,'','','','','-','');
                var sku_gvpriceFixed=formatNumber(products[i].sku_gvprice,0,'','','','','-','');
                                
                var perc = Math.round(((products[i].sku_mrp - products[i].sku_gvprice) / products[i].sku_mrp) * 100);
                                
                var liNo = i + ( (pageNo - 1) * pageSize);
				
                var htmlLi = '<a href="'+baseUrl+'index.php/details/'+products[i].pro_pk_id+ '/' +products[i].pro_seopath+'">';
                if( products[i].chkImage == 'Yes' )
                {
                    htmlLi += '<img src="'+imageUrl+'assets/img/'+products[i].pro_image+'"  height="127" />';
                }
                else
                {
                    htmlLi += '<img src="'+baseUrl+'assets/images2.0/noImage.jpg"  height="127" />';   
                }
                htmlLi += '</a><br />';
                htmlLi+='<div class="fixedHeight"><a href="'+baseUrl+'index.php/details/'+products[i].pro_pk_id+ '/' +products[i].pro_seopath+'">'+products[i].pro_name+'</a></div>';
                htmlLi+='<div class="cate_price"> <span class="cate_left">Rs. '+sku_mrpFixed+'</span>';
                if(perc > 1)
                {
                    htmlLi+='<br/>';
                }
                htmlLi+='<span class="cate_right">Rs. '+sku_gvpriceFixed+' </span>';
                htmlLi+='</div>';
                if(perc > 1)
                {
                    htmlLi += '<div class="discountImage"><div class="discountText"> '+perc+'%</div></div>';
                }

                htmlLi+='<div class="cate_btns"><img src="'+baseUrl+'assets/images2.0/add_cart_btn.jpg" width="72" height="22" onclick="return addProduct('+products[i].pro_pk_id+', '+products[i].sku_pk_id+');" style="cursor:pointer;" />';
                htmlLi+='<img src="'+baseUrl+'assets/images2.0/buy_nw_btn.jpg" width="72" height="22" onclick="return buyProduct('+products[i].pro_pk_id+', '+products[i].sku_pk_id+');" style="cursor:pointer;" /></div>';

                $('div.cate_4products ul li:eq('+liNo+')').html(htmlLi);
                                
                if(perc > 1)
                {
                }
                else
                {
                    $('div.cate_4products ul li:eq('+liNo+') div.cate_price').css("width", "161px");
                    $('div.cate_4products ul li:eq('+liNo+') div.cate_price span.cate_right').css("textAlign", "right");   
                }
				
            }
            if( pageNo > 1 )
            {
                htmlImage='<img src="'+baseUrl+'assets/images2.0/ButtPrev_normal.gif" width="15" height="19" title="Previous"';
                htmlImage+='style="cursor:pointer;" onclick="return bestSellingProducts('+(pageNo-1)+', '+totalProdCount+');"  />&nbsp;';
            }
            else
            {
                htmlImage='<img width="15" height="19" title="Previous"';
                htmlImage+='src="'+baseUrl+'assets/images2.0/ButtPrev_hover.gif">&nbsp;';
            }
				
            if( totalProdCount > ( pageNo * pageSize ) )
            {
                htmlImage+='<img width="15" height="19" onclick="return bestSellingProducts('+(pageNo+1)+', '+totalProdCount+');" style="cursor:pointer;"';
                htmlImage+='title="Next" src="'+baseUrl+'assets/images2.0/ButtNext_hover.gif">';
            }
            else
            {
                htmlImage+='<img src="'+baseUrl+'assets/images2.0/ButtNext_normal.gif" width="15" height="19" title="Next"   />';
            }
            $('div.left_right_arrow1').html(htmlImage);
            for( var j = products.length; j < pageSize; j++ )	
            {
                $('div.cate_4products ul li:eq('+j+')').html('');
            }					
        }
    });		
}

/*
    * This fuction is used to display the recommended products
*/
function recommendedProducts ( pageNo, prodCount )
{
   
    var pageSize = 4;
    var htmlLi;
    var htmlImage;
    var endLimit = pageSize * pageNo;
    var startLimit = pageSize * (pageNo - 1);
        
    var liWidth = 184;	
    var marginLeft = (pageNo - 1) * (-(liWidth * pageSize) );
	
    $('div.rec_Products ul').animate({
        "marginLeft": marginLeft
    }, "slow");
        
    for(var i = startLimit; i < endLimit; i++)
    {
        $('div.rec_Products ul li:eq('+i+')').html('<div class="imgLoader" align="center">'+
            '<img src="'+baseUrl+'assets/images2.0/ajax-loader-small.gif" /></div>');	
    }
        
    if( prodCount > pageSize)
    {
        var width = (liWidth * prodCount);
        $('div.rec_Products ul').css('width', width);
    }
				
    var postData = {
        'count': pageSize, 
        'pageNo': pageNo
    };
    $.ajax({
        url: baseUrl + "index.php/home/recommendedProducts",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) 
        {
            var products = response.allProducts;	
            var totalProdCount = response.totalProdCount;
            for( i = 0; i < products.length; i++)
            {
                var sku_mrpFixed=formatNumber(products[i].sku_mrp,0,'','','','','-','');
                var sku_gvpriceFixed=formatNumber(products[i].sku_gvprice,0,'','','','','-','');
                                
                var perc = Math.round(((products[i].sku_mrp - products[i].sku_gvprice) / products[i].sku_mrp) * 100);
                                
                var liNo = i + ( (pageNo - 1) * pageSize);
				
                var htmlLi = '<a href="'+baseUrl+'index.php/details/'+products[i].pro_pk_id+ '/' +products[i].pro_seopath+'">';
                if( products[i].chkImage == 'Yes' )
                {
                    htmlLi += '<img src="'+imageUrl+'assets/img/'+products[i].pro_image+'"  height="127" />';
                }
                else
                {
                    htmlLi += '<img src="'+baseUrl+'assets/images2.0/noImage.jpg"  height="127" />';   
                }
                htmlLi += '</a><br />';
                htmlLi+='<div class="fixedHeight"><a href="'+baseUrl+'index.php/details/'+products[i].pro_pk_id+ '/' +products[i].pro_seopath+'">'+products[i].pro_name+'</a></div>';
                htmlLi+='<div class="cate_price"> <span class="cate_left">Rs. '+sku_mrpFixed+'</span>';
                if(perc > 1)
                {
                    htmlLi+='<br/>';
                }
                htmlLi+='<span class="cate_right">Rs. '+sku_gvpriceFixed+' </span>';
                htmlLi+='</div>';
                if(perc > 1)
                {
                    htmlLi += '<div class="discountImage"><div class="discountText"> '+perc+'%</div></div>';
                }

                htmlLi+='<div class="cate_btns"><img src="'+baseUrl+'assets/images2.0/add_cart_btn.jpg" width="72" height="22" onclick="return addProduct('+products[i].pro_pk_id+', '+products[i].sku_pk_id+');" style="cursor:pointer;" />';
                htmlLi+='<img src="'+baseUrl+'assets/images2.0/buy_nw_btn.jpg" width="72" height="22" onclick="return buyProduct('+products[i].pro_pk_id+', '+products[i].sku_pk_id+');" style="cursor:pointer;" /></div>';
                
                $('div.rec_Products ul li:eq('+liNo+')').html(htmlLi);
                                
                if(perc > 1)
                {
                }
                else
                {
                    $('div.rec_Products ul li:eq('+liNo+') div.cate_price').css("width", "161px");
                    $('div.rec_Products ul li:eq('+liNo+') div.cate_price span.cate_right').css("textAlign", "right");   
                }
				
            }
            if( pageNo > 1 )
            {
                htmlImage='<img src="'+baseUrl+'assets/images2.0/ButtPrev_normal.gif" width="15" height="19" title="Previous"';
                htmlImage+='style="cursor:pointer;" onclick="return recommendedProducts('+(pageNo-1)+', '+totalProdCount+');"  />&nbsp;';
            }
            else
            {
                htmlImage='<img width="15" height="19" title="Previous"';
                htmlImage+='src="'+baseUrl+'assets/images2.0/ButtPrev_hover.gif">&nbsp;';
            }
				
            if( totalProdCount > ( pageNo * pageSize ) )
            {
                htmlImage+='<img width="15" height="19" onclick="return recommendedProducts('+(pageNo+1)+', '+totalProdCount+');" style="cursor:pointer;"';
                htmlImage+='title="Next" src="'+baseUrl+'assets/images2.0/ButtNext_hover.gif">';
            }
            else
            {
                htmlImage+='<img src="'+baseUrl+'assets/images2.0/ButtNext_normal.gif" width="15" height="19" title="Next"   />';
            }
            $('div.left_right_arrow_rec').html(htmlImage);
            for( var j = products.length; j < pageSize; j++ )	
            {
                $('div.rec_Products ul li:eq('+j+')').html('');
            }					
        }
    });		
}


function shopByBrands ( pageNo )
{
    var pageSize = 6;
    var htmlLi;
    var htmlImage;
    for(var i = 0; i < pageSize; i++)
    {
        $('div.rightBoxCondent ul li:eq('+i+')').html('<div class="imgLoader1" align="center">'+
            '<img src="'+baseUrl+'assets/images2.0/ajax-loader-small.gif" /></div>');	
    }
				
    var postData = {
        'count': pageSize, 
        'pageNo': pageNo
    };
    $.ajax({
        url: baseUrl + "index.php/home/shopByBrands",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) 
        {
            var brands = response.AllBrands;	
            var totalBrandCount =	response.totalBrandCount;
            for( i = 0; i < brands.length; i++)
            {
                if( brands[i].fileExists == true )	
                {					
                    htmlLi='<a href="'+baseUrl+'index.php/products/search/shopBrands/'+brands[i].brd_pk_id+'">';
                    htmlLi+='<img src="'+baseUrl+'assets/images/brands/'+brands[i].brd_logo+'" title="'+brands[i].brd_name+'" width="60"';
                    htmlLi+='height="30" /></a>';
                }
                else
                {
                    htmlLi='<a href="'+baseUrl+'index.php/products/search/shopBrands/'+brands[i].brd_pk_id+'">';
                    htmlLi+='<img src="'+baseUrl+'assets/images2.0/noImage.jpg" width="90" height="50" title="'+brands[i].brd_name+'" />';
                    htmlLi+='</a>';	
                }		
                           
                $('div.rightBoxCondent ul li:eq('+i+')').html(htmlLi);				
            }
			
			
            if( pageNo > 1 )
            {
                htmlImage='<img src="'+baseUrl+'assets/images2.0/ButtPrev_normal.gif" width="15" height="19" title="Previous"';
                htmlImage+='style="cursor:pointer;" onclick="return shopByBrands('+(pageNo-1)+');"  />&nbsp;';
            }
            else
            {
                htmlImage='<img width="15" height="19" title="Previous"';
                htmlImage+='src="'+baseUrl+'assets/images2.0/ButtPrev_hover.gif">&nbsp;';
            }
				
            if( totalBrandCount > ( pageNo * pageSize ) )
            {
                htmlImage+='<img width="15" height="19" onclick="return shopByBrands('+(pageNo+1)+');" style="cursor:pointer;"';
                htmlImage+='title="Next" src="'+baseUrl+'assets/images2.0/ButtNext_hover.gif">';
            }
            else
            {
                htmlImage+='<img src="'+baseUrl+'assets/images2.0/ButtNext_normal.gif" width="15" height="19" title="Next"   />';
            }
			
            $('div.left_right_arrow2').html(htmlImage);
            for( var j = brands.length; j < pageSize; j++ )	
            {
                $('div.rightBoxCondent ul li:eq('+j+')').html('');
            }							
        }
    });		
}

function getFeatureProducts ( catId, featureId, prodCount, pageNo )
{	
    var pageSize = 4;
    var liWidth = 185;
	
    var marginLeft = (pageNo - 1) * (-(liWidth * pageSize) );
    $('#featurId_'+featureId+' ul').animate({
        "marginLeft": marginLeft
    }, "slow");
	
    if( prodCount > pageSize)
    {
        var width = (liWidth * prodCount) + 180;
        $('#featurId_'+featureId+' ul').css('width', width);
    }
	
    var endLimit = pageSize * pageNo;
    var startLimit = pageSize * (pageNo - 1);
    for( var j = startLimit; j < endLimit; j++)
    {
        $('#featurId_'+featureId+' li:eq('+j+')').html('<div class="imgLoader" align="center">'+
            '<img src="'+baseUrl+'assets/images2.0/ajax-loader-small.gif" /></div>');
    }
    var postData = {
        'catId': catId, 
        'featureId': featureId, 
        'pageNo': pageNo, 
        'pageSize': pageSize
    };
    $.ajax({
        url: baseUrl + "index.php/products/category/getFeaturedProducts",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) {
			
            var totProductCount = response.totProductCount;
            var featuredProducts = response.featuredProducts;
            var htmlLi = '';
            var i;
            var endLimitNew = startLimit + totProductCount;
			
            for( i = 0; i < totProductCount; i++ )
            {
                var sku_mrpFixed=formatNumber(featuredProducts[i].sku_mrp,0,'','','','','-','');
                var sku_gvpriceFixed=formatNumber(featuredProducts[i].sku_gvprice,0,'','','','','-','');
                                
                var perc = Math.round(((featuredProducts[i].sku_mrp - featuredProducts[i].sku_gvprice) / featuredProducts[i].sku_mrp) * 100);
				
                var liNo = i + ( (pageNo - 1) * pageSize);
                htmlLi = '<a href="'+baseUrl+'index.php/details/'+featuredProducts[i].pro_pk_id + '/' + featuredProducts[i].pro_seopath +'">';
                if( featuredProducts[i].chkImage == 'Yes' )
                {
                    htmlLi += '<img src="'+imageUrl+'assets/img/'+featuredProducts[i].pro_image+'"  height="127" />';
                }
                else
                {
                    htmlLi += '<img src="'+baseUrl+'assets/images2.0/noImage.jpg"  height="127" />';   
                }
                htmlLi += '</a><br />';
                htmlLi += '<div class="fixedHeight"><a href="'+baseUrl+'index.php/details/'+featuredProducts[i].pro_pk_id + '/' + featuredProducts[i].pro_seopath +'">'+featuredProducts[i].pro_name+'</a></div>';
                htmlLi += '<div class="cate_price"> <span class="cate_left">Rs. '+sku_mrpFixed+'</span> <br/><span class="cate_right">Rs. '+sku_gvpriceFixed+' </span></div>';
                if(perc > 1)
                {
                    htmlLi += '<div class="discountImage"><div class="discountText"> '+perc+'%</div></div>';
                }
                htmlLi += '<div class="cate_btns"><img src="'+baseUrl+'assets/images2.0/add_cart_btn.jpg" width="72" height="22" onclick="return addProduct('+featuredProducts[i].pro_pk_id+', '+featuredProducts[i].sku_pk_id+');" style="cursor:pointer;"  />';
                htmlLi += '<img src="'+baseUrl+'assets/images2.0/buy_nw_btn.jpg" width="72" height="22" onclick="return buyProduct('+featuredProducts[i].pro_pk_id+', '+featuredProducts[i].sku_pk_id+');" style="cursor:pointer;" /></div>';
				
                $('#featurId_'+featureId+' li:eq('+liNo+')').html(htmlLi);
            }
			
            if( pageNo > 1 )
            {
                htmlImage='<img src="'+baseUrl+'assets/images2.0/ButtPrev_normal.gif" width="15" height="19" title="Previous"';
                htmlImage+='style="cursor:pointer;" onclick="return getFeatureProducts('+catId+', '+featureId+', '+prodCount+', '+(pageNo - 1)+');"  />&nbsp;';
            }
            else
            {
                htmlImage='<img width="15" height="19" title="Previous"';
                htmlImage+='src="'+baseUrl+'assets/images2.0/ButtPrev_hover.gif">&nbsp;';
            }
				
            if( prodCount > ( pageNo * pageSize ) )
            {
                htmlImage+='<img width="15" height="19" onclick="return getFeatureProducts('+catId+', '+featureId+', '+prodCount+', '+(pageNo+1)+');" style="cursor:pointer;"';
                htmlImage+='title="Next" src="'+baseUrl+'assets/images2.0/ButtNext_hover.gif">';
            }
            else
            {
                htmlImage+='<img src="'+baseUrl+'assets/images2.0/ButtNext_normal.gif" width="15" height="19" title="Next"   />';
            }
			
            $('div#arrow_'+featureId).html(htmlImage);
                        
            if( featuredProducts.length == 0 )
            {
						   
                $('div#right_contentProductList div.cate_ListProducts ul').html('<li class="noMatchesFound">No Matching Product Available</li>');
                $('div#right_contentProductList div.cate_ListProducts ul li').css('width', '740px');
							   
            }
			
        }
    });
}

function getAllSearchcategoryProducts( catId, featureId,prodCount,prodid, pageNo )
{	
    var pageSize = 4;
    var liWidth = 185;
    var proArr = new Array();
             
    var mySplitResult = prodid.split("-");

    for(i = 0; i < mySplitResult.length; i++){
        proArr[i] = mySplitResult[i]; 
    }

    var marginLeft = (pageNo - 1) * (-(liWidth * pageSize) );
    $('#featurId_'+featureId+' ul').animate({
        "marginLeft": marginLeft
    }, "slow");
	
    if( prodCount > pageSize)
    {
        var width = (liWidth * prodCount) + 180;
        $('#featurId_'+featureId+' ul').css('width', width);
    }
	
    var endLimit = pageSize * pageNo;
    var startLimit = pageSize * (pageNo - 1);
    for( var j = startLimit; j < endLimit; j++)
    {
        $('#featurId_'+featureId+' li:eq('+j+')').html('<div class="imgLoader" align="center">'+
            '<img src="'+baseUrl+'assets/images2.0/ajax-loader-small.gif" /></div>');
    }
    var postData = {
        'catId': catId, 
        'featureId': featureId, 
        'pageNo': pageNo, 
        'pageSize': pageSize , 
        'proArr':proArr
    };
    $.ajax({
        url: baseUrl + "index.php/products/search/getsearchProducts",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) {
			
            var totProductCount = response.totProductCount;
            var featuredProducts = response.featuredProducts;
            var htmlLi = '';
            var i;
            var endLimitNew = startLimit + totProductCount;
			
            for( i = 0; i < totProductCount; i++ )
            {   //alert(featuredProducts[i].cat_name);
                var sku_mrpFixed=formatNumber(featuredProducts[i].sku_mrp,0,'','','','','-','');
                var sku_gvpriceFixed=formatNumber(featuredProducts[i].sku_gvprice,0,'','','','','-','');
                                
                var perc = Math.round(((featuredProducts[i].sku_mrp - featuredProducts[i].sku_gvprice) / featuredProducts[i].sku_mrp) * 100);
				
                var liNo = i + ( (pageNo - 1) * pageSize);
                htmlLi = '<a href="'+baseUrl+'index.php/details/'+featuredProducts[i].pro_pk_id + '/' + featuredProducts[i].pro_seopath +'">';
                if( featuredProducts[i].chkImage == 'Yes' )
                {
                    htmlLi += '<img src="'+imageUrl+'assets/img/'+featuredProducts[i].pro_image+'"  height="127" />';
                }
                else
                {
                    htmlLi += '<img src="'+baseUrl+'assets/images2.0/noImage.jpg"  height="127" />';   
                }
                htmlLi += '</a><br />';
                htmlLi += '<div class="fixedHeight"><a href="'+baseUrl+'index.php/details/'+featuredProducts[i].pro_pk_id + '/' + featuredProducts[i].pro_seopath +'">'+featuredProducts[i].pro_name+'</a></div>';
                htmlLi += '<div class="cate_price"> <span class="cate_left">Rs. '+sku_mrpFixed+'</span> <br/><span class="cate_right">Rs. '+sku_gvpriceFixed+' </span></div>';
                if(perc > 1)
                {
                    htmlLi += '<div class="discountImage"><div class="discountText"> '+perc+'%</div></div>';
                }
                htmlLi += '<div class="cate_btns"><img src="'+baseUrl+'assets/images2.0/add_cart_btn.jpg" width="72" height="22" onclick="return addProduct('+featuredProducts[i].pro_pk_id+', '+featuredProducts[i].sku_pk_id+');" style="cursor:pointer;"  />';
                htmlLi += '<img src="'+baseUrl+'assets/images2.0/buy_nw_btn.jpg" width="72" height="22" onclick="return buyProduct('+featuredProducts[i].pro_pk_id+', '+featuredProducts[i].sku_pk_id+');" style="cursor:pointer;" /></div>';
				
                $('#featurId_'+featureId+' li:eq('+liNo+')').html(htmlLi);
                var rightlink = '<a href="'+baseUrl+'index.php/products/category/index/'+catId+'"><span class="search_see_all_btn"><span class="search_see_all_left"></span>See All '+featuredProducts[i].cat_name+' »</span></a>';
            }
			
            if( pageNo > 1 )
            {
                htmlImage='<img src="'+baseUrl+'assets/images2.0/ButtPrev_normal.gif" width="15" height="19" title="Previous"';
                htmlImage+='style="cursor:pointer;" onclick="return getAllSearchcategoryProducts('+catId+', '+featureId+', '+prodCount+','+"'"+prodid+"'"+', '+(pageNo - 1)+');"  />&nbsp;';
            }
            else
            {
                htmlImage='<img width="15" height="19" title="Previous"';
                htmlImage+='src="'+baseUrl+'assets/images2.0/ButtPrev_hover.gif">&nbsp;';
            }
				
            if( prodCount > ( pageNo * pageSize ) )
            {
                htmlImage+='<img width="15" height="19" onclick="return getAllSearchcategoryProducts('+catId+', '+featureId+','+prodCount+','+"'"+prodid+"'"+', '+(pageNo+1)+');" style="cursor:pointer;"';
                htmlImage+='title="Next" src="'+baseUrl+'assets/images2.0/ButtNext_hover.gif">';
            }
            else
            {
                htmlImage+='<img src="'+baseUrl+'assets/images2.0/ButtNext_normal.gif" width="15" height="19" title="Next"   />';
            }
            var paginationWithLink = htmlImage+rightlink;
            $('div#arrow_'+featureId).html(paginationWithLink);
                        
            if( featuredProducts.length == '0' )
            {
						   
                $('div#right_contentProductList div.cate_3products_search ul').html('<li class="noMatchesFound">No Matching Product Available</li>');
                $('div#right_contentProductList div.cate_3products_search ul li').css('width', '740px');
							   
            }
			
        }
    });
}


function getPopular_categoryProducts( catId, featureId, prodCount, pageNo )
{	
    var pageSize = 4;
    var liWidth = 185;
	
    var marginLeft = (pageNo - 1) * (-(liWidth * pageSize) );
    $('#featurId_'+featureId+' ul').animate({
        "marginLeft": marginLeft
    }, "slow");
	
    if( prodCount > pageSize)
    {
        var width = (liWidth * prodCount) + 180;
        $('#featurId_'+featureId+' ul').css('width', width);
    }
	
    var endLimit = pageSize * pageNo;
    var startLimit = pageSize * (pageNo - 1);
    for( var j = startLimit; j < endLimit; j++)
    {
        $('#featurId_'+featureId+' li:eq('+j+')').html('<div class="imgLoader" align="center">'+
            '<img src="'+baseUrl+'assets/images2.0/ajax-loader-small.gif" /></div>');
    }
    var postData = {
        'popCatId': featureId, 
        'pageNo': pageNo, 
        'pageSize': pageSize
    };
    $.ajax({
        url: baseUrl + "index.php/products/category/getPopularProducts",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) {
			
            var totProductCount = response.totProductCount;
            var featuredProducts = response.featuredProducts;
            var htmlLi = '';
            var i;
            var endLimitNew = startLimit + totProductCount;
			
            for( i = 0; i < totProductCount; i++ )
            {
                var sku_mrpFixed=formatNumber(featuredProducts[i].sku_mrp,0,'','','','','-','');
                var sku_gvpriceFixed=formatNumber(featuredProducts[i].sku_gvprice,0,'','','','','-','');
                                
                var perc = Math.round(((featuredProducts[i].sku_mrp - featuredProducts[i].sku_gvprice) / featuredProducts[i].sku_mrp) * 100);
				
                var liNo = i + ( (pageNo - 1) * pageSize);
                htmlLi = '<a href="'+baseUrl+'index.php/details/'+featuredProducts[i].pro_pk_id + '/' + featuredProducts[i].pro_seopath +'">';
                if( featuredProducts[i].chkImage == 'Yes' )
                {
                    htmlLi += '<img src="'+imageUrl+'assets/img/'+featuredProducts[i].pro_image+'"  height="127" />';
                }
                else
                {
                    htmlLi += '<img src="'+baseUrl+'assets/images2.0/noImage.jpg"  height="127" />';   
                }
                htmlLi += '</a><br />';
                htmlLi += '<div class="fixedHeight"><a href="'+baseUrl+'index.php/details/'+featuredProducts[i].pro_pk_id + '/' + featuredProducts[i].pro_seopath +'">'+featuredProducts[i].pro_name+'</a></div>';
                htmlLi += '<div class="cate_price"> <span class="cate_left">Rs. '+sku_mrpFixed+'</span> <br/><span class="cate_right">Rs. '+sku_gvpriceFixed+' </span></div>';
                if(perc > 1)
                {
                    htmlLi += '<div class="discountImage"><div class="discountText"> '+perc+'%</div></div>';
                }
                htmlLi += '<div class="cate_btns"><img src="'+baseUrl+'assets/images2.0/add_cart_btn.jpg" width="72" height="22" onclick="return addProduct('+featuredProducts[i].pro_pk_id+', '+featuredProducts[i].sku_pk_id+');" style="cursor:pointer;"  />';
                htmlLi += '<img src="'+baseUrl+'assets/images2.0/buy_nw_btn.jpg" width="72" height="22" onclick="return buyProduct('+featuredProducts[i].pro_pk_id+', '+featuredProducts[i].sku_pk_id+');" style="cursor:pointer;" /></div>';
				
                $('#featurId_'+featureId+' li:eq('+liNo+')').html(htmlLi);
            }
			
            if( pageNo > 1 )
            {
                htmlImage='<img src="'+baseUrl+'assets/images2.0/ButtPrev_normal.gif" width="15" height="19" title="Previous"';
                htmlImage+='style="cursor:pointer;" onclick="return getPopular_categoryProducts('+catId+', '+featureId+', '+prodCount+', '+(pageNo - 1)+');"  />&nbsp;';
            }
            else
            {
                htmlImage='<img width="15" height="19" title="Previous"';
                htmlImage+='src="'+baseUrl+'assets/images2.0/ButtPrev_hover.gif">&nbsp;';
            }
				
            if( prodCount > ( pageNo * pageSize ) )
            {
                htmlImage+='<img width="15" height="19" onclick="return getPopular_categoryProducts('+catId+', '+featureId+', '+prodCount+', '+(pageNo+1)+');" style="cursor:pointer;"';
                htmlImage+='title="Next" src="'+baseUrl+'assets/images2.0/ButtNext_hover.gif">';
            }
            else
            {
                htmlImage+='<img src="'+baseUrl+'assets/images2.0/ButtNext_normal.gif" width="15" height="19" title="Next"   />';
            }
			
            $('div#arrow_'+featureId).html(htmlImage);
                        
            if( featuredProducts.length == 0 )
            {
						   
                $('div#right_contentProductList div.cate_ListProducts ul').html('<li class="noMatchesFound">No Matching Product Available</li>');
                $('div#right_contentProductList div.cate_ListProducts ul li').css('width', '740px');
							   
            }
			
        }
    });
}

function getbrand_categoryProducts( catId, featureId, prodCount, pageNo )
{	
    var pageSize = 4;
    var liWidth = 185;
	
    var marginLeft = (pageNo - 1) * (-(liWidth * pageSize) );
    $('#featurId_'+featureId+' ul').animate({
        "marginLeft": marginLeft
    }, "slow");
	
    if( prodCount > pageSize)
    {
        var width = (liWidth * prodCount) + 180;
        $('#featurId_'+featureId+' ul').css('width', width);
    }
	
    var endLimit = pageSize * pageNo;
    var startLimit = pageSize * (pageNo - 1);
    for( var j = startLimit; j < endLimit; j++)
    {
        $('#featurId_'+featureId+' li:eq('+j+')').html('<div class="imgLoader" align="center">'+
            '<img src="'+baseUrl+'assets/images2.0/ajax-loader-small.gif" /></div>');
    }
    var postData = {
        'CatId': catId , 
        'brandId':featureId, 
        'pageNo': pageNo, 
        'pageSize': pageSize
    };
    $.ajax({
        url: baseUrl + "index.php/products/category/getBrandProducts",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) {
			
            var totProductCount = response.totProductCount;
            var featuredProducts = response.featuredProducts;
            var htmlLi = '';
            var i;
            var endLimitNew = startLimit + totProductCount;
			
            for( i = 0; i < totProductCount; i++ )
            {
                var sku_mrpFixed=formatNumber(featuredProducts[i].sku_mrp,0,'','','','','-','');
                var sku_gvpriceFixed=formatNumber(featuredProducts[i].sku_gvprice,0,'','','','','-','');
                                
                var perc = Math.round(((featuredProducts[i].sku_mrp - featuredProducts[i].sku_gvprice) / featuredProducts[i].sku_mrp) * 100);
				
                var liNo = i + ( (pageNo - 1) * pageSize);
                htmlLi = '<a href="'+baseUrl+'index.php/details/'+featuredProducts[i].pro_pk_id + '/' + featuredProducts[i].pro_seopath +'">';
                if( featuredProducts[i].chkImage == 'Yes' )
                {
                    htmlLi += '<img src="'+imageUrl+'assets/img/'+featuredProducts[i].pro_image+'"  height="127" />';
                }
                else
                {
                    htmlLi += '<img src="'+baseUrl+'assets/images2.0/noImage.jpg"  height="127" />';   
                }
                htmlLi += '</a><br />';
                htmlLi += '<div class="fixedHeight"><a href="'+baseUrl+'index.php/details/'+featuredProducts[i].pro_pk_id + '/' + featuredProducts[i].pro_seopath +'">'+featuredProducts[i].pro_name+'</a></div>';
                htmlLi += '<div class="cate_price"> <span class="cate_left">Rs. '+sku_mrpFixed+'</span> <br/><span class="cate_right">Rs. '+sku_gvpriceFixed+' </span></div>';
                if(perc > 1)
                {
                    htmlLi += '<div class="discountImage"><div class="discountText"> '+perc+'%</div></div>';
                }
                htmlLi += '<div class="cate_btns"><img src="'+baseUrl+'assets/images2.0/add_cart_btn.jpg" width="72" height="22" onclick="return addProduct('+featuredProducts[i].pro_pk_id+', '+featuredProducts[i].sku_pk_id+');" style="cursor:pointer;"  />';
                htmlLi += '<img src="'+baseUrl+'assets/images2.0/buy_nw_btn.jpg" width="72" height="22" onclick="return buyProduct('+featuredProducts[i].pro_pk_id+', '+featuredProducts[i].sku_pk_id+');" style="cursor:pointer;" /></div>';
				
                $('#featurId_'+featureId+' li:eq('+liNo+')').html(htmlLi);
            }
			
            if( pageNo > 1 )
            {
                htmlImage='<img src="'+baseUrl+'assets/images2.0/ButtPrev_normal.gif" width="15" height="19" title="Previous"';
                htmlImage+='style="cursor:pointer;" onclick="return getbrand_categoryProducts('+catId+', '+featureId+', '+prodCount+', '+(pageNo - 1)+');"  />&nbsp;';
            }
            else
            {
                htmlImage='<img width="15" height="19" title="Previous"';
                htmlImage+='src="'+baseUrl+'assets/images2.0/ButtPrev_hover.gif">&nbsp;';
            }
				
            if( prodCount > ( pageNo * pageSize ) )
            {
                htmlImage+='<img width="15" height="19" onclick="return getbrand_categoryProducts('+catId+', '+featureId+', '+prodCount+', '+(pageNo+1)+');" style="cursor:pointer;"';
                htmlImage+='title="Next" src="'+baseUrl+'assets/images2.0/ButtNext_hover.gif">';
            }
            else
            {
                htmlImage+='<img src="'+baseUrl+'assets/images2.0/ButtNext_normal.gif" width="15" height="19" title="Next"   />';
            }
			
            $('div#arrow_'+featureId).html(htmlImage);
                        
            if( featuredProducts.length == 0 )
            {
						   
                $('div#right_contentProductList div.cate_ListProducts ul').html('<li class="noMatchesFound">No Matching Product Available</li>');
                $('div#right_contentProductList div.cate_ListProducts ul li').css('width', '740px');
							   
            }
			
        }
    });
}

function getAllSubcategoryProducts( catId, featureId, prodCount, pageNo )
{	
    var pageSize = 4;
    var liWidth = 185;
	
    var marginLeft = (pageNo - 1) * (-(liWidth * pageSize) );
    $('#featurId_'+featureId+' ul').animate({
        "marginLeft": marginLeft
    }, "slow");
	
    if( prodCount > pageSize)
    {
        var width = (liWidth * prodCount) + 180;
        $('#featurId_'+featureId+' ul').css('width', width);
    }
	
    var endLimit = pageSize * pageNo;
    var startLimit = pageSize * (pageNo - 1);
    for( var j = startLimit; j < endLimit; j++)
    {
        $('#featurId_'+featureId+' li:eq('+j+')').html('<div class="imgLoader" align="center">'+
            '<img src="'+baseUrl+'assets/images2.0/ajax-loader-small.gif" /></div>');
    }
    var postData = {
        'popCatId': featureId, 
        'pageNo': pageNo, 
        'pageSize': pageSize
    };
    $.ajax({
        url: baseUrl + "index.php/products/category/getAllSubcategoryProducts",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) {
			
            var totProductCount = response.totProductCount;
            var featuredProducts = response.featuredProducts;
            var htmlLi = '';
            var i;
            var endLimitNew = startLimit + totProductCount;
			
            for( i = 0; i < totProductCount; i++ )
            {
                var sku_mrpFixed=formatNumber(featuredProducts[i].sku_mrp,0,'','','','','-','');
                var sku_gvpriceFixed=formatNumber(featuredProducts[i].sku_gvprice,0,'','','','','-','');
                                
                var perc = Math.round(((featuredProducts[i].sku_mrp - featuredProducts[i].sku_gvprice) / featuredProducts[i].sku_mrp) * 100);
				
                var liNo = i + ( (pageNo - 1) * pageSize);
                htmlLi = '<a href="'+baseUrl+'index.php/details/'+featuredProducts[i].pro_pk_id + '/' + featuredProducts[i].pro_seopath +'">';
                if( featuredProducts[i].chkImage == 'Yes' )
                {
                    htmlLi += '<img src="'+imageUrl+'assets/img/'+featuredProducts[i].pro_image+'"  height="127" />';
                }
                else
                {
                    htmlLi += '<img src="'+baseUrl+'assets/images2.0/noImage.jpg"  height="127" />';   
                }
                htmlLi += '</a><br />';
                htmlLi += '<div class="fixedHeight"><a href="'+baseUrl+'index.php/details/'+featuredProducts[i].pro_pk_id + '/' + featuredProducts[i].pro_seopath +'">'+featuredProducts[i].pro_name+'</a></div>';
                htmlLi += '<div class="cate_price"> <span class="cate_left">Rs. '+sku_mrpFixed+'</span> <br/><span class="cate_right">Rs. '+sku_gvpriceFixed+' </span></div>';
                if(perc > 1)
                {
                    htmlLi += '<div class="discountImage"><div class="discountText"> '+perc+'%</div></div>';
                }
                htmlLi += '<div class="cate_btns"><img src="'+baseUrl+'assets/images2.0/add_cart_btn.jpg" width="72" height="22" onclick="return addProduct('+featuredProducts[i].pro_pk_id+', '+featuredProducts[i].sku_pk_id+');" style="cursor:pointer;"  />';
                htmlLi += '<img src="'+baseUrl+'assets/images2.0/buy_nw_btn.jpg" width="72" height="22" onclick="return buyProduct('+featuredProducts[i].pro_pk_id+', '+featuredProducts[i].sku_pk_id+');" style="cursor:pointer;" /></div>';
				
                $('#featurId_'+featureId+' li:eq('+liNo+')').html(htmlLi);
            }
			
            if( pageNo > 1 )
            {
                htmlImage='<img src="'+baseUrl+'assets/images2.0/ButtPrev_normal.gif" width="15" height="19" title="Previous"';
                htmlImage+='style="cursor:pointer;" onclick="return getAllSubcategoryProducts('+catId+', '+featureId+', '+prodCount+', '+(pageNo - 1)+');"  />&nbsp;';
            }
            else
            {
                htmlImage='<img width="15" height="19" title="Previous"';
                htmlImage+='src="'+baseUrl+'assets/images2.0/ButtPrev_hover.gif">&nbsp;';
            }
				
            if( prodCount > ( pageNo * pageSize ) )
            {
                htmlImage+='<img width="15" height="19" onclick="return getAllSubcategoryProducts('+catId+', '+featureId+', '+prodCount+', '+(pageNo+1)+');" style="cursor:pointer;"';
                htmlImage+='title="Next" src="'+baseUrl+'assets/images2.0/ButtNext_hover.gif">';
            }
            else
            {
                htmlImage+='<img src="'+baseUrl+'assets/images2.0/ButtNext_normal.gif" width="15" height="19" title="Next"   />';
            }
			
            $('div#arrow_'+featureId).html(htmlImage);
                        
            if( featuredProducts.length == 0 )
            {
						   
                $('div#right_contentProductList div.cate_ListProducts ul').html('<li class="noMatchesFound">No Matching Product Available</li>');
                $('div#right_contentProductList div.cate_ListProducts ul li').css('width', '740px');
							   
            }
			
        }
    });
}

function search_brand(cat_id, pageNo)
{
    var brand_id = new Array();
    $('.brandCheckbox:checked').each(function() {
        brand_id.push($(this).val());
    });
    $('#right_content').slideUp('slow');
    var attributes_val = new Array();

    $('.attributeCheckbox:checked').each(function() {
        attributes_val.push($(this).val());
    });
        
    if( $('#pageSize').val() != undefined ) {
        var pageSize = $('#pageSize').val();
    }else {
        var pageSize = 12;
    }
        
    if( $('#sortByPrice').val() != undefined ) {
        var sortByPrice = $('#sortByPrice').val();
    }else {
        var sortByPrice = '';
    }

    if( $('#uri_value').val() != undefined ) {
        var uri_value = $('#uri_value').val();
    }else {
        var uri_value = '';
    }
        
    var liHtml = '';
    liHtml += '<div class="home_title" ></div>';
    liHtml += '<div id="cate_listing_page_no">';
    liHtml += '<div id="view_list"> Item Per Page ';
    liHtml += ' <select id="pageSize" name="pageSize" class="search_list" onchange="return search_brand('+cat_id+', 1);">';
    liHtml += '<option value="4" ';
    if(pageSize == 4){
        liHtml += ' selected="selected"';
    }
    liHtml += '>4</option>';
    liHtml += '<option value="12" ';
    if(pageSize == 12){
        liHtml += ' selected="selected"';
    }
    liHtml += '>12</option>';
    liHtml += '<option value="24" ';
    if(pageSize == 24){
        liHtml += ' selected="selected"';
    }
    liHtml += '>24</option>';
    liHtml += '<option value="48" ';
    if(pageSize == 48){
        liHtml += ' selected="selected"';
    }
    liHtml += '>48</option>';
    liHtml += '<option value="96" ';
    if(pageSize == 96){
        liHtml += ' selected="selected"';
    }
    liHtml += '>96</option>';
                        
    liHtml += '</select>';
    liHtml += '<span style="padding-left:15px;">sort by</span>';
    liHtml += ' <select id="sortByPrice" name="sortByPrice" class="search_list" onchange="return search_brand('+cat_id+', 1);">';
                        
    liHtml += '<option value=""';
    if(sortByPrice == ''){
        liHtml += ' selected="selected"';
    }
    liHtml += '>Please Select</option>';
                        
    liHtml += '<option value="ASC"';
    if(sortByPrice == 'ASC'){
        liHtml += ' selected="selected"';
    }
    liHtml += '>low to high (Price)</option>';
                        
    liHtml += '<option value="DESC"';
    if(sortByPrice == 'DESC'){
        liHtml += ' selected="selected"';
    }
    liHtml += '>high to low (Price)</option>';
                        
			            
    liHtml += '</select>';
    liHtml += '</div>';
    liHtml += '<div id="search_top" class="black_title">';
                 
                 
    liHtml += '<div class="pages_link">';
    liHtml += '<ul>';
                         
    liHtml += '</ul>';
    liHtml += '</div>';
    liHtml += '</div>';
    liHtml += '</div><div class="cate_ListProducts">';
    liHtml += '<ul>';
    for(var liCount = 0; liCount < pageSize; liCount++)
    {
        liHtml += '<li><div align="center" class="imgLoader"><img src="' + baseUrl + 'assets/images2.0/ajax-loader-small.gif"></div></li>';
    }
    liHtml += '</ul>'; 
    liHtml += '</div><div class="page_no_bottom"></div>'; 
        
    liHtml += '<div class="pages_link">'; 
    liHtml += '<ul>'; 
                        
    liHtml += '</ul>'; 
    liHtml += '</div>'; 
                
    $('#right_contentProductList').html(liHtml);
     
    /*var attributes_val_array=[];
	
	var attributes_val_droplist=$('#attributes_val_droplist').val();
	
	if(attributes_val_droplist!='')
	attributes_val_array[attributes_val_array.length]=attributes_val_droplist;
	
	
	var j=0;
	for(var i=0;i<attributes_val.length;i++)
	{
		if(attributes_val[i].checked==true)
		{
			attributes_val_array[j]=attributes_val[i].value;
			j++;
		}
	}*/
    var sortPrice= $('#sortByPrice').val();
        
    var min_value=$("#min_value_value").html();
    var max_value=$("#max_value_value").html();
        
    //var min_value=$slider.slider("values", 0);
    //var max_value=$slider.slider("values", 1);
	
    var postData = {
        'brand_id': brand_id, 
        'cat_id': cat_id, 
        'attributes': attributes_val, 
        'min_value': min_value, 
        'max_value': max_value,         
        'pageNo': pageNo, 
        'pageSize': pageSize, 
        'sortPrice': sortPrice
    };
    $.ajax({
        url: baseUrl + "index.php/products/search/productSeacrh",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) 
        {
            var totalProdCount = response.totalProdCount;
            var numberOfPages = Math.ceil(totalProdCount / pageSize);
                       
            var liHtml = '';
            var products = response.allProducts;
					 
            for( var liCount = (pageSize - 1); liCount >= products.length; liCount-- )
            {      
                $('div.cate_ListProducts ul li:eq('+liCount+')').remove();
            }
            for( var liCount = 0; liCount < products.length; liCount++ )
            {       
                var sku_mrpFixed=formatNumber(products[liCount].sku_mrp,0,'','','','','-','');
                var sku_gvpriceFixed=formatNumber(products[liCount].sku_gvprice,0,'','','','','-','');
                               
                var perc = Math.round(((products[liCount].sku_mrp - products[liCount].sku_gvprice) / products[liCount].sku_mrp) * 100);
                               
                               
                liHtml = '<a href="'+baseUrl+'index.php/details/'+ products[liCount].pro_pk_id + '/' + products[liCount].pro_seopath +'">';
                if( products[liCount].chkImage == 'Yes' )
                {
                    liHtml += '<img src="'+imageUrl+'assets/img/'+products[liCount].pro_image+'"  height="127" />';
                }
                else
                {
                    liHtml += '<img src="'+baseUrl+'assets/images2.0/noImage.jpg"  height="127" />';   
                }
                liHtml += '</a>';
                liHtml += '<p><div class="fixedHeight"><a href="'+baseUrl+'index.php/details/'+ products[liCount].pro_pk_id + '/' + products[liCount].pro_seopath +'">'+products[liCount].pro_name+'</a></div></p>'; 
                liHtml += '<div class="priceList"> <span class="list_price"><div class="cate_left">Rs. '+sku_mrpFixed+'</div>';
                if(perc > 1)
                {
                    liHtml += '<br/>';
                }
                liHtml += '<div class="cate_right">Rs. '+sku_gvpriceFixed+'</div></span></div>';
                if(perc > 1)
                {
                    liHtml += '<div class="discountImage"><div class="discountText"> '+perc+'%</div></div>';
                }
                liHtml += '<div><img src="'+baseUrl+'assets/images2.0/add_cart_btn.jpg" width="72" height="22" onclick="return addProduct('+products[liCount].pro_pk_id+', '+products[liCount].sku_pk_id+');" style="cursor:pointer;" /><img src="'+baseUrl+'assets/images2.0/buy_nw_btn.jpg" width="72" height="22" onclick="return buyProduct('+products[liCount].pro_pk_id+', '+products[liCount].sku_pk_id+');" style="cursor:pointer;" /></div>'; 
                liHtml += ''; 
                $('div.cate_ListProducts ul li:eq('+liCount+')').html(liHtml);
                               
                if(perc > 1)
                {
                }
                else
                {
                    $('div.cate_ListProducts ul li:eq('+liCount+') div.priceList').css("width", "161px");
                    $('div.cate_ListProducts ul li:eq('+liCount+') div.priceList span.list_price div.cate_right').css("textAlign", "right");   
                }
            }
            var baseUrlUrl = "'"+baseUrl+"'";
                       
            var htmlPagination = '<ul><li><ul>';
            var nullStr = "''";
                       
                       
            if(cat_id != ''){
                if(pageNo > 1) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_brand('+cat_id+', '+(pageNo-1)+');">&lt;&lt; Prev</a></li>';
                }
                if((pageNo - 2) > 0) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_brand('+cat_id+', '+(pageNo-2)+');">'+(pageNo-2)+'</a></li>';
                }
                if((pageNo - 1) > 0) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_brand('+cat_id+', '+(pageNo-1)+');">'+(pageNo-1)+'</a></li>';
                }
                htmlPagination += '<li><a class="selected" href="#">'+pageNo+'</a></li>';

                if((pageNo + 1) <= numberOfPages){
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_brand('+cat_id+', '+(pageNo+1)+');">'+(pageNo+1)+'</a></li>';
                }
                if((pageNo + 2) <= numberOfPages){
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_brand('+cat_id+', '+(pageNo+2)+');">'+(pageNo+2)+'</a></li>';
                }
                if(totalProdCount > (pageNo * pageSize)) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_brand('+cat_id+', '+(pageNo+1)+');">Next &gt;&gt;</a></li>';
                }
            }else {
                if(pageNo > 1) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_brand('+nullStr+', '+(pageNo-1)+');">&lt;&lt; Prev</a></li>';
                }
                if((pageNo - 2) > 0) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_brand('+nullStr+', '+(pageNo-2)+');">'+(pageNo-2)+'</a></li>';
                }
                if((pageNo - 1) > 0) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_brand('+nullStr+', '+(pageNo-1)+');">'+(pageNo-1)+'</a></li>';
                }
                htmlPagination += '<li><a class="selected" href="#">'+pageNo+'</a></li>';

                if((pageNo + 1) <= numberOfPages){
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_brand('+nullStr+', '+(pageNo+1)+');">'+(pageNo+1)+'</a></li>';
                }
                if((pageNo + 2) <= numberOfPages){
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_brand('+nullStr+', '+(pageNo+2)+');">'+(pageNo+2)+'</a></li>';
                }
                if(totalProdCount > (pageNo * pageSize)) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_brand('+nullStr+', '+(pageNo+1)+');">Next &gt;&gt;</a></li>';
                }
            }
            htmlPagination += '</ul></li></ul>';
                       
            $('div.pages_link').html(htmlPagination);
            if(uri_value == 'hotestProducts')
            {
                $('div#right_contentProductList div.home_title').html('Hottest Products <img src="'+baseUrl+'assets/images2.0/help_icon.png" width="21" height="21" class="right" />');
            }
            else
            {
                $('div#right_contentProductList div.home_title').html('Your Perfect '+response.catName+'<img src="'+baseUrl+'assets/images2.0/help_icon.png" width="21" height="21" class="right" />');
            }
            if( products.length == 0 )
            {
						   
                $('div#right_contentProductList div.cate_ListProducts ul').html('<li class="noMatchesFound">No Matching Product Available</li>');
                $('div#right_contentProductList div.cate_ListProducts ul li').css('width', '740px');
							   
            }
        }
    });
}

function search_product_keyword( catId, pageNo, keyword )
{
    //alert(catId);
    var keywordStr = "'"+keyword+"'";
    /* var brand_id = $('#brands').val();
        $('#right_content').slideUp('slow');
        var attributes_val=document.getElementsByName("attributes_val");*/
    var brand_id = new Array();
    $('.brandCheckbox:checked').each(function() {
        brand_id.push($(this).val());
		
    });
     
    $('#right_content').slideUp('slow');
    // var attributes_val=document.getElementsByName("attributes_val");
    var attributes_val = new Array();
	
    $('.attributeCheckbox:checked').each(function() {
        attributes_val.push($(this).val());
    //alert(attributes_val.push($(this).val()));
    });
        
    if( $('#pageSize').val() != undefined ) {
        var pageSize = $('#pageSize').val();
    }else {
        var pageSize = 12;
    }
        
    if( $('#sortByPrice').val() != undefined ) {
        var sortByPrice = $('#sortByPrice').val();
    }else {
        var sortByPrice = '';
    }        
    var liHtml = '';
    liHtml += '<div class="home_title" ></div>';
    liHtml += '<div id="cate_listing_page_no">';
    liHtml += '<div id="view_list"> item per page';
    if(catId != '')
    {
        liHtml += ' <select id="pageSize" name="pageSize" class="search_list" onchange="return search_product_keyword('+catId+', 1, '+keywordStr+');">';
    }
    else
    {
        liHtml += '<select id="pageSize" name="pageSize" class="search_list" onchange="return search_product_keyword(\'\', 1, '+keywordStr+');">';    
    }
    liHtml += '<option value="4" ';
    if(pageSize == 4){
        liHtml += ' selected="selected"';
    }
    liHtml += '>4</option>';
    liHtml += '<option value="12" ';
    if(pageSize == 12){
        liHtml += ' selected="selected"';
    }
    liHtml += '>12</option>';
    liHtml += '<option value="24" ';
    if(pageSize == 24){
        liHtml += ' selected="selected"';
    }
    liHtml += '>24</option>';
    liHtml += '<option value="48" ';
    if(pageSize == 48){
        liHtml += ' selected="selected"';
    }
    liHtml += '>48</option>';
    liHtml += '<option value="96" ';
    if(pageSize == 96){
        liHtml += ' selected="selected"';
    }
    liHtml += '>96</option>';
                        
    liHtml += '</select>';
    liHtml += '<span style="padding-left:15px;">sort by</span>';
    if(catId != '')
    {
        liHtml += ' <select id="sortByPrice" name="sortByPrice" class="search_list" onchange="return search_product_keyword('+catId+', 1, '+keywordStr+');">';
    }
    else
    {
        liHtml += '<select id="sortByPrice" name="sortByPrice" class="search_list" onchange="return search_product_keyword(\'\', 1, '+keywordStr+');">';
    }
                        
    liHtml += '<option value=""';
    if(sortByPrice == ''){
        liHtml += ' selected="selected"';
    }
    liHtml += '>Please Select</option>';
                        
    liHtml += '<option value="ASC"';
    if(sortByPrice == 'ASC'){
        liHtml += ' selected="selected"';
    }
    liHtml += '>low to high (Price)</option>';
                        
    liHtml += '<option value="DESC"';
    if(sortByPrice == 'DESC'){
        liHtml += ' selected="selected"';
    }
    liHtml += '>high to low (Price)</option>';
                        
			            
    liHtml += '</select>';
    liHtml += '</div>';
    liHtml += '<div id="search_top" class="black_title">';
                 
                 
    liHtml += '<div class="pages_link">';
    liHtml += '<ul>';
                         
    liHtml += '</ul>';
    liHtml += '</div>';
    liHtml += '</div>';
    liHtml += '</div><div class="cate_ListProducts">';
    liHtml += '<ul>';
    for(var liCount = 0; liCount < pageSize; liCount++)
    {
        liHtml += '<li><div align="center" class="imgLoader"><img src="' + baseUrl + 'assets/images2.0/ajax-loader-small.gif"></div></li>';
    }
    liHtml += '</ul>'; 
    liHtml += '</div><div class="page_no_bottom"></div>'; 
        
    liHtml += '<div class="pages_link">'; 
    liHtml += '<ul>'; 
                        
    liHtml += '</ul>'; 
    liHtml += '</div>'; 
                
    $('#right_contentProductList').html(liHtml);
     
    var attributes_val_array=[];
	
    var attributes_val_droplist=$('#attributes_val_droplist').val();
	
    if(attributes_val_droplist!='')
        attributes_val_array[attributes_val_array.length]=attributes_val_droplist;
	
	
    var j=0;
    for(var i=0;i<attributes_val.length;i++)
    {
        if(attributes_val[i].checked==true)
        {
            attributes_val_array[j]=attributes_val[i].value;
            j++;
        }
    }
    var sortPrice= $('#sortByPrice').val();
        
    var min_value=$("#min_value_value").html();
    var max_value=$("#max_value_value").html();
        
        
    //var min_value=$slider.slider("values", 0);
    //var max_value=$slider.slider("values", 1);
    var postData = {
        'brand_id': brand_id, 
        'keyword': keyword, 
        'cat_id': catId, 
        'attributes': attributes_val, 
        'min_value': min_value, 
        'max_value': max_value,         
        'pageNo': pageNo, 
        'pageSize': pageSize, 
        'sortPrice': sortPrice
    };
    $.ajax({
        url: baseUrl + "index.php/products/search/productSeacrh",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) 
        {
            var totalProdCount = response.totalProdCount;
            var numberOfPages = Math.ceil(totalProdCount / pageSize);
                       
            var liHtml = '';
            var products = response.allProducts;
				
            for( var liCount = (pageSize - 1); liCount >= products.length; liCount-- )
            {      
                $('div.cate_ListProducts ul li:eq('+liCount+')').remove();
            }
            for( var liCount = 0; liCount < products.length; liCount++ )
            {       
                var sku_mrpFixed=formatNumber(products[liCount].sku_mrp,0,'','','','','-','');
                var sku_gvpriceFixed=formatNumber(products[liCount].sku_gvprice,0,'','','','','-','');
                var perc = Math.round(((products[liCount].sku_mrp - products[liCount].sku_gvprice) / products[liCount].sku_mrp) * 100);
                               
                liHtml = '<a href="'+baseUrl+'index.php/details/'+ products[liCount].pro_pk_id + '/' + products[liCount].pro_seopath +'">';
                if( products[liCount].chkImage == 'Yes' )
                {
                    liHtml += '<img src="'+imageUrl+'assets/img/'+products[liCount].pro_image+'"  height="127" />';
                }
                else
                {
                    liHtml += '<img src="'+baseUrl+'assets/images2.0/noImage.jpg"  height="127" />';   
                }
                liHtml += '</a>';
                liHtml += '<p><div class="fixedHeight"><a href="'+baseUrl+'index.php/details/'+ products[liCount].pro_pk_id + '/' + products[liCount].pro_seopath +'">'+products[liCount].pro_name+'</a></div></p>'; 
                liHtml += '<div class="priceList"> <span class="list_price"><div class="cate_left">Rs. '+sku_mrpFixed+'</div>';
                               
                if(perc > 1)
                {
                    liHtml += '<br/>';
                }
                liHtml += '<div class="cate_right">Rs. '+sku_gvpriceFixed+'</div></span></div>'; 
                if(perc > 1)
                {
                    liHtml += '<div class="discountImage"><div class="discountText"> '+perc+'%</div></div>';
                }
                liHtml += '<div><img src="'+baseUrl+'assets/images2.0/add_cart_btn.jpg" width="72" height="22" onclick="return addProduct('+products[liCount].pro_pk_id+', '+products[liCount].sku_pk_id+');" style="cursor:pointer;" /><img src="'+baseUrl+'assets/images2.0/buy_nw_btn.jpg" width="72" height="22" onclick="return buyProduct('+products[liCount].pro_pk_id+', '+products[liCount].sku_pk_id+');" style="cursor:pointer;" /></div>'; 
                liHtml += ''; 
                $('div.cate_ListProducts ul li:eq('+liCount+')').html(liHtml);
                               
                if(perc > 1)
                {
                }
                else
                {
                    $('div.cate_ListProducts ul li:eq('+liCount+') div.priceList').css("width", "161px");
                    $('div.cate_ListProducts ul li:eq('+liCount+') div.priceList span.list_price div.cate_right').css("textAlign", "right");   
                }
            }
            var baseUrlUrl = "'"+baseUrl+"'";
                       
            var htmlPagination = '<ul><li><ul>';
                       
            if(catId != ''){
                if(pageNo > 1) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_keyword('+catId+', '+(pageNo-1)+', '+keywordStr+');">&lt;&lt; Prev</a></li>';
                }
                if((pageNo - 2) > 0) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_keyword('+catId+', '+(pageNo-2)+', '+keywordStr+');">'+(pageNo-2)+'</a></li>';
                }
                if((pageNo - 1) > 0) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_keyword('+catId+', '+(pageNo-1)+', '+keywordStr+');">'+(pageNo-1)+'</a></li>';
                }
                htmlPagination += '<li><a class="selected" href="#">'+pageNo+'</a></li>';

                if((pageNo + 1) <= numberOfPages){
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_keyword('+catId+', '+(pageNo+1)+', '+keywordStr+');">'+(pageNo+1)+'</a></li>';
                }
                if((pageNo + 2) <= numberOfPages){
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_keyword('+catId+', '+(pageNo+2)+', '+keywordStr+');">'+(pageNo+2)+'</a></li>';
                }
                if(totalProdCount > (pageNo * pageSize)) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_keyword('+catId+', '+(pageNo+1)+', '+keywordStr+');">Next &gt;&gt;</a></li>';
                }
            }else {
                if(pageNo > 1) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_keyword(\'\', '+(pageNo-1)+', '+keywordStr+');">&lt;&lt; Prev</a></li>';
                }
                if((pageNo - 2) > 0) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_keyword(\'\', '+(pageNo-2)+', '+keywordStr+');">'+(pageNo-2)+'</a></li>';
                }
                if((pageNo - 1) > 0) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_keyword(\'\', '+(pageNo-1)+', '+keywordStr+');">'+(pageNo-1)+'</a></li>';
                }
                htmlPagination += '<li><a class="selected" href="#">'+pageNo+'</a></li>';

                if((pageNo + 1) <= numberOfPages){
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_keyword(\'\', '+(pageNo+1)+', '+keywordStr+');">'+(pageNo+1)+'</a></li>';
                }
                if((pageNo + 2) <= numberOfPages){
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_keyword(\'\', '+(pageNo+2)+', '+keywordStr+');">'+(pageNo+2)+'</a></li>';
                }
                if(totalProdCount > (pageNo * pageSize)) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_keyword(\'\', '+(pageNo+1)+', '+keywordStr+');">Next &gt;&gt;</a></li>';
                }
            }
            htmlPagination += '</ul></li></ul>';
                       
            $('div.pages_link').html(htmlPagination);
                       
            $('div#right_contentProductList div.home_title').html("Your keyword '"+keyword+"'");
                       
            if( products.length == 0 )
            {
						   
                $('div#right_contentProductList div.cate_ListProducts ul').html('<li class="noMatchesFound">No Matching Product Available</li>');
                $('div#right_contentProductList div.cate_ListProducts ul li').css('width', '740px');
							   
            }
        }
    });
}

function search_product_brand(  pageNo, brand_id )
{
    
    //var brand_id = $('#brands').val();
    $('#right_content').slideUp('slow');
    //    var attributes_val=document.getElementsByName("attributes_val");
        
    //  $('#brands').val(brand_id);
    var brand_id = new Array();
    $('.brandCheckbox:checked').each(function() {
        brand_id.push($(this).val());
		
    });
     
    $('#right_content').slideUp('slow');
    // var attributes_val=document.getElementsByName("attributes_val");
    var attributes_val = new Array();
	
    $('.attributeCheckbox:checked').each(function() {
        attributes_val.push($(this).val());
    //alert(attributes_val.push($(this).val()));
    });
        
    if( $('#pageSize').val() != undefined ) {
        var pageSize = $('#pageSize').val();
    }else {
        var pageSize = 12;
    }
        
    if( $('#sortByPrice').val() != undefined ) {
        var sortByPrice = $('#sortByPrice').val();
    }else {
        var sortByPrice = '';
    }        
    var liHtml = '';
    liHtml += '<div class="home_title" ></div>';
    liHtml += '<div id="cate_listing_page_no">';
    liHtml += '<div id="view_list"> item per page';
    liHtml += ' <select id="pageSize" name="pageSize" class="search_list" onchange="return search_product_brand(1, '+brand_id+');">';
    liHtml += '<option value="4" ';
    if(pageSize == 4){
        liHtml += ' selected="selected"';
    }
    liHtml += '>4</option>';
    liHtml += '<option value="12" ';
    if(pageSize == 12){
        liHtml += ' selected="selected"';
    }
    liHtml += '>12</option>';
    liHtml += '<option value="24" ';
    if(pageSize == 24){
        liHtml += ' selected="selected"';
    }
    liHtml += '>24</option>';
    liHtml += '<option value="48" ';
    if(pageSize == 48){
        liHtml += ' selected="selected"';
    }
    liHtml += '>48</option>';
    liHtml += '<option value="96" ';
    if(pageSize == 96){
        liHtml += ' selected="selected"';
    }
    liHtml += '>96</option>';
                        
    liHtml += '</select>';
    liHtml += '<span style="padding-left:15px;">sort by</span>';
    liHtml += ' <select id="sortByPrice" name="sortByPrice" class="search_list" onchange="return search_product_brand(1, '+brand_id+');">';
                        
    liHtml += '<option value=""';
    if(sortByPrice == ''){
        liHtml += ' selected="selected"';
    }
    liHtml += '>Please Select</option>';
                        
    liHtml += '<option value="ASC"';
    if(sortByPrice == 'ASC'){
        liHtml += ' selected="selected"';
    }
    liHtml += '>low to high (Price)</option>';
                        
    liHtml += '<option value="DESC"';
    if(sortByPrice == 'DESC'){
        liHtml += ' selected="selected"';
    }
    liHtml += '>high to low (Price)</option>';
                        
			            
    liHtml += '</select>';
    liHtml += '</div>';
    liHtml += '<div id="search_top" class="black_title">';
                 
                 
    liHtml += '<div class="pages_link">';
    liHtml += '<ul>';
                         
    liHtml += '</ul>';
    liHtml += '</div>';
    liHtml += '</div>';
    liHtml += '</div><div class="cate_ListProducts">';
    liHtml += '<ul>';
    for(var liCount = 0; liCount < pageSize; liCount++)
    {
        liHtml += '<li><div align="center" class="imgLoader"><img src="' + baseUrl + 'assets/images2.0/ajax-loader-small.gif"></div></li>';
    }
    liHtml += '</ul>'; 
    liHtml += '</div><div class="page_no_bottom"></div>'; 
        
    liHtml += '<div class="pages_link">'; 
    liHtml += '<ul>'; 
                        
    liHtml += '</ul>'; 
    liHtml += '</div>'; 
                
    $('#right_contentProductList').html(liHtml);
     
    var attributes_val_array=[];
	
    var attributes_val_droplist=$('#attributes_val_droplist').val();
	
    if(attributes_val_droplist!='')
        attributes_val_array[attributes_val_array.length]=attributes_val_droplist;
	
	
    var j=0;
    for(var i=0;i<attributes_val.length;i++)
    {
        if(attributes_val[i].checked==true)
        {
            attributes_val_array[j]=attributes_val[i].value;
            j++;
        }
    }
    var sortPrice= $('#sortByPrice').val();
        
    var min_value=$("#min_value_value").html();
    var max_value=$("#max_value_value").html();
        
    //var min_value=$slider.slider("values", 0);
    //var max_value=$slider.slider("values", 1);
    var postData = {
        'brand_id': brand_id, 
        'attributes': attributes_val, 
        'min_value': min_value, 
        'max_value': max_value,        
        'pageNo': pageNo, 
        'pageSize': pageSize, 
        'sortPrice': sortPrice
    };
    $.ajax({
        url: baseUrl + "index.php/products/search/productSeacrh",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) 
        {
            var totalProdCount = response.totalProdCount;
            var numberOfPages = Math.ceil(totalProdCount / pageSize);
                       
            var liHtml = '';
            var products = response.allProducts;
            for( var liCount = (pageSize - 1); liCount >= products.length; liCount-- )
            {      
                $('div.cate_ListProducts ul li:eq('+liCount+')').remove();
            }
            for( var liCount = 0; liCount < products.length; liCount++ )
            {       
                var sku_mrpFixed=formatNumber(products[liCount].sku_mrp,0,'','','','','-','');
                var sku_gvpriceFixed=formatNumber(products[liCount].sku_gvprice,0,'','','','','-','');
                var perc = Math.round(((products[liCount].sku_mrp - products[liCount].sku_gvprice) / products[liCount].sku_mrp) * 100);
                               
                liHtml = '<a href="'+baseUrl+'index.php/details/'+ products[liCount].pro_pk_id + '/' + products[liCount].pro_seopath +'">';
                if( products[liCount].chkImage == 'Yes' )
                {
                    liHtml += '<img src="'+imageUrl+'assets/img/'+products[liCount].pro_image+'"  height="127" />';
                }
                else
                {
                    liHtml += '<img src="'+baseUrl+'assets/images2.0/noImage.jpg"  height="127" />';   
                }
                liHtml += '</a>';
                liHtml += '<p><div class="fixedHeight"><a href="'+baseUrl+'index.php/details/'+ products[liCount].pro_pk_id + '/' + products[liCount].pro_seopath +'">'+products[liCount].pro_name+'</a></div></p>'; 
                liHtml += '<div class="priceList"> <span class="list_price"><div class="cate_left">Rs. '+sku_mrpFixed+'</div>';
                                                              
                if(perc > 1)
                {
                    liHtml += '<br/>';
                }
                               
                liHtml += '<div class="cate_right">Rs. '+sku_gvpriceFixed+'</div></span></div>'; 
                if(perc > 1)
                {
                    liHtml += '<div class="discountImage"><div class="discountText"> '+perc+'%</div></div>';
                }
                liHtml += '<div><img src="'+baseUrl+'assets/images2.0/add_cart_btn.jpg" width="72" height="22" onclick="return addProduct('+products[liCount].pro_pk_id+', '+products[liCount].sku_pk_id+');" style="cursor:pointer;" /><img src="'+baseUrl+'assets/images2.0/buy_nw_btn.jpg" width="72" height="22" onclick="return buyProduct('+products[liCount].pro_pk_id+', '+products[liCount].sku_pk_id+');" style="cursor:pointer;" /></div>'; 
                liHtml += ''; 
                $('div.cate_ListProducts ul li:eq('+liCount+')').html(liHtml);
                               
                if(perc > 1)
                {
                }
                else
                {
                    $('div.cate_ListProducts ul li:eq('+liCount+') div.priceList').css("width", "161px");
                    $('div.cate_ListProducts ul li:eq('+liCount+') div.priceList span.list_price div.cate_right').css("textAlign", "right");   
                }
            }
            var baseUrlUrl = "'"+baseUrl+"'";
                       
            var htmlPagination = '<ul><li><ul>';
                       
            if(brand_id != ''){
                if(pageNo > 1) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_brand('+(pageNo-1)+', '+brand_id+');">&lt;&lt; Prev</a></li>';
                }
                if((pageNo - 2) > 0) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_brand('+(pageNo-2)+', '+brand_id+');">'+(pageNo-2)+'</a></li>';
                }
                if((pageNo - 1) > 0) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_brand('+(pageNo-1)+', '+brand_id+');">'+(pageNo-1)+'</a></li>';
                }
                htmlPagination += '<li><a class="selected" href="#">'+pageNo+'</a></li>';

                if((pageNo + 1) <= numberOfPages){
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_brand('+(pageNo+1)+', '+brand_id+');">'+(pageNo+1)+'</a></li>';
                }
                if((pageNo + 2) <= numberOfPages){
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_brand('+(pageNo+2)+', '+brand_id+');">'+(pageNo+2)+'</a></li>';
                }
                if(totalProdCount > (pageNo * pageSize)) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_brand('+(pageNo+1)+', '+brand_id+');">Next &gt;&gt;</a></li>';
                }
            }else {
                if(pageNo > 1) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_brand('+(pageNo-1)+');">&lt;&lt; Prev</a></li>';
                }
                if((pageNo - 2) > 0) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_brand('+(pageNo-2)+');">'+(pageNo-2)+'</a></li>';
                }
                if((pageNo - 1) > 0) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_brand('+(pageNo-1)+');">'+(pageNo-1)+'</a></li>';
                }
                htmlPagination += '<li><a class="selected" href="#">'+pageNo+'</a></li>';

                if((pageNo + 1) <= numberOfPages){
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_brand('+(pageNo+1)+');">'+(pageNo+1)+'</a></li>';
                }
                if((pageNo + 2) <= numberOfPages){
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_brand('+(pageNo+2)+');">'+(pageNo+2)+'</a></li>';
                }
                if(totalProdCount > (pageNo * pageSize)) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_brand('+(pageNo+1)+');">Next &gt;&gt;</a></li>';
                }
            }
            htmlPagination += '</ul></li></ul>';
                       
            $('div.pages_link').html(htmlPagination);
                       
            $('div#right_contentProductList div.home_title').html(response.brandName);
                       
            if( products.length == 0 )
            {
						   
                $('div#right_contentProductList div.cate_ListProducts ul').html('<li class="noMatchesFound">No Matching Product Available</li>');
                $('div#right_contentProductList div.cate_ListProducts ul li').css('width', '740px');
							   
            }
        }
    });
}


function search_product_brand1(  pageNo, brand_id )
{
    
    //var brand_id = $('#brands').val();
    $('#right_content').slideUp('slow');
    //    var attributes_val=document.getElementsByName("attributes_val");
        
    //  $('#brands').val(brand_id);
    var brand_id1 = new Array(brand_id);
    /*$('.brandCheckbox:checked').each(function() {
        brand_id.push($(this).val());
		
    });*/
    
    $('#right_content').slideUp('slow');
    // var attributes_val=document.getElementsByName("attributes_val");
    var attributes_val = new Array();
	
    $('.attributeCheckbox:checked').each(function() {
        attributes_val.push($(this).val());
    //alert(attributes_val.push($(this).val()));
    });
        
    if( $('#pageSize').val() != undefined ) {
        var pageSize = $('#pageSize').val();
    }else {
        var pageSize = 12;
    }
        
    if( $('#sortByPrice').val() != undefined ) {
        var sortByPrice = $('#sortByPrice').val();
    }else {
        var sortByPrice = '';
    }        
    var liHtml = '';
    liHtml += '<div class="home_title" ></div>';
    liHtml += '<div id="cate_listing_page_no">';
    liHtml += '<div id="view_list"> item per page';
    liHtml += ' <select id="pageSize" name="pageSize" class="search_list" onchange="return search_product_brand1(1, '+brand_id1+');">';
    liHtml += '<option value="4" ';
    if(pageSize == 4){
        liHtml += ' selected="selected"';
    }
    liHtml += '>4</option>';
    liHtml += '<option value="12" ';
    if(pageSize == 12){
        liHtml += ' selected="selected"';
    }
    liHtml += '>12</option>';
    liHtml += '<option value="24" ';
    if(pageSize == 24){
        liHtml += ' selected="selected"';
    }
    liHtml += '>24</option>';
    liHtml += '<option value="48" ';
    if(pageSize == 48){
        liHtml += ' selected="selected"';
    }
    liHtml += '>48</option>';
    liHtml += '<option value="96" ';
    if(pageSize == 96){
        liHtml += ' selected="selected"';
    }
    liHtml += '>96</option>';
                        
    liHtml += '</select>';
   liHtml += '<span style="padding-left:15px;">sort by</span>';
    liHtml += ' <select id="sortByPrice" name="sortByPrice" class="search_list" onchange="return search_product_brand1(1, '+brand_id1+');">';
                        
    liHtml += '<option value=""';
    if(sortByPrice == ''){
        liHtml += ' selected="selected"';
    }
    liHtml += '>Please Select</option>';
                        
    liHtml += '<option value="ASC"';
    if(sortByPrice == 'ASC'){
        liHtml += ' selected="selected"';
    }
    liHtml += '>low to high (Price)</option>';
                        
    liHtml += '<option value="DESC"';
    if(sortByPrice == 'DESC'){
        liHtml += ' selected="selected"';
    }
    liHtml += '>high to low (Price)</option>';
                        
			            
    liHtml += '</select>';
    liHtml += '</div>';
    liHtml += '<div id="search_top" class="black_title">';
                 
                 
    liHtml += '<div class="pages_link">';
    liHtml += '<ul>';
                         
    liHtml += '</ul>';
    liHtml += '</div>';
    liHtml += '</div>';
    liHtml += '</div><div class="cate_ListProducts">';
    liHtml += '<ul>';
    for(var liCount = 0; liCount < pageSize; liCount++)
    {
        liHtml += '<li><div align="center" class="imgLoader"><img src="' + baseUrl + 'assets/images2.0/ajax-loader-small.gif"></div></li>';
    }
    liHtml += '</ul>'; 
    liHtml += '</div><div class="page_no_bottom"></div>'; 
        
    liHtml += '<div class="pages_link">'; 
    liHtml += '<ul>'; 
                        
    liHtml += '</ul>'; 
    liHtml += '</div>'; 
                
    $('#right_contentProductList').html(liHtml);
     
    var attributes_val_array=[];
	
    var attributes_val_droplist=$('#attributes_val_droplist').val();
	
    if(attributes_val_droplist!='')
        attributes_val_array[attributes_val_array.length]=attributes_val_droplist;
	
	
    var j=0;
    for(var i=0;i<attributes_val.length;i++)
    {
        if(attributes_val[i].checked==true)
        {
            attributes_val_array[j]=attributes_val[i].value;
            j++;
        }
    }
    var sortPrice= $('#sortByPrice').val();
        
    var min_value=$("#min_value_value").html();
    var max_value=$("#max_value_value").html();
        
    //var min_value=$slider.slider("values", 0);
    //var max_value=$slider.slider("values", 1);
    var postData = {
        'brand_id': brand_id1, 
        'attributes': attributes_val, 
        'min_value': min_value, 
        'max_value': max_value,        
        'pageNo': pageNo, 
        'pageSize': pageSize, 
        'sortPrice': sortPrice
    };
    $.ajax({
        url: baseUrl + "index.php/products/search/productSeacrh",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) 
        {
            var brand_ID = response.brand_ID;
            var totalProdCount = response.totalProdCount;
            var numberOfPages = Math.ceil(totalProdCount / pageSize);
                       
            var liHtml = '';
            var products = response.allProducts;
            for( var liCount = (pageSize - 1); liCount >= products.length; liCount-- )
            {      
                $('div.cate_ListProducts ul li:eq('+liCount+')').remove();
            }
            for( var liCount = 0; liCount < products.length; liCount++ )
            {       
                var sku_mrpFixed=formatNumber(products[liCount].sku_mrp,0,'','','','','-','');
                var sku_gvpriceFixed=formatNumber(products[liCount].sku_gvprice,0,'','','','','-','');
                var perc = Math.round(((products[liCount].sku_mrp - products[liCount].sku_gvprice) / products[liCount].sku_mrp) * 100);
                               
                liHtml = '<a href="'+baseUrl+'index.php/details/'+ products[liCount].pro_pk_id + '/' + products[liCount].pro_seopath +'">';
                if( products[liCount].chkImage == 'Yes' )
                {
                    liHtml += '<img src="'+imageUrl+'assets/img/'+products[liCount].pro_image+'"  height="127" />';
                }
                else
                {
                    liHtml += '<img src="'+baseUrl+'assets/images2.0/noImage.jpg"  height="127" />';   
                }
                liHtml += '</a>';
                liHtml += '<p><div class="fixedHeight"><a href="'+baseUrl+'index.php/details/'+ products[liCount].pro_pk_id + '/' + products[liCount].pro_seopath +'">'+products[liCount].pro_name+'</a></div></p>'; 
                liHtml += '<div class="priceList"> <span class="list_price"><div class="cate_left">Rs. '+sku_mrpFixed+'</div>';
                                                              
                if(perc > 1)
                {
                    liHtml += '<br/>';
                }
                               
                liHtml += '<div class="cate_right">Rs. '+sku_gvpriceFixed+'</div></span></div>'; 
                if(perc > 1)
                {
                    liHtml += '<div class="discountImage"><div class="discountText"> '+perc+'%</div></div>';
                }
                liHtml += '<div><img src="'+baseUrl+'assets/images2.0/add_cart_btn.jpg" width="72" height="22" onclick="return addProduct('+products[liCount].pro_pk_id+', '+products[liCount].sku_pk_id+');" style="cursor:pointer;" /><img src="'+baseUrl+'assets/images2.0/buy_nw_btn.jpg" width="72" height="22" onclick="return buyProduct('+products[liCount].pro_pk_id+', '+products[liCount].sku_pk_id+');" style="cursor:pointer;" /></div>'; 
                liHtml += ''; 
                $('div.cate_ListProducts ul li:eq('+liCount+')').html(liHtml);
                               
                if(perc > 1)
                {
                }
                else
                {
                    $('div.cate_ListProducts ul li:eq('+liCount+') div.priceList').css("width", "161px");
                    $('div.cate_ListProducts ul li:eq('+liCount+') div.priceList span.list_price div.cate_right').css("textAlign", "right");   
                }
            }
            var baseUrlUrl = "'"+baseUrl+"'";
                       
            var htmlPagination = '<ul><li><ul>';
                     
            if(brand_ID != ''){
                
                if(pageNo > 1) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_brand1('+(pageNo-1)+', '+brand_ID+');">&lt;&lt; Prev</a></li>';
                }
                if((pageNo - 2) > 0) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_brand1('+(pageNo-2)+', '+brand_ID+');">'+(pageNo-2)+'</a></li>';
                }
                if((pageNo - 1) > 0) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_brand1('+(pageNo-1)+', '+brand_ID+');">'+(pageNo-1)+'</a></li>';
                }
                htmlPagination += '<li><a class="selected" href="#">'+pageNo+'</a></li>';

                if((pageNo + 1) <= numberOfPages){
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_brand1('+(pageNo+1)+', '+brand_ID+');">'+(pageNo+1)+'</a></li>';
                }
                if((pageNo + 2) <= numberOfPages){
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_brand1('+(pageNo+2)+', '+brand_ID+');">'+(pageNo+2)+'</a></li>';
                }
                if(totalProdCount > (pageNo * pageSize)) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_brand1('+(pageNo+1)+', '+brand_ID+');">Next &gt;&gt;</a></li>';
                }
            }else {
                if(pageNo > 1) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_brand1('+(pageNo-1)+', '+brand_ID+');">&lt;&lt; Prev</a></li>';
                }
                if((pageNo - 2) > 0) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_brand1('+(pageNo-2)+', '+brand_ID+');">'+(pageNo-2)+'</a></li>';
                }
                if((pageNo - 1) > 0) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_brand1('+(pageNo-1)+', '+brand_ID+');">'+(pageNo-1)+'</a></li>';
                }
                htmlPagination += '<li><a class="selected" href="#">'+pageNo+'</a></li>';

                if((pageNo + 1) <= numberOfPages){
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_brand1('+(pageNo+1)+', '+brand_ID+');">'+(pageNo+1)+'</a></li>';
                }
                if((pageNo + 2) <= numberOfPages){
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_brand1('+(pageNo+2)+', '+brand_ID+');">'+(pageNo+2)+'</a></li>';
                }
                if(totalProdCount > (pageNo * pageSize)) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return search_product_brand1('+(pageNo+1)+', '+brand_ID+');">Next &gt;&gt;</a></li>';
                }
            }
            htmlPagination += '</ul></li></ul>';
                       
            $('div.pages_link').html(htmlPagination);
                       
            $('div#right_contentProductList div.home_title').html(response.brandName);
                       
            if( products.length == 0 )
            {
						   
                $('div#right_contentProductList div.cate_ListProducts ul').html('<li class="noMatchesFound">No Matching Product Available</li>');
                $('div#right_contentProductList div.cate_ListProducts ul li').css('width', '740px');
							   
            }
        }
    });
}

function productBybrands(  pageNo, brand_id ,catId)
{
    
    //var brand_id = $('#brands').val();
    $('#right_content').slideUp('slow');
    //    var attributes_val=document.getElementsByName("attributes_val");
        
    //  $('#brands').val(brand_id);
    //var brand_id1 = new Array(brand_id);
    /*$('.brandCheckbox:checked').each(function() {
        brand_id.push($(this).val());
		
    });*/
    
    $('#right_content').slideUp('slow');
    // var attributes_val=document.getElementsByName("attributes_val");
    var attributes_val = new Array();
	
    $('.attributeCheckbox:checked').each(function() {
        attributes_val.push($(this).val());
    //alert(attributes_val.push($(this).val()));
    });
        
    if( $('#pageSize').val() != undefined ) {
        var pageSize = $('#pageSize').val();
    }else {
        var pageSize = 12;
    }
        
    if( $('#sortByPrice').val() != undefined ) {
        var sortByPrice = $('#sortByPrice').val();
    }else {
        var sortByPrice = '';
    }        
    var liHtml = '';
    liHtml += '<div class="home_title" ></div>';
    liHtml += '<div id="cate_listing_page_no">';
    liHtml += '<div id="view_list"> item per page';
    liHtml += ' <select id="pageSize" name="pageSize" class="search_list" onchange="return productBybrands(1, '+brand_id+','+catId+');">';
    liHtml += '<option value="4" ';
    if(pageSize == 4){
        liHtml += ' selected="selected"';
    }
    liHtml += '>4</option>';
    liHtml += '<option value="12" ';
    if(pageSize == 12){
        liHtml += ' selected="selected"';
    }
    liHtml += '>12</option>';
    liHtml += '<option value="24" ';
    if(pageSize == 24){
        liHtml += ' selected="selected"';
    }
    liHtml += '>24</option>';
    liHtml += '<option value="48" ';
    if(pageSize == 48){
        liHtml += ' selected="selected"';
    }
    liHtml += '>48</option>';
    liHtml += '<option value="96" ';
    if(pageSize == 96){
        liHtml += ' selected="selected"';
    }
    liHtml += '>96</option>';
                        
    liHtml += '</select>';
   
    liHtml += '<span style="padding-left:15px;">sort by</span>';
    
    liHtml += ' <select id="sortByPrice" name="sortByPrice" class="search_list" onchange="return productBybrands(1, '+brand_id+','+catId+');">';
                        
    liHtml += '<option value=""';
    if(sortByPrice == ''){
        liHtml += ' selected="selected"';
    }
    liHtml += '>Please Select</option>';
                        
    liHtml += '<option value="ASC"';
    if(sortByPrice == 'ASC'){
        liHtml += ' selected="selected"';
    }
    liHtml += '>low to high (Price)</option>';
                        
    liHtml += '<option value="DESC"';
    if(sortByPrice == 'DESC'){
        liHtml += ' selected="selected"';
    }
    liHtml += '>high to low (Price)</option>';
                        
			            
    liHtml += '</select>';
    liHtml += '</div>';
    liHtml += '<div id="search_top" class="black_title">';
                 
                 
    liHtml += '<div class="pages_link">';
    liHtml += '<ul>';
                         
    liHtml += '</ul>';
    liHtml += '</div>';
    liHtml += '</div>';
    liHtml += '</div><div class="cate_ListProducts">';
    liHtml += '<ul>';
    for(var liCount = 0; liCount < pageSize; liCount++)
    {
        liHtml += '<li><div align="center" class="imgLoader"><img src="' + baseUrl + 'assets/images2.0/ajax-loader-small.gif"></div></li>';
    }
    liHtml += '</ul>'; 
    liHtml += '</div><div class="page_no_bottom"></div>'; 
        
    liHtml += '<div class="pages_link">'; 
    liHtml += '<ul>'; 
                        
    liHtml += '</ul>'; 
    liHtml += '</div>'; 
                
    $('#right_contentProductList').html(liHtml);
     
    var attributes_val_array=[];
	
    var attributes_val_droplist=$('#attributes_val_droplist').val();
	
    if(attributes_val_droplist!='')
        attributes_val_array[attributes_val_array.length]=attributes_val_droplist;
	
	
    var j=0;
    for(var i=0;i<attributes_val.length;i++)
    {
        if(attributes_val[i].checked==true)
        {
            attributes_val_array[j]=attributes_val[i].value;
            j++;
        }
    }
    var sortPrice= $('#sortByPrice').val();
        
    var min_value=$("#min_value_value").html();
    var max_value=$("#max_value_value").html();
        
    //var min_value=$slider.slider("values", 0);
    //var max_value=$slider.slider("values", 1);
    var postData = {
        'brand_id': brand_id, 
        'cat_id': catId,
        'attributes': attributes_val, 
        'min_value': min_value, 
        'max_value': max_value,         
        'pageNo': pageNo, 
        'pageSize': pageSize, 
        'sortPrice': sortPrice
    };
    $.ajax({
        url: baseUrl + "index.php/products/search/productBybrand",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) 
        {
            var brand_ID = response.brand_ID;
            var totalProdCount = response.totalProdCount;
            var numberOfPages = Math.ceil(totalProdCount / pageSize);
                       
            var liHtml = '';
            var products = response.allProducts;
            for( var liCount = (pageSize - 1); liCount >= products.length; liCount-- )
            {      
                $('div.cate_ListProducts ul li:eq('+liCount+')').remove();
            }
            for( var liCount = 0; liCount < products.length; liCount++ )
            {       
                var sku_mrpFixed=formatNumber(products[liCount].sku_mrp,0,'','','','','-','');
                var sku_gvpriceFixed=formatNumber(products[liCount].sku_gvprice,0,'','','','','-','');
                var perc = Math.round(((products[liCount].sku_mrp - products[liCount].sku_gvprice) / products[liCount].sku_mrp) * 100);
                               
                liHtml = '<a href="'+baseUrl+'index.php/details/'+ products[liCount].pro_pk_id + '/' + products[liCount].pro_seopath +'">';
                if( products[liCount].chkImage == 'Yes' )
                {
                    liHtml += '<img src="'+imageUrl+'assets/img/'+products[liCount].pro_image+'"  height="127" />';
                }
                else
                {
                    liHtml += '<img src="'+baseUrl+'assets/images2.0/noImage.jpg"  height="127" />';   
                }
                liHtml += '</a>';
                liHtml += '<p><div class="fixedHeight"><a href="'+baseUrl+'index.php/details/'+ products[liCount].pro_pk_id + '/' + products[liCount].pro_seopath +'">'+products[liCount].pro_name+'</a></div></p>'; 
                liHtml += '<div class="priceList"> <span class="list_price"><div class="cate_left">Rs. '+sku_mrpFixed+'</div>';
                                                              
                if(perc > 1)
                {
                    liHtml += '<br/>';
                }
                               
                liHtml += '<div class="cate_right">Rs. '+sku_gvpriceFixed+'</div></span></div>'; 
                if(perc > 1)
                {
                    liHtml += '<div class="discountImage"><div class="discountText"> '+perc+'%</div></div>';
                }
                liHtml += '<div><img src="'+baseUrl+'assets/images2.0/add_cart_btn.jpg" width="72" height="22" onclick="return addProduct('+products[liCount].pro_pk_id+', '+products[liCount].sku_pk_id+');" style="cursor:pointer;" /><img src="'+baseUrl+'assets/images2.0/buy_nw_btn.jpg" width="72" height="22" onclick="return buyProduct('+products[liCount].pro_pk_id+', '+products[liCount].sku_pk_id+');" style="cursor:pointer;" /></div>'; 
                liHtml += ''; 
                $('div.cate_ListProducts ul li:eq('+liCount+')').html(liHtml);
                               
                if(perc > 1)
                {
                }
                else
                {
                    $('div.cate_ListProducts ul li:eq('+liCount+') div.priceList').css("width", "161px");
                    $('div.cate_ListProducts ul li:eq('+liCount+') div.priceList span.list_price div.cate_right').css("textAlign", "right");   
                }
            }
            var baseUrlUrl = "'"+baseUrl+"'";
                       
            var htmlPagination = '<ul><li><ul>';
                     
            if(brand_ID != ''){
                
                if(pageNo > 1) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return productBybrands('+(pageNo-1)+', '+brand_id+','+catId+');">&lt;&lt; Prev</a></li>';
                }
                if((pageNo - 2) > 0) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return productBybrands('+(pageNo-2)+', '+brand_id+','+catId+');">'+(pageNo-2)+'</a></li>';
                }
                if((pageNo - 1) > 0) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return productBybrands('+(pageNo-1)+', '+brand_id+','+catId+');">'+(pageNo-1)+'</a></li>';
                }
                htmlPagination += '<li><a class="selected" href="#">'+pageNo+'</a></li>';

                if((pageNo + 1) <= numberOfPages){
                    htmlPagination += '<li><a href="javascript:;" onclick="return productBybrands('+(pageNo+1)+', '+brand_id+','+catId+');">'+(pageNo+1)+'</a></li>';
                }
                if((pageNo + 2) <= numberOfPages){
                    htmlPagination += '<li><a href="javascript:;" onclick="return productBybrands('+(pageNo+2)+', '+brand_id+','+catId+');">'+(pageNo+2)+'</a></li>';
                }
                if(totalProdCount > (pageNo * pageSize)) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return productBybrands('+(pageNo+1)+', '+brand_id+','+catId+');">Next &gt;&gt;</a></li>';
                }
            }else {
                if(pageNo > 1) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return productBybrands('+(pageNo-1)+', '+brand_id+','+catId+');">&lt;&lt; Prev</a></li>';
                }
                if((pageNo - 2) > 0) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return productBybrands('+(pageNo-2)+', '+brand_id+','+catId+');">'+(pageNo-2)+'</a></li>';
                }
                if((pageNo - 1) > 0) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return productBybrands('+(pageNo-1)+', '+brand_id+','+catId+');">'+(pageNo-1)+'</a></li>';
                }
                htmlPagination += '<li><a class="selected" href="#">'+pageNo+'</a></li>';

                if((pageNo + 1) <= numberOfPages){
                    htmlPagination += '<li><a href="javascript:;" onclick="return productBybrands('+(pageNo+1)+', '+brand_id+','+catId+');">'+(pageNo+1)+'</a></li>';
                }
                if((pageNo + 2) <= numberOfPages){
                    htmlPagination += '<li><a href="javascript:;" onclick="return productBybrands('+(pageNo+2)+', '+brand_id+','+catId+');">'+(pageNo+2)+'</a></li>';
                }
                if(totalProdCount > (pageNo * pageSize)) {
                    htmlPagination += '<li><a href="javascript:;" onclick="return productBybrands('+(pageNo+1)+', '+brand_id+','+catId+');">Next &gt;&gt;</a></li>';
                }
            }
            htmlPagination += '</ul></li></ul>';
                       
            $('div.pages_link').html(htmlPagination);
                       
            $('div#right_contentProductList div.home_title').html(response.brandName);
                       
            if( products.length == 0 )
            {
						   
                $('div#right_contentProductList div.cate_ListProducts ul').html('<li class="noMatchesFound">No Matching Product Available</li>');
                $('div#right_contentProductList div.cate_ListProducts ul li').css('width', '740px');
							   
            }
        }
    });
}


function getCategoryProducts ( catId, prodCount, pageNo )
{
    //alert('hiiii'); exit();
    // alert(catId); 
    var pageSize = 4;
    var liWidth = 185;
	
    var marginLeft = (pageNo - 1) * (-(liWidth * pageSize) );
    $('#CatId_'+catId+' ul').animate({
        "marginLeft": marginLeft
    }, "slow");
	
    if( prodCount > pageSize)
    {
        var width = (liWidth * prodCount) + 180;
        $('#CatId_'+catId+' ul').css('width', width);
    }
	
    var endLimit = pageSize * pageNo;
    var startLimit = pageSize * (pageNo - 1);
    for( var j = startLimit; j < endLimit; j++)
    {
        $('#CatId_'+catId+' li:eq('+j+')').html('<div class="imgLoader" align="center">'+
            '<img src="'+baseUrl+'assets/images2.0/ajax-loader-small.gif" /></div>');
    }
    var postData = {
        'catId': catId, 
        'pageNo': pageNo, 
        'pageSize': pageSize
    };
    $.ajax({
        url: baseUrl + "index.php/products/category/getCategoryProducts",
        type: "POST",
        cache: false,
        data: postData,
        dataType: 'json',
        success: function(response, status, XHR) {
            //alert(response.totProductCount); exit();
            var totalProductCount = response.totProductCount;
            var categoryProducts = response.categoryProducts;
            var htmlLi = '';
            var i;
            var endLimitNew = startLimit + totalProductCount;
			
            for( i = 0; i < totalProductCount; i++ )
            {
                // alert(featuredProducts[i].pro_name);
                var sku_mrpFixed=formatNumber(categoryProducts[i].sku_mrp,0,'','','','','-','');
                var sku_gvpriceFixed=formatNumber(categoryProducts[i].sku_gvprice,0,'','','','','-','');
                                
                var perc = Math.round(((categoryProducts[i].sku_mrp - categoryProducts[i].sku_gvprice) / categoryProducts[i].sku_mrp) * 100);
				
                var liNo = i + ( (pageNo - 1) * pageSize);
                htmlLi = '<a href="'+baseUrl+'index.php/details/'+ categoryProducts[i].pro_pk_id + '/' + categoryProducts[i].pro_seopath +'">';
                if( categoryProducts[i].chkImage == 'Yes' )
                {
                    htmlLi += '<img src="'+imageUrl+'assets/img/'+categoryProducts[i].pro_image+'"  height="127" />';
                }
                else
                {
                    htmlLi += '<img src="'+baseUrl+'assets/images2.0/noImage.jpg"  height="127" />';   
                }
                htmlLi += '</a><br />';
                htmlLi += '<div class="fixedHeight"><a href="'+baseUrl+'index.php/details/'+ categoryProducts[i].pro_pk_id + '/' + categoryProducts[i].pro_seopath +'">'+categoryProducts[i].pro_name+'</a></div>';
                htmlLi += '<div class="cate_price"> <span class="cate_left">Rs. '+sku_mrpFixed+'</span> <br/><span class="cate_right">Rs. '+sku_gvpriceFixed+' </span></div>';
                if(perc > 1)
                {
                    htmlLi += '<div class="discountImage"><div class="discountText"> '+perc+'%</div></div>';
                }
                htmlLi += '<div class="cate_btns"><img src="'+baseUrl+'assets/images2.0/add_cart_btn.jpg" width="72" height="22" onclick="return addProduct('+categoryProducts[i].pro_pk_id+', '+categoryProducts[i].sku_pk_id+');" style="cursor:pointer;"  />';
                htmlLi += '<img src="'+baseUrl+'assets/images2.0/buy_nw_btn.jpg" width="72" height="22" onclick="return buyProduct('+categoryProducts[i].pro_pk_id+', '+categoryProducts[i].sku_pk_id+');" style="cursor:pointer;" /></div>';
                //alert(htmlLi);
                $('#CatId_'+catId+' li:eq('+liNo+')').html(htmlLi);
            }
			
            /*if( pageNo > 1 )
            {
                htmlImage='<img src="'+baseUrl+'assets/images2.0/ButtPrev_normal.gif" width="15" height="19" title="Previous"';
                htmlImage+='style="cursor:pointer;" onclick="return getCategoryProducts('+catId+', '+prodCount+', '+(pageNo - 1)+');"  />&nbsp;';
            }
            else
            {
                htmlImage='<img width="15" height="19" title="Previous"';
                htmlImage+='src="'+baseUrl+'assets/images2.0/ButtPrev_hover.gif">&nbsp;';
            }
				
            if( prodCount > ( pageNo * pageSize ) )
            {
                htmlImage+='<img width="15" height="19" onclick="return getCategoryProducts('+catId+', '+prodCount+', '+(pageNo+1)+');" style="cursor:pointer;"';
                htmlImage+='title="Next" src="'+baseUrl+'assets/images2.0/ButtNext_hover.gif">';
            }
            else
            {
                htmlImage+='<img src="'+baseUrl+'assets/images2.0/ButtNext_normal.gif" width="15" height="19" title="Next"   />';
            }*/
			
            $('div#arrow_'+catId).html(htmlImage);
            if( categoryProducts.length == 0 )
            {
						   
                $('div#right_contentProductList div.cate_ListProducts ul').html('<li class="noMatchesFound">No Matching Product Available</li>');
                $('div#right_contentProductList div.cate_ListProducts ul li').css('width', '740px');
							   
            }
			
        }
    });
}
