$nym=jQuery.noConflict();


$nym(document).ready(function() {

    $nym('.sp-slides').cycle({
	fx:'scrollHorz',
	next: '.next-slide', 
	prev:'.prev-slide',
	timeout:0
	 // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});

});
//


// FORM SUBMIT + VALIDATE
$nym(document).ready(function(){
	function validateNoempty(text) {
		if (!text || text.length < 2) { return false;	}

		return true;
	}

	function validateText(text) {
		if (!validateNoempty(text)) { return false; }

		var re_text = /[^A-Za-z0-9\s!@#$nym%^&()_+-=}{';":.,><]/;
		if (text.match(re_text) != null ) { return false; }
		return true;
	}

	function validateEmail(email) {
		if (!validateNoempty(email)) { return false; }

		var splitted = email.match("^(.+)@(.+)$nym");
		if (splitted == null) return false;
		if (splitted[1] != null ) {
			var regexp_user=/^\"?[\w-_\.]*\"?$nym/;
			if (splitted[1].match(regexp_user) == null) { return false; }
		}

		if(splitted[2] != null) {
			var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$nym/;
			if (splitted[2].match(regexp_domain) == null) {
				var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$nym/;
				if (splitted[2].match(regexp_ip) == null) { return false; }
			}
			return true;
		}
		return false;
	}

	$nym('.js-proceed').click( function(event) {
			event.preventDefault();
			error = false;

			$nym(this).parents('form').find('input[type="text"], textarea').each( function() {
				if ($nym(this).hasClass('v-noempty')) {
					if (!validateNoempty($nym(this).val())) {
						$nym(this).animate( { opacity: 0.2 }, 175 ).animate( { opacity: 1 }, 150 );
						error = true;
					}

				} else if ($nym(this).hasClass('v-text')) {
					if (!validateText($nym(this).val())) {
						$nym(this).animate( { opacity: 0.2 }, 175 ).animate( { opacity: 1 }, 150 ).animate( { opacity: 0.2 }, 150 ).animate( { opacity: 1 }, 150 ).animate( { opacity: 0.2 }, 150 ).animate( { opacity: 1 }, 150 );
						
						error = true;
					}
				} else if ($nym(this).hasClass('v-mail')) {
					if (!validateEmail($nym(this).val())) {
						$nym(this).animate( { opacity: 0.2 }, 175 ).animate( { opacity: 1 }, 150 ).animate( { opacity: 0.2 }, 150 ).animate( { opacity: 1 }, 150 ).animate( { opacity: 0.2 }, 150 ).animate( { opacity: 1 }, 150 );
						error = true;
					}
				}
			});

			if (!error) {
				//var node = $nym(this).parents('.js-hidebox');
				//node.slideUp('slow');
				//loadnote($nym(this));
				$nym(this).parents('form').submit();
			}

			//alert( (error)?'error' : 'no' ) ;
			return false;
		}
	);

							  });









  $nym(function() {

    var galleries = $nym('.ad-gallery').adGallery();
    $nym('#switch-effect').change(
      function() {
        galleries[0].settings.effect = $nym(this).val();
        return false;
      }
    );
    $nym('#toggle-slideshow').click(
      function() {
        galleries[0].slideshow.toggle();
        return false;
      }
    );
  });








// FORM AUTOVALUES
$nym(document).ready(function(){

	function populateElement(selector, defvalue) {
		$nym(selector).focus(function() {
			if ($nym(selector).val() == 'Website') {
				$nym(selector).val('http://');
			} else if ($nym(selector).val() == defvalue) {
				$nym(selector).val('');
			}
		});

		$nym(selector).blur(function() {
				if ($nym.trim($nym(selector).val()) == '') {
						$nym(selector).val(defvalue);
				}
		});
	};

	$nym('form').find('input[type="text"], input[type="password"], textarea').each(function() {
				populateElement($nym(this), $nym(this).val());
			}
	);

});
//





$nym(document).ready
(
 function(){
	$nym('.add-a-comment').click( function(event) 
		{			
			var node = $nym(this).parents('.post-container').children('.add-commentbox');

			
			if(node.css('display') == 'none')
			{
				node.animate({height:'show',opacity:'show'}, 'slow');
			}
			else
			{
				node.animate({height:'hide',opacity:'hide'}, 'slow');
			}
			
			

			
		}
	);

  }
);
//


