function filter_click(checkbox){
	checkbox.checked = !checkbox.checked;
	document.filter_form.submit();
}

function catalog_sort(sortby){

	if(sortby == 'price-highlow'){
		document.getElementById('sort_by').value = 'price';
		document.getElementById('sort_order').value = 'DESC';
	} else if (sortby == 'price-lowhigh'){
		document.getElementById('sort_by').value = 'price';
		document.getElementById('sort_order').value = 'ASC';
	} else if (sortby == 'bestseller'){
		document.getElementById('sort_by').value = 'bestseller';
		document.getElementById('sort_order').value = 'DESC';
	} else if (sortby == 'bestmatch'){
		document.getElementById('sort_by').value = 'bestmatch';
		document.getElementById('sort_order').value = 'DESC';
	} else if (sortby == 'newest-first'){
		document.getElementById('sort_by').value = 'newest';
		document.getElementById('sort_order').value = 'DESC';
	}  else if (sortby == 'newest-last'){
		document.getElementById('sort_by').value = 'newest';
		document.getElementById('sort_order').value = 'ASC';
	}
	
	document.sort_form.submit();
	
}

function labelClick(cbObject){
	cbObject.checked = !cbObject.checked;
}

function item_appraisal(id){
	window.open('/modules/item_appraisal.cfm?id_item='+id, 'appraisal'+id, 'statusbar=no,menubar=no');
}

function shipping_validate(shipping_country){
	var params = "shipping_country=" + shipping_country;
	makeRequest('GET', '/com/controller/ajax/get/shippingmethods.cfm', params, 'shipping_update(http_request)');
}

function shipping_update(http_request){
	
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			
			document.getElementById('shippingmethod').options.length = 0;
			var methods = eval(trim(http_request.responseText));
			for (var i=0; i < methods.length; i++){
				document.getElementById('shippingmethod').options[i] = new Option(methods[i].value, methods[i].id, false, false);
			}
			
		}
	}
	
}

window.onload = function(){
  if(document.all && navigator.appVersion.indexOf("MSIE")>-1 && navigator.appVersion.indexOf("Windows")>-1)
  {
    var a = document.getElementsByTagName("label");
    for(var i=0,j=a.length;i<j;i++){
      if(a[i].hasChildNodes && a[i].childNodes.item(0).tagName == "IMG")
      {
        a[i].childNodes.item(0).forid = a[i].htmlFor;
        a[i].childNodes.item(0).onclick = function(){
          var e = document.getElementById(this.forid);
          switch(e.type){
            case "radio": e.checked|=1;break;
            case "checkbox": e.checked=!e.checked;break;
            case "text": case "password": case "textarea": e.focus(); break;
          }
        }
      }
    }
  }
}