function findValue(li) {
			if (li==null){
			alert("Leider kein Treffer!");}
			var sValue = li.selectValue;
			var lastchar = sValue.substr(sValue.length-1, 1);
			if (lastchar == " ")
			window.location.href='http://www.gutscheincodes24.de/weitere-gutscheine.html#' + sValue.charAt(0);
   			else
   			window.location.href='http://www.gutscheincodes24.de/#' + sValue.charAt(0);
		}
		function selectItem(li) {
			findValue(li);
		}
		function lookupLocal(){
			var oSuggest = $("#ShopsLocal")[0].autocompleter;
			oSuggest.findValue();
			return false;
		}
		$(document).ready(function() {
			var searchBox = $("#ShopsLocal");
			searchBox.autocompleteArray(shops ,
			{
			delay:10,
			minChars:0,
			matchSubset:1,
			onFindValue:findValue,
			onItemSelect:selectItem,
			autoFill:true,
			maxItemsToShow:15,
			selectFirst:1
			}
			);
			var url = String(window.location);
			var result = url.search(/#/);
			if (result != -1) {}
			else {
			searchBox.focus(function(e){
			$(this).addClass("active");
			});
			searchBox.focus();
			}
			}
			);

function showVoucher(element,voucher,color)
{
 var vouchercode;
 vouchercode = getcode(voucher);
 if (vouchercode){
 element.parentNode.innerHTML='<span class="col3'+color+'Code">Code: <span class="col3'+color+'Bg"><strong>'+vouchercode+'</strong></span></span>';
  win=window.open(element,'win','status=1,toolbar=1,location=1,menubar=1,directories=1,resizable=1,scrollbars=1,top=0,left=0,width=400,height=400');
  win.blur();
  window.focus();
 }
 else {
  win=window.open(element);
 }
}

function getcode(shop) {
	var vcode;
	switch (shop) {
		case "Adler": vcode = "";
		break;
		case "BabyWalz": vcode = "748633";
		break;
		case "Bakker": vcode = "TD";
		break;
		case "Blume": vcode = "AFP3657654";
		break;
		case "Bonprix": vcode = "53025";
		break;
		case "Buecher": vcode = "E7PLNGFJVGTDB1F2";
		break;
		case "DouglasDetail": vcode = "AF7HP5";
		break;
		case "Edeka": vcode = "EDEKA24_2011";
		break;
		case "Ernstings": vcode = "EF-RABATT2011";
		break;
		case "Fashionsisters": vcode = "ANB1201FS15e";
		break;
		case "Fotokasten": vcode = "anti472wucher";
		break;
		case "Goertz": vcode = "";
		break;
		case "Gourmondo": vcode = "";
		break;
		case "Herrenausstatter": vcode = "AND1201H15e";
		break;
		case "HSE": vcode = "neu0212";
		break;
		case "Javari": vcode = "";
		break;
		case "Kaufhof": vcode = "Sale";
		break;
		case "mypix": vcode = "PROMODE05 + PROMODE10";
		break;
		case "myToys": vcode = "4BKM89ZHG56X";
		break;
		case "Neckermann": vcode = "WSH40";
		break;
		case "NeckermannDetail": vcode = "";
		break;
		case "NeckermannJubi": vcode = "";
		break;
		case "Otto": vcode = "80641";
		break;
		case "OttoDetail": vcode = "83505";
		break;
		case "Plus": vcode = "Danke11-572";
		break;
		case "sOliver": vcode = "";
		break;
		case "SC": vcode = "PX964LD10+ CN1572TW20";
		break;
		case "Schwab": vcode = "63557";
		break;
		case "Sheego": vcode = "10522";
		break;
		case "ShopApotheke": vcode = "wx9312312";
		break;
		case "TOnlineShop": vcode = "TSHOP10EUR TSHOP20EUR";
		break;
		case "ToysRus": vcode = "7031911";
		break;
		case "UllaPopken": vcode = "";
		break;
		case "Valentins": vcode = "val4664";
		break;
		case "Walzkidzz": vcode = "838207";
		break;
		case "Zalando": vcode = "Gutscheincodes24";
		break;
		case "Zooplus": vcode = "10PRDE";
		break;
		case "Suisses": vcode = "069";
		break;
	}
	return vcode;
}
