﻿function searchsitedept(querystring){
//alert("1");
showdivproducts(querystring);
//alert("2");
showdivdepartment(querystring);
//showdivbrand(querystring)
//alert("3");
showdivdiscount(querystring)
//$("#showtotalproducts").html(document.getElementById('totalcount').value);

}

function searchsitebrand(querystring){
//alert("1");
showdivproducts(querystring);
//showdivdepartment(querystring);
//alert("2");
showdivbrand(querystring)
//alert("3");
showdivdiscount(querystring)
}

function searchsitedeptbrand(querystring){
//alert("1");
showdivproducts(querystring);
//showdivdepartment(querystring);
//alert("2");
showdivdepartmentbrand(querystring)
//alert("3");
showdivdiscount(querystring)
}

function showproducts(querystring)
{	
	var orderby ="ProductName asc";
	var pagesize = "24"		
	
	if(document.getElementById('ddlOrderby')!=null)
	{
		orderby = document.getElementById('ddlOrderby').value		
	}
	if(document.getElementById('ddlPagesize')!=null)
	{
		pagesize = document.getElementById('ddlPagesize').value
	}	
	
	if(querystring == null || querystring=='' || querystring == undefined)
	{
		querystring ="";
	}
	//alert(querystring);
	var pageUrl = "";
	if(querystring !=""){pageUrl =  querystring + "&orderby=" +orderby +"&pagesize=" +pagesize
	}else{pageUrl = "orderby=" +orderby +"&pagesize=" + pagesize} 
	
	showdivproducts(pageUrl);
	// var pagesize = (document.getElementById('totalcount').value);
	// var orderby = (document.getElementById('totalcount').value);
}

function showdivproducts(querystring) {  
	var height = document.getElementById("divprod").clientHeight 
	// if(height>300)
	// {
		// alert(height);
		// var strdiv = "<div class='searchloading' style='height:"+ height +"px;'><span></span><img src='images/loading.gif' /></div>";		
	// }
	// else
	// {
		// alert(height);
		
	// }
	var strdiv = "<div class='searchloading'><span></span><img src='images/loading.gif' /></div>";
	$("#divprod").html(strdiv);  
	
    $.ajax({
        type: "POST",
        url: "sitesearchresultproducts.ashx?" + querystring ,
        success: function(response) {
			$("#divprod").html(response);  
        },
        error: function(response) {
            $("#divprod").html("");            
        }
    });
	
	$(window).scrollTop(0);
}

function showdivdepartmentbrand(querystring) {   
	var height = document.getElementById("divdepartmentbrand").clientHeight 
	if(height>100)
	{
		var strdiv = "<div style='height:"+ height +"px;'><span></span><img src='images/loading.gif' /><br /><span>Loading </span></div>";		
	}
	else
	{
		var strdiv = "<div><img src='images/loading.gif' /><br /><span>Loading </span></div>";
	}
	//var strdiv = "<div><img src='images/loading.gif' /><br /><span>Loading </span></div>";
	
	$("#divdepartmentbrand").html(strdiv);  
    $.ajax({
        type: "POST",
        url: "sitesearchresultdepartmentbrand.ashx?" + querystring,
        success: function(response) {  			
            $("#divdepartmentbrand").html(response);            
        },
        error: function(response) {
            $("#divdepartmentbrand").html("");            
        }
    });
}

function showdivdepartment(querystring) {   
var strdiv = "<div><img src='images/loading.gif' /><br /><span>Loading Department</span></div>";
$("#divdepartment").html(strdiv);  
    $.ajax({
        type: "POST",
        url: "sitesearchresult.ashx?" + querystring,
        success: function(response) {  			
            $("#divdepartment").html(response);            
        },
        error: function(response) {
            $("#divdepartment").html("");            
        }
    });
}

function showdivbrand(querystring) {
var strdiv = "<div><img src='images/loading.gif' /><br /><span>Loading Brand</span></div>";
$("#divbrandsearch").html(strdiv); 
    $.ajax({
        type: "POST",
        url: "sitesearchresultbrand.ashx?" + querystring,
        success: function(response) { 			
            $("#divbrandsearch").html(response);            
        },
        error: function(response) {
            $("#divbrandsearch").html("");            
        }
    });
}

function showdivdiscount(querystring) {
var strdiv = "<div><img src='images/loading.gif' /><br /><span>Loading Discount</span></div>";
$("#divdis").html(strdiv);
    $.ajax({
        type: "POST",
        url: "sitesearchresultdiscount.ashx?" + querystring,
        success: function(response) {            			
            $("#divdis").html(response);            
        },
        error: function(response) {
            $("#divdis").html("");            
        }
    });
}

