function libPRODSslider() {
	jQuery('#produkt_container h3').toggle(
		function() {
			jQuery(this).next('div').slideUp('fast');
		},
		function() {
			jQuery(this).next('div').slideDown('fast');
		}
	);	
}


function flipin(element){
	element.style.background='#f1f3f4';
}

function flipout(element){
	element.style.background='none';
}



function findreiter(){
	
	if(!jQuery('#inovationen').find('img').attr('src')){
		jQuery('#lnk_inno').css({'display' : 'none' });
	}
	
 	if(jQuery('#t_daten').find('td:e1(2)').text() == ""){
		jQuery('#lnk_daten').css({'display' : 'none' });
	}

	
	
}


function livesearchheight(){
		var height = jQuery('#livesearch').height();
		height = height+12;
		jQuery('#livesearch').css("top","-"+height+"px");
}



function locator_display() {
    jQuery('.tx-locator-pi1 li.lb2').each(
        function() {
            if(!jQuery(this).text()) {
                jQuery(this).css('display','none');
                jQuery(this).prev().css('display','none');
            }
        }
    );
}

function openYouTubeVideo() {
    jQuery('<div class="fakevid"></div>').prependTo('.rgmediaimages-media');
    jQuery('div.fakevid').each(function() {
        width = jQuery(this).parent().width();
        height = jQuery(this).parent().height();
        jQuery(this).css('height',height+'px');
        jQuery(this).css('width',width+'px');
    });
	jQuery('.rgmediaimages-media').click(
			function() {
				var attr = jQuery(this).find('embed').attr('flashvars');
                if(!attr) {
                    attr = jQuery(this).find('param[name="flashvars"]').val();
                }
                
                src = attr.split('=');
				window.open(src[1]+'='+src[2]);
			}
	);
}

function openURL(url) {
    window.open(url);
}

function countrySelect() {
    jQuery('#countryselector').change(function() {
        jQuery('#tx_locator_pi1_city').attr("readonly", "readonly");
        jQuery('#tx_locator_pi1_city').addClass("blackedout");
        jQuery('#address').attr("readonly", "readonly");
        jQuery('#address').addClass("blackedout");
        jQuery('#zipcode').attr("readonly", "readonly");
        jQuery('#zipcode').addClass("blackedout");
        jQuery('#tx_locator_pi1_categories_0').checked='';
                
        jQuery('#countryselector option:selected').each(function () {
            if(jQuery('.thelist #'+jQuery(this).text()).length >0) {
                window.location.hash = '#'+jQuery(this).text();
            } else {
                document.getElementById('address').removeAttribute('readonly');
            	document.getElementById('zipcode').removeAttribute('readonly');
            	document.getElementById('tx_locator_pi1_city').removeAttribute('readonly');
            	document.getElementById('tx_locator_pi1_city').removeAttribute('class');
            	document.getElementById('address').removeAttribute('class');
            	document.getElementById('zipcode').removeAttribute('class');
           	 	document.getElementById('tx_locator_pi1_categories_0').checked='checked';
            }
        });
    });
}

function mapSelect(indx) {
    document.getElementById('address').removeAttribute('readonly');
    document.getElementById('zipcode').removeAttribute('readonly');
    document.getElementById('tx_locator_pi1_city').removeAttribute('readonly');
    document.getElementById('tx_locator_pi1_city').removeAttribute('class');
    document.getElementById('address').removeAttribute('class');
    document.getElementById('zipcode').removeAttribute('class');
    document.getElementById('tx_locator_pi1_categories_0').checked='checked';
    document.getElementById('countryselector').selectedIndex = indx;
}

jQuery(document).ready(
	function() {
		libPRODSslider();
		findreiter();
        locator_display();
        openYouTubeVideo();
        
        countrySelect();
        
        jQuery('span.more_info').click(function() {
            jQuery('#info_text').slideToggle();
        });
        
        jQuery('span.close').click(function() {
            jQuery('#info_text').slideToggle();
        });
        
        var val = jQuery("select option:selected").val();
        
        if(val == 'Österreich' || val == 'Deutschland' || val == 'Italien') {
            jQuery('input[readonly]').each(function() {
                jQuery(this).removeAttr('readonly');
                jQuery(this).removeClass('blackedout');
            });
        }
	}
    
);
