$(document).ready(function() {
	
	$('div.dropdown').bind('mouseenter', function() {
		$(this).find('div.holder').fadeIn('fast');
		$(this).find('div.scroll-pane').jScrollPane({showArrows:true, scrollbarWidth:22, dragMinHeight:35});
	});

	$('div.dropdown').bind('mouseleave', function() {
		$(this).find('div.holder').fadeOut('fast');
	});
	
	$('td.comparesets').click(function() {
		if ($(this).find('a').hasClass('whitearrow_right')) {
			$(this).find('a').removeClass('whitearrow_right').addClass('whitearrow_down');
			$('table.compare').show();
		} else {
			$(this).find('a').removeClass('whitearrow_down').addClass('whitearrow_right');			
			$('table.compare').hide();
		}
	});
		
	
	$('td.hmUltraDropDown').click(function() {
   if ($(this).find('a').hasClass('product-headline')) {
			$(this).find('a').removeClass('product-headline blackarrow_right').addClass('product-headline2 blackarrow_down');
			$('tr.hmUltraDropDown').show();
		} else {
			$(this).find('a').removeClass('product-headline2 blackarrow_down').addClass('product-headline blackarrow_right');			
			$('tr.hmUltraDropDown').hide();
		}		
	});

	$('td.hssDuraDropDown').click(function() {
   if ($(this).find('a').hasClass('product-headline')) {
			$(this).find('a').removeClass('product-headline blackarrow_right').addClass('product-headline2 blackarrow_down');
			$('tr.hssDuraDropDown').show();
		} else {
			$(this).find('a').removeClass('product-headline2 blackarrow_down').addClass('product-headline blackarrow_right');			
			$('tr.hssDuraDropDown').hide();
		}		
	});	

	
	$('div.gototop > a').click(function() {
		jumpto('body');
	});
	
	var animationInProgress = false;
	
	$('td.comparesets').bind('mouseenter', function() {
		if (animationInProgress==false) {
			animationInProgress = true;
			$(this).animate( {backgroundColor:"#555555"}, 150, function() {
				animationInProgress = false;
			});
		}
	});
	
	$('td.comparesets').bind('mouseleave', function() {
		animationInProgress = false;
		$(this).animate( {backgroundColor:"#444444"}, 150);
	});
	
	$('ul.dropdown > li > a').click(function() {
		var val = $(this).attr('rel').split('|');		
		$('.'+$(this).attr('class')+'_diameter').html( val[0] );
		$('span.'+$(this).attr('class')+'_order').html( val[1] );
		$('span.'+$(this).attr('class')+'_price').html( val[2] );
		$(this).parent().parent().parent().parent().parent().fadeOut('fast');
	});
	

	
	/* --- Request a demo --- */
	
	$('div#black').css('width', $(document).width() ).css('height', $(document).height() ).css('opacity','0.7');
	
	$('div#requestdemo').find('img.close').click(function() {
		$('div#requestdemo').hide();
		$('div#black').hide();
	});
	
	$('form#form_requestdemo').submit(function() {
		$.post('../campaign_data/requestdemo.php', $(this).serialize(), function(data) {
			$('div.inputholder').removeClass('error');
			if (data['stat']=='error') {
				//Recaptcha.reload();
				for(i=0; i<=data['msg'].length; i++) {
					$('div.jInput_'+data['msg'][i]).addClass('error');
				}
			} else {
				$('form#form_requestdemo').hide();
				$('div.request_sent').append('<iframe src="https://tracking.quisma.com/l.cfs?qupid=32058&CID=2&OrderID=[bestellungid]&Price=[preis]&CurrencySymbol=EUR&Note=[bemerkung]" width="1" height="1" frameborder="0"></iframe>').show();
			}
		},'json');
	});
	

 if ($('#flashreasons').html() == ''){
    $('#flashreasons').hide();
    $('.headline1').hide();
 };
	
});

var tokbm = function(){
	jumpto('div.headline2anchor');
}



function jumpto(element) {
	if (element=='div.setcontainer') {
		showRequestForm();
	} else {
		$.scrollTo($(element), 800);
	}
}


function showRequestForm() {
	//Recaptcha.reload();
	$.scrollTo($('body'), 400);
	$('div#requestdemo').show();
	$('div#black').show();
}



