function window_open(url, win_width, win_height) {
	
	var screen_width = window.screen.width;
	var screen_height = window.screen.height;
	
	var win_left = screen_width / 2 - win_width / 2;
	var win_top = screen_height / 2 - win_height / 2;
	
	var win = window.open(url, "", "width=" + win_width + ", height=" + win_height + ", location=0, menubar=0, resizable=0, status=0, titlebar=0, toolbar=0, screenX=100, left=" + win_left + ", screenY=30, top=" + win_top);
}

function window_open_resizable(url, win_width, win_height) {
	
	var screen_width = window.screen.width;
	var screen_height = window.screen.height;
	
	var win_left = screen_width / 2 - win_width / 2;
	var win_top = screen_height / 2 - win_height / 2;
	
	var win = window.open(url, "", "width=" + win_width + ", height=" + win_height + ", location=0, menubar=0, resizable=1,scrollbars=1 status=0, titlebar=0, toolbar=0, screenX=100, left=" + win_left + ", screenY=30, top=" + win_top);
}

function addToFavorite(http, name) {
	var ie5 = navigator.userAgent.indexOf("MSIE 5") > -1;
	var ie6 = navigator.userAgent.indexOf("MSIE 6") > -1 && navigator.userAgent.indexOf("Opera") == -1;
	if (ie5 || ie6) {
		window.external.AddFavorite(http, name);
	}
}

function configSearch() {
	
	var form = document.forms["search"];
	var action = form.action;
	
	var cat = document.getElementById("cat");
	if (cat) {
		if (cat.value != "") {
			action = "/" + cat.value + "/";
		}
		cat.disabled = true;
	}
	
	var brand = document.getElementById("brand_" + cat.options[cat.selectedIndex].label);
	if (brand) {
		if (brand.value) {
			action += "type/" + brand.value + "_0_0" + "/";
		}
		brand.disabled = true;
	}

	var minp = document.getElementById("minp");
	if (minp) {
		if (minp.value) {
			if (isNaN(parseFloat(minp.value))) {
				minp.value = "";
			}
			else {
				action += "min/" + parseFloat(minp.value) + "/";
			}
		}
		minp.disabled = true;
	}
	
	var maxp = document.getElementById("maxp");
	if (maxp) {
		if (maxp.value) {
			if (isNaN(parseFloat(maxp.value))) {
				maxp.value = "";
			}
			else {
				action += "max/" + parseFloat(maxp.value) + "/";
			}
		}
		maxp.disabled = true;
	}
	
	var ok = document.getElementById("ok");
	if (ok) {
		ok.disabled = true;
	}
	
	window.location = action;
	
	return false;
	
}

function changeBrand() {
	
	var form = document.forms["search"];
	
	var cat = form.elements["cat"].options[form.elements["cat"].selectedIndex].label;
	
	var brands = document.getElementsByName("brand");
	for (var i = 0; i < brands.length; i += 1) {
		if (brands[i].id == "brand_" + cat) {
			brands[i].style.display = "inline";
			brands[i].disabled = false;
		}
		else {
			brands[i].style.display = "none";
			brands[i].disabled = true;
		}
	}
	
}
function add_to_favs(url,title) {
/*  if (window.sidebar) { // firefox
     window.sidebar.addPanel(title, url, "");
  } else if (document.all) { // IE
     window.external.AddFavorite(url, title);
  } else if (window.opera && window.print) { // opera
     var elem = document.createElement('a');
     elem.setAttribute('href',url);
     elem.setAttribute('title',title);
     elem.setAttribute('rel','sidebar');
     elem.click();
  }*/
  
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");	}
	else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }	
	else if(window.opera && window.print) { // Opera Hotlist
     var elem = document.createElement('a');
     elem.setAttribute('href',url);
     elem.setAttribute('title',title);
     elem.setAttribute('rel','sidebar');
     elem.click();
//	return true; 

	}
	
	
//	if (window.external) {  
//		document.write('<a href = "javascript:CreateBookmarkLink()");">Add to Favorites</a>');
//	} else if (window.sidebar) {
//		document.write('<a href = "javascript:CreateBookmarkLink()");">Bookmark Page</a>');  
//	} else if (window.opera && window.print) {
//		document.write('<a href = "javascript:CreateBookmarkLink()");">Add Bookmark</a>');
//	} 
}
