//###############################
// Factfinder suggest
//###############################
$().ready(function() {
	action = '/cron/suggest.php';
	$("#searchbox").autocomplete(action, {
		minChars: 1,
		cacheLength: 10,
		matchSubset: false,
		matchContains: true,
		extraParams: {ajax:1,shop:narayanaShop,lang:narayanaLang},
		width: 400,
		scrollHeight: 600,
		max: 99,
		selectFirst:false,
	//		autoFill: true
		formatItem: function(data, i, n, value) {
			liStyle='';
			if(data[0]=='' || data[1].indexOf('type=button')>-1) liStyle = 'background:#FBE8AB;';
			return {liStyle:liStyle, item:data[1]};
		},
		formatMatch: function(data, i, n, value) {
			return data[1];
		},
		formatResult: function(data, i, n, value) {
			return data[0];
		}
	});
	
		$("#searchbox").result(function(event, data, formatted) {
			if (data && data[0]!=0) {
				if(data[1].indexOf('type=button')==-1) document.quick_find.queryFromSuggest.value='true';
				$(this).parent().next().find("input").val(data[1]);
				document.quick_find.submit();
			}
			else {
				return false;
			}
		});
	$('input[type=radio]').css('cursor', 'pointer');
	$('input[type=checkbox]').css('cursor', 'pointer');
	$('input[type=submit]').css('cursor', 'pointer');
});

//###############################
// submit must be in timeout-function otherwise IE6 doesn't work !!
function timeout_submitform(thisform) {
	window.setTimeout('submitform('+thisform+')', 1);
}

//###############################
function submitform(thisform) {
	thisform.submit();
}

//###############################
function seminar_changeform() {
	var price;
	allDays=$("input[name='day']").length; 
	days=$("input[name='day']:checked");
	translation=$('[name=uebersetzung]:checked').length;
	daysChecked=days.length;
	price=0;
	books_ids='';
	if(allDays==daysChecked) {
		price=priceDay[translation][priceDay[0].length-1];
		books_ids=orderDay[translation][priceDay[0].length-1]+',';
	}
	else {
		days.each(function() {
			price+=priceDay[translation][$(this).val()];
			books_ids+=orderDay[translation][$(this).val()]+',';
		});
	}
	priceMeals=0;
	mealValue=$('[name=essen]:checked').val();
	if(mealValue!='0') {
		priceMeals=priceMeal[mealValue]*daysChecked;
		books_ids+=orderMeal[mealValue]+'~'+daysChecked+',';
	}
	price+=priceMeals;
	busValue=$('[name=bus]:checked').val();
	if(busValue!='0') {
		price+=priceBus;
		books_ids+=orderBus
	}
	price_format = price+',00';
	$('#price').html(price_format);
	$('[name=books_ids]').val(books_ids);
}
 
//#################################
function setCookie(name, value, expiry, path, domain) { 
//expiry in days
	if (name != null) {
		var expdate=new Date();
		expdate.setTime(expdate.getTime() + (1000 * 60 * 60 * 24 * expiry))
		expdatestr=expdate.toGMTString();
		expdatestr=expdatestr.replace('UTC', '');
		s= name + "=" + escape(value) +
		((path == null) ? "" : "; path=" + path) +
		((domain == null) ? "" : "; domain=" + domain) +
		((expiry == null) ? "" : "; expires=" + expdatestr);
		document.cookie=s;
	}
}
  
 