var $j = jQuery.noConflict();
$j(document).ready(function(){
		
			if ($j("#s4").length) {
			$j.fn.cycle.defaults.timeout = 6000;
					$j(function() {
					// run the code in the markup!
					$j('#s4').after('<div id="nav" class="nav"><span id="prevCase" style="margin-right: 5px;">&laquo;</span><span id="nextCase" style="float:right; cursor: pointer;line-height: 5px; font-size: 14px;">&raquo;</span>').cycle({
						fx:     'fade',
						speed:  'slow',
						timeout: 10000,
						pager:  '#nav',
						height:	'324px',
						next: '#nextCase',
						prev: '#prevCase'
					});
					});
				};
			//$j('#nav').prepend('<span id="prevCase" style="margin:0px 5px 0px 0px;">&laquo;</span>');
			//$j('#nav').append('<span id="nextCase" style="float:right; cursor: pointer;line-height: 5px; font-size: 14px;">&raquo;</span>');
		    if ($j("#featureCarousel").length) {
			$j(document).ready(function() {
								$j("#featureCarousel").featureCarousel({
								});
			});
			};
			$j.fn.equalHeight = function() {
				var group = this;
				$j(window).bind('resize', function(){
				var tallest = 0;
				$j(group).height('auto').each(function() {
				tallest = Math.max(tallest, $j(this).height());
				}).height(tallest);
				}).trigger('resize');
			}
			$j('#prevCase, #nextCase').mouseover(function(){
				$j(this).css('text-decoration','underline');
			}).mouseout(function(){
				$j(this).css('text-decoration','none');
			});
			// prettyPhoto
			if ($j(".novisites_lightbox_image").length) {
			$j("a[rel^='prettyPhoto']").prettyPhoto({theme:'facebook'});
			};		
			// lightbox image
			$j(".novisites_lightbox_image").append("<span></span>")
					
			$j(".novisites_lightbox_image").hover(function(){
				$j(this).find("img").stop().animate({opacity:0.5}, "normal")
			}, function(){
				$j(this).find("img").stop().animate({opacity:1}, "normal")
			});
			$j(".novisites_lightbox_video").append("<span></span>")
				
			$j(".novisites_lightbox_video").hover(function(){
				$j(this).find("img").stop().animate({opacity:0.5}, "normal")
			}, function(){
				$j(this).find("img").stop().animate({opacity:1}, "normal")
			});

			$j('#toc a').click(function(){//$j.scrollTo works EXACTLY the same way, but scrolls the whole screen
				//$j.scrollTo( this.hash, 1500);
				$j(this.hash).find('#options-examples').text( this.title );
				return false;
			});
			$j(".novisites_height").equalHeight();
						jQuery('ul#mainmenu_1').superfish();
						
						function ajaxContact(theForm) {
		//var $j = jQuery;
	
        $j('#loader').fadeIn();

        var formData = $j(theForm).serialize(),
			note = $j('#Note');
	
        $j.ajax({
            type: "POST",
            url: "http://www.novisites.nl/pages/send.php",
            data: formData,
            success: function(response) {
				if ( note.height() ) {			
					note.fadeIn('fast', function() { $j(this).hide(); });
				} else {
					note.hide();
				}

				$j('#LoadingGraphic').fadeOut('fast', function() {
					//$j(this).remove();
					if (response === 'success') {
						$j('.field').animate({opacity: 0},'fast');
					}

					// Message Sent? Show the 'Thank You' message and hide the form
					result = '';
					c = '';
					if (response === 'success') { 
						result = 'Uw bericht is verzenden, bedankt!';
						c = 'success';
					}

					note.removeClass('success').removeClass('error').text('');
					var i = setInterval(function() {
						if ( !note.is(':visible') ) {
							note.html(result).addClass(c).slideDown('fast');
							clearInterval(i);
						}
					}, 40);    
				});
            }
        });

        return false;
    }
	if ($j("#contactform").length) {
	jQuery("#contactform").validate({
			submitHandler: function(form) {				
				ajaxContact(form);
				return false;
			},
			 messages: {
    		 formname: "Please specify your name.",
			 formcomments: "Please enter your message.",
    		 formemail: {
      			 required: "We need your email address to contact you.",
      			 email: "Your email address must be in the format of name@domain.com"
    		 },
			 rules: {
			 	suma: {
			      equalTo: "#hh"
			    }

			 }
  		 }
		});
		 }
	});
	
	
	$j(document).ready(function(){
		
		jQuery('#suma').keyup(function(){
			if(jQuery(this).val()&&(jQuery(this).val()!=4)){
				jQuery('#sumaError').css('display','block');
			}
			else
				jQuery('#sumaError').css('display','none');
		});
		
	 function ajaxContact(theForm) {
		var $j = jQuery;
	
        $j('#loader2').fadeIn();

        var formData = $j(theForm).serialize(),
			note = $j('#Note2');
	
        $j.ajax({
            type: "POST",
            url: "http://www.novisites.nl/pages/send.php",
            data: formData,
            success: function(response) {
				if ( note.height() ) {			
					note.fadeIn('fast', function() { $j(this).hide(); });
				} else {
					note.hide();
				}

				$j('#LoadingGraphic2').fadeOut('fast', function() {
					//$j(this).remove();
					if (response === 'success') {
						$j('.field2').animate({opacity: 0},'fast');
						$j('.novisites_input').animate({opacity: 0},'fast');
					}

					// Message Sent? Show the 'Thank You' message and hide the form
					result = '';
					c = '';
					if (response === 'success') { 
						result = 'Uw bericht is verzenden, bedankt!';
						c = 'success';
					}

					note.removeClass('success').removeClass('error').text('');
					var i = setInterval(function() {
						if ( !note.is(':visible') ) {
							note.html(result).addClass(c).slideDown('fast');
							clearInterval(i);
						}
					}, 40);    
				});
            }
        });

        return false;
    }
	if ($j("#contactform2").length) {
	jQuery("#contactform2").validate({
			submitHandler: function(form) {				
				ajaxContact(form);
				return false;
			},
			 messages: {
    		 formname: "Please specify your name.",
			 formcomments: "Please enter your message.",
    		 formemail: {
      			 required: "We need your email address to contact you.",
      			 email: "Your email address must be in the format of name@domain.com"
    		 },
			 rules: {
			 	suma: {
			      equalTo: "#hh"
			    }

			 }
  		 }
		});
		 }
	});
