﻿//Copyright dbDirector
Event.observe(window, 'load', function() {

  if (Request.QueryString("category").Count > 0) {
    if (getCookie("pCategory") != '') {
      if (Request.QueryString("category") != getCookie("pCategory")) {
        deleteCookie("color");
        deleteCookie("brand");
        deleteCookie("category");
        deleteCookie("size");
        deleteCookie("sort");
        //Sai
        deleteCookie("showtype");
        deleteCookie("pno");
        deleteCookie("minPrice");
        deleteCookie("maxPrice");
        deleteCookie("ids");
        deleteCookie("pCategory");
        deleteCookie("dressstyle");
        deleteCookie("dresssleeve");
        deleteCookie("dresslength");
        deleteCookie("topstyle");
        deleteCookie("topsleeve");
        deleteCookie("heelheight");
        deleteCookie("show");                                    //29/01/2010
        pCategory = Request.QueryString("category");
        setCookie('pCategory', Request.QueryString("category"));
        clearthis('');
      }
      else {
        sColor = getCookie("color");
        sBrand = getCookie("brand");
        sCategory = getCookie("category");
        pCategory = getCookie("pCategory");
        sSize = getCookie("size");
        sSort = getCookie("sort");
        //sai
        sshowtype = getCookie("showtype");
        pageNo = getCookie("pno");
        minPrice = getCookie("minPrice");
        maxPrice = getCookie("maxPrice");
        sID = getCookie("ids");
        sdrstyle = getCookie("dressstyle");
        sdrsleeve = getCookie("dresssleeve");
        sdrlength = getCookie("dresslength");
        stopstyle = getCookie("topstyle");
        stopsleeve = getCookie("topsleeve");
        sheelheight = getCookie("heelheight");
        sshow = getCookie("show");                             //29/01/2010
        ajaxCall(sColor, sBrand, sCategory, sSize, pageNo, sSort, minPrice, maxPrice, sdrstyle, sdrsleeve, sdrlength, stopstyle, stopsleeve, sheelheight, sshowtype, sshow);
      }
    }
    else {
      sColor = getCookie("color");
      sBrand = getCookie("brand");
      sCategory = getCookie("category");
      //pCategory = getCookie("pCategory");
      pCategory = Request.QueryString("category");
      sSize = getCookie("size");
      sSort = getCookie("sort");
      //sai
      sshowtype = getCookie("showtype");
      pageNo = getCookie("pno");
      minPrice = getCookie("minPrice");
      maxPrice = getCookie("maxPrice");
      sID = getCookie("ids");
      sdrstyle = getCookie("dressstyle");
      sdrsleeve = getCookie("dresssleeve");
      sdrlength = getCookie("dresslength");
      stopstyle = getCookie("topstyle");
      stopsleeve = getCookie("topsleeve");
      sheelheight = getCookie("heelheight");
      sshow = getCookie("show");                             //29/01/2010
      ajaxCall(sColor, sBrand, sCategory, sSize, pageNo, sSort, minPrice, maxPrice, sdrstyle, sdrsleeve, sdrlength, stopstyle, stopsleeve, sheelheight, sshowtype, sshow);
    }
  }
  else {
    sColor = getCookie("color");
    sBrand = getCookie("brand");
    sCategory = getCookie("category");
    pCategory = getCookie("pCategory");
    sSize = getCookie("size");
    sSort = getCookie("sort");
    //sai
    sshowtype = getCookie("showtype");
    pageNo = getCookie("pno");
    minPrice = getCookie("minPrice");
    maxPrice = getCookie("maxPrice");
    sID = getCookie("ids");
    sdrstyle = getCookie("dressstyle");
    sdrsleeve = getCookie("dresssleeve");
    sdrlength = getCookie("dresslength");
    stopstyle = getCookie("topstyle");
    stopsleeve = getCookie("topsleeve");
    sheelheight = getCookie("heelheight");
    sshow = getCookie("show");                             //29/01/2010
    ajaxCall(sColor, sBrand, sCategory, sSize, pageNo, sSort, minPrice, maxPrice, sdrstyle, sdrsleeve, sdrlength, stopstyle, stopsleeve, sheelheight, sshowtype, sshow);
  }
  SetCSS();
});


function SetCSS() {
  if (sID != '') {
    aID = sID.split(",");
    for (var C_index = 0; C_index < aID.length; C_index++) {
      if (aID[C_index] != '')
        $(aID[C_index]).toggleClassName('selected');
    }
  }
}

var sshow = "";          //29/01/2010
asdrshow = new Array();
if (getCookie("show") != '') {
  sshow = getCookie("show");
  asdrshow.push(sshow);
}
var StrAsshow = "";


var sdrstyle = "";
asdrstyle = new Array();
if (getCookie("dressstyle") != '') {
  sdrstyle = getCookie("dressstyle");
  asdrstyle.push(sdrstyle);
}
var StrAsdrstyle = "";

var sdrsleeve = "";
asdrsleeve = new Array();
if (getCookie("dresssleeve") != '') {
  sdrsleeve = getCookie("dresssleeve");
  asdrsleeve.push(sdrsleeve);
}
var StrAsdrsleeve = "";

var sdrlength = "";
asdrlength = new Array();
if (getCookie("dresslength") != '') {
  sdrlength = getCookie("dresslength");
  asdrlength.push(sdrlength);
}
var StrAsdrlength = "";

var stopstyle = "";
astopstyle = new Array();
if (getCookie("topstyle") != '') {
  stopstyle = getCookie("topstyle");
  astopstyle.push(stopstyle);
}
var StrAstopstyle = "";

var stopsleeve = "";
astopsleeve = new Array();
if (getCookie("topsleeve") != '') {
  stopsleeve = getCookie("topsleeve");
  astopsleeve.push(stopsleeve);
}
var StrAstopsleeve = "";

var sheelheight = "";
asheelheight = new Array();
if (getCookie("heelheight") != '') {
  sheelheight = getCookie("heelheight");
  asheelheight.push(sheelheight);
}
var StrAsheelheight = "";

//'C' name space
var sColor = "";
aColor = new Array();
if (getCookie("color") != '') {
  sColor = getCookie("color");
  aColor.push(sColor);
}
var StrAColor = "";
//'B' name space3
var sBrand = "";
aBrand = new Array();
if (getCookie("brand") != '') {
  sBrand = getCookie("brand");
  aBrand.push(sBrand);
}
var StrABrand = "";
//'S' name space

var pCategory = "";

var sCategory = "";
aCategory = new Array();
if (getCookie("category") != '') {
  sCategory = getCookie("category");
  aCategory.push(sCategory);
}
var StrACategory = "";

var sSize = "";
aSize = new Array();
if (getCookie("size") != '') {
  sSize = getCookie("size");
  aSize.push(sSize);
}
var StrASize = "";
var sSort = "";
//Sai
var sshowtype = "";
var strElmId;
var ajaxUrl = "";

var pageNo = '0';
var minPrice = getCookie("minPrice");
var maxPrice = getCookie("maxPrice");

aID = new Array();
var sID = "";
var StrAID = "";
//createst string comma separated string out of array
//this could be rewritten into one function    
function C_joinArray() {
  StrAColor = aColor.join("', '");
  return (StrAColor);
};
function B_joinArray() {
  StrABrand = aBrand.join("', '");
  return (StrABrand);
};

function SH_joinArray() {                   //29/01/2010
  StrAsshow = asdrshow.join("', '");
  return (StrAsshow);
};

function DRS_joinArray() {
  StrAsdrstyle = asdrstyle.join("', '");
  return (StrAsdrstyle);
};
function DRSL_joinArray() {
  StrAsdrsleeve = asdrsleeve.join("', '");
  return (StrAsdrsleeve);
};

function DRL_joinArray() {
  StrAsdrlength = asdrlength.join("', '");
  return (StrAsdrlength);
};

function TSY_joinArray() {
  StrAstopstyle = astopstyle.join("', '");
  return (StrAstopstyle);
};

function TSL_joinArray() {
  StrAstopsleeve = astopsleeve.join("', '");
  return (StrAstopsleeve);
};

function HL_joinArray() {
  StrAsheelheight = asheelheight.join("', '");
  return (StrAsheelheight);
};
function Ct_joinArray() {
  StrACategory = aCategory.join("', '");
  return (StrACategory);
};
function S_joinArray() {
  StrASize = aSize.join("', '");
  return (StrASize);
};
function I_joinArray() {
  StrAID = aID.join(",");
  return (StrAID);
};

//generates query sting that loads AJAX data
function MakeSelection(strType, strValue, strElmId, pno) {
  pageNo = pno;
  //checks for class being selected        
  var selTrue = Element.hasClassName(strElmId, "selected").toString();

  $(strElmId).toggleClassName('selected');

  var C_found = -1;
  for (var C_index = 0; C_index < aID.length; C_index++) {
    if (aID[C_index] == strElmId) { C_found = C_index; break; }
  }
  if (C_found == -1)
    aID.push(strElmId);
  else {
    if (C_found >= 0) {
      //handles bug in splice function (splice cannot delete '0' value)
      if (aID.length == 1) {
        aID.splice(C_found, 1);
      }
      else {
        //handles bug in splice function (splice cannot delete '0' value)
        if (C_found == 0) {
          aID.splice(0, 1);
        }
        else {
          aID.splice(C_found, C_found);
        }
      }
    }
  }
  setCookie("ids", I_joinArray());
  //COLOR
  //*****************************************************
  if (strType == 'color') {
    //checks of selection was made through current CSS class: creates 'toggle effect'
    if (selTrue == 'true') {
      //deleting item from the array
      var C_found = -1;
      for (var C_index = 0; C_index < aColor.length; C_index++) {
        if (aColor[C_index] == strValue) { C_found = C_index; break; }
      }
      if (C_found >= 0) {

        //handles bug in splice function (splice cannot delete '0' value)
        if (aColor.length == 1) {
          aColor.splice(C_found, 1);
        }
        else {
          //handles bug in splice function (splice cannot delete '0' value)
          if (C_found == 0) {
            aColor.splice(0, 1);
          }
          else {
            aColor.splice(C_found, C_found);
          }
        }
      }
      sColor = C_joinArray();
    }
    else {
      //adding item from the array
      //handles bug in splice function (splice cannot delete '0' value)
      if (aColor.length == 0) {
        aColor.push(strValue);
      }
      else {
        aColor.push(strValue);
      }
      sColor = C_joinArray();
    };
  };
  //BRAND
  //*****************************************************
  if (strType == 'brand') {
    //checks of selection was made through current CSS class: creates 'toggle effect'
    if (selTrue == 'true') {
      //deleting item from the array
      var B_found = -1;
      for (var B_index = 0; B_index < aBrand.length; B_index++) {
        if (aBrand[B_index] == strValue) { B_found = B_index; break; }
      }
      if (B_found >= 0) {

        //handles bug in splice function (splice cannot delete '0' value)
        if (aBrand.length == 1) {
          aBrand.splice(B_found, 1);
        }
        else {
          //handles bug in splice function (splice cannot delete '0' value)
          if (B_found == 0) {
            aBrand.splice(0, 1);
          }
          else {
            aBrand.splice(B_found, B_found);
          }
        }
      }
      sBrand = B_joinArray();
    }
    else {
      //adding item from the array
      //handles bug in splice function (splice cannot delete '0' value)
      if (aBrand.length == 0) {
        aBrand.push(strValue);
      }
      else {
        aBrand.push(strValue);
      }
      sBrand = B_joinArray();
    };
  };

  //KeyWord
  //*****************************************************
  if (strType == 'dressstyle') {
    //checks of selection was made through current CSS class: creates 'toggle effect'
    if (selTrue == 'true') {
      //deleting item from the array
      var sdrstyle_found = -1;
      for (var sdrstyle_index = 0; sdrstyle_index < asdrstyle.length; sdrstyle_index++) {
        if (asdrstyle[sdrstyle_index] == strValue) { sdrstyle_found = sdrstyle_index; break; }
      }
      if (sdrstyle_found >= 0) {

        //handles bug in splice function (splice cannot delete '0' value)
        if (asdrstyle.length == 1) {
          asdrstyle.splice(sdrstyle_found, 1);
        }
        else {
          //handles bug in splice function (splice cannot delete '0' value)
          if (sdrstyle_found == 0) {
            asdrstyle.splice(0, 1);
          }
          else {
            asdrstyle.splice(sdrstyle_found, sdrstyle_found);
          }
        }
      }
      sdrstyle = DRS_joinArray();
    }
    else {
      //adding item from the array
      //handles bug in splice function (splice cannot delete '0' value)
      if (asdrstyle.length == 0) {
        asdrstyle.push(strValue);
      }
      else {
        asdrstyle.push(strValue);
      }
      sdrstyle = DRS_joinArray();
    };
  };
  if (strType == 'dresssleeve') {
    //checks of selection was made through current CSS class: creates 'toggle effect'
    if (selTrue == 'true') {
      //deleting item from the array
      var sdrsleeve_found = -1;
      for (var sdrsleeve_index = 0; sdrsleeve_index < asdrsleeve.length; sdrsleeve_index++) {
        if (asdrsleeve[sdrsleeve_index] == strValue) { sdrsleeve_found = sdrsleeve_index; break; }
      }
      if (sdrsleeve_found >= 0) {

        //handles bug in splice function (splice cannot delete '0' value)
        if (asdrsleeve.length == 1) {
          asdrsleeve.splice(sdrsleeve_found, 1);
        }
        else {
          //handles bug in splice function (splice cannot delete '0' value)
          if (sdrsleeve_found == 0) {
            asdrsleeve.splice(0, 1);
          }
          else {
            asdrsleeve.splice(sdrsleeve_found, sdrsleeve_found);
          }
        }
      }
      sdrsleeve = DRSL_joinArray();
    }
    else {
      //adding item from the array
      //handles bug in splice function (splice cannot delete '0' value)
      if (asdrsleeve.length == 0) {
        asdrsleeve.push(strValue);
      }
      else {
        asdrsleeve.push(strValue);
      }
      sdrsleeve = DRSL_joinArray();
    };
  };

  if (strType == 'dresslength') {
    //checks of selection was made through current CSS class: creates 'toggle effect'
    if (selTrue == 'true') {
      //deleting item from the array
      var sdrlength_found = -1;
      for (var sdrlength_index = 0; sdrlength_index < asdrlength.length; sdrlength_index++) {
        if (asdrlength[sdrlength_index] == strValue) { sdrlength_found = sdrlength_index; break; }
      }
      if (sdrlength_found >= 0) {

        //handles bug in splice function (splice cannot delete '0' value)
        if (asdrlength.length == 1) {
          asdrlength.splice(sdrlength_found, 1);
        }
        else {
          //handles bug in splice function (splice cannot delete '0' value)
          if (sdrlength_found == 0) {
            asdrlength.splice(0, 1);
          }
          else {
            asdrlength.splice(sdrlength_found, sdrlength_found);
          }
        }
      }
      sdrlength = DRL_joinArray();
    }
    else {
      //adding item from the array
      //handles bug in splice function (splice cannot delete '0' value)
      if (asdrlength.length == 0) {
        asdrlength.push(strValue);
      }
      else {
        asdrlength.push(strValue);
      }
      sdrlength = DRL_joinArray();
    };
  };

  if (strType == 'topstyle') {
    //checks of selection was made through current CSS class: creates 'toggle effect'
    if (selTrue == 'true') {
      //deleting item from the array
      var stopstyle_found = -1;
      for (var topstyle_index = 0; topstyle_index < astopstyle.length; topstyle_index++) {
        if (astopstyle[topstyle_index] == strValue) { stopstyle_found = topstyle_index; break; }
      }
      if (stopstyle_found >= 0) {

        //handles bug in splice function (splice cannot delete '0' value)
        if (astopstyle.length == 1) {
          astopstyle.splice(stopstyle_found, 1);
        }
        else {
          //handles bug in splice function (splice cannot delete '0' value)
          if (stopstyle_found == 0) {
            astopstyle.splice(0, 1);
          }
          else {
            astopstyle.splice(stopstyle_found, stopstyle_found);
          }
        }
      }
      stopstyle = TSY_joinArray();
    }
    else {
      //adding item from the array
      //handles bug in splice function (splice cannot delete '0' value)
      if (astopstyle.length == 0) {
        astopstyle.push(strValue);
      }
      else {
        astopstyle.push(strValue);
      }
      stopstyle = TSY_joinArray();
    };
  };

  if (strType == 'topsleeve') {
    //checks of selection was made through current CSS class: creates 'toggle effect'
    if (selTrue == 'true') {
      //deleting item from the array
      var topsleeve_found = -1;
      for (var topsleeve_index = 0; topsleeve_index < astopsleeve.length; topsleeve_index++) {
        if (astopsleeve[topsleeve_index] == strValue) { topsleeve_found = topsleeve_index; break; }
      }
      if (topsleeve_found >= 0) {

        //handles bug in splice function (splice cannot delete '0' value)
        if (astopsleeve.length == 1) {
          astopsleeve.splice(topsleeve_found, 1);
        }
        else {
          //handles bug in splice function (splice cannot delete '0' value)
          if (topsleeve_found == 0) {
            astopsleeve.splice(0, 1);
          }
          else {
            astopsleeve.splice(topsleeve_found, topsleeve_found);
          }
        }
      }
      stopsleeve = TSL_joinArray();
    }
    else {
      //adding item from the array
      //handles bug in splice function (splice cannot delete '0' value)
      if (astopsleeve.length == 0) {
        astopsleeve.push(strValue);
      }
      else {
        astopsleeve.push(strValue);
      }
      stopsleeve = TSL_joinArray();
    };
  };

  //HEEL HEIGHT
  if (strType == 'heelheight') {
    //checks of selection was made through current CSS class: creates 'toggle effect'
    if (selTrue == 'true') {
      //deleting item from the array
      var heelheight_found = -1;
      for (var heelheight_index = 0; heelheight_index < asheelheight.length; heelheight_index++) {
        if (asheelheight[heelheight_index] == strValue) { heelheight_found = heelheight_index; break; }
      }
      if (heelheight_found >= 0) {

        //handles bug in splice function (splice cannot delete '0' value)
        if (asheelheight.length == 1) {
          asheelheight.splice(heelheight_found, 1);
        }
        else {
          //handles bug in splice function (splice cannot delete '0' value)
          if (heelheight_found == 0) {
            asheelheight.splice(0, 1);
          }
          else {
            asheelheight.splice(heelheight_found, heelheight_found);
          }
        }
      }
      sheelheight = HL_joinArray();
    }
    else {
      //adding item from the array
      //handles bug in splice function (splice cannot delete '0' value)
      if (asheelheight.length == 0) {
        asheelheight.push(strValue);
      }
      else {
        asheelheight.push(strValue);
      }
      sheelheight = HL_joinArray();
    };
  };
  //CATEGORY
  //*****************************************************
  if (strType == 'category') {
    //checks of selection was made through current CSS class: creates 'toggle effect'
    if (selTrue == 'true') {
      //deleting item from the array
      var Ct_found = -1;
      for (var Ct_index = 0; Ct_index < aCategory.length; Ct_index++) {
        if (aCategory[Ct_index] == strValue) { Ct_found = Ct_index; break; }
      }
      if (Ct_found >= 0) {
        //handles bug in splice function (splice cannot delete '0' value)
        if (aCategory.length == 1) {
          aCategory.splice(Ct_found, 1);
        }
        else {
          //handles bug in splice function (splice cannot delete '0' value)
          if (Ct_found == 0) {
            aCategory.splice(0, 1);
          }
          else {
            aCategory.splice(Ct_found, Ct_found);
          }
        }
      }
      sCategory = Ct_joinArray();
    }
    else {
      //adding item from the array
      //handles bug in splice function (splice cannot delete '0' value)
      if (aCategory.length == 0) {
        aCategory.push(strValue);
      }
      else {
        aCategory.push(strValue);
      }
      sCategory = Ct_joinArray();
    };
  };
  //SIZE
  //*****************************************************
  if (strType == 'size') {
    //checks of selection was made through current CSS class: creates 'toggle effect'
    if (selTrue == 'true') {
      //deleting item from the array
      var S_found = -1;
      for (var S_index = 0; S_index < aSize.length; S_index++) {
        if (aSize[S_index] == strValue) { S_found = S_index; break; }
      }
      if (S_found >= 0) {
        //handles bug in splice function (splice cannot delete '0' value)
        if (aSize.length == 1) {
          aSize.splice(S_found, 1);
        }
        else {
          //handles bug in splice function (splice cannot delete '0' value)
          if (S_found == 0) {
            aSize.splice(0, 1);
          }
          else {
            aSize.splice(S_found, S_found);
          }
        }
      }
      sSize = S_joinArray();
    }
    else {
      //adding item from the array
      //handles bug in splice function (splice cannot delete '0' value)
      if (aSize.length == 0) {
        aSize.push(strValue);
      }
      else {
        aSize.push(strValue);
      }
      sSize = S_joinArray();
    };
  };


  //SHOW     29/01/2010
  //*****************************************************//
  if (strType == 'show') {
  //alert('make sele: ' + selTrue);
    //checks of selection was made through current CSS class: creates 'toggle effect'
    if (selTrue == 'true') {
      //deleting item from the array
      var Show_found = -1;
      for (var Show_index = 0; Show_index < asdrshow.length; Show_index++) {
        if (asdrshow[Show_index] == strValue) { Show_found = Show_index; break; }
      }
      if (Show_found >= 0) {
        //handles bug in splice function (splice cannot delete '0' value)
        if (asdrshow.length == 1) {
          asdrshow.splice(Show_found, 1);
        }
        else {
          //handles bug in splice function (splice cannot delete '0' value)
          if (Show_found == 0) {
            asdrshow.splice(0, 1);
          }
          else {
            asdrshow.splice(Show_found, Show_found);
          }
        }
      }
       //alert('if ssshow: ' + sshow);
      sshow = SH_joinArray();
       //alert('if ssshow: ' + sshow);
    }
    else {
      //adding item from the array
      //handles bug in splice function (splice cannot delete '0' value)
      if (asdrshow.length == 0) {
        asdrshow.push(strValue);
      }
      else {
        asdrshow.push(strValue);
      }
       //alert('ssshow: ' + sshow);
      sshow = SH_joinArray();
       //alert('ssshow: ' + sshow);
    };
    //alert('ssshow: ' + sshow);
  };
  //*****************************************************//
  ajaxCall(sColor, sBrand, sCategory, sSize, 0, sSort, minPrice, maxPrice, sdrstyle, sdrsleeve, sdrlength, stopstyle, stopsleeve, sheelheight, sshowtype, sshow);
};

function sortBy(sort) {
  sSort = sort;
  ajaxCall(sColor, sBrand, sCategory, sSize, 0, sSort, minPrice, maxPrice, sdrstyle, sdrsleeve, sdrlength, stopstyle, stopsleeve, sheelheight, sshowtype, sshow);
}
//Sai
function showBy(showtype) {
  sshowtype = showtype;
  ajaxCall(sColor, sBrand, sCategory, sSize, 0, sSort, minPrice, maxPrice, sdrstyle, sdrsleeve, sdrlength, stopstyle, stopsleeve, sheelheight, sshowtype, sshow);
}
function gotoPage(pno) {
  pageNo = pno;
  ajaxCall(sColor, sBrand, sCategory, sSize, pageNo, sSort, minPrice, maxPrice, sdrstyle, sdrsleeve, sdrlength, stopstyle, stopsleeve, sheelheight, sshowtype, sshow);
}
function byPrice(strMin, strMax, strElmId) {
  minPrice = strMin;
  maxPrice = strMax;
  setCookie("min", minPrice);
  setCookie("max", maxPrice);
  ajaxCall(sColor, sBrand, sCategory, sSize, 0, sSort, minPrice, maxPrice, sdrstyle, sdrsleeve, sdrlength, stopstyle, stopsleeve, sheelheight, sshowtype, sshow);
}
//AJAX CALL function
function ajaxCall(color, brand, category, size, pno, sort, minPrice, maxPrice, drstyle, drsleeve, drlength, topstyle, topsleeve, heelheight, showtype, show) {
  setCookie("color", color);
  setCookie("brand", brand);
  setCookie("pCategory", pCategory);
  setCookie("category", category);
  setCookie("size", size);
  if (pno == '')
    pno = 0;
  setCookie("pno", pno);
  setCookie("sort", sort);
  //Sai
  setCookie("showtype", showtype);
  setCookie("minPrice", minPrice);
  setCookie("maxPrice", maxPrice);
  setCookie("dressstyle", drstyle);
  setCookie("dresssleeve", drsleeve);
  setCookie("dresslength", drlength);
  setCookie("topstyle", topstyle);
  setCookie("topsleeve", topsleeve);
  setCookie("heelheight", heelheight);
  setCookie("show", show);

  $('products').hide();
  if (category != '')
    category = category; //+ "," + pCategory;
  else
    category = pCategory;
  
  ajaxUrl = "filterresults.aspx?color=" + color + "&brand=" + brand + "&category=" + category + "&size=" + size + "&cp=" + pno + '&sortby=' + sort + '&min=' + minPrice + '&max=' + maxPrice + "&keyword=" + drsleeve + ',' + drlength + ',' + topsleeve + ',' + heelheight + "&style=" + drstyle + ',' + topstyle + "&isreg=" + Request.QueryString("isreg") + "&showtype=" + showtype + "&show=" + show
  Element.hide('products');
  new Ajax.Updater
  (
      'products', ajaxUrl,
      {
        method: 'get',
        onSuccess: function(t) {
          Effect.Appear('products', { duration: 0.3 });
        }
      }
  );

};
//Clear Functions    
function clearthis(strClearItem) {
  //COLOR
  if (strClearItem == 'color') {
    allNodes = $('color_wrapper').getElementsByClassName('selected')
    if (allNodes.length == 0)
      return;
    clearCssClass('color_wrapper', 'selected');
    aColor = new Array();
    sColor = ''
  }
  //BRAND
  else if (strClearItem == 'brand') {
    allNodes = $('brand_wrapper').getElementsByClassName('selected')
    if (allNodes.length == 0)
      return;
    clearCssClass('brand_wrapper', 'selected');
    aBrand = new Array();
    sBrand = ''
  }
  //CATEGORY 
  else if (strClearItem == 'category') {
    allNodes = $('category_wrapper').getElementsByClassName('selected')
    if (allNodes.length == 0) return;
    clearCssClass('category_wrapper', 'selected');
    aCategory = new Array();
    sCategory = ''
  }
  else if (strClearItem == 'catsize') {
    allNodes = $('cat_size').getElementsByClassName('selected')
    if (allNodes.length == 0) return;
    clearCssClass('cat_size', 'selected');
    aSize = new Array();
    sSize = ''
  }
  else if (strClearItem == 'shoecategory') {
    allNodes = $('shoe_cat').getElementsByClassName('selected')
    if (allNodes.length == 0) return;
    clearCssClass('shoe_cat', 'selected');
    aCategory = new Array();
    sCategory = ''
  }
  else if (strClearItem == 'appcategory') {
    allNodes = $('app_cat').getElementsByClassName('selected')
    if (allNodes.length == 0) return;
    clearCssClass('app_cat', 'selected');
    aCategory = new Array();
    sCategory = ''
  }
  else if (strClearItem == 'acccategory') {
    allNodes = $('acc_cat').getElementsByClassName('selected')
    if (allNodes.length == 0) return;
    clearCssClass('acc_cat', 'selected');
    aCategory = new Array();
    sCategory = ''
    sdrstyle = '';
    sdrsleeve = '';
    sdrlength = '';
    stopstyle = '';
    stopsleeve = '';
    sheelheight = '';
  }
  //SIZE
  else if (strClearItem == 'size') {
    allNodes = $('size_wrapper').getElementsByClassName('selected')
    if (allNodes.length == 0) return;
    clearCssClass('size_wrapper', 'selected');
    aSize = new Array();
    sSize = ''
  }
  else if (strClearItem == 'kidsize') {
    allNodes = $('kid_size').getElementsByClassName('selected')
    if (allNodes.length == 0) return;
    clearCssClass('kid_size', 'selected');
    aSize = new Array();
    sSize = ''
  }
  else if (strClearItem == 'dresssize') {
    allNodes = $('dress_size').getElementsByClassName('selected')
    if (allNodes.length == 0) return;
    clearCssClass('dress_size', 'selected');
    aSize = new Array();
    sSize = ''
  }
  else if (strClearItem == 'price') {
    allNodes = $('price_wrapper').getElementsByClassName('selected')
    if (allNodes.length == 0) return;
    clearCssClass('price_wrapper', 'selected');
    minPrice = '';
    maxPrice = '';
  }
  else if (strClearItem == 'dressstyle') {
    allNodes = $('dress_style').getElementsByClassName('selected')
    if (allNodes.length == 0) return;
    clearCssClass('dress_style', 'selected');
    sdrstyle = '';
  }
  else if (strClearItem == 'dresssleeve') {
    allNodes = $('dress_sleeve').getElementsByClassName('selected')
    if (allNodes.length == 0) return;
    clearCssClass('dress_sleeve', 'selected');
    sdrsleeve = '';
  }
  else if (strClearItem == 'dresslength') {
    allNodes = $('dress_length').getElementsByClassName('selected')
    if (allNodes.length == 0) return;
    clearCssClass('dress_length', 'selected');
    sdrlength = '';
  }
  else if (strClearItem == 'topstyle') {
    allNodes = $('top_style').getElementsByClassName('selected')
    if (allNodes.length == 0) return;
    clearCssClass('top_style', 'selected');
    stopstyle = '';
  }
  else if (strClearItem == 'topsleeve') {
    allNodes = $('top_sleeve').getElementsByClassName('selected')
    if (allNodes.length == 0) return;
    clearCssClass('top_sleeve', 'selected');
    stopsleeve = '';
  }
  else if (strClearItem == 'heelheight') {
    allNodes = $('heelheight').getElementsByClassName('selected')
    if (allNodes.length == 0) return;
    clearCssClass('heelheight', 'selected');
    asheelheight = new Array();
    sheelheight = '';
  }
  //SHOW
  else if (strClearItem == 'show') { 
  //added on 29/01/2010
    allNodes = $('show').getElementsByClassName('selected')
    if (allNodes.length == 0) return;
    clearCssClass('show', 'selected');
    asdrlength = new Array();
    sshow = '';
  }
  else {
    aSize = new Array();
    aColor = new Array();
    aBrand = new Array();
    aCategory = new Array();
    asdrlength = new Array();
    asdrsleeve = new Array();
    asdrstyle = new Array();
    asheelheight = new Array();
    astopsleeve = new Array();
    astopstyle = new Array();
    asdrshow = new Array();                    //29/01/2010
    sColor = '';
    sBrand = '';
    sCategory = '';
    sSize = '';
    pageNo = 0;
    minPrice = '';
    maxPrice = '';
    sdrstyle = '';
    sdrsleeve = '';
    sdrlength = '';
    stopstyle = '';
    stopsleeve = '';
    sheelheight = '';
    sshow = '';                              //29/01/2010
    clearCssClass('brand_wrapper', 'selected');
    /*clearCssClass('category_wrapper', 'selected');*/
    clearCssClass('size_wrapper', 'selected');
    clearCssClass('color_wrapper', 'selected');
    clearCssClass('dress_size', 'selected');
    clearCssClass('kid_size', 'selected');
    clearCssClass('acc_cat', 'selected');
    clearCssClass('shoe_cat', 'selected');
    clearCssClass('app_cat', 'selected');
    clearCssClass('cat_size', 'selected');
    clearCssClass('price_wrapper', 'selected');
    clearCssClass('dress_style', 'selected');
    clearCssClass('dress_sleeve', 'selected');
    clearCssClass('dress_length', 'selected');
    clearCssClass('top_style', 'selected');
    clearCssClass('top_sleeve', 'selected');
    clearCssClass('heelheight', 'selected');
    clearCssClass('show', 'selected');                   //29/01/2010
    dualSlider.setValueOnly(0, 0);
    dualSlider.setValueOnly(maxprice, 1);
    $('ctl00_CP_Nav1_dualSliderReadoutSpan').innerHTML = "Range: 0 to " + maxprice;
    //ajaxCall('', '', '', '', pageNo, sSort, minPrice, maxPrice, '', '', '', '', '');
  }
  ajaxCall(sColor, sBrand, sCategory, sSize, 0, sSort, minPrice, maxPrice, sdrstyle, sdrsleeve, sdrlength, stopstyle, stopsleeve, sheelheight, sshowtype, sshow);
};

//clears classes of children with in ID (wrapper id, class to be cleared)
function clearCssClass(WrapperId, CssClass) {
  //try {
  if ($(WrapperId) != null) {
    allNodes = $(WrapperId).getElementsByClassName(CssClass);
    var leng = allNodes.length;
    var S_found = -1;
    for (i = leng - 1; i >= 0; i--) {
      for (j = 0; j < aID.length; j++) {
        if (allNodes[i].id == aID[j]) {
          if (j >= 0) {
            //handles bug in splice function (splice cannot delete '0' value)
            if (aID.length == 1) {
              aID.splice(j, 1, '');
            }
            else {
              //handles bug in splice function (splice cannot delete '0' value)
              if (j == 0) {
                aID.splice(0, 1);
              }
              else {
                aID.splice(j, j);
              }
            }
          }
          break;
        }
      }
      $(allNodes[i]).removeClassName(CssClass);
    }
  }

  setCookie("ids", I_joinArray());
  //}
  //catch (e) { }
}
