/* Author: 

*/

/* Use this syntax for your jQuery code if you use two js libs using the $ placeholder
$.noConflict();
jQuery(document).ready(function($) {
  // Code that uses jQuery's $ can follow here.
	$(function(){
		$("a[rel*=lightbox]").fancybox();
	});
}); */


$(function(){
	
  // FOR IE
	$('.ie #nav li').hover(
		function(){
		  //var tabnr = parseFloat($("li").index(this)+ 1);
		  //alert(tabnr);
		  //tabmouseenter(tabnr);
		  $('li.active').trigger('mouseleave');
		  
			$(this)
			.stop(true,true)
			.css({
				'background-image': 	'url("tl_files/codeprofiler/layout/images/tab-ausgefahren-bg.png")',
				'background-repeat': 	'no-repeat',
				'background-position': 	'top left',
				'font-size':	  		'14px',
				'color':		  		'#666666',
				'height':     '129px',
				'width':      '210px',
				'position':   'relative',
				'margin-top': '-1px'
			});
			
			$(this).find('p').css({
					'color':	 '#666',
					'font-size': '14px',
					'line-height': '16px'
			});
			$(this).find('.threat_descr').css({
				  'display': 'block',
					'color':	 '#666',
					'font-size': '11px',
					'line-height': '13px'
			});
			
		},
		function(){
		  //var tabnr = parseFloat($("li").index(this)+ 1);
		  //alert(tabnr);
		  //tabmouseleave(tabnr);
        	
			$(this)
			.removeClass('active')
			.stop(true,true)
			.css({
				'margin':     		   '72px 0 0 2px',
				'height':     		   '45px',
				'width':      		   '94px',
				'background-image':    'url("tl_files/codeprofiler/layout/images/tabs-bg-default.gif")',
				'background-repeat':   'no-repeat',
				'background-position': 'bottom left',
				'font-size':	       '7px',
				'color':		       '#c7c7c7'
			});
			
			$(this).find('p').css({
				'font-size': '7px',
				'color':	 '#c7c7c7',
				'line-height': '8px'
			});
			$(this).find('.threat_descr').css({
		    'display': 'none'
			});
  			
		}
	);
	
	// For all other browsers
	$('#nav li').hover(
		function(){
		  //var tabnr = parseFloat($("li").index(this)+ 1);
		  //alert(tabnr);
		  //tabmouseenter(tabnr);
		  $('li.active').trigger('mouseleave');
		  
			$(this)
			.stop(true,true)
			.css({
				'background-image': 	'url("tl_files/codeprofiler/layout/images/tab-ausgefahren-bg.png")',
				'background-repeat': 	'no-repeat',
				'background-position': 	'top left',
				'font-size':	  		'14px',
				'color':		  		'#666'
			})
			.animate({
				'height':     '129px',
				'width':      '210px',
				'position':   'relative',
				'margin-top': '-1px'
			}, 
			200, 
			function(){
				$(this).find('p')
					.stop(true,true)
					.css({
						'color':	 '#666',
						'font-size': '14px',
						'line-height': '16px'
				});
				$(this).find('.threat_descr')
					.stop(true,true)
					.css({
					  'display': 'block',
						'color':	 '#666',
						'font-size': '11px',
						'line-height': '13px'
				});
			});
			
		},
		function(){
		  //var tabnr = parseFloat($("li").index(this)+ 1);
		  //alert(tabnr);
		  //tabmouseleave(tabnr);
        
			$(this)
			.removeClass('active')
			.stop(true,true)
			.css({
				'margin':     		   '72px 0 0 2px',
				'height':     		   '45px',
				'width':      		   '94px',
				'background-image':    'url("tl_files/codeprofiler/layout/images/tabs-bg-default.gif")',
				'background-repeat':   'no-repeat',
				'background-position': 'bottom left',
				'font-size':	       '7px',
				'color':		       '#c7c7c7'
			});
			
			$('p', this).css({
				'font-size': '7px',
				'color':	 '#c7c7c7',
				'line-height': '8px'
			});
			$('.threat_descr',this).css({
		    'display': 'none'
			});
  			
		}
	);
	
	
	// Special hover params for .last
	$('#nav li.last').hover(
		function(){
		  var p = $(this);
		  var position = p.position();

			$(this)
			.css({
        'position': 'absolute',
        'left': position.left,
        'z-index': '100'
	 		});
  },
		function(){
			$(this)
			.stop(true,true)
			.css({
        'position': 'inherit'
			});
		}
  );
  
  
  // click function for flash
  $('#nav li.inactive').click(
    function(){
      if( $('.active').length > 0) { /*alert("active vorhanden");*/ }
      
      $(this).removeClass('inactive');
      $(this).addClass('active');
    	var tabnr = parseFloat($("li").index(this)+ 1);
    	document.getElementById( "animation" ).callMe(tabnr);
    	return false;
    }
  );
  

	// Clear input placeholder
  $('input.text').each(function(){
    $(this)
    .data('default', $(this).val())
    .addClass('inactive')
    .focus(function(){
      $(this).removeClass('inactive');
      if ($(this).val() == $(this).data('default') || ''){
        $(this).val('');
      }
    })
    .blur(function(){
      if ($(this).val() == '') {
        $(this).addClass('inactive');
        $(this).val($(this).data('default'));
      }
    });
  });
  
  
  
  // Form eula
  eula();
  $(".radio_container .radio").click(function(){
    eula();
  });
  $(".radio_container label").click(function(){
    eula();
  });
  
  
  // Form Validation
  $.validator.addMethod("defaultInvalid", function(value, element) 
  {
   switch(element.value) 
   {
    case "Enter your full name here":
      if (element.name == "name") return false;
    break;
    case "Company name":
      if (element.name == "company") return false;
    break;
    case "Telephone number":
      if (element.name == "telephone") return false;
    break;
    default:
      return true;
    break;
   }
  });
  $.validator.addMethod("eula", function(value, element) 
  {
    if(($("#opt_8_2:checked").attr('checked')) && (!$("#opt_11_0:checked").attr('checked'))){
      $('label.eula').css({'color': '#ff0000'});
      return false;
    }
    else {
      $('label.eula').css({'color': '#939496'});
      return true;
    }
  });
  
  $("#f1").validate({
    rules: {
    	name: "required defaultInvalid",
    	company: "required defaultInvalid",
    	telephone: {
			required: true,
			minlength: 5, 
			defaultInvalid: true,
			digits: true
		},
    	email: {
    		required: true,
    		email: true,
    	},
    	testType: "required eula"
    },
    errorPlacement: function(error, element) {
      error.remove();
    }
  });
  
  $("#vform").validate();
  $("#contactForm").validate();

	$("#advisories-anfordern").validate({
    rules: {
    	name: "required defaultInvalid",
    	company: "required defaultInvalid",
    	telephone: {
			required: true,
			minlength: 5, 
			defaultInvalid: true,
			digits: true
		},
    	email: {
    		required: true,
    		email: true,
    	},
		dataprot: "required"
    },
    errorPlacement: function(error, element) {
      error.remove();
    }
  });

});







function tabmouseenter(tabnr){
  $('.tab'+tabnr)
  .removeClass('inactive')
  .addClass('active')
	.stop(true,true)
	.css({
		'background-image': 	'url("tl_files/codeprofiler/layout/images/tab-ausgefahren-bg.png")',
		'background-repeat': 	'no-repeat',
		'background-position': 	'top left',
		'font-size':	  		'14px',
		'color':		  		'#666',
		'height':     '129px',
		'width':      '210px',
		'position':   'relative',
		'margin-top': '-1px'
	});
	$('.tab'+tabnr).find('p')
		.css({
			'color':	 '#666',
			'font-size': '14px',
			'line-height': '16px'
	});
	$('.tab'+tabnr).find('.threat_descr')
		.css({
		  'display': 'block',
			'color':	 '#666',
			'font-size': '11px',
			'line-height': '13px'
	});
}

function tabmouseleave(tabnr){
	$('.tab'+tabnr)
  .ramoveClass('active')
  .addClass('inactive')
	.stop(true,true)
	.css({
		'margin':     		   '72px 0 0 2px',
		'height':     		   '45px',
		'width':      		   '94px',
		'background-image':    'url("tl_files/codeprofiler/layout/images/tabs-bg-default.gif")',
		'background-repeat':   'no-repeat',
		'background-position': 'bottom left',
		'font-size':	       '7px',
		'color':		       '#c7c7c7'
	});
	
	$(this).find('p').css({
		'font-size': '7px',
		'color':	 '#c7c7c7',
		'line-height': '8px'
	});
	$(this).find('.threat_descr').css({
    'display': 'none'
	});
}



function eula()
{
  $('.checkbox_container').hide();
  if($("#opt_8_2:checked").attr('checked')) {
    $('.checkbox_container').slideDown();
  }
}




 









