function do_search(shopping_site_id, category_id)
{               
    var attributes = $('.jqTransformHidden').not('select');
    attributes = JSON.stringify(attributes.serializeObject());    
    var dest_url = parent.location.toString();
    
    //remove previous selection
    dest_url = dest_url.substring(0, dest_url.indexOf('&att='));
    if (dest_url.indexOf('&ssid') != -1 ) {
    	dest_url = dest_url.substring(0, dest_url.indexOf('&ssid='));
    }
    
    dest_url = dest_url + '&ssid=' + shopping_site_id;
    dest_url = dest_url + '&cid=' + category_id;
    dest_url = dest_url + '&att=' + attributes;    

    parent.location = dest_url;
    return false;
}

$(document).ready(function() {
    $('li[id^=find-nav-tab-] a').click(function(event) {
        event.preventDefault();
        var $target = $(event.target);    
        $target.parent().toggleClass('active');
    });
    
    $('input[id^=affcashportal-]').change(function(event) {
	    
    	var ssid = $('#ssid').val(),
	    	cid = $("#cid").val();
	    	do_search(ssid,cid);                      
    });
    
    
    $('div.title-fild p.label').click(function(){
    	var i = $(this).parent().prev().find('a').click();
    });
});


$.fn.serializeObject = function()
{
    var o = {};
    var a = this.serializeArray();
    $.each(a, function() {
        if (o[this.name] !== undefined) {
            if (!o[this.name].push) {
                o[this.name] = [o[this.name]];
            }
            o[this.name].push(this.value || '');
        } else {
            o[this.name] = this.value || '';
        }
    });
    return o;
};
