function currLocation(locationReferer) {
	window.location = locationReferer;
}

function refreshToNewCat(elem) {
	
	if (document.getElementById(elem).value) {
		window.location = document.getElementById(elem).value;
	} else {
		window.location = '/projects/acara/katalog-produktu.html';
	}
	
	
}

function showDetail(absolute_url, elemShort, elemDetail, openDetail, manufacture, manufactureElem, color, idCustomer) {
	
	exist = 1;
	if (document.getElementById('par' + openDetail).style.display  == 'none') {
		exist = 0;
	}
	
	if (exist == 1) {
		document.getElementById('par' + openDetail).style.display = 'none';
		document.getElementById(elemShort + openDetail).style.backgroundColor = color;
		document.getElementById(elemShort + openDetail).removeAttribute('class');		
	}
	
	//document.getElementById(manufactureElem + manufacture).value = openDetail;
	
	if (exist == 0) {		
		document.getElementById('par' + openDetail).style.display = '';
		document.getElementById(elemShort + openDetail).style.backgroundColor = '#ffdb00';
		document.getElementById(elemShort + openDetail).setAttribute('class','active');		
	
	
		xmlHttp_detail = createXmlHttpObject();
		
		if (xmlHttp_detail==null) {
			ajax_not_supported();
			return false;
		} 
		
		var url = absolute_url + '/ajax_detail.php?id='+ openDetail +'&idCustomer='+ idCustomer;
		var block = document.getElementById('idAddToCart'+ openDetail);
		
		xmlHttp_detail.onreadystatechange = function () {
			stateChanged(xmlHttp_detail,block,block);
		}
		
		xmlHttp_detail.open("GET",url,true);
		xmlHttp_detail.send(null);
		setTimeout("tb_init('a.thickbox, area.thickbox, input.thickbox')", 200); // the delay is expressed in milliseconds
		
		return true;
	}	
}

function defaultPaging(locationReferer, absolute_url, sess, count) {
			
		xmlHttp_cart = createXmlHttpObject();
		
		if (xmlHttp_cart==null) {
			ajax_not_supported();
			return false;
		} 
		
		//alert(locationReferer);
		
		var url = absolute_url + '/ajax_shop.php?maxOnPage='+count+'&sess='+sess;
		
		//window.location(locationReferer);
		
				
		var block = document.getElementById('shopSess');
		
		xmlHttp_cart.onreadystatechange = function () {
			stateChanged(xmlHttp_cart,block,block);
		}
		
		xmlHttp_cart.open("GET",url,true);
		xmlHttp_cart.send(null);
		
		currLocation(locationReferer);
		
		return true;
}

function inputIdFilter(input, elem) {
	document.getElementById(elem).value = input;
}

function inputSelected(input, div) {
	input = document.getElementById(input);
	document.getElementById(div).innerHTML = input.options[input.selectedIndex].text;
}

function defaultSelect(locationReferer, absolute_url, sess, hodnota, filter, detail, input) {
	
		var locationReferer = locationReferer;
		
		xmlHttp_cart = createXmlHttpObject();
		
		if (xmlHttp_cart==null) {
			ajax_not_supported();
			return false;
		} 
		
		//alert(locationReferer);
		
		var url = absolute_url + '/ajax_shop.php?shop_default_select='+hodnota+'&sess='+sess +'&filter='+filter +'&detail='+detail+'&url='+locationReferer;
				
		//window.location(locationReferer);
		
				
		var block = document.getElementById('shopSess');
		
		xmlHttp_cart.onreadystatechange = function () {
			stateChanged(xmlHttp_cart,block,block);
		}
		
		xmlHttp_cart.open("GET",url,true);
		xmlHttp_cart.send(null);
		
		//currLocation(locationReferer);
		//setTimeout("alert(locationReferer)", 500); // the delay is expressed in milliseconds
		
		
		
		setTimeout("alert(locationReferer)",300);

		return true;
}

function defaultOrderingType(locationReferer, absolute_url, sess, type) {
			
		xmlHttp_cart = createXmlHttpObject();
		
		if (xmlHttp_cart==null) {
			ajax_not_supported();
			return false;
		} 
		
		//alert(locationReferer);
		
		var url = absolute_url + '/ajax_shop.php?orderingType='+type+'&sess='+sess;
		
		//window.location(locationReferer);
		
				
		var block = document.getElementById('shopSess');
		
		xmlHttp_cart.onreadystatechange = function () {
			stateChanged(xmlHttp_cart,block,block);
		}
		
		xmlHttp_cart.open("GET",url,true);
		xmlHttp_cart.send(null);
		
		currLocation(locationReferer);
		
		return true;
}

function addBookmarks(absolute_url, id_user, id_product, code, elem) {
			
		xmlHttp_bookmark = createXmlHttpObject();
		
		if (xmlHttp_bookmark==null) {
			ajax_not_supported();
			return false;
		} 
		
		var urlBookmark = absolute_url + '/ajax_bookmark.php?product='+id_product+'&user='+id_user+'&code='+code;

		var blockBookmark = document.getElementById(elem + id_product);
		
		xmlHttp_bookmark.onreadystatechange = function () {
			stateChanged(xmlHttp_bookmark,blockBookmark,blockBookmark);
		}
		
		xmlHttp_bookmark.open("GET",urlBookmark,true);
		xmlHttp_bookmark.send(null);
				
		return true;
}

