/*
 * COPYRIGHT (C) 2009 ZIGABYTE CORPORATION. ALL RIGHTS RESERVED.
 */

if (window.focus) {
  self.focus();
}

function $(elename) {
  return document.getElementById(elename);
}

function get_screen_info(form)
{
	$('ScreenInfo').value = screen.width + ',' + screen.height + ',' + screen.colorDepth;
}

function selectAllOptions(selStr)
{
  var selObj = document.getElementById(selStr);
  for (var i=0; i<selObj.options.length; i++) {
    selObj.options[i].selected = true;
  }
}	

function formatPrice(price) {
	if (price.value.indexOf(".") > 0) {
		price.value = price.value.substr(0, price.value.length - (price.value.length - price.value.indexOf(".")));
	}
	price.value = price.value.replace("$", "");
	price.value = price.value.replace(",", "");
}

function CloseMe()
{
  window.opener.refreshMe();
  window.close();
}

function lowPrice() {
	if ($('SearchForm').PriceLow.selectedIndex > $('SearchForm').PriceHigh.selectedIndex)
		$('SearchForm').PriceHigh.selectedIndex = $('SearchForm').PriceLow.selectedIndex + 1;
}

function highPrice() {
	if ($('SearchForm').PriceHigh.selectedIndex < $('SearchForm').PriceLow.selectedIndex) {
		if ($('SearchForm').PriceHigh.selectedIndex - 1 >= 0) {
			$('SearchForm').PriceLow.selectedIndex = $('SearchForm').PriceHigh.selectedIndex - 1;
		} else {
			$('SearchForm').PriceLow.selectedIndex = 0;
		}
	}
}

function toggleHoods() {
	if ($('hoods').style.display == 'none') {
		$('hoods').style.display = 'block';
	} else {
		$('hoods').style.display = 'none';
	}
}

function checkAll2(frm, controlChkbox, className)
{
	var i;
    items = document.forms[frm].elements;

    checkAll = (controlChkbox.checked)?true:false; // what to do? Check all or uncheck all.

    // Is it an array
    if (items.length) {
        if (checkAll) {
            for (i = 0; i < items.length; i++) {
            	if(items[i].className == className)
            		items[i].checked = true;
            }
        }
        else {
            for (i = 0; i < items.length; i++) {
            	if(items[i].className == className)
            		items[i].checked = false;
            }
        }
    }
    else {
        if (checkAll) items.checked = true;
        else          items.checked = false;
    }
    return;
}
