﻿//for girs_fitted_subcaegory.aspx page //
 var designVertical = null;
 var designHorizontal = null;
function sortProducts(fobjval)
{
   var lstrsortString = "";
   if(fobjval == "dcMinPrice asc")
     lstrsortString = "Price";
   else if(fobjval == "dtcreationdate desc")
     lstrsortString = "NewProducts";
   else if(fobjval == "stBrand asc")
     lstrsortString = "Brand"; 

  if($get('ctl00_ContentPlaceHolder1_ddlProductSort').selectedIndex != 0)
  {
       if(location.search.indexOf("?") != -1)
       {
         if(location.search.indexOf("sort=") != -1)
         {
            var searchstr = location.search;
            searchstr = searchstr.replace(searchstr.substring(searchstr.indexOf("sort=")),"sort="+lstrsortString+"&fp=true");
            location.search = searchstr;
         }
         else
            location.search += "&sort="+lstrsortString+"&fp=true";
       }
       else
         location.search = "?sort="+lstrsortString+"&fp=true";
   }
   else
   {
      var searchstr = location.search;
      searchstr = searchstr.replace(searchstr.substring(searchstr.indexOf("&sort=")),"&fp=true");
      location.search = searchstr;
   }
}


 //below function is to validate product quantity entered (for girls_fitted_subcategory_subdetails.aspx) //
 function validateProductQty(source,args)
 {
    if($get('ctl00_ContentPlaceHolder1_txtQuantity').value.trim() == "")
    {
       source.errormessage = "Quantity."
       args.IsValid = false;
    }
    else if (parseInt($get('ctl00_ContentPlaceHolder1_txtQuantity').value.trim()) == 0)
    {
       source.errormessage = "Valid Quantity."  
       args.IsValid = false;
    }
    else
     args.IsValid = true;
 }
 
 function getPosition(zxcobj)
 {
    var zxclft=zxcobj.offsetLeft;
    var zxctop=zxcobj.offsetTop;
    while(zxcobj.offsetParent!=null)
    {
      zxcpar=zxcobj.offsetParent;
      zxclft+=zxcpar.offsetLeft;
      zxctop+=zxcpar.offsetTop;
      zxcobj=zxcpar;
    }
    designVertical = zxctop;
    designHorizontal = zxclft; 
 }
 
function sortProducts(fobjval)
{
   var lstrsortString = "";
   if(fobjval == "dcMinPrice asc")
     lstrsortString = "Price";
   else if(fobjval == "dtcreationdate desc")
     lstrsortString = "NewProducts";
   else if(fobjval == "stBrand asc")
     lstrsortString = "Brand"; 

  if($get('ctl00_ContentPlaceHolder1_ddlProductSort').selectedIndex != 0)
  {
       if(location.search.indexOf("?") != -1)   //if there's a query string //
       {
         if(location.search.indexOf("sort=") != -1)    //if there's a sort string //
         {
            var searchstr = location.search;
            searchstr = searchstr.replace(searchstr.substring(searchstr.indexOf("sort=")),"sort="+lstrsortString+"&Pfp=true");
            location.search = searchstr;
         }
         else
            location.search += "&Pfp=true&sort="+lstrsortString+"";
       }
       else
         location.search = "?Pfp=true&sort="+lstrsortString+"";
   }
   else
   {
      var searchstr = location.search;
      searchstr = searchstr.replace(searchstr.substring(searchstr.indexOf("&sort=")),"&Pfp=true");
      location.search = searchstr;
   }
}

function sortDesigns(fobjval)
{
   var lstrsortString = "";
   if(fobjval == "stDesignTitle asc")
     lstrsortString = "DesignTitle";
   else if(fobjval == "dtCreationDate desc")
     lstrsortString = "NewDesigns";
   else if(fobjval == "stDesignerName asc")
     lstrsortString = "Designer"; 

  if($get('ctl00_ContentPlaceHolder1_ddlDesignSort').selectedIndex != 0)
  {
       if(location.search.indexOf("?") != -1)
       {
         if(location.search.indexOf("dessort=") != -1)
         {
            var searchstr = location.search;
            searchstr = searchstr.replace(searchstr.substring(searchstr.indexOf("dessort=")),"sort="+lstrsortString+"&Dfp=true");
            location.search = searchstr;
         }
         else
            location.search += "&Dfp=true&dessort="+lstrsortString+"";
       }
       else
         location.search = "?Dfp=true&dessort="+lstrsortString+"";
   }
   else
   {
      var searchstr = location.search;
      searchstr = searchstr.replace(searchstr.substring(searchstr.indexOf("&dessort=")),"&Dfp=true");
      location.search = searchstr;
   }
}

