﻿
function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}
 
 function removeSpaces(string) {
 return string.split(' ').join('');
}


function SelectedStartProcessing(object,url)
{

    price = document.getElementById('ePrice');
    width = document.getElementById('eWidth');
    
   var pf;
    var pt;
    var addedquery = '';
    var istrue=false;
    
    
    
    if ((price.value != "" ) && (price.value != "Price"))
    {
            pv = trim(price.value);
            
            if (pv == "Most Popular")
            {
            
            }
            else
            {
                 addedquery= "?p="+pv;
            }
            
            istrue = true;
   }
    
   if ((width.value != "") && (trim(width.value) != "Width"))
    {
        
        if (trim(width.value) == "Load All")
        {
             // nothing
        }
        else
        {
            if(addedquery != '')
            {
                
             ///   width.value =  removeSpaces(width.value);
              //  alert(width.value);
                
                addedquery += "&w=" + trim(width.value.replace("mm"," mm"));
            }
            else
            {
           // alert(width.value);
            //   width.value =  removeSpaces(width.value);
           //     alert(width.value);
                addedquery = "?w=" + trim(width.value.replace("mm"," mm"));
            }
        }
         istrue = true;
    }
    
    if (istrue)
    {
        location.href =  url + addedquery;
    }
    
}