$(document).ready(function() {

	//When page loads...
	$(".tab_content").hide(); //Hide all content
	//$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	// $(".tab_content:first").show(); //Show first tab content

	//On Click Event
	$("ul.tabs li").click(function() {

		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});

});

function cmadvajaxtabs() {

	//When page loads...
	$(".tab_content").hide(); //Hide all content
	//$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	
	// $(".tab_content:first").show(); //Show first tab content
        $('.wod').click(function() {
            
            var activeTab = $(this).attr("href"); //Find the href attribute value to identify the active tab + content
            myclass = $(this).find('div').attr('class'); 
            myclass = myclass.replace(' active','');
            $('ul.tabs li').removeClass('active');
            
            $(".wod div").removeClass('active');
            $(".tab_content").hide(); //Hide all tab content

      
            $(activeTab).fadeIn(); //Fade in the active ID content
            $('#cmadvtabarea .'+myclass).addClass('active');

        }); 
	//On Click Event
	$("ul.tabs li").click(function() { 
            myclass = $(this).attr('class');
            myclass = myclass.replace(' active','');
            $('#cmadvtabarea div').removeClass('active');
            $('#cmadvtabarea .'+myclass).addClass('active');
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});


}
$(document).ready(function() {

   


	//When page loads...
	//$(".tab_content").hide(); //Hide all content
	//$(".tabbbox").addClass("active").show(); //Activate first tab
	// $(".tabbox").show(); //Show first tab content

        $('ul.tabs li').click(function() {
          
            myclass = $(this).attr('class');
            myclass = myclass.replace(' active','');
            
            $('#cmadvtabarea div').removeClass('active');
            $('#cmadvtabarea .'+myclass).addClass('active');

       

        });
        $('.wod').click(function() {
            
            var activeTab = $(this).attr("href"); //Find the href attribute value to identify the active tab + content
            myclass = $(this).find('div').attr('class'); 
            myclass = myclass.replace(' active','');
            $('ul.tabs li').removeClass('active');
            
            $(".wod div").removeClass('active');
            $(".tab_content").hide(); //Hide all tab content

      
            $(activeTab).fadeIn(); //Fade in the active ID content
            $('#cmadvtabarea .'+myclass).addClass('active');

        }); 
 
	//On Click Event
//	$(".tabbox").click(function() {

//		$(".tabbox").removeClass("active"); //Remove any "active" class
//		$(this).addClass("active"); //Add "active" class to selected tab
//		$(".tab_content").hide(); //Hide all tab content

//		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
//		$(activeTab).fadeIn(); //Fade in the active ID content
//		return false;
//	});

});
//TAB ENDE


		function cmadvsend(paramform,goto,sessionid) {
			$('#mask').addClass('on');
			$('#loading-indicator').fadeIn('fast');
			//$('#cmadvisorajaxarea').attr('style','opacity:80');
			
			if(document.getElementById("cmadvisorquantity")) {
				
				var quantityval = 	document.getElementById("cmadvisorquantity").value;
			}
			if(!quantityval) {
			    var quantityval = 0;	
			}
			 
			//document.getElementById("produktlistcontainer").style.height = document.getElementById("produktlistcontainer").offsetHeight+'px'; 
			
		   $.scrollTo( 150, 2000, {queue:true} ); 
			
			var formdata = JSON.stringify($('#cmadvisorformcontainer form').serializeArray()); 
			//alert(formdata);
			formdata = formdata.replace(/ö/g, "-AJAXOE-").replace(/ü/g, "-AJAXUE-").replace(/ä/g, "-AJAXAE-").replace(/Ö/g, "-AJAXOEB-").replace(/Ü/g, "-AJAXZEB-").replace(/Ä/g, "-AJAXAEB-").replace(/ß/g, "-AJAXS-").replace(/\\u00fc/g, "-AJAXUE-").replace(/\\u00e4/g, "-AJAXAE-");
			
			//alert(formdata);
			
          	$.post("/index.php", { cl: "cmadvisor", cmformvars: formdata, cmadvid: goto, cmadvsess: sessionid, quantityval: quantityval, cmajax: "yes" }, 
  						function(data){
								
								//$('#cmadvisorajaxarea').fadeOut('fast');
								$('#loading-indicator').hide();
								$('#mask').removeClass('on');
								
								document.getElementById('cmadvisorajaxarea').innerHTML = data;
								
								$('#cmadvisorajaxarea').fadeIn('slow');
								eval("Custom.init();"); // Custom radio buttons javascript
								eval("cmadvajaxtabs();"); // Ajax Tab integration
								
 					    }, "text");
			
		 }
		 
		 function cmadvcalc(paramform,goto,sessionid,calcset) {
			$('#mask').addClass('on');
			$('#loading-indicator2').fadeIn('fast');
			$.scrollTo( 675, 2000, {queue:true} );
			if(document.getElementById("cmadvisorquantity")) {
				var quantityval = 	document.getElementById("cmadvisorquantity").value;
			}
			if(!quantityval) {
			    var quantityval = 0;	
			}
			if(document.getElementById("cmadvisorquantity2")) {
				var quantityval2 = 	document.getElementById("cmadvisorquantity2").value;
			}
			if(!quantityval2) {
			    var quantityval2 = 0;	
			}
			
			//document.getElementById("produktlistcontainer").style.height = document.getElementById("produktlistcontainer").offsetHeight+'px'; 
			//$.scrollTo( 0, 2000, {queue:true} ); 
			var formdata = JSON.stringify($('#cmadvisorformcontainer form').serializeArray()); 
			//alert(formdata);
			formdata = formdata.replace(/ö/g, "-AJAXOE-").replace(/ü/g, "-AJAXUE-").replace(/ä/g, "-AJAXAE-").replace(/Ö/g, "-AJAXOEB-").replace(/Ü/g, "-AJAXZEB-").replace(/Ä/g, "-AJAXAEB-").replace(/ß/g, "-AJAXS-").replace(/\\u00fc/g, "-AJAXUE-").replace(/\\u00e4/g, "-AJAXAE-");
			
			//alert(formdata);
          	$.post("/index.php", { cl: "cmadvisor", cmformvars: formdata, cmadvid: goto, cmadvsess: sessionid, quantityval: quantityval, quantityval2: quantityval2, cmajax: "yes", cmcalc: "yes", calcset: calcset },
  						function(data){
								//$('#cmadvproductsarea').fadeOut('fast');
								setTimeout(function() {
									$('#loading-indicator2').hide();
									$('#mask').removeClass('on');
								},1000);
								if(calcset == '1') {
									document.getElementById('cmadvproductsarea').innerHTML = data;
									//$('#cmadvproductsarea').fadeIn('slow');	
								} else if (calcset == '2') {
									document.getElementById('cmadvproductsarea2').innerHTML = data;
									//$('#cmadvproductsarea').fadeIn('slow');	
								}
 					    }, "text");
			
		 }
		 
		 function cmadvsync(sessionid,calcnum) {
			
			
			//document.getElementById("produktlistcontainer").style.height = document.getElementById("produktlistcontainer").offsetHeight+'px'; 
			//$.scrollTo( 0, 2000, {queue:true} ); 
		    //$('#cmadvisorajaxarea').fadeOut('fast');
			var formdata = JSON.stringify($('#cmadvisorformcontainer form').serializeArray()); 
			//alert(formdata);
			formdata = formdata.replace(/ö/g, "-AJAXOE-").replace(/ü/g, "-AJAXUE-").replace(/ä/g, "-AJAXAE-").replace(/Ö/g, "-AJAXOEB-").replace(/Ü/g, "-AJAXZEB-").replace(/Ä/g, "-AJAXAEB-").replace(/ß/g, "-AJAXS-").replace(/\\u00fc/g, "-AJAXUE-").replace(/\\u00e4/g, "-AJAXAE-");
			
			//alert(formdata);
			
          	$.post("/index.php", { cl: "cmadvisorsync", cmformvars: formdata, cmadvsess: sessionid, cmajax: "yes", calcnum: calcnum },
  						function(data){
								window.location = "http://www.faxeshop.de/warenkorb/";

 					    }, "text");
			
		 }
		 
		 
	function cmadvhelp(action) {
			if(action == 'show') {
			$.scrollTo( 150, 2000, {queue:true} ); 
			$('.pfad').fadeOut('fast');
			if(document.getElementById('cmadvcontainter')) {
				 
				$('#cmadvcontainter').fadeOut('fast');
				/*$('#cmadvtabarea').fadeOut('fast');*/
				$('#cmadvhelp').fadeIn('fast');	
			}
		} 
		if(action == 'hide') {
			$('.pfad').fadeIn('fast');
			if(document.getElementById('cmadvhelp')) {
				$('#cmadvhelp').fadeOut('fast');
				$('#cmadvcontainter').fadeIn('fast');
				/* $('#cmadvtabarea').fadeIn('fast'); */
				
			}
		
		} 
	}
	
	function cmadvactive() {
		document.getElementById('cmadvgofurtherdeact').style.display = 'none';
		document.getElementById('cmadvgofurtheract').style.display = 'block';
	}
	
	function cmadvsendrequest(sessionid) {
		var formdata = JSON.stringify($('#cmadvisorformcontainer form').serializeArray()); 
			//alert(formdata);
			formdata = formdata.replace(/ö/g, "-AJAXOE-").replace(/ü/g, "-AJAXUE-").replace(/ä/g, "-AJAXAE-").replace(/Ö/g, "-AJAXOEB-").replace(/Ü/g, "-AJAXZEB-").replace(/Ä/g, "-AJAXAEB-").replace(/ß/g, "-AJAXS-").replace(/\\u00fc/g, "-AJAXUE-").replace(/\\u00e4/g, "-AJAXAE-");
			
			//alert(formdata);
          	$.post("/index.php", { cl: "cmadvisorcontact", cmformvars: formdata, cmadvsess: sessionid },
  						function(data){
								//$('#cmadvproductsarea').fadeOut('fast');
								setTimeout(function() {
									$('#loading-indicator2').hide();
									$('#mask').removeClass('on');
								},1000);
								document.getElementById('advcontactform').innerHTML = data;
								
								var myregexp = /nohideofsendbutton/;
								var matcher = myregexp.exec(data);
								if (matcher == null) {
									document.getElementById('advcontactsend').innerHTML = '';
								}
								eval("Custom.init();"); // Custom radio buttons javascript
								//$('#cmadvproductsarea').fadeIn('slow');								
 					    }, "text");
			
		//document.getElementById('advcontactform').innerHTML = '<p style="font-weight:bold; font-size:14px;">Vielen Dank f&uuml;r Ihre Anfrage. Der R&uuml;ckruf wird jetzt aufgebaut.</p><p><strong> Unser Mitarbeiter wird automatisch &uuml;ber den Aktuellen Stand Ihres Beratungsvorgangs informiert.</strong></p>';
		//document.getElementById('advcontactsend').innerHTML = '';
		
	}
	
	function cmadvgo(gototab) {
		$('#cmadvchoose').fadeOut('fast');
		$('#cmadvtabarea').fadeIn('fast');
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(".tab_content").hide(); //Hide all tab content
       
		var activeTab = $('#tab2'); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn('fast', function() {
                    $('#cmadvtabarea .tabbox2').addClass('active');
                }); //Fade in the active ID content
	}
            function cmadvgo1(gototab) {
		$('#cmadvchoose').fadeOut('fast');
		$('#cmadvtabarea').fadeIn('fast');
                

		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(".tab_content").hide(); //Hide all tab content

		var activeTab = $('#tab1'); //Find the href attribute value to identify the active tab + content
                
		$(activeTab).fadeIn('fast', function() {
					
                    $('#cmadvtabarea .tabbox').addClass('active');
                }); //Fade in the active ID content


	}
	 function cmadvgo3(gototab) {
        $('#cmadvchoose').fadeOut('fast');
        $('#cmadvtabarea').fadeIn('fast');
           
        $(".tab_content").hide(); //Hide all tab content
        var activeTab = $('#tab3'); //Find the href attribute value to identify the active tab + content

             $(activeTab).fadeIn('fast', function() {
                    $('#cmadvtabarea .tabbox3').addClass('active'); 
                }); //Fade in the active ID content

    }
    
    

      
