function gotoLink(htmlElement) {

    var destinationURL = "";

    var target = "";



    if (htmlElement.href) {

        destinationURL = htmlElement.href;

        target = htmlElement.getAttribute("target");

    }

    else {

        if (htmlElement.childNodes) {

            if (htmlElement.getElementsByTagName("a")) {

                destinationURL = htmlElement.getElementsByTagName("a")[0].href;

                target = htmlElement.getElementsByTagName("a")[0].getAttribute("target");

            }

        }

    }



    if (destinationURL.length > 0) {

        if (target != "_blank") {

            location.href = destinationURL;

        }

    }

    return false;

}






Array.prototype.in_array = function(needle) {

    for (var i = 0; i < this.length; i++) {

        if (this[i] === needle) {

            return true;

        }

    }

    

    return false;

}



Array.prototype.foreach = function(callback) {

    for (var i = 0; i < this.length; i++) {

        callback(i, this[i]);

    }

}



$(document).ready(function() {



	/* language_menu */

	

	$(".international").mouseover(function() {



		$('#langChoose').animate({

			width: '400px'

		}, 1000, function() {



		});



	}).mouseout(function(){



		$('#langChoose').animate({

			width: '0px'

		}, 1000, function() {



		});

	});







    

	/* Tabellen */

	

	/* Messetabelle Styling */

	if ( $("table.exhibitions").length > 0) {

		$("td").css("width","25%");

		$("th").css("textAlign","left");

	}



    /* Messe Filter */

	$('input.messefilter').click(function() {

        var visibleCats = new Array();

        $('input.messefilter:checked').each(function() {

            visibleCats.push($(this).val());

        });



        $('table tbody tr').each(function() {

            var visible = false;

            var classes = $(this).attr("class").split(' ');

            

            classes.foreach(function(i, cat) {

                if (visibleCats.in_array(cat)) {

                    visible = true;

                }

            });



            if (visible) {

                $(this).show();

            } else {

                $(this).hide();

            }

        });



        $('h4').each(function() {

            var visible = false;

            var classes = $(this).attr("class").split(' ');



            classes.foreach(function(i, cat) {

                if (visibleCats.in_array(cat)) {

                    visible = true;

                }

            });



            if (visible) {

                $(this).show();

            } else {

                $(this).hide();

            }

        });



        $('table.exhibitions').each(function() {

            var visible = false;

            $(this).find('tbody tr').each(function() {

                if ($(this).css('display') == 'table-row') {

                    visible = true;

                }

            });



            if (visible) {

                $(this).show();

            } else {

                $(this).hide();

            }

        });



		$('table.exhibitions tr.visible:even').css("backgroundColor", "#eaeaea");

		$('table.exhibitions tr.visible:odd').css("backgroundColor", "#fff");

    });



  /* ende tabellen*/



    var settings = new Array();

    settings['diacontainer0'] = {targettop: '-0px', origd: '195px', origdh: '210px', origtop: '0', zstart: '10', bgcolor: "#bfbfbf", scolor: "#dcdcdc", borigw: "178px", borigh: "238px", borigtop: '15px', btargettop: '19px', z1size: "2.4em", z1tsize: "2.5em", z2size: "1.1em",  z2tsize: "1.1em", spanoh: "119px" };

    settings['diacontainer1'] = {targettop: '-5px', origd: '185px', origdh: '200px', origtop: '5', zstart: '9', bgcolor: "#c8c8c8", scolor: "#e4e4e4", borigw: "170px", borigh: "228px", borigtop: '15px', btargettop: '19px', z1size: "2.3em", z1tsize: "2.5em", z2size: "1.1em", z2tsize: "1.1em", spanoh: "114px" };

    settings['diacontainer2'] = {targettop: '-10px', origd: '175px', origdh: '190px', origtop: '10', zstart: '8', bgcolor: "#d0d0d0", scolor: "#ededed", borigw: "161px", borigh: "216px", borigtop: '15px', btargettop: '19px', z2size: "1.0em", z2tsize: "1.1em", z1size: "2.3em",  z1tsize: "2.5em", spanoh: "108px" };

    settings['diacontainer3'] = {targettop: '-15px', origd: '165px', origdh: '180px', origtop: '15', zstart: '7', bgcolor: "#dfdfdf", scolor: "#f5f5f5", borigw: "153px", borigh: "204px", borigtop: '15px', btargettop: '19px', z2size: "1.0em", z2tsize: "1.1em", z1size: "2.2em", z1tsize: "2.5em", spanoh: "102px" };

    settings['diacontainer4'] = {targettop: '-20px', origd: '155px', origdh: '170px', origtop: '20', zstart: '6', bgcolor: "#ededed", scolor: "#fdfdfd", borigw: "144px", borigh: "192px", borigtop: '15px', btargettop: '19px', z2size: "1.0em", z2tsize: "1.1em", z1size: "2.2em", z1tsize: "2.5em", spanoh: "96px" };


	$("#dia0").css("background","#bfbfbf");
	$("#dia1").css("background","#c8c8c8");
	$("#dia2").css("background","#d0d0d0");
	$("#dia3").css("background","#dfdfdf");
	$("#dia4").css("background","#ededed");


    $("#dia0 .thumb span").css("width", "178px").css("height", "119px");

    $("#dia1 .thumb span").css("width", "170px").css("height", "114px");

    $("#dia2 .thumb span").css("width", "161px").css("height", "108px");

    $("#dia3 .thumb span").css("width", "153px").css("height", "102px");

    $("#dia4 .thumb span").css("width", "144px").css("height", "96px");



	$("#dia0 .zeile1 .big").css("font-size", "2.4em");

    $("#dia1 .zeile1 .big").css("font-size", "2.3em");

    $("#dia2 .zeile2 .big").css("font-size", "2.3em");

    $("#dia3 .zeile2 .big").css("font-size", "2.2em");

    $("#dia4 .zeile2 .big").css("font-size", "2.2em");

	

    $("#dia0 .zeile2 .small").css("font-size", "1.1em");

    $("#dia1 .zeile2 .small").css("font-size", "1.1em");

    $("#dia2 .zeile1 .small").css("font-size", "1.0em");

    $("#dia3 .zeile1 .small").css("font-size", "1.0em");

    $("#dia4 .zeile1 .small").css("font-size", "1.0em");

	

	



    /****************************

     DIASHOW

     ****************************/

    if ($(".diacontainer").length > 0) {

        $(".diacontainer").hoverIntent(

                function() {

                    $(this).stop().css("zIndex", "11");



                    var fadeColor = "#727272";

                    var dia = $(this).find(".dia").first();

                    var schatten = $(this).find(".schatten").first();

                    var pfeil = $(this).find(".pfeil");

                    var tbig = $(this).find(".big");

                    var tsmall = $(this).find(".small");

                    var thumb_g = $(this).find("span.thumb");

                    var thumb_c = $(this).find("a.thumb");

                    var thumbOver = $(this).find("img").attr("src");



                    $(dia).stop().animate({

                        width: "205px",

                        height: "220px"

                    },

                            200,

                            function() {

                                $(dia).css("background", "#727272");

                            });



                    $(schatten).stop().animate({

                        width: "220px"

                    }, 200, function() {



                        $(schatten).css("background", "#d9d9d9");



                    });



                    $(thumb_g).stop().animate({

                        width: "187px",

                        height: "125px"

                    }, 200, function () {





                      /*  $(thumb_c).stop().css({'background' : 'url(' + thumbOver + ') no-repeat center bottom','width':'220px','height':'150px','display':'block'});*/
					  
						$(thumb_c).stop().css({'background' : 'url(' + thumbOver + ') no-repeat 0 -150px','width':'190px','height':'140px','display':'block'});
						
					/*	$(thumb_c).stop().css({'background' : 'red','width':'190px','height':'140px','display':'block'});*/

                        $(thumb_g).stop().fadeTo('normal', 0, function() {

                        });

                    });

                    $(tbig).stop().animate({

                        fontSize: /*settings[$(this).attr('id')].z1tsize*/ "2.5em"

                    }, 200, function() {





                    });

                    $(tsmall).stop().animate({

                        fontSize: settings[$(this).attr('id')].z2tsize

                    }, 200, function() {



                        $(tsmall).css("color", "#cacaca");



                    });

                    $(pfeil).stop().animate({

                    }, 200, function() {





                        $(pfeil).css("color", "#ffc800");

                        $(tbig).css("color", "#fff");



                    });





                },

                function() {

                    $(this).stop().css("zIndex", settings[$(this).attr('id')].zstart);

                    var fadeColor = "#727272";

                    var dia = $(this).find(".dia").first();

                    var schatten = $(this).find(".schatten").first();

                    var pfeil = $(this).find(".pfeil");

                    var tbig = $(this).find(".big");

                    var tsmall = $(this).find(".small");

                    var thumb_g = $(this).find("span.thumb");

                    var thumb_c = $(this).find("a.thumb");





                    $(dia).css("background", settings[$(this).attr('id')].bgcolor).stop().animate({

                        width: settings[$(this).attr('id')].origd,

                        height: settings[$(this).attr('id')].origdh,

                        fontSize: "1.6em"

                    }, 200, function() {



                    });





                    $(schatten).css("background", settings[$(this).attr('id')].scolor).stop().animate({

                        width: settings[$(this).attr('id')].origdh

                    }, 200, function() {





                    });

                    $(thumb_c).stop().animate({

                        width: settings[$(this).attr('id')].borigw,

                        height: settings[$(this).attr('id')].spanoh

                    }, 200);

                    $(thumb_g).stop().animate({

                        width: settings[$(this).attr('id')].borigw,

                        height: settings[$(this).attr('id')].spanoh,

                        opacity: 100

                    }, 200);

                    $(tbig).stop().animate({

                        fontSize: settings[$(this).attr('id')].z1size

                    }, 200);

                    $(tsmall).stop().animate({

                        fontSize: settings[$(this).attr('id')].z2size

                    }, 200);

                    $(pfeil).stop().animate({

                    }, 200, function() {

                        $(tbig).css("color", "#717171");

                        $(tsmall).css("color", "#717171");

                        $(pfeil).css("color", "#a1a1a1");

                    });

                });

    }





    /****************************

     MENUE

     ****************************/

    var submenu = $(".submenu");

    var smallsubmenu = $(".smallsubmenu");

    $("#topnav ul li.other ul").append("<li class='abschluss'></li>");
	
	$("#topnav .spalte ul").append("<li class='abschluss'></li>");



    $("#topnav ul li:first").hover(

            function() {

                $("#topnav ul li:first a:first").addClass("hover");

				$("#topnav ul li:first a:first").css("cursor","default");

                $(this).addClass("hover");

                $(submenu).show();

                $(this).find(".spalte").first().css("borderLeft", "none");

                $(this).find(".spalte").last().css("borderRight", "none");

            },

            function() {

                $("#topnav ul li:first a").removeClass("hover");

                $(this).removeClass("hover");

                $(submenu).hide();

            });



    $("li.other").hover(

            function() {

                $(this).css("color", "#8a6e02").css("margin-left","-20px").css("padding-left","20px");

				$(this).find("a").css("color","#8a6e02");

				/*$(this).find("a:first").css("cursor","default");*/

                $(this).addClass("hov");

				$(this).find("ul").show();

            },

            function() {

                $(this).css("color", "white");

                $(this).removeClass("hov");

				$(this).find("ul").hide();

				$(this).find("a").css("color","white");

            });

	

	// Erste Ebene unklickbar machen

	

	$("#topnav ul li:first a:first").click(function () {

				return false;	

	});

	

/*	$("#topnav ul li.other a:first").click(function () {

				return false;	

	}); */



    $("#footer li:last").css("background", "none");

    $(".colorbox").colorbox({inline:true, href:"#contact", transition: "none", opacity: 0, overlayClose: false, width: "414px", height: "483px"});

    //$("#powershow").colorbox({inline:true, href:"#youtube", transition: "none", opacity: 0, overlayClose: false, width: "530px", height: "520px"});
	
	$("#powershow").colorbox();


    $(".partner").colorbox({transition: "none", opacity: 0, overlayClose: false, width: "530px", height: "520px"});
	
	$(".partnerload").colorbox({width: "530px"});
	
	$(".yvid").colorbox({width: "857px"});




	$("a[rel='zoom']").colorbox();



	



    /* Tabelle */

    $(".tabelle .row:even").css("backgroundColor", "#eaeaea");

    $(".mttabelle .row:even").css("backgroundColor", "#eaeaea");

    $("table.exhibitions tr:even").css("backgroundColor", "#eaeaea");



    /* Diashow anzeigen */

    $("#diashow").show();

	

	/*if ( $("#slider").length > 0 ) {

	

		$("#slider").easySlider({

			auto: false,

			continuous: false 

		});

	

	}*/

	

	/* Videoslider */

    var anzahl = $(".videoslider_list a").children().size();

    var breite = anzahl * 190;

    var kontrollvariable = 0;



    $(".videoslider_list").css("width", breite);



    $(".vidnext").click(function() {

        if (kontrollvariable < anzahl * 190 - 190) {

            $(".videoslider_list").animate({"right": "+=190px"}, "slow");

            kontrollvariable = kontrollvariable + 190;

        }

    });





    $(".vidprev").click(function() {

        if (kontrollvariable != 0) {

            $(".videoslider_list").animate({"right": "-=190px"}, "slow");

            kontrollvariable = kontrollvariable - 190;

        }

    });





    $(".videoslider_list ul li a").click(function() {

        swfobject.embedSWF($(this).attr('href'), "powershow-video", "470", "265", "10.0.0", "", {"width":470,"height":265,"config":{"clip":{"autoPlay":true}}}, {quality: "high",wmode: "transparent",scale: "noscale",allowfullscreen: "true",allowscriptaccess: "always"});

        return false;

    });



    // FANCYBOX

    if ($(".zoom").length > 0) {

       $(".zoom a").fancybox({ 'padding':10,'titlePosition':'outside','transitionIn':'elastic','transitionOut':'elastic' });

    }



    $(".zyoutube").click(function() {

        $.fancybox({

            'padding'       : 10,

            'autoScale'     : false,

            'transitionIn'  : 'elastic',

            'transitionOut' : 'elastic',

            'width'         : 680,

            'height'        : 495,

            'href'          : $(this).find('a').attr('href').replace(new RegExp("watch\\?v=", "i"), 'v/') + '&autoplay=1',

            'type'          : 'swf',

            'swf'           : {'allowfullscreen': 'true'}

        });



        return false;

    });



	

	

	// FORMULARVALIDIERUNG

    $('#footer-form').submit(function() {

        if ($(this).valid()) {

            $.ajax({

                type: 'post',

                url: $(this).attr('action'),

                data: $(this).serialize(),

                success: function(msg){

                    if (msg.success) {

                        $('#contact').html($('#footer-form-success'));

                        $.colorbox.resize({height: 450, width: 350})

                    }

                }

            });

        }

        

        return false;

    });



    $('#footer-form').validate({

       rules: {

         frage: "required",

         name: "required",

         email: {

            required: true,

            email: true

         },

         email:  "required"

       }

    }); 



    $('#contact-form').validate({

       rules: {

         firma: "required",

         email: {

            required: true,

            email: true

         },

         strasse:  "required",

         plz:  "required",

         ort:  "required",

         telefon:  "required",

         email:  "required",

         material:  "required",

         lhb:  "required",

         endfraktionsgroesse:  "required",

         durchsatzleistung:  "required"

       }

    });





	

// SLIDER



	var slidervariable = $(".col2").children().size();

	var slidercontroller = 1;

	

	

	$(".sub_right span#prevBtn a").css("visibility","hidden");

	

	if (slidercontroller < slidervariable) {

	

		$(".sub_right span#nextBtn a").click(function() {

													  

			$(".uvisible").removeClass("uvisible").addClass("uhidden").next().removeClass("uhidden").addClass("uvisible");

			$(".sub_right span#prevBtn a").css("visibility","visible");

			++slidercontroller;

			

			if (slidercontroller == slidervariable) {

				

				$(".sub_right span#nextBtn a").css("visibility","hidden");

				

			}

		});

	

	}

	



		

		$("span#prevBtn a").click(function() {

					$(".uvisible").removeClass("uvisible").addClass("uhidden").prev().removeClass("uhidden").addClass("uvisible");

					$(".sub_right span#nextBtn a").css("visibility","visible");

					--slidercontroller;

					

					if (slidercontroller == 1) {

						

						$(".sub_right span#prevBtn a").css("visibility","hidden");

					

					}

					

				});





		

	//}



}); 



$(document).ready(function($) {
	$('form.primagesswitch input').click(function() {
		
		if($(this).attr('checked')?1:0 == 1){
			$('.col2').find('h3.'+$(this).attr("name")).css("display","block");
			$('.col2').find('#'+$(this).attr("name")).css("display","block");
		} else {
			$('.col2').find('h3.'+$(this).attr("name")).css("display","none");
			$('.col2').find('#'+$(this).attr("name")).css("display","none");
		}
		

		
	});
});
