/********************************************************************************************************************************************* 
	Common window.onload {*/
	window.onload = function() {
	
	/******************************************************************************************************************************************* 
	Margin from image in the content {*/
	 (function marginImage(){
			$(".main-content img").each(function(){
				var x = 23, y = 23;
				var align = $(this).attr("align");
				var float = $(this).css("float");
				
				if(align == "left" || float == "left") y = 0;
				if(align == "right" || float == "right") x = 0;
				
				$(this).css({marginRight : x,  marginLeft : y, marginTop : 0});
			})
	  })();
	  
	  /*CSS Browser Selector*/
	  css(navigator.userAgent);
	  
	  /*Use Placeholder plugin if not support HTML5 placeholder*/
	  if (!Modernizr.input.placeholder){$('input[placeholder], textarea[placeholder]').placeHoldize();}
	  
	  
		
		
	/*	var a = new bgDesign({
			srcImage: "design/design.jpg",
			opacityDesign: 1,
			opacityHtml: 1,
			controlOpacityHtml: "true",
			controlOpacityDesign: "true"
		});
	*/	
	
	
	

	
	
		
	};


/********************************************************************************************************************************************* 
	Common window.onresize	 {*/	
	window.onresize = function() {
		
	}

	
	

$(document).ready(function(){
	
	
	/*$(".header-menu img").hover(function(){
		src = $(this).attr("src");
		$(this).attr("src", $(this).attr("hover_image"));
	}, function(){
		$(this).attr("src", src);
	});
	*/
	
	
	/*$(".header-menu .shadow-submenu").parent().children("ul").each(
		function(){
			$(this).height()
		}
	);*/
	

	cur_src = 0;
	
	function out_menu(){
		var _this = $(this)
		var submenu = $(this).find(".shadow-submenu");
		submenu.parent().children("ul").hide(0, function(){
			submenu.removeClass("active");
		});
		
		var this_image = $(this).find("img");
		this_image.attr("src", cur_src);
	}
	
	$(".header-menu>li").hover(hover_menu, out_menu);
	
	
	function hover_menu(){
		$(this).find(".shadow-submenu").addClass("active").parent().children("ul").show(100);
		
		var this_image = $(this).find("img");
		
		cur_src = this_image.attr("src");
		this_image.attr("src", this_image.attr("hover_image"));
	}
	
	
	
	$(".header-additionally-menu>li").hover(function(){
		$(this).children("ul").show(100);
	}, function(){
		$(this).children("ul").hide();
	});
	
	/*0, function(){
			//submenu.removeClass("active");
		}
	*/
		
/********************************************************************************************************************************************* 
	Initialization plugin placeHoldize
	*/
	
	
	
	
/********************************************************************************************************************************************* 
	Initialization nivoSlider{
	(function() {
		var slider = $('#header-slider');
		if(slider.length > 0){
			slider.nivoSlider({
				controlNav: true, 
				directionNav: false,
				effect: 'boxRainGrowReverse', // Specify sets like: 'fold,fade,sliceDown'
				pauseTime: 6000, // How long each slide will show
				animSpeed: 200
				 
			});
			
		}
	})();
	*/
	
	
	

	

	
	

/******************************************************************************************************************************************* 
	Table zebra {*/
	$(".table1 tr").mouseover(function() {$(this).addClass("over");}).mouseout(function() {$(this).removeClass("over");});
	$(".table1 tr:even").addClass("alt");

	
/******************************************************************************************************************************************* 
	Cufon {*/
	
	//Cufon.replace('.');


/******************************************************************************************************************************************* 
	Clear text input {*/
	//$(".clear").clearTextInput();
	
	
/******************************************************************************************************************************************* 
	Animate hover opacity {*/
	function anim(){
		$(this).find('img').animate({opacity:'0.60'},300).animate({opacity:'1'},200);	
	}
	$('.gallery a').hover(anim, function(){});
	
	
/******************************************************************************************************************************************* 
	Crop links with current element {
	$(".header-navigation .current").each(function(){
		var text = $(this).find("a").remove().html();
		$(this).append(text);
	});*/

/******************************************************************************************************************************************* 
	Crop links with current element {
	$(".top-menu .current").each(function(){
		var text = $(this).find("a").remove().html();
		$(".wrapper", $(this)).append(text);
	});
*/





/******************************************************************************************************************************************* 
	Last element {*/
	//$("#top-navigation li:last").addClass("last");

/******************************************************************************************************************************************* 
	First element {*/
	//$("#top-navigation li:first").addClass("first");
	



/******************************************************************************************************************************************* 
	Set height dynamic block {*/
	
	function dynamic_height_column(){
		$(".dynamic_height").each(function(){
			/*select siblings this element*/
			var siblings = $(this).parent().children().not($(this));
			
			/*count total height siblings element*/
			var siblingsH = 0;
			siblings.each(
				function(){
					siblingsH += $(this).outerHeight(true);
				}
			);
			
			/*set dynamic height this block (parentHeight - childrensOuterHeight - thisOnlyOuterHeight*/
			$(this).height($(this).parent().height() - siblingsH - ($(this).outerHeight(true) - $(this).height())) ;
		})
	};	



	/******************************************************************************************************************************************* 
	wrap photo in gallery{*/


	(function(){
		var photo = $(".gallery-list-photo .photo");
		photo_amount = Math.ceil(photo.length / 4);
		
		for(var i = 0; i < photo_amount; i++){
			$(".gallery-list-photo>.photo").slice(0, 4).wrapAll('<div class="wrap-photo"></div>');
		}
		
		$(".wrap-photo").each(function(){
			$(this).height($(this).height());
		}).first().addClass("first");
		
	})();	

	
	


/******************************************************************************************************************************************* 
	Accordion {*/

    //$(".accordion").accordion();


/******************************************************************************************************************************************* 
	Custom form elements {*/

	// $('.enter-form input[type="checkbox"]').customFormElements();


	
/******************************************************************************************************************************************* 
	submenu {*/
	


}); 

/******************************************************************************************************************************************* 
	?? {*/
	


/*
$(window).load(function() {
	
});


*/

/******************************************************************************************************************************************* 
	Plugin :: Clear text input{*/
	
	
/*(function($){
	$.fn.clearTextInput =  function clearTextInput()
	{
		
		$(this).each(function(){
			var el = $(this), val = $(this).val();
	    
			el.focus(function(){
					if (el.val() == val) el.val('');
				}).focusout(function(){
					if (!el.val()) el.val(val);
				});
			})
	

}})(jQuery);*/


/******************************************************************************************************************************************* 
	Plugin :: Accordion menu{
{
	(function($){
		$.fn.accordion = function(){
			
			var acc_menu = $(this);
			
			$(".container" ,acc_menu).hide().addClass("hide").parent().addClass("submenu").data(status, "close").children("a").removeAttr("href");
			
			$(".current" ,acc_menu).parents("div.hide").show().removeClass("hide").addClass("open").parent().addClass("active").data(status, "open");
			
			acc_menu.delegate(".name", "click", function(){
				
				if($(this).parents(".submenu").data(status) == "close"){
					$(".submenu" ,acc_menu).removeClass("active").data(status, "close").find(".open").slideUp(150).removeClass("open").addClass("hide");
					$(this).parents(".submenu").addClass("active").data(status, "open").children(".hide").removeClass("hide").slideDown(150).addClass("open");
				}
				else{
					$(this).parents(".submenu").removeClass("active").data(status, "close").children(".open").addClass("hide").slideUp(150).removeClass("open");
				}
			})
		
		}
		
		return $(this)  
			
	})(jQuery);
*/
/*} Accordion menu*/



/******************************************************************************************************************************************* 
	Plugin :: tree menu{
{*/
	/*(function($){
		$.fn.treeMenu = function(){
			
			
			
			$(this).children("li").prepend("<span class='marker2 plus'></span>").children("ul").hide().end().children("a").addClass("g_link");
		
			$(this).children("li").has("ul").find(".marker2").removeClass("marker2").addClass("marker");
			
			$(this).children("li").find(".current").parents("ul").show().parents("li").addClass("active").find(".marker").removeClass("plus").addClass("minus");
			
			//$(this).children("li").children("a").click(function(event){event.stopPropagation()})
			
			$(this).children(".current").children("ul").show().parents("li").addClass("active").find(".marker").removeClass("plus").addClass("minus");
			
			$(this).find(".marker").click(function(){
				
					
					$(this).parents("ul").find(".marker").not($(this)).removeClass("minus").addClass("plus").parent("li").removeClass("active").find("ul").hide();
					
					//if($(this).parents("li").children("ul").css("display") == "block"){return 0}
					
					if($(this).parents("li").children("ul").css("display") == "none")
					{
						$(this).removeClass("plus").addClass("minus").parent().addClass("active").children("ul").show();
					}
					else
					{
						$(this).removeClass("minus").addClass("plus").parent().removeClass("active").children("ul").hide();	
				
				}
			});
		
		}
		
		
			
	})(jQuery);*/

/*} Accordion menu*/




