document.write('<div class="input" align="center" onclick="return {type: 2, logo: \'rb\', arrow: false, webopt: false, websearch: false, bg: \'#fff\', fg: \'#000000\', fontsize: 14, suggest: true, site_suggest: true, encoding: \'utf-8\'}"><form action="/wp-content/themes/ipmoney/searchform.php" method="get"><input type="hidden" name="searchid" value="205428" /><input name="text" size="18" /><br /><input class="input" type="submit" value=">>>" /></form></div><script type="text/javascript" src="http://site.yandex.net/load/form/1/form.js" charset="utf-8"></script>');
//goto_top
function featured_slider(){
	$('.feautered').css('display','none');
	if($("a.nav_item.active").next().length == 0) {
		obj = $('a.nav_item:first-child');
	}else{
		obj = $("a.nav_item.active").next();
	}
	$(obj).parent().children().removeClass('active');
	$(obj).addClass("active");

	$('#feauter_'+($(obj).index('.nav_item')+1)).fadeIn("fast");
	setTimeout(featured_slider, 7000);
}


 
function PopupCenter(pageURL, title, w, h){
 var left = (screen.width/2)-(w/2);
 var top = (screen.height/2)-(h/2);
 var targetWin = window.open(pageURL, '', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
} 


VKmax=165; 
function VKCheck(text){
	if(VKmax>0&&VKmax-text.length<=0)
	{
		text=text.substr(0,VKmax-3)+'...';
		VKmax=VKmax-text.lenght;
		return text;
	}
	else {
		if(VKmax<=0) return false;
		else return text;
	}
}

function set_same_height(){
	var left = 0;
	$('.same').each(function(index){
		if(left>0){
			height = $(this).height();
			if(height<left){
				$(this).css('height',left);
			}else{
				$('.same:eq('+(index-1)+')').css('height',height);
			}
			left = 0;
		}else{
			left = $(this).height();
		}
	});
}

function randomFromTo(from, to){
   return Math.floor(Math.random() * (to - from + 1) + from);
}

var changeable_count=0;
function changeable(id,count){
	var obj = $('.changeable');
	obj.css('display','none');

	if(changeable_count>=count){
		changeable_count = 0;
	}
	//alert(changeable_count);
	obj.eq(changeable_count).css('display','block');	
	changeable_count++;	
}
function start_changeable(){
	changeable('changeable',5);
	setTimeout(start_changeable, 7000);
}
	

$(document).ready(function() {
	
	start_changeable();
	
	$("a.nav_item").live('click', function() {
		$('.feautered').css('display','none');
		$(this).parent().children().removeClass('active');
		$(this).addClass("active");
		$('#feauter_'+($(this).index('.nav_item')+1)).fadeIn("fast");
	});
	
	$('.sections').hover(
		function(){
			$('a',$(this)).addClass('active');
			$('ul.top_sub_menu',$(this)).fadeIn('normal');
		},
		function(){
			$('a',$(this)).removeClass('active');
			$('.top_sub_menu',$(this)).css('display','none');
		}
	);
	
	
	
	$(".tabs > ul > li.tab").live('click', function() {
		var id = $('a',$(this)).attr('href');
		
		$("li.tab > a", $(this).parent()).each(function() {
			$($(this).attr('href')).removeClass('active');
			$(this).parent().removeClass('active');
		});
		$(id).addClass('active');
		$(this).addClass('active');
		return false;
	});
	
	
	// Add form submit capability to buttons
	$(".submit").click(function() {
		var error = false;
		$('.required',$(this).parent().parent()).each(function(){
			if($(this).val()==''){ $(this).addClass('error'); error = true;}
			
		});
			
		if(error==true){
			$('#validation').fadeIn(900);
			$('input.error,textarea.error,select.error').click(function(){$(this).removeClass('error');$('#validation').fadeOut(900);});
			return false;
		}
		
		return true;
	});
	
	$('.video_img').each(function(){
		var w = $('img',$(this)).width();
		var h = $('img',$(this)).height();
		$('span',$(this)).width(w);
		$('span',$(this)).height(h);
		$('span',$(this)).css('opacity',0.5);
		$(this).hover(
			function(){$('span',$(this)).css('opacity',0.7);},
			function(){$('span',$(this)).css('opacity',0.5);}
		)
	});
	
	$('img.photoset').each(function(){
		$(this).parent().append('<span class="layer"></span>').css({'position':'relative','display':'block'});
		var span = $(this).parent().find('span.layer');
		span.width($(this).width());
		span.height($(this).height());
		span.css({
			'opacity':0.5,
			'left': $(this).position().left,
			'top': $(this).position().top
		});
		span.hover(
			function(){$(this).css('opacity',0.7);},
			function(){$(this).css('opacity',0.5);}
		)
	});
	
	
	// hide #back-top first
	$("#goto_top").hide();
	
	// fade in #back-top
	$(function () {
		$(window).scroll(function () {
			if ($(this).scrollTop() > 100) {
				$('#goto_top').fadeIn();
			} else {
				$('#goto_top').fadeOut();
			}
		});

		// scroll body to 0px on click
		$('#goto_top').click(function () {
			$('body,html').animate({
				scrollTop: 0
			}, 800);
			return false;
		});
	});
	

});
