$('document').ready(function() {


	
	$rahmenhoehe = $(document).height();
	$leftmenuehoehe = $("div#leftmenue").height();
	//alert($leftmenuehoehe);
	if ($leftmenuehoehe > 500) {
	
		$leftmenuehoehead = $leftmenuehoehe - 500;
		$("div#leftmenue").css('padding-bottom', $leftmenuehoehead);
		$("div#leftstempelsub").css('top', $rahmenhoehe - $leftmenuehoehead);
	}
	else {	
		
	
		$("div#leftstempelsub").css('top', $rahmenhoehe - 280);
	}
	//lang img switcher
	var srcOrigin = $("img#langimg").attr("src");
	 
	$("area#dearea").mouseover(function() { 
            var src = "/src/web/foxcof/front/images/de.jpg";
            $("img#langimg").attr("src", src);
        });
   
	$("area#dearea").mouseout(function() {
            var src = "/src/web/foxcof/front/images/de.jpg";
            $("img#langimg").attr("src", srcOrigin);
        });

	$("area#enarea").mouseover(function() { 
            var src = "/src/web/foxcof/front/images/en.jpg";
            $("img#langimg").attr("src", src);
        });

	$("area#enarea").mouseout(function() {
            var src = "/src/web/foxcof/front/images/en.jpg";
            $("img#langimg").attr("src", srcOrigin);
        });	
        // / lang img switcher 

	//calculator


	var $priceRange1 = [];
	$priceRange1 = ["de","en","fr","fl","gr","it","nl"];
	var $priceRange2 = [];
	$priceRange2 = ["bu","kr","po","pg","ru","se","sl","so","sp","ts","tu","un"];
	var $priceRange3 = [];
	$priceRange3 = ["ar","da","fi","no","rs","sc"];
	var $priceRange4 = [];
	$priceRange4 = ["ch","jp"];
	
	$priceNz1 = 1.58;
	$priceNz2 = 1.50;
	$priceNz3 = 1.65;
	$priceNz4 = 2.20;
	
	$minPrice1 = 50;
	$minPrice1_1 = 35; //english
	$minPrice2 = 50;
	$minPrice3 = 50;
	$minPrice4 = 55;
	
	$normZeile = 55;


	$('form#calcform').submit(function() {
	  //alert('calcform submit called.');
	  calcPrice();
	  return false;

	});
	

	$('select#ziel1').change(function() {
	  //alert('ziel change called.');
	  calcPrice();
	});
	
	$('select#ausgang').change(function() {
	   //alert('ausgang change called.');
	   calcPrice();
	});
	
	$('input#anzword').change(function() {
	  //alert('anzword change called.');
	  calcPrice();
	});
	
	$('input#stunden').change(function() {
	  //alert('stunden change called.');
	  checkCheckbox(1);
	  calcPrice();
	});
	
	$('input#nacht').change(function() {
	  //alert('nacht change called.');
	  checkCheckbox(2);
	  calcPrice();
	});
	
	function setText(dyntextif) {
		 //alert("setText called");
		 $("div#ergebnis").html(dyntextif);	
	}
	
	function getText() {
		 //alert("getText called");
		 return $("div#ergebnis").html();	
		
	}
	
	getMailText = function() {
		var $ergebnisText = getText();
		var $ausgangVal2 = $('select#ausgang :selected').val();  	
		var $zielVal2 = $('select#ziel1 :selected').val(); 
		var $mailText = "mailto:foxcof@foxcof.at?subject=Preis Anfrage&body=Ausgangssprache: " + $ausgangVal2 + "%09%0D%0AZielsprache: " + $zielVal2 + "%09%0D%0A%09%0D%0A" + $ergebnisText;
		$mailText = $mailText.replace('<br>', '%09%0D%0A');
		$mailText = $mailText.replace('<br />', '%09%0D%0A');
		$mailText = $mailText.replace('<br>', '%09%0D%0A');
		$mailText = $mailText.replace('<br />', '%09%0D%0A');
		$mailText = $mailText.replace('<br>', '%09%0D%0A');
		$mailText = $mailText.replace('<br />', '%09%0D%0A');
		$mailText = $mailText.replace('<br>', '%09%0D%0A');
		$mailText = $mailText.replace('<br />', '%09%0D%0A');
		$mailText = $mailText.replace('<br>', '%09%0D%0A');
		$mailText = $mailText.replace('<br />', '%09%0D%0A');	
		$mailText = $mailText.replace('<BR>', '%09%0D%0A');
		$mailText = $mailText.replace('<BR>', '%09%0D%0A');	
		$mailText = $mailText.replace('<BR>', '%09%0D%0A');	
		$mailText = $mailText.replace('<BR>', '%09%0D%0A');				
		$mailText = $mailText.replace('<strong>', '');
		$mailText = $mailText.replace('</strong>', '');
		$mailText = $mailText.replace('<strong>', '');
		$mailText = $mailText.replace('</strong>', '');
		$mailText = $mailText.replace('<strong>', '');
		$mailText = $mailText.replace('</strong>', '');
		$mailText = $mailText.replace('<strong>', '');
		$mailText = $mailText.replace('</strong>', '');	
		$mailText = $mailText.replace('<STRONG>', '');	
		$mailText = $mailText.replace('<STRONG>', '');	
		$mailText = $mailText.replace('</STRONG>', '');	
		$mailText = $mailText.replace('</STRONG>', '');	
		$mailText = $mailText.replace('<small>', '');
		$mailText = $mailText.replace('</small>', '');
		$mailText = $mailText.replace('<SMALL>', '');
		$mailText = $mailText.replace('</SMALL>', '');
		$mailText = $mailText.replace('ü', 'ue');
		$mailText = $mailText.replace('ü', 'ue');
		$mailText = $mailText.replace('ü', 'ue');
		$mailText = $mailText.replace('ö', 'oe');
		$mailText = $mailText.replace('ä', 'ae');
		$mailText = $mailText.replace('ö', 'oe');
		$mailText = $mailText.replace('ä', 'ae');
		$mailText = $mailText.replace('ö', 'oe');
		$mailText = $mailText.replace('ä', 'ae');
		$mailText = $mailText.replace('Ã¼', 'ue');
		$mailText = $mailText.replace('Ã¶', 'oe');
		$mailText = $mailText.replace('&uuml;', 'ue');
		$mailText = $mailText.replace('&auml;', 'oe');
	
		$("a#anfragesendfc").attr("href", $mailText)
		//return $mailText;
	}
	
	function checkCheckbox(delim) {
		if (delim == 1) {
			
			$('input#nacht').attr('checked', false);
		}
		else {
			$('input#stunden').attr('checked', false);
		}
		
	}
	
	function calcPrice() {
		 //alert("calcPrice 1");
		 $ausgangVal = $('select#ausgang :selected').val();  	
		 $zielVal = $('select#ziel1 :selected').val(); 
		 $anzwordVal = $('input#anzword').val(); 
		 $stundenVal = $('input#stunden').is(':checked');
		 $nachtVal = $('input#nacht').is(':checked');
		 
		 //wenn ausgang und zielsprache ausgewählt und nicht ident
		 if ($ausgangVal != 0 && $zielVal != 0 && $ausgangVal != $zielVal) {
		 	//alert("calcPrice called: ausgangVal:" + $ausgangVal + " zielVal:" + $zielVal + " anzwordVal:" + $anzwordVal + " stundenVal:" + $stundenVal + " nachtVal:" + $nachtVal); 
		 	
		 	$priceRangeZ = 0; // ziel
		 	$priceRangeA = 0; // ausgang
		 	$priceRangeG = 0; // gesamt
		 	
		 	//preisrange der sprachen festlegen
		 	$.each($priceRange1, function(index, value) { 
			//alert(index + ': ' + value); 
				if ($zielVal.indexOf(value) != -1) {
	  				//alert(index + ': ' + value); 
	  				$priceRangeZ = 1;
	  			}
	  			if ($ausgangVal.indexOf(value) != -1) {
	  				//alert(index + ': ' + value); 
	  				$priceRangeA = 1;
	  			}
			});
		 	$.each($priceRange2, function(index, value) { 
			//alert(index + ': ' + value); 
				if ($zielVal.indexOf(value) != -1) {
	  				//alert(index + ': ' + value); 
	  				$priceRangeZ = 2;
	  			}
	  			if ($ausgangVal.indexOf(value) != -1) {
	  				//alert(index + ': ' + value); 
	  				$priceRangeA = 2;
	  			}
			});
			$.each($priceRange3, function(index, value) { 
			//alert(index + ': ' + value); 
				if ($zielVal.indexOf(value) != -1) {
	  				//alert(index + ': ' + value); 
	  				$priceRangeZ = 3;
	  			}
	  			if ($ausgangVal.indexOf(value) != -1) {
	  				//alert(index + ': ' + value); 
	  				$priceRangeA = 3;
	  			}
			});
			$.each($priceRange4, function(index, value) { 
			//alert(index + ': ' + value); 
				if ($zielVal.indexOf(value) != -1) {
	  				//alert(index + ': ' + value); 
	  				$priceRangeZ = 4;
	  			}
	  			if ($ausgangVal.indexOf(value) != -1) {
	  				//alert(index + ': ' + value); 
	  				$priceRangeA = 4;
	  			}
			});
			
			//alert("pricerangeZ:" + $priceRangeZ);
			//alert("pricerangeA:" + $priceRangeA);
		 	
		 	//nimm den höheren preisrange
		 	if ($priceRangeA > $priceRangeZ) {
		 		//$priceRangeG = $priceRangeA;	
		 		$priceRangeG = $priceRangeZ;
		 	}
		 	else {
		 		$priceRangeG = $priceRangeZ;
		 	}
		 	
		 	//alert("pricerangeG:" + $priceRangeG);
		 	
		 	var $dynprice = 0;
		 	var $dynpriceRange = 0;
		 	
		 	if ($priceRangeG == 1) {
		 		$dynpriceRange = $priceNz1;
		 	}
		 	else if ($priceRangeG == 2) {
		 		$dynpriceRange = $priceNz2;
		 	}
		 	else if ($priceRangeG == 3) {
		 		$dynpriceRange = $priceNz3;
		 	}
		 	else if ($priceRangeG == 4) {
		 		$dynpriceRange = $priceNz4;
		 	}
		 	
		 	else {
		 		$dynpriceRange = $priceNz4;
		 	}
		 	
		 	$anzNormzeilen = $anzwordVal / $normZeile;
		 	$dynprice = $anzNormzeilen * $dynpriceRange;
 	
		 	$anzNormzeilen = $anzNormzeilen.toFixed(0);
		 	
			
			//alert($priceRangeG);
			
	 		if ($priceRangeG == 1) {
		 		
		 		if ($zielVal == "en") {
		 			$dynMinprice = $minPrice1_1;
		 		}
		 		else {
		 			$dynMinprice = $minPrice1;	
		 		}
		 			
		 	}
		 	else if ($priceRangeG == 2) {
		 		$dynMinprice = $minPrice2;
		 	}
		 	else if ($priceRangeG == 3) {
		 		$dynMinprice = $minPrice3;
		 	}
		 	
		 	else if ($priceRangeG == 4) {
		 		$dynMinprice = $minPrice4;
		 	}
		 	else {
		 		$dynMinprice = $minPrice4;
		 	}

			if ($dynprice < $dynMinprice) {
				//alert("Achtung: Mindesthonrar: " + $dynMinprice + "EUR");
				$dynprice = $dynprice.toFixed(2);
				$dynprice2 = $dynprice;
				$dynprice = $dynMinprice;
				dyntext = "<strong>F&uuml;r Ihre Auswahl konnten wir folgende Preiskalkulation ermitteln:</strong><br />";	
				dyntext = dyntext + "" + $anzNormzeilen + " Normzeile(n): " + $dynprice2 + " Euro Basispreis<br />";
				dyntext = dyntext + "Mindesthonorar: " + $dynprice + " Euro<br />";
				dyntext = dyntext + "<strong>Gesamtpreis: " + $dynprice + " Euro (Mindesthonorar)</strong><br />";
				dyntext = dyntext + "<small>Die ermittelten Preise sind Sch&auml;tzungen ohne Ihren realen Text zu kennen, sie k&ouml;nnen je nach Menge und Anspr&uuml;chen variieren (siehe Konditionen weiter unten).</small>";
				setText(dyntext);
			}
			else {
		 		$dynprice = $dynprice.toFixed(0);
			 	dyntext = "<strong>F&uuml;r Ihre Auswahl konnten wir folgende Preiskalkulation ermitteln:</strong><br />";	
			 	dyntext = dyntext + "" + $anzNormzeilen + " Normzeile(n): " + $dynprice + " Euro Basispreis<br />";
			 	
				
			 	
			 	$dynpricePlus1 = 0;
			 	$dynpricePlus2 = 0;
			 	
			 	if ($stundenVal == true) {
			 		$dynpricePlus1 =  $dynprice / 100 * 15;
			 		$dynpricePlus1 = $dynpricePlus1.toFixed(0);
			 		dyntext = dyntext + "Eilzuschlag: " + $dynpricePlus1 + " Euro<br />";
			 	}
			 	
			 	if ($nachtVal == true) {
			 		$dynpricePlus2 =  $dynprice / 100 * 25;	
			 		$dynpricePlus2 = $dynpricePlus2.toFixed(0);
			 		dyntext = dyntext + "Nachtzuschlag: " + $dynpricePlus2 + " Euro<br />";
			 	}
			 	
			 	
		 		$gesamtPreis =  parseFloat($dynprice) + parseFloat($dynpricePlus1) + parseFloat($dynpricePlus2);
		 		$gesamtPreis = $gesamtPreis.toFixed(0);
		 		dyntext = dyntext + "<strong>Gesamtpreis: " + $gesamtPreis + " Euro</strong><br />";
			 	dyntext = dyntext + "<small>Die ermittelten Preise sind Sch&auml;tzungen ohne Ihren realen Text zu kennen, sie k&ouml;nnen je nach Menge und Anspr&uuml;chen variieren (siehe Konditionen weiter unten).</small>";
			
	
			 	setText(dyntext);
			 }
	
		 }
		 
		 //wenn ausgang und zielsprache ausgewählt und nicht ident
		 else {
		 	if ($ausgangVal == 0 || $zielVal == 0) {
		 		dyntext = "<h2>Achtung: Bitte w&auml;hlen Sie Ausgangs und Zielsprache</h2>";
		 		setText(dyntext);	
		 	}
		 	
		 	if ($ausgangVal == $zielVal && $ausgangVal != 0 && $zielVal != 0) {
		 		dyntext = "<h2>Achtung: Ausgangs und Zielsprache m&uuml;ssen f&uuml;r eine Berechnung unterschiedlich sein</h2>";
		 		setText(dyntext);	
		 	}
		 } 
		
		 
		 
	}	
    	
	$("#pluslang").click(function () {
		//alert("pluslang called");
		
		var trsadds = $("tr.trmulti"); 
		$anztrs = trsadds.length;
		
		if ($anztrs < 6) {
			$anztrsNew = $anztrs + 1;
			$trnewline = "<tr id='tr" + $anztrsNew + "' class='trmulti'><td class='noicon'></td><td valign='top' class='oicon'><select name='ziel" + $anztrsNew + "' id='ziel" + $anztrsNew + "' class='selectspacing' ><option value='0'>weitere Zielsprache w&auml;hlen</option><option value='de'>de</option><option value='en'>en</option><option value='fr'>fr</option></select></td></tr>";			
			//alert($trnewline);
			$('table#calctable').append($trnewline);
		}
		else {
			alert("max 6 fields");
		}
		
    	});
    	
	$("#minuslang").click(function () {
		//alert("minuslang called");
		var trsadds = $("tr.trmulti"); 
		$anztrs = trsadds.length;
		if ($anztrs > 2) {
			$remover = "tr#tr" + $anztrs;
			//alert($remover);
			$($remover).remove();
		}
		else {
			alert("min 2 fields");
		}	
    	});    	

	
	// / calculator
	
    	
    	
    	//faq toggle
    	
    	
    	$.each($('a.faqtoggle '), function(index, value) { 
	  $('a.faqtoggle' + index + '').click(function() {$('div.faqtextdiv' + index + '').toggle();$('a.faqtoggle' + index + '').toggleClass("highlights");});
	  
	});
	

    	/*
    	$('a.faqtoggle00').click(function() {$('div.faqtextdiv00').toggle();$('a.faqtoggle00').toggleClass("highlights");});
    	$('a.faqtoggle0').click(function() {$('div.faqtextdiv0').toggle();$('a.faqtoggle0').toggleClass("highlights");});
    	$('a.faqtoggle1').click(function() {$('div.faqtextdiv01').toggle();$('a.faqtoggle1').toggleClass("highlights");});
    	$('a.faqtoggle2').click(function() {$('div.faqtextdiv02').toggle();$('a.faqtoggle2').toggleClass("highlights");});
    	$('a.faqtoggle3').click(function() {$('div.faqtextdiv03').toggle();$('a.faqtoggle3').toggleClass("highlights");});
    	$('a.faqtoggle4').click(function() {$('div.faqtextdiv04').toggle();$('a.faqtoggle4').toggleClass("highlights");});
    	$('a.faqtoggle5').click(function() {$('div.faqtextdiv05').toggle();$('a.faqtoggle5').toggleClass("highlights");});
    	$('a.faqtoggle6').click(function() {$('div.faqtextdiv06').toggle();$('a.faqtoggle6').toggleClass("highlights");});
    	$('a.faqtoggle7').click(function() {$('div.faqtextdiv07').toggle();$('a.faqtoggle7').toggleClass("highlights");});
    	$('a.faqtoggle8').click(function() {$('div.faqtextdiv08').toggle();$('a.faqtoggle8').toggleClass("highlights");});
    	$('a.faqtoggle9').click(function() {$('div.faqtextdiv09').toggle();$('a.faqtoggle9').toggleClass("highlights");});
    	$('a.faqtoggle10').click(function() {$('div.faqtextdiv10').toggle();$('a.faqtoggle10').toggleClass("highlights");});
    	$('a.faqtoggle11').click(function() {$('div.faqtextdiv11').toggle();$('a.faqtoggle11').toggleClass("highlights");});
    	$('a.faqtoggle12').click(function() {$('div.faqtextdiv12').toggle();$('a.faqtoggle12').toggleClass("highlights");});
    	$('a.faqtoggle13').click(function() {$('div.faqtextdiv13').toggle();$('a.faqtoggle13').toggleClass("highlights");});
    	$('a.faqtoggle14').click(function() {$('div.faqtextdiv14').toggle();$('a.faqtoggle14').toggleClass("highlights");});
    	$('a.faqtoggle15').click(function() {$('div.faqtextdiv15').toggle();$('a.faqtoggle15').toggleClass("highlights");});
    	$('a.faqtoggle16').click(function() {$('div.faqtextdiv16').toggle();$('a.faqtoggle16').toggleClass("highlights");});
    	$('a.faqtoggle17').click(function() {$('div.faqtextdiv17').toggle();$('a.faqtoggle17').toggleClass("highlights");});
    	$('a.faqtoggle18').click(function() {$('div.faqtextdiv18').toggle();$('a.faqtoggle18').toggleClass("highlights");});
    	$('a.faqtoggle19').click(function() {$('div.faqtextdiv19').toggle();$('a.faqtoggle19').toggleClass("highlights");});
    	$('a.faqtoggle20').click(function() {$('div.faqtextdiv20').toggle();$('a.faqtoggle20').toggleClass("highlights");});    
    	$('a.faqtoggle21').click(function() {$('div.faqtextdiv21').toggle();$('a.faqtoggle21').toggleClass("highlights");});
    	$('a.faqtoggle22').click(function() {$('div.faqtextdiv22').toggle();$('a.faqtoggle22').toggleClass("highlights");}); 
    	$('a.faqtoggle23').click(function() {$('div.faqtextdiv23').toggle();$('a.faqtoggle23').toggleClass("highlights");});
    	$('a.faqtoggle24').click(function() {$('div.faqtextdiv24').toggle();$('a.faqtoggle24').toggleClass("highlights");});
    	$('a.faqtoggle25').click(function() {$('div.faqtextdiv25').toggle();$('a.faqtoggle25').toggleClass("highlights");});
    	$('a.faqtoggle26').click(function() {$('div.faqtextdiv26').toggle();$('a.faqtoggle26').toggleClass("highlights");});
    	$('a.faqtoggle27').click(function() {$('div.faqtextdiv27').toggle();$('a.faqtoggle27').toggleClass("highlights");});
    	$('a.faqtoggle28').click(function() {$('div.faqtextdiv28').toggle();$('a.faqtoggle28').toggleClass("highlights");});
    	$('a.faqtoggle29').click(function() {$('div.faqtextdiv29').toggle();$('a.faqtoggle29').toggleClass("highlights");});
	$('a.faqtoggle30').click(function() {$('div.faqtextdiv30').toggle();$('a.faqtoggle30').toggleClass("highlights");});    
    	$('a.faqtoggle31').click(function() {$('div.faqtextdiv31').toggle();$('a.faqtoggle31').toggleClass("highlights");});
    	$('a.faqtoggle32').click(function() {$('div.faqtextdiv32').toggle();$('a.faqtoggle32').toggleClass("highlights");}); 
    	$('a.faqtoggle33').click(function() {$('div.faqtextdiv33').toggle();$('a.faqtoggle33').toggleClass("highlights");});
    	$('a.faqtoggle34').click(function() {$('div.faqtextdiv34').toggle();$('a.faqtoggle34').toggleClass("highlights");});
    	$('a.faqtoggle35').click(function() {$('div.faqtextdiv35').toggle();$('a.faqtoggle35').toggleClass("highlights");});
    	$('a.faqtoggle36').click(function() {$('div.faqtextdiv36').toggle();$('a.faqtoggle36').toggleClass("highlights");});
    	$('a.faqtoggle37').click(function() {$('div.faqtextdiv37').toggle();$('a.faqtoggle37').toggleClass("highlights");});
    	$('a.faqtoggle38').click(function() {$('div.faqtextdiv38').toggle();$('a.faqtoggle38').toggleClass("highlights");});
    	$('a.faqtoggle39').click(function() {$('div.faqtextdiv39').toggle();$('a.faqtoggle39').toggleClass("highlights");});
    	$('a.faqtoggle40').click(function() {$('div.faqtextdiv40').toggle();$('a.faqtoggle40').toggleClass("highlights");});     

    	*/
    	   	   		
	//$('div.faqtextdiv1').toggleClass('bounceinger', addOrRemove);
	
	/// faq toggle	
	
});

 
