function menuakce()
{
x = document.getElementById("menicko1").style.display="block";
}
function menuakce1()
{
x = document.getElementById("menicko1").style.display="none";
}


    function make(category_id){

  //alert("hodnota: " + attribut_id + "\n pocet: " +pocet);
  if(category_id == 217){         //hlodavci
 document.getElementById('head').style.background = 'transparent url(/images/layout/head/head3.png) no-repeat scroll 0 0';

 }else if(category_id == 218){   //ptactvo
 document.getElementById('head').style.background = 'transparent url(/images/layout/head/head1.png) no-repeat scroll 0 0';

 }else if(category_id == 119){   //kocky
 document.getElementById('head').style.background = 'transparent url(/images/layout/head/head4.png) no-repeat scroll 0 0';

 }else if(category_id == 2){    //psi
 document.getElementById('head').style.background = 'transparent url(/images/layout/head/head2.png) no-repeat scroll 0 0';

 }else if(category_id == 202){  //akvaristika
 document.getElementById('head').style.background = 'transparent url(/images/layout/head/head5.png) no-repeat scroll 0 0';

 }else if(category_id == 219){  //teraristika
 document.getElementById('head').style.background = 'transparent url(/images/layout/head/head6.png) no-repeat scroll 0 0';

 }
 /* var w="/tree.php?category_id="+category_id;

  //window.open(w);
  loadXMLDoc_tree(w);*/
}
function loadXMLDoc_tree(url)
{	if (window.XMLHttpRequest)
	{	req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange_tree;
		req.open("POST", url);
		req.send(null);
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Msxml2.XMLHTTP");
		if (req)
		{	req.onreadystatechange = processReqChange_tree;
			req.open("POST", url);
			req.send();
		}
	}
}

function processReqChange_tree()
{	
if (req.readyState == 4)
	{	if (req.status == 200)
		{	       
                    var xml = req.responseXML;

                    /**
                     * Nacteni xml a prochazeni jednotlivych atributu.
                     */

                    var items = xml.getElementsByTagName('tree');
                    var tree;
                    for(var i=0;i<items.length;i++){
                        var item = items.item(i);
                        var data = item.getAttribute('id');
                        var cat_id = item.getAttribute('cat_id');
                    
                        /**
                         * V tomhle miste cyklu je v promenne attribute_id nactene id a v promenne
                         * attribute_name jmeno prave prochazeneho atributu (toto je cilem, pokud jsem to spravne pochopil z dat vracenych serverem)
                         * a s temito daty ted je mozne pracovat. Nevim co s nimi konkretne, tak tady je jen alert tech dat pro overeni funkcnosti. 
                         */
                        
                      
                   } 
                 // tree = "</ul>"+data+"<ul class=\"block-menu\">";
                    document.getElementById('sub_cat_'+cat_id).innerHTML = data;  
                 document.getElementById('sub_cat_'+cat_id).style.display="block";  
                     
                    
		} else
			alert("Nelze získat XML data:\n" + req.statusText);
	}
}

function cislaplus(myfield, e, plus)
{	var key; var keychar;
	if (window.event) key = window.event.keyCode;
	else if (e) key = e.which; else return true;
	keychar = String.fromCharCode(key);
	if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) ) return true;
	else if ((("0123456789"+plus).indexOf(keychar) > -1)) return true; else return false;
}

function checkMail(email)
{	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return filter.test(email);
}

isDate = function(y, m, d)
{	if (typeof y == "string" && m instanceof RegExp && d)
	{	if(!m.test(y)) return 1;
		y = RegExp["$" + d.y], m = RegExp["$" + d.m], d = RegExp["$" + d.d];
	}
	d = Math.abs(d) || 0, m = Math.abs(m) || 0, y = Math.abs(y) || 0;
	return arguments.length != 3 ? 1 : d < 1 || d > 31 ? 2 : m < 1 || m > 12 ? 3 : /4|6|9|11/.test(m) && d == 31 ? 4        : m == 2 && (d > ((y = !(y % 4) && (y % 1e2) || !(y % 4e2)) ? 29 : 28)) ? 5 + !!y : 0;
};

function numberformat(n,DECIMAL_POINT,THOUSANDS_SEP)
{	n += '';
	x = n.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? DECIMAL_POINT + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + THOUSANDS_SEP + '$2');
	}
	return x1 + x2;
}

function IntoBasket(product_id, option_set_id)
{	product_quantity=Number(document.forms.frm_amount.product_quantity.value);
	if (product_quantity<=0) product_quantity=1;
	window.location.href='/scripts/intobasket.php?product_id='+product_id+'&option_set_id='+option_set_id+'&product_quantity='+product_quantity;
}



function RemoveItem(product_id, attribute_arr, accessory_product_id, A, metraz, i)
{	window.location.href='scripts/recount_basket.php?product_id='+product_id+'&attribute_arr='+attribute_arr+'&accessory_product_id='+accessory_product_id+'&A='+A+'&metraz='+metraz+'&i='+i;
}

function PutRating(product_id, product_rating_nr)
{	window.location.href='/scripts/put_rating.php?product_id='+product_id+'&product_rating_nr='+product_rating_nr;
}

function SbmtManForm(manufacturer_name_url, f)
{	f.action="/vyrobce/"+manufacturer_name_url;
	f.submit();
}
function RemoveVoucher(discount_voucher_id)
{	window.location.href='/scripts/recount_basket.php?A=RemoveVoucher&discount_voucher_id='+discount_voucher_id;
}

