var active_color = '#000'; 
var inactive_color = '#ccc'; 



jQuery(document).ready(function(){

	$("input.shopsearchfield").css("color", inactive_color);
  var default_values = new Array();
  $("input.shopsearchfield").focus(function() {
    if (!default_values[this.id]) {
      default_values[this.id] = this.value;
    }
    if (this.value == default_values[this.id]) {
      this.value = '';
      this.style.color = active_color;
    }
    $(this).blur(function() {
      if (this.value == '') {
        this.style.color = inactive_color;
        this.value = default_values[this.id];
      }
    });
  });
  
  /*
	$('#formbox0').hide();
	$('#formbox1').hide();
	$('#formbox2').hide();
	
	$("#formchooser").change(function(){
		$('#formbox0').fadeOut();
		$('#formbox1').fadeOut();
		$('#formbox2').fadeOut();	
		$("#" + this.value).fadeIn(400, function(){ 
			$.scrollTo($('div#formselector').parent(),1000) 
		});			
	});  
	*/	
		
	$("#form1subject").next('div').children('select').change(function(){
			var selectedIndex = $(this).attr("selectedIndex");
			if(selectedIndex == 3){
				$("#techsupporthider").show();
				$("input[name='type']").attr("value", "Integration");
			}else{
				$("#techsupporthider").hide();
				$("input[name='type']").attr("value", "Key Account Support");
			}
  });
  $("#form1subject").next('div').children('select').change();
  
  $("select[name='00N200000014o7g']").change(function(){
			var selectedIndex = $(this).attr("selectedIndex");
			if(selectedIndex == 29){
				var text = $("#00N200000014o7g_value").text();
				$("textarea[name='00N200000014yIZ']").attr("value", text );
			}else{
				$("textarea[name='00N200000014yIZ']").attr("value", "");
			}
  });
});






// FOLDABLE CONTENT
$(function(){	
	var ptitle = $(document).attr('title');
	var etfunc = '<a href="#" class="foldbutton" onmousedown="ET_Event.eventStart(\'+Button\', \''+ptitle+'\', \'click\')"><div class="more"></div></a>';
	$('.copy-collapsable-button').hide();
	var collapseheight = 120; 
	$("div.collapsable-content").each(function(intIndex){
		var defheight = $(this).height();
		$(this).attr("id", defheight);				
		$(this).next('.copy-collapsable-button').append(etfunc);		
		$(this).next('.copy-collapsable-button').bind("click",function(){
			var oldheight = $(this).prev('.collapsable-content').attr("id");
			var nowheight = $(this).prev('.collapsable-content').height();
			if(nowheight == collapseheight){
				$('.collapsable-content').animate({
				  height: collapseheight
				}, {queue:false, duration:1300, easing:'easeInCubic'});
				$('.collapsable-form').animate({
				  height: collapseheight
				}, {queue:false, duration:1300, easing:'easeInCubic'});
				$('.copy-collapsable-button a').html('<div class="more"></div>');
				$('.copy-collapsable-formbutton a').html('<div class="toform"></div>');	
				$('.copy-collapsable-overlay').fadeIn();
							
				$(this).next('.copy-collapsable-overlay').fadeOut();
				$(this).prev('.collapsable-content').animate({
				  height: oldheight
				},{queue:false, duration:1300, easing:'easeInCubic'});	
				$(this).children('a').html('<div class="less"></div>');
			}
			else{
				$(this).prev('.collapsable-content').animate({
				  height: collapseheight
				}, {queue:false, duration:1300, easing:'easeInCubic'});
				$(this).children('a').html('<div class="more"></div>');
				$(this).next('.copy-collapsable-overlay').fadeIn();
			}
			return false;	
		});
	});
	$("div.collapsable-content").css('height' , collapseheight + 'px');
	$('.copy-collapsable-button').show();
});


// FOLDABLE FORM
$(function(){	
	var ptitle = $(document).attr('title');
	var etfunc = '<a href="#" class="foldbutton" onmousedown="ET_Event.eventStart(\'+Button\', \''+ptitle+'\', \'click\')"><div class="more"></div></a>';
	$('.copy-collapsable-formbutton').hide();
	var collapseheight = 120; 
	$("div.collapsable-form").each(function(intIndex){
		var defheight = $(this).height()+40;
		$(this).attr("id", defheight);				
		
		$(this).next('.copy-collapsable-formbutton').append(etfunc);		
			
		$(this).next('.copy-collapsable-formbutton').bind("click",function(){
			var oldheight = $(this).prev('.collapsable-form').attr("id");
			var nowheight = $(this).prev('.collapsable-form').height();
			if(nowheight == collapseheight){
				$('.collapsable-form').animate({
				  height: collapseheight
				}, {queue:false, duration:1300, easing:'easeInCubic'});
				$('.collapsable-content').animate({
				  height: collapseheight
				}, {queue:false, duration:1300, easing:'easeInCubic'});
				$('.copy-collapsable-formbutton a').html('<div class="toform"></div>');
				$('.copy-collapsable-button a').html('<div class="more"></div>');				
				$('.copy-collapsable-overlay').fadeIn();
				$(this).next('.copy-collapsable-overlay').fadeOut();
				
				$(this).prev('.collapsable-form').animate({
				  height: oldheight
				}, {queue:false, duration:1300, easing:'easeInCubic'});	
				$(this).children('a').html('<div class="close"></div>');
			}
			else{
				$(this).prev('.collapsable-form').animate({
				  height: collapseheight
				}, {queue:false, duration:1300, easing:'easeInCubic'});
				$(this).children('a').html('<div class="toform"></div>');
				$(this).next('.copy-collapsable-overlay').fadeIn();
			}
			return false;	
		});
	});
	$("div.collapsable-form").css('height' , collapseheight + 'px');
	$('.copy-collapsable-formbutton').show();
});


// SLIDABLE CONTENT
$(function(){
	var ptitle = $(document).attr('title');
	var etfunc = '<a href="#" class="foldbutton" onmousedown="ET_Event.eventStart(\'+Button\', \''+ptitle+'\', \'click\')"><div class="more"></div></a>';
	$('.copy-foldable-button').hide();
	var slideHeight = 250; // px
	var defHeight = $('.copy-foldable-placer').height();
	$('.copy-foldable-overlay').hide();
	//$('.copy-foldable-overlay').fadeOut();
	if(defHeight >= slideHeight){
		$('.copy-foldable-overlay').show();
		$('.copy-foldable-placer').css('height' , slideHeight + 'px');	
		$('.copy-foldable-placer').css('padding-bottom' , '20px');	//Muss zusaetzlich benutzt werden, um den Abstand fon Text mit button hinzubekommen.		
		$('.copy-foldable-button').append(etfunc);		
		$('.copy-foldable-button a').click(function(){
			var curHeight = $('.copy-foldable-placer').height();
			if(curHeight <= slideHeight){
				$('.copy-foldable-placer').animate({
				  height: defHeight
				}, "normal");
				$('.copy-foldable-button a').html('<div class="less"></div>');
				// Falls ein Fade-Effekt über dem verdeckten Inhalt liegen soll...				
				//$('.copy-foldable-gradient').fadeOut();
				$('.copy-foldable-overlay').hide();
			}else{
				$('.copy-foldable-placer').animate({
				  height: slideHeight
				}, "normal");
				$('.copy-foldable-button a').html('<div class="more"></div>');
				$('.copy-foldable-overlay').show();
			}
			return false;
		});
	}
	$('.copy-foldable-button').show();
});





// HOVER-BUTTONS
$(function() {
  $('a.hoverlink').hover(function() {
      var noImage = $(this).children("div.item_no").children("img").attr("src");
      var roImage = $(this).children("div.item_ro").children("img").attr("src");
      $(this).children("div.item_no").children("img").attr("src", roImage);
      $(this).children("div.item_ro").children("img").attr("src", noImage);
  }, function() {
      var noImage = $(this).children("div.item_no").children("img").attr("src");
      var roImage = $(this).children("div.item_ro").children("img").attr("src");
      $(this).children("div.item_no").children("img").attr("src", roImage);
      $(this).children("div.item_ro").children("img").attr("src", noImage);
  });
});

$(function() {
  $('a.content_box_link').hover(function() {      
      var cb = $(this).parents('div:first').parents('div:first').find('div.contentbox:first');
      var noImage = cb.children("div.csc-header").children("div.item_no").children("img").attr("src");
      var roImage = cb.children("div.csc-header").children("div.item_ro").children("img").attr("src");
      cb.children("div.csc-header").children("div.item_no").children("img").attr("src", roImage);
      cb.children("div.csc-header").children("div.item_ro").children("img").attr("src", noImage);
      
      var noImage2 = $(this).parents('div:first').parents('div:first').find('div.content_box_button:first').children("a.content_box_link:first").children("img").attr("src");
      var roImage2 = $(this).parents('div:first').parents('div:first').find('div.content_box_button_ro:first').children("img").attr("src");
      $(this).parents('div:first').parents('div:first').find('div.content_box_button:first').children("a.content_box_link:first").children("img").attr("src", roImage2);
      $(this).parents('div:first').parents('div:first').find('div.content_box_button_ro:first').children("img").attr("src", noImage2);   
      
  }, function() {
  		var cb = $(this).parents('div:first').parents('div:first').find('div.contentbox:first');
      var noImage = cb.children("div.csc-header").children("div.item_no").children("img").attr("src");
      var roImage = cb.children("div.csc-header").children("div.item_ro").children("img").attr("src");
      cb.children("div.csc-header").children("div.item_no").children("img").attr("src", roImage);
      cb.children("div.csc-header").children("div.item_ro").children("img").attr("src", noImage);
      
      var noImage2 = $(this).parents('div:first').parents('div:first').find('div.content_box_button:first').children("a.content_box_link:first").children("img").attr("src");
      var roImage2 = $(this).parents('div:first').parents('div:first').find('div.content_box_button_ro:first').children("img").attr("src");
      $(this).parents('div:first').parents('div:first').find('div.content_box_button:first').children("a.content_box_link:first").children("img").attr("src", roImage2);
      $(this).parents('div:first').parents('div:first').find('div.content_box_button_ro:first').children("img").attr("src", noImage2);      
  });
});

$(function() {
  $('a.closelogin').hover(function() {
      var noImage = $(this).children("div.item_no").children("img").attr("src");
      var roImage = $(this).children("div.item_ro").children("img").attr("src");
      $(this).children("div.item_no").children("img").attr("src", roImage);
      $(this).children("div.item_ro").children("img").attr("src", noImage);
  }, function() {
      var noImage = $(this).children("div.item_no").children("img").attr("src");
      var roImage = $(this).children("div.item_ro").children("img").attr("src");
      $(this).children("div.item_no").children("img").attr("src", roImage);
      $(this).children("div.item_ro").children("img").attr("src", noImage);
  });
});








