jQuery.noConflict();

jQuery(document).ready(function() {

	//SEITENTITLE BIE ONESTEPCHECKOUT ÄNDERN

	jQuery(".onestepcheckout-index-index").prev().find("title").before("<title>Finken-Verlag</title>");

	//FILTERNAVIGATION IN KATEGORIEN AUSBLENDEN

	jQuery("#narrow-by-list dt").each(function(){
		jQuery(this).addClass(jQuery(this).text());
		jQuery(this).next().addClass(jQuery(this).text());
	});

	jQuery(".mainnav li:last a").css("background", "none");

	jQuery(".category-elternhaus .Alter.Jahren").hide();
	jQuery(".category-elternhaus .Alter.Freitext").hide();
	jQuery(".category-elternhaus .Alter.Sekundarstufe").hide();
	jQuery(".category-elternhaus .Bereich").hide();
	jQuery(".category-elternhaus .Klasse").hide();
	jQuery(".category-elternhaus .Produktart").hide();
	jQuery(".category-elternhaus .Fach").hide();
	jQuery(".category-elternhaus .Preis").hide();

	jQuery(".category-kindergarten .Alter.Freitext").hide();
	jQuery(".category-kindergarten .Alter.Sekundarstufe").hide();
	jQuery(".category-kindergarten .Alter.Eltern").hide();
	jQuery(".category-kindergarten .Bereich.Logopaedie").hide();
	jQuery(".category-kindergarten .Klasse").hide();
	jQuery(".category-kindergarten .Produktart").hide();
	
	jQuery(".category-grund-und-foerderschule .Alter").hide();
	jQuery(".category-grund-und-foerderschule .Bereich").hide();
	jQuery(".category-grund-und-foerderschule .Fach.Sekundarstufe").hide();
	jQuery(".category-grund-und-foerderschule .Preis").hide();

	jQuery(".category-sek-1-ab-klasse-5 .Alter.Jahren").hide();
	jQuery(".category-sek-1-ab-klasse-5 .Alter.Freitext").hide();
	jQuery(".category-sek-1-ab-klasse-5 .Alter.Eltern").hide();
	jQuery(".category-sek-1-ab-klasse-5 .Fach.Grundschule").hide();
	jQuery(".category-sek-1-ab-klasse-5 .Bereich").hide();
	jQuery(".category-sek-1-ab-klasse-5 .Klasse").hide();
	jQuery(".category-sek-1-ab-klasse-5 .Produktart").hide();

	jQuery(".category-logopaedie .Bereich.Kindergarten").hide();
	jQuery(".category-logopaedie .Preis").hide();
	jQuery(".category-logopaedie .Alter").hide();
	jQuery(".category-logopaedie .Fach").hide();
	jQuery(".category-logopaedie .Klasse").hide();
	jQuery(".category-logopaedie .Produktart").hide();

	if (jQuery("#narrow-by-list dd:visible").length){}else{jQuery(".block-subtitle:eq(1)").hide();}
	
	jQuery("#narrow-by-list dt").each(function(){
		txt = jQuery(this).text();
		txt = txt.split(' ')[0];
		jQuery(this).html(txt);
	});

	//MEIN KONTO NAVIGATION AUSBLENDEN


	//TARGET IN TABCONTAINER IN NEUER SEITE ÖFFNEN LASSEN

	jQuery(".tabcontainer a").attr("target", "_blank");
	
	//LINKPFEIL BEI VERLINKTEN BILDERN IN RECHTER SPALTE ENTFERNEN

	jQuery(".col-right .block a img").parent().addClass("imglink");
	
	//LETZTES HR BEI NACHBEZUG IN RECHTER SPALTE ENTFERNEN

	jQuery(".nachbezug_trenner:last").remove();

	//ANPASSUNGEN AN CHECKOUT FORMULAR

	fax_bill = jQuery("#billing_address_list .input-fax").html();
	jQuery("#billing_address_list .input-telephone").after("<div class='input-box input-fax'>"+fax_bill+"</div>");
	jQuery("#billing_address_list .input-fax:first").remove();

	fax_ship = jQuery("#shipping_address .input-fax").html();
	jQuery("#shipping_address .input-telephone").after("<div class='input-box input-fax'>"+fax_ship+"</div>");
	jQuery("#shipping_address .input-fax:first").remove();

	jQuery(".kundennummer").after("<div style='clear:both;padding:15px 0 10px!important;'><hr /></div>");
	jQuery(".input-lastname").after("<div style='clear:both;padding:15px 0 10px!important;'><hr /></div>");
	jQuery(".input-company").after("<div style='clear:both;padding:15px 0 10px!important;'><hr /></div>");
	jQuery(".input-city").after("<div style='clear:both;padding:15px 0 10px!important;'><hr /></div>");
	jQuery(".taxbilling").after("<div style='clear:both;padding:15px 0 10px!important;'><hr /></div>");

	jQuery(".genderbox").after("<div style='clear:both;padding:5px 0 0px!important;'></div>");
	jQuery(".input-country").before("<div style='clear:both;padding:5px 0 0px!important;'></div>");
	jQuery(".input-country").after("<div style='clear:both;padding:5px 0 0px!important;'></div>");
	jQuery(".input-email").after("<div style='clear:both;padding:5px 0 0px!important;'></div>");

	jQuery(".genderbox option:eq(1)").text("Herr");
	jQuery(".genderbox option:eq(2)").text("Frau");

	jQuery(".input-company label").text("Institution / Firma");

	jQuery(".onestepcheckout-enable-terms br:eq(2)").remove();

	//ANPASSUNGEN AN CHECKOUT FORMULAR - BEREICH ICH BIN

	jQuery(".ichbincheckbox input").change(function() {

		jQuery("#id_ichbin_freetext").val("");
		jQuery(".meineschule input").val("");
		jQuery(".meinkindergarten input").val("");
		jQuery(".meinepraxis input").val("");

		var checkstatus = jQuery(this).attr('checked');
		if (checkstatus == false){
			jQuery(".ichbincheckbox input").attr('checked', false);
			jQuery(this).attr('checked', false);
		}
		else{
			jQuery(".ichbincheckbox input").attr('checked', false);
			jQuery(this).attr('checked', true);
		}
		
		jQuery(".meineschule").hide();
		jQuery(".meinkindergarten").hide();
		jQuery(".meinepraxis").hide();

		var checkstatus = jQuery("#lehrer").attr('checked');
		if (checkstatus == true){
			jQuery(".meineschule").show();
			jQuery("#id_ichbin_freetext").val("Lehrer/Lehrerin");
		}

		var checkstatus = jQuery("#erzieher").attr('checked');
		if (checkstatus == true){
			jQuery(".meinkindergarten").show();
			jQuery("#id_ichbin_freetext").val("Erzieher/Erzieherin");
		}

		var checkstatus = jQuery("#logopaede").attr('checked');
		if (checkstatus == true){
			jQuery(".meinepraxis").show();
			jQuery("#id_ichbin_freetext").val("Logopäde/Logopädin");
		}

		var checkstatus = jQuery("#privatperson").attr('checked');
		if (checkstatus == true){
			jQuery("#id_ichbin_freetext").val("Privatperson");
		}

	});

	jQuery(".meineschule input").change(function() {
		var ichbin = jQuery(".meineschule input").val();
		jQuery("#id_ichbin_freetext").val("Lehrer/Lehrerin bei: " + ichbin);
	});

	jQuery(".meinkindergarten input").change(function() {
		var ichbin = jQuery(".meinkindergarten input").val();
		jQuery("#id_ichbin_freetext").val("Erzieher/Erzieherin bei: " + ichbin);
	});

	jQuery(".meinepraxis input").change(function() {
		var ichbin = jQuery(".meinepraxis input").val();
		jQuery("#id_ichbin_freetext").val("Logopäde/Logopädin bei: " + ichbin);
	});

	//ANPASSUNGEN AN IMPRESSUM

	jQuery(".impressum_container br:eq(1)").remove();

	jQuery(".impressum_container p:eq(1)").html("<p>Telefon: 0 61 71-63 88-0<br>Fax: 0 61 71-63 88-44<br>Web: <a title='Finken-Verlag GmbH' href='http://www.finken.de'>www.finken.de</a><br>E-Mail: <a title='Finken-Verlag GmbH' href='mailto:info@finken.de'>info@finken.de</a></p>");

	//ANPASSUNGEN SERVICE NICHT VERLINKT IN NAVIGATION
	jQuery(".top-container #nav .open a:first").click(function(){
		return false;
	});

	//STATUS IN "LETZTE BESTELLUNGEN" VERSTECKEN
	jQuery("th:contains('Status')").hide();
	jQuery("td:contains('Ausstehend')").hide();

	//ARRAY IN CHECKOUT FIX
	var arraycheck = jQuery(".checkoutcontainer .input-address input").attr("value");
	if(arraycheck === 'Array'){
		jQuery(".checkoutcontainer .input-address input").attr("value", "");
		//alert("Array im Feld!");
	} else {
	
	}

	//FLAGGENAUSWAHL - OVERLAY
	jQuery(".flags_at").click(function(){
		var goUrl = "http://www.finken.at/";
		jQuery(".b_f-at").show();
		jQuery("#flag_overlay").fadeIn();
		setTimeout("redirectAT()", 5000);
		return false;
	});
	jQuery(".flags_ch").click(function(){
		var goUrl = "http://www.schulverlag.ch/";
		jQuery(".b_f-ch").show();
		jQuery("#flag_overlay").fadeIn();
		setTimeout("redirectCH()", 5000);
		return false;
	});

});

function redirectAT(url){
	window.location.href = "http://www.finken.at/";
}

function redirectCH(url){
	window.location.href = "http://www.schulverlag.ch/";
}

