/* - ++resource++lotussoftwareshop.js - */
// http://www.software-license-portal.com/portal_javascripts/++resource++lotussoftwareshop.js?original=1
var SWL_SEARCHTERM='Searchterm';var swl_search_focus=false;var swl_timeout=0;var swl_timeout_delay=400;var swl_last_searchterm='';var swl_default_content=null;
function getQueryFromUrl(url){url=decodeURI(url);var query={};var query_string=url.split('?')[1];if(query_string){var query_items=query_string.split('&');if(query_items){for(var i=0;i<query_items.length;i++){var item=query_items[i].split('=');if(item[1]){query[item[0]]=item[1]}}}}
return query}
function swlBuildQueryAddItem(instance){var query={};var active_item=getBaseId(instance.attr("id"),"-submit");if(jQuery("*").index(jQuery('#'+active_item+'-items_uid_records')[0])!=-1){var item=jQuery('#'+active_item+'-items_uid_records');var val=item.val();if(val){query[item.attr('name')]=val}}
if(jQuery("*").index(jQuery('#'+active_item+'-vutotal')[0])!=-1){var item=jQuery('#'+active_item+'-vutotal');var val=item.val();if(val){query[item.attr('name')]=val}}
if(jQuery("*").index(jQuery('#'+active_item+'-quantity')[0])!=-1){var item=jQuery('#'+active_item+'-quantity');var val=item.val();if(val){query[item.attr('name')]=val}}
query['portlet']='1';return query}
function swlSpinner(content_id){jQuery(content_id).html(jQuery("#kss-spinner").html());jQuery(content_id+' img').css({"display":"block","margin-top":"20px","margin-bottom":"20px","margin-left":"auto","margin-right":"auto"})}
function swlRebindContentArea(){jQuery("#region-content").unbind();jQuery("#region-content").ajaxComplete(function(request,settings){swlRebindContentArea();swlRebindVucalc()});jQuery("div.listingBar a").unbind();jQuery("div.listingBar a").click(function(event){event.preventDefault();var query=getQueryFromUrl(jQuery(this).attr('href'));swlSpinner("#region-content");jQuery("#region-content").load("@@category-view-body",query)});jQuery("form.swl_shop_item").unbind();jQuery("#cfv_form").submit(function(event){event.preventDefault()});jQuery("form.swl_shop_item input[type='submit']").unbind();jQuery("form.swl_shop_item input[type='submit']").click(function(event){event.preventDefault();var query=swlBuildQueryAddItem(jQuery(this));var form_id=getBaseId(jQuery(this).attr("id"),"-submit");var url=jQuery('#'+form_id+'-form').attr('action');swlSpinner("#portlet-cart");jQuery("#portlet-cart").parent().load(url,query)})}
function swlRebindFilter(){jQuery("#category-filter-view").unbind();jQuery("#category-filter-view").ajaxComplete(function(request,settings){swlRebindFilter()});jQuery("#cfv_form").unbind();jQuery("#cfv_form").submit(function(event){event.preventDefault()});jQuery("#cfv_product_swbrand").unbind();jQuery("#cfv_product_swbrand").change(function(event){event.preventDefault();window.location.href=jQuery(this).val()});jQuery("#cfv_product_subgroup").unbind();jQuery("#cfv_product_subgroup").change(function(event){event.preventDefault();jQuery("#cfv_part_type").val(0);jQuery("#cfv_charge_unit").val(0);jQuery("#cfv_searchtext").val(SWL_SEARCHTERM);swlFilterReload()});jQuery("#cfv_part_type, #cfv_charge_unit").unbind();jQuery("#cfv_part_type, #cfv_charge_unit").change(function(event){event.preventDefault();swlFilterReload()});jQuery("#cfv_searchtext").unbind();jQuery("#cfv_searchtext").keyup(function(event){event.preventDefault();if(event.keyCode==13){swlContentReload()} else if(jQuery("#cfv_searchtext").val().length>2){swl_search_focus=true;swl_last_searchterm=jQuery("#cfv_searchtext").val();if(swl_timeout){window.clearTimeout(swl_timeout)}
swl_timeout=window.setTimeout(swlContentReload,swl_timeout_delay)} else if(jQuery("#cfv_searchtext").val().length<swl_last_searchterm.length){swl_last_searchterm='';if(swl_timeout){window.clearTimeout(swl_timeout)}
swl_timeout=window.setTimeout(swlDefaultReload,swl_timeout_delay)}});jQuery("#cfv_searchtext").focus(function(event){event.preventDefault();if(jQuery(this).val()==SWL_SEARCHTERM){jQuery(this).val('')}});jQuery("#cfv_searchtext").blur(function(event){event.preventDefault();if(jQuery(this).val()==''){jQuery(this).val(SWL_SEARCHTERM)}});jQuery("#cfv_reset").unbind();jQuery("#cfv_reset").click(function(event){event.preventDefault();jQuery("#cfv_product_subgroup").val(0);jQuery("#cfv_part_type").val(0);jQuery("#cfv_charge_unit").val(0);jQuery("#cfv_searchtext").val(SWL_SEARCHTERM);swlFilterReload()});jQuery("#cfv_submit").unbind();jQuery("#cfv_submit").click(function(event){event.preventDefault();swlFilterReload()});if(swl_search_focus){swl_search_focus=false;jQuery("#cfv_searchtext").focus()}}
function swlBuildQuery(){var query={};if(jQuery("*").index(jQuery('#cfv_product_swbrand')[0])!=-1){var val=jQuery("#cfv_product_swbrand").val();if(val){query.cfv_product_swbrand=val}}
if(jQuery("*").index(jQuery('#cfv_product_subgroup')[0])!=-1){var val=jQuery("#cfv_product_subgroup").val();if(val){query.cfv_product_subgroup=val}}
if(jQuery("*").index(jQuery('#cfv_part_type')[0])!=-1){var val=jQuery("#cfv_part_type").val();if(val){query.cfv_part_type=val}}
if(jQuery("*").index(jQuery('#cfv_charge_unit')[0])!=-1){var val=jQuery("#cfv_charge_unit").val();if(val){query.cfv_charge_unit=val}}
if(jQuery("*").index(jQuery('#cfv_searchtext')[0])!=-1){var val=jQuery("#cfv_searchtext").val();if(val){query.cfv_searchtext=val}}
return query}
function swlDefaultReload(){jQuery("#region-content").html(swl_default_content)}
function swlContentReload(){var query=swlBuildQuery();swlSpinner("#region-content");jQuery("#region-content").load("@@category-view-body",query)}
function swlFilterReload(){var query=swlBuildQuery();swlSpinner("#region-content");jQuery("#region-content").load("@@category-view-body",query);jQuery("#category-filter-view").load("@@category-filter-body",query)}
jQuery(document).ready(function(){swl_default_content=jQuery("#region-content").contents().clone(true);swlRebindFilter();swlRebindContentArea()});
