function pricecheck(obj){
    var pspan = obj.find('.tickspan');
    var inputprice = $('#pricecont #pricerange');    
    if(pspan.hasClass('unticked')){
        var sep = '|';
        pspan.removeClass('unticked').addClass('ticked'); 
        if(inputprice.val().length >0){     
            inputprice.val(inputprice.val() + sep + obj.attr('rel'));
        }else{
            inputprice.val(obj.attr('rel'));    
        }
    }else{      
        pspan.removeClass('ticked').addClass('unticked'); 
        var replace = obj.attr('rel').replace('price-','');        
        inputprice.val(inputprice.val().replace(replace,''));   
        var size = inputprice.val().length;
        if(inputprice.val().charAt(size-1) == '|')  inputprice.val(inputprice.val().substr(0,size-1)); 
        if(inputprice.val().charAt(0) == '|')  inputprice.val(inputprice.val().substr(1,size));             
    }
    filter();
 }
 
 function filter(){   
    var options = {
        target: '.pagecontainer',
        beforeSubmit:  showRequest,
        success:       showResponse
    };
    //$('#filter_form').submit(function(){
        $('#filter_form').ajaxSubmit(options);
        window.scrollTo(0,0);
        //return false;
    //});
 }
 function showRequest(formData, jqForm, options) { 
    var page = $('body').attr('id');
    if(page == 'index')
        $('#page-right').addClass('filtershow');
    var obj = $('.pagecontainer');
    var h = 490; w = 748; nh = obj.height(); nw= obj.width();
    
    if(nh < h ) nh = h;
    if(nw < w ) nw = w;
    
    var replace = '<img id="loading-gif" src="/themes/specky/img/ajax-loader.gif" alt="loading" />' +
        '<div id="overlay-cont" style="height:' + nh + 'px; width:' + nw + 'px"></div>';
    //$('#overlay-cont').height(obj.height()).width(obj.width()).show(); 
    //$('#loading-gif').show(); 
    obj.html(replace);  
 }
 function showResponse(responseText, statusText, xhr, $form)  { 
    //var obj = $('.pagecontainer');
    //$('#loading-gif').hide();
    //$('#overlay-cont').hide().after(responseText);
    //obj.html(responseText);       
 }
 
function checktypes(){
    var l = $('li#type .sub-options ol :checkbox:checked').length;
    if(l == 0)
        $('#style').hide();
    else
        $('#style').show();    
}

function filterrem(){   
    var options = {
        target: '.pagecontainer',
        beforeSubmit:  showRequestRem
        //success:       showResponse
    };
    //$('#filter_form').submit(function(){
        $('#filter_form').ajaxSubmit(options);
        window.scrollTo(0,0);
        //return false;
    //});
 }
 function showRequestRem(formData, jqForm, options) { 
    var page = $('body').attr('id');
    if(page == 'index')
        $('#page-right').addClass('filtershow');
    var obj = $('.pagecontainer');
    var h = 490; w = 748; nh = obj.height(); nw= obj.width();
    
    if(nh < h ) nh = h;
    if(nw < w ) nw = w;
    
    var replace = '<img id="loading-gif" src="/themes/specky/img/ajax-loader.gif" alt="loading" />' +
        '<div id="overlay-cont" style="height:' + nh + 'px; width:' + nw + 'px"></div>';
    //$('#overlay-cont').height(obj.height()).width(obj.width()).show(); 
    //$('#loading-gif').show(); 
    obj.html(replace);  
 }
