function load_data(brand, group)
{
    $('catalogData').innerHTML = '<div><img src="/img/z.gif" height="35px" width="1px" border=0></div>';
    $('catalogData').innerHTML = '<div style="text-align: center; vertical-align: middle;"><img src="/img/loading.gif" border=0></div>';
    var url = '/load_data.php';
    var pars = 'brand=' + brand + '&group=' + group;

    var myAjax = new Ajax.Request(
    url,
    {method: 'post', parameters: pars, onComplete: showData}
    );
}

function showData(originalRequest) {
    html = originalRequest.responseText;
    $('catalogData').innerHTML = '';
    if (html != null) {
        $('catalogData').innerHTML = html;
    } else {
        $('catalogData').innerHTML = 'Контент не найден!';
    }
}

function reloadImage() {
  	var captcha = $('captcha').src;
  	$('captcha').src = '/captcha.php?' + Math.random();
}

function getHTML()
{
    var url = '/cart.php';
    var pars = '';
    var myAjax = new Ajax.Updater('h-basket', url, {method: 'get', parameters: pars});
}

function addToCart(item_id, count)
{
    var url = '/cart.php';
    var pars = 'item_id='+item_id+'&count='+count;
    //alert(pars);
    var myAjax = new Ajax.Updater('h-basket', url, {method: 'post', parameters: pars});
    alert('Товар добавлен в корзину!');
}

function loadCollections(type)
{
	$('collectionsList').disabled = true;
	var Brand = $F('collectionBrand');
	var url = '/load_collections.php';
	var pars = 'brand=' + Brand;

	var myAjax = new Ajax.Request(
	url,
	{method: 'post', parameters: pars, onComplete: showCollections}
	);
}

function showCollections(originalRequest)
{
	optionList = eval('(' + originalRequest.responseText + ')');
	$('collectionsList').innerHTML = '';
	if (optionList.length > 1) {
		for (i=0; i<optionList.length; i++) {
		 optData = optionList[i];
		 newOpt  = document.createElement('option');
		 //newOpt.key = optData['key'];
		 newOpt.value = optData['key'];
		 newOpt.innerHTML = optData['value'];
		 //alert('key => ' + optData['key'] + ' value => ' + optData['value']);
		 $('collectionsList').appendChild(newOpt);
		}
	} else {
		 optData = optionList;
		 newOpt  = document.createElement('option');
		 //newOpt.key = optData;
		 newOpt.value = optData['key'];
		 newOpt.innerHTML = optData['value'];
		 $('collectionsList').appendChild(newOpt);
	}
	if (optionList.length > 0) {
		$('collectionsList').disabled = false;
	}

}

function quickPass(href) {
    document.location.href = href;
    //alert(href);
}
