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





	jQuery.fn.exists = function() { return jQuery(this).length>0; }





	

	

	

	// Fancybox



			$(".fancy").fancybox({

				'titlePosition'	:	'over',

				'padding'			: 0,

				'transitionIn'		: 'none',

				'transitionOut'		: 'none',

				'type'              : 'image',

				'changeFade'        : 0,

				'onComplete'	:	function() {

					$("#fancybox-wrap").hover(function() {

						$("#fancybox-title").show();

					}, function() {

						$("#fancybox-title").hide();

					});

				}

			});





	

	

	

	// Menu Drop-Down:

	

			$(".menu_head").click(function() {

				$(".menu_body").slideUp (300);

				$(this).next(".menu_body").slideToggle(300);

				return false;

			});

			

			$(".hit").next(".menu_body").slideToggle(300).siblings(".menu_body").slideUp("fast");









	



	// Opacity



			$.fn.opacity = function() {

				$(this).hover(

				  function () {

					$(this).css({ opacity: ".9" });

				  }, 

				  function () {

					$(this).css({ opacity: "1" });

				  }

				);

			}



			$("button, #flags a, #gallery a").opacity();

			









	// Remove margin in last element

			

			$("#buttons a:eq(1), #buttons a:eq(3)").css({ marginRight: '0' });

			$('#gallery .photo:eq(4)').css({ marginRight: '0' });

			$("#materialy dd:last").css({ paddingBottom: '0' });











	// _blank



			$('a.blank').click( function() {

				window.open(this.href);

				return false;

			});









	

	

	// Do something in (n) element

	

			var i = 4;

		    $('#gallery a').each(function() {

				var item = $('#gallery a:eq('+i+')');

    				i=i+4;

			    	item.css({ marginRight: '0' });

		    });

		    







	// Form validate

	

		$('#error').hide();

		$('form').bind('submit', function(){

			var valid = true;

			$('.required').click(function(){

				$(this).removeClass('error-input');

			});

			$('.required').each(function(){

				if($(this).val()==''){

					$(this).addClass('error-input');

					 valid = false;

				}else{

					$(this).removeClass('error-input');

				}

			});

			if(!valid){

				$('#error').fadeIn();

				return false;

			}

		});

		









	// Drop down horiz menu

	

		$("ul.topnav li a").mouseover(function() { 

			$(this).parent().find("ul.subnav").show();

			$(this).parent().addClass("hover");

	

			$(this).parent().hover(function() {

			}, function(){	

				$(this).parent().find("ul.subnav").hide();

				$(this).removeClass("hover");

			});

		});





	// systemyTable
		
		$('.systemyTable tr:odd').addClass('odd');


});






