//CSS menu (для IE)
function cssmenuhover()
{
        if(!document.getElementById("cssmenu"))
                return;
        var lis = document.getElementById("cssmenu").getElementsByTagName("LI");
        for (var i=0;i<lis.length;i++)
        {
                lis[i].onmouseover=function(){this.className+=" iehover";}
                lis[i].onmouseout=function() {this.className=this.className.replace(new RegExp(" iehover\\b"), "");}
        }
}
if (window.attachEvent) window.attachEvent("onload", cssmenuhover);

navHover = function() {
	var lis = document.getElementById("navmenu-v").getElementsByTagName("LI");
	for (var i=0; i<lis.length; i++) {
		lis[i].onmouseover=function() {
			this.className+=" iehover";
		}
		lis[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", navHover);

//jGrowl
(function($){$.jGrowl=function(m,o){if($('#jGrowl').size()==0)
$('<div id="jGrowl"></div>').addClass((o&&o.position)?o.position:$.jGrowl.defaults.position).appendTo('body');$('#jGrowl').jGrowl(m,o);};$.fn.jGrowl=function(m,o){if($.isFunction(this.each)){var args=arguments;return this.each(function(){var self=this;if($(this).data('jGrowl.instance')==undefined){$(this).data('jGrowl.instance',$.extend(new $.fn.jGrowl(),{notifications:[],element:null,interval:null}));$(this).data('jGrowl.instance').startup(this);}
if($.isFunction($(this).data('jGrowl.instance')[m])){$(this).data('jGrowl.instance')[m].apply($(this).data('jGrowl.instance'),$.makeArray(args).slice(1));}else{$(this).data('jGrowl.instance').create(m,o);}});};};$.extend($.fn.jGrowl.prototype,{defaults:{pool:0,header:'',group:'',sticky:false,position:'top-right',glue:'after',theme:'default',themeState:'highlight',corners:'10px',check:250,life:3000,closeDuration:'normal',openDuration:'normal',easing:'swing',closer:true,closeTemplate:'&times;',closerTemplate:'<div>[ close all ]</div>',log:function(e,m,o){},beforeOpen:function(e,m,o){},afterOpen:function(e,m,o){},open:function(e,m,o){},beforeClose:function(e,m,o){},close:function(e,m,o){},animateOpen:{opacity:'show'},animateClose:{opacity:'hide'}},notifications:[],element:null,interval:null,create:function(message,o){var o=$.extend({},this.defaults,o);if(typeof o.speed!=='undefined'){o.openDuration=o.speed;o.closeDuration=o.speed;}
this.notifications.push({message:message,options:o});o.log.apply(this.element,[this.element,message,o]);},render:function(notification){var self=this;var message=notification.message;var o=notification.options;var notification=$('<div class="jGrowl-notification '+o.themeState+' ui-corner-all'+
((o.group!=undefined&&o.group!='')?' '+o.group:'')+'">'+'<div class="jGrowl-close">'+o.closeTemplate+'</div>'+'<div class="jGrowl-header">'+o.header+'</div>'+'<div class="jGrowl-message">'+message+'</div></div>').data("jGrowl",o).addClass(o.theme).children('div.jGrowl-close').bind("click.jGrowl",function(){$(this).parent().trigger('jGrowl.close');}).parent();$(notification).bind("mouseover.jGrowl",function(){$('div.jGrowl-notification',self.element).data("jGrowl.pause",true);}).bind("mouseout.jGrowl",function(){$('div.jGrowl-notification',self.element).data("jGrowl.pause",false);}).bind('jGrowl.beforeOpen',function(){if(o.beforeOpen.apply(notification,[notification,message,o,self.element])!=false){$(this).trigger('jGrowl.open');}}).bind('jGrowl.open',function(){if(o.open.apply(notification,[notification,message,o,self.element])!=false){if(o.glue=='after'){$('div.jGrowl-notification:last',self.element).after(notification);}else{$('div.jGrowl-notification:first',self.element).before(notification);}
$(this).animate(o.animateOpen,o.openDuration,o.easing,function(){if($.browser.msie&&(parseInt($(this).css('opacity'),10)===1||parseInt($(this).css('opacity'),10)===0))
this.style.removeAttribute('filter');$(this).data("jGrowl").created=new Date();$(this).trigger('jGrowl.afterOpen');});}}).bind('jGrowl.afterOpen',function(){o.afterOpen.apply(notification,[notification,message,o,self.element]);}).bind('jGrowl.beforeClose',function(){if(o.beforeClose.apply(notification,[notification,message,o,self.element])!=false)
$(this).trigger('jGrowl.close');}).bind('jGrowl.close',function(){$(this).data('jGrowl.pause',true);$(this).animate(o.animateClose,o.closeDuration,o.easing,function(){$(this).remove();var close=o.close.apply(notification,[notification,message,o,self.element]);if($.isFunction(close))
close.apply(notification,[notification,message,o,self.element]);});}).trigger('jGrowl.beforeOpen');if(o.corners!=''&&$.fn.corner!=undefined)$(notification).corner(o.corners);if($('div.jGrowl-notification:parent',self.element).size()>1&&$('div.jGrowl-closer',self.element).size()==0&&this.defaults.closer!=false){$(this.defaults.closerTemplate).addClass('jGrowl-closer ui-state-highlight ui-corner-all').addClass(this.defaults.theme).appendTo(self.element).animate(this.defaults.animateOpen,this.defaults.speed,this.defaults.easing).bind("click.jGrowl",function(){$(this).siblings().trigger("jGrowl.beforeClose");if($.isFunction(self.defaults.closer)){self.defaults.closer.apply($(this).parent()[0],[$(this).parent()[0]]);}});};},update:function(){$(this.element).find('div.jGrowl-notification:parent').each(function(){if($(this).data("jGrowl")!=undefined&&$(this).data("jGrowl").created!=undefined&&($(this).data("jGrowl").created.getTime()+parseInt($(this).data("jGrowl").life))<(new Date()).getTime()&&$(this).data("jGrowl").sticky!=true&&($(this).data("jGrowl.pause")==undefined||$(this).data("jGrowl.pause")!=true)){$(this).trigger('jGrowl.beforeClose');}});if(this.notifications.length>0&&(this.defaults.pool==0||$(this.element).find('div.jGrowl-notification:parent').size()<this.defaults.pool))
this.render(this.notifications.shift());if($(this.element).find('div.jGrowl-notification:parent').size()<2){$(this.element).find('div.jGrowl-closer').animate(this.defaults.animateClose,this.defaults.speed,this.defaults.easing,function(){$(this).remove();});}},startup:function(e){this.element=$(e).addClass('jGrowl').append('<div class="jGrowl-notification"></div>');this.interval=setInterval(function(){$(e).data('jGrowl.instance').update();},parseInt(this.defaults.check));if($.browser.msie&&parseInt($.browser.version)<7&&!window["XMLHttpRequest"]){$(this.element).addClass('ie6');}},shutdown:function(){$(this.element).removeClass('jGrowl').find('div.jGrowl-notification').remove();clearInterval(this.interval);},close:function(){$(this.element).find('div.jGrowl-notification').each(function(){$(this).trigger('jGrowl.beforeClose');});}});$.jGrowl.defaults=$.fn.jGrowl.prototype.defaults;})(jQuery);


$(document).ready(function(){
	$("#gmail").colorbox({iframe:true, innerWidth:425, innerHeight:330}); 
	$("#youfeed").colorbox({iframe:true, innerWidth:425, innerHeight:420}); 
	//pikak

	$(".pika-stage .pikai").colorbox(); 
	$(".pika-stage .pikak").colorbox(); 
	$(".datepicker").datepicker();
	$("#datepickerleft").datepicker();
	$('#coda-slider-1').codaSlider();
	
	$('.panel').css('display', 'none');
	$('#pa1').css('display','block');
	
	//$("#tabs").tabs();
	var $tabs = $('#tabs').tabs();
	
	$("#ultabs2 a").click(function(){
		var d = $(this).attr('id').replace('r','');
		$("#ultabs2 li").attr('class','ui-state-default ui-corner-top');
		$('#do'+d).attr('class','ui-state-default ui-corner-top ui-tabs-selected ui-state-active');
		//$('#tabs').tabs('select', d);
		$tabs.tabs('select', d);
		return false;
		//alert(d);
	});
	
	
	$('#coda-nav-2 li').click(function(){
		var tab = $(this).attr('class');
		//$('#coda-nav-2 li a').attr('class', '');
		
		//class="current"
		//alert(tab);
		$('#coda-nav-1 .'+tab+' a').click();
		//$($(this)).find('a').attr('class', 'current');
		//alert();
	});

	$( ".tabs-bottom .ui-tabs-nav, .tabs-bottom .ui-tabs-nav > *" ).removeClass( "ui-corner-all ui-corner-top" ).addClass( "ui-corner-bottom" );
	// $(".tatr").easyTooltip({
		// tooltipId: "easyTooltip2",
		// content: '<h4>Какой хороший сайт</h4><p>Вы когда нибудь видели такой хороший сайт, <strong>consectetur</strong> adipiscing elit. Mauris placerat.</p>'
	// });
$('#doptou').load(function() {
	$('#ultabs li a').each(function(){
		var dd= $(this).attr('id');
		var dd0 = dd.replace('b','');
		$("#"+dd).attr('href', $('#doptou').attr('rel')+'#tabs-'+dd0);
	});
});
	
	//Опросы////////////////////////////////////////
	$(".votetable input").click( function() {
		var id = $(this).attr('value');
		var cl = $(this).attr('class');
		//alert(cl);
		$.get("js/funcajax.php", { 'cid': id, 'type': 'vote' }, function(data){
			//alert(id);
			if(data == 'cvotes')
			{
				$('#votab'+cl).remove();
				$.jGrowl("Вы уже принимали участие в этом опросе!");
			}else{
				$('#votab'+cl).empty();
				$('#votab'+cl).html(data);
			}
		});
	});
	///////////////////////////////////////////////
	//$('#ultabs li').click(function(){
		//alert($(this).width());
		//$('#ultabs li').each(function() {
			//alert(i.width());
			//alert($(this).width());
		//});

	//});
	$('#fmenu #cssmenu2 li').hover(function(){ /*alert();*/ if($(this).find('ul').height()){ var dd = $(this).find('ul').height(); dd = (dd-2); }  $('#cssmenu2 ul').css('top', '-'+dd+'px'); }, function(){ });
	
	$('.fsend').click(function(){
		if($('form[class=gorline]').attr('action'))
		{
			if(!$('input[name=fname]').attr('value')) { $.jGrowl('Заполните поле <b>От кого</b>');	return false;	}
			if(!$('input[name=fsvyaz]').attr('value')) { $.jGrowl('Заполните поле <b>Обратная связь</b>');	return false;	}
			if(!$('input[name=fcapcha]').attr('value')) { $.jGrowl('Введите текст с картинки');	return false;	}
			$('.gorline').submit();
			return false;
		}

		if($('form[class=pochtaline]').attr('action'))
		{
			if(!$('input[name=fname]').attr('value')) { $.jGrowl('Заполните поле <b>От кого</b>');	return false;	}
			if(!$('input[name=fsvyaz]').attr('value')) { $.jGrowl('Заполните поле <b>Обратная связь</b>');	return false;	}
			if(!$('input[name=fcapcha]').attr('value')) { $.jGrowl('Введите текст с картинки');	return false;	}
			$('.pochtaline').submit();
			return false;
		}
		
		if($('form[class=propusk]').attr('action'))
		{
			if(!$('input[name=fname]').attr('value')) { $.jGrowl('Заполните поле <b>ФИО</b>');	return false;	}
			if(!$('input[name=fdate]').attr('value')) { $.jGrowl('Укажите дату');	return false;	}
			if(!$('input[name=fcapcha]').attr('value')) { $.jGrowl('Введите текст с картинки');	return false;	}
			$('.propusk').submit();
			return false;		
		}
		
		if($('form[class=emaillist]').attr('action'))
		{
			if(!$('input[name=agname]').attr('value')) 	{	$.jGrowl('Заполните поле <b>Название агентства</b>');	return false;	}
			if(!$('input[name=city]').attr('value')) 	{	$.jGrowl('Заполните поле <b>Город</b>');				return false;	}
			if(!$('input[name=fiouse]').attr('value')) 	{	$.jGrowl('Заполните поле <b>Контактное лицо</b>');		return false;	}
			if(!$('input[name=tellp]').attr('value')) 	{	$.jGrowl('Заполните поле <b>Телефон</b>');				return false;	}
			if(!$('input[name=email]').attr('value')) 	{	$.jGrowl('Заполните поле <b>E-mail</b>');				return false;	}
			if(!$('input[name=fcapcha]').attr('value')) { 	$.jGrowl('Введите текст с картинки');					return false;	}
			$('.emaillist').submit();
			return false;		
		}		
		
		if($('form[class=bronirov]').attr('action'))
		{
			if(!$('input[name=fname]').attr('value')) { 		$.jGrowl('Заполните поле <b>ФИО заказчика</b>');									return false;	}
			if(!$('input[name=ftelefo]').attr('value')) {		$.jGrowl('Заполните поле <b>Контактные телефоны </b>');								return false;	}
			if(!$('input[name=femail]').attr('value')) {	 	$.jGrowl('Заполните поле <b>E-mail</b>');											return false;	}
			if(!$('input[name=flagername]').attr('value')) { 	$.jGrowl('Заполните поле <b>Название лагеря </b>');									return false;	}
			if(!$('input[name=fsmenanum]').attr('value')) {		$.jGrowl('Заполните поле <b>Смена</b>');											return false;	}
			if(!$('input[name=fjdtyda]').attr('value')) {		$.jGrowl('Заполните поле <b>Ж/д проезд</b>');										return false;	}
			if(!$('input[name=fjdobratno]').attr('value')) { 	$.jGrowl('Заполните поле <b>Ж/д проезд</b>');										return false;	}
			if(!$('input[name=ffioreba]').attr('value')) { 		$.jGrowl('Заполните поле <b>ФИО ребенка</b>');										return false;	}
			if(!$('input[name=fdateborn]').attr('value')) { 	$.jGrowl('Заполните поле <b>Дата рождения </b>');									return false;	}
			if(!$('input[name=fpasport]').attr('value')) { 		$.jGrowl('Заполните поле <b>Документ, по которому ребенок поедет в лагерь </b>');	return false;	}
			if(!$('input[name=fadresrow]').attr('value')) { 	$.jGrowl('Заполните поле <b>Адрес проживания </b>');								return false;	}
			if(!$('input[name=ftellpar]').attr('value')) { 		$.jGrowl('Заполните поле <b>Телефон родителей</b>');								return false;	}
			if(!$('input[name=ffiopar]').attr('value')) { 		$.jGrowl('Заполните поле <b>ФИО родителей</b>');									return false;	}
			
			if(!$('input[name=fcapcha]').attr('value')) { $.jGrowl('Введите текст с картинки');														return false;	}
			$('.bronirov').submit();
			return false;
		}		
	});
	
	$('.freload').click(function(){
		//$('#fcapcha').attr('src', $('#fcapcha').attr('src'));
		document.getElementById('fcapcha').src = 'libs/kcaptcha/';
		//alert($('#fcapcha').attr('src'));
	});
	
	////////////////////////////////////////////////////////////////////////
	/////////////////////////////////*Верхнее меню*/////////////////////////
	$('.odleft td').hover(
	function(){
		//alert('ssss');
		var id = $(this).attr('id').replace('fl','');
		//alert(id);
		$('#st'+id).css('display','table');
	},
	function(){
		
		var id = $(this).attr('id').replace('fl','');
		if($('#fl'+id+' a').attr('class') != 'hova')
		{
			$('#st'+id).css('display','none');
		}

	}
	);
	
	$('.lact').hover(
	
		function()
		{
			//var id = $(this).attr('id').replace('st','');
			$(this).css('display','table');
		},
		function()
		{
			var id = $(this).attr('id').replace('st','');
			if($('#fl'+id+' a').attr('class') != 'hova')
			{
				$(this).css('display','none');
			}
		}		
	
	);
	
});


