
function create_swither()
{
}

$(document).ready(function(){

hs.showCredits = 0;
hs.padToMinWidth = true;
hs.graphicsDir = '/web/view/front/hs/';
if (hs.addEventListener && hs.Outline) hs.addEventListener(window, 'load', function () {
	new hs.Outline('rounded-white');
	new hs.Outline('glossy-dark');
});
hs.Expander.prototype.onAfterExpand = function() {
	if (this.a.id == 'contactAnchor') {
		var iframe = window.frames[this.iframe.name],
			doc = iframe.document;
    	if (doc.getElementById("theForm")) {
        	doc.getElementById("theForm").elements["name"].focus();
    	}

	}
};


	var width_body=parseInt($('body').innerWidth());
	var widths=[1280,1600,2000,3000];
	for(var i=0;i<widths.length-1;i++)
		if(width_body<widths[i])
			break;
	var src=' transparent   top center  no-repeat url(/web/view/front/img/backgrounds/'+background+'_'+widths[i]+'.jpg)';
	$('body').css("background",src);

	//create_swither();

$("#all-content div.center div.left").mouseover(function(){
	$(this).children('div.content').css('opacity','1');
	$(this).children('div.content').css('filter','alpha(opacity=100)');
});

$("#all-content div.center div.left").mouseout(function(){
	$(this).children('div.content').css('opacity','0.5');
	$(this).children('div.content').css('filter','alpha(opacity=50)');
});
	$('#bills li a').live('mouseover',function(){
		$(this).find('.afisha').stop();
		$(this).find('.afisha').animate({'height':170});
	});
	
	$('#bills li a').live('mouseleave',function(){
		$(this).find('.afisha').stop();
		$(this).find('.afisha').animate({'height':0});
	});
	
	$('ul#switcher li').live('mouseover',function(){
		$(this).find('div.dateshow').stop();
		$(this).find('div.dateshow').animate({'height':23},200);
	   });
	$('ul#switcher li').live('mouseleave',function(){
		$(this).find('div.dateshow').stop();
		$(this).find('div.dateshow').animate({'height':0},200);
	   });


function mainGalery(){
	var sec=this;
	sec.length=$('.left .view ul li').length;
	if(sec.length==0)return;
	sec.width=parseInt($('.view  li:first').innerWidth());
	sec.current=0;
	sec.ul=$('.left .view ul');
	sec.all=new Array();
	$('.view ul li').each(function(){
		sec.all.push($(this).css('background'));})
	
	sec.createElement=function(n,width){
//		alert(n);
		return '<li style=\'background:'+sec.all[n]+';width:'+width+'px;\'></li>';}
		
	sec.getNumber=function(n){
		if(n<0)	return ((sec.current+n)<0)?(sec.length+sec.current+n):(sec.current+n);
		else return ((sec.current+n)>=sec.length)?(sec.current+n-sec.length):(sec.current+n);}
			
	sec.first=function(){
		sec.ul.empty().css('margin-left',-sec.width);
		sec.ul.append(sec.createElement( sec.getNumber(-1),sec.width)+sec.createElement(sec.current,sec.width));};
	
	sec.toLeft=function(){
		if($('.left .view ul li:animated').length>0) return;
		sec.current=sec.getNumber(-1);
		sec.ul.prepend(sec.createElement(sec.getNumber(-1),0));
		sec.ul.find('li:first').animate({'width':sec.width},function(){sec.ul.find('li:last').remove();});};

	sec.toRight=function(isInterval){
		if($('.left .view ul li:animated').length>0) return;
		sec.current=sec.getNumber(1);
		sec.ul.append(sec.createElement(sec.current,sec.width));
		sec.ul.find('li:first').animate({'width':0},function(){sec.ul.find('li:first').remove();});
		if(!isInterval)clearInterval(intervalGallery);
	};

}
var intervalGallery=null;
var obj=new mainGalery();
if(obj.length>0)obj.first();

$('.left-buttons').live('click',function(){
	obj.toLeft();
});

$('.right-buttons').live('click',function(){
	obj.toRight(false);
});
if($('.left-buttons').length) intervalGallery=setInterval(function(){obj.toRight(true);},4000);
});




	var showes=function()
	{
		var content=new Array();
		var curBill=0;
		var width;
		var length;
		$(document).ready(function(){
			width=$('ul#bills li').outerWidth();
			var i=0
			$('ul#bills li').each(function(){
				if($(this).find('div:first').is('.active')) {
					curBill=i;
					$('ul#switcher li.active').removeClass('active');}
				content[i]='<li style="width:0px;">'+$(this).html()+'</li>';
				$('ul#switcher').append('<li '+((i==curBill)?'class="active"':'')+'><div class="dateshow">'+$(this).find('div:first').html()+'</div></li>');
				$(this).remove();
				i++;});
			length=content.length;
			$('ul#bills').append(content[(curBill==0)?(length-1):(curBill-1)]);
			$('ul#bills').append(content[curBill]);
			$('ul#bills').append(content[(curBill==(length-1))?0:(curBill+1)]);
			$('ul#bills').css('marginLeft',-width);
			$('ul#bills li').css('width',width);
		});
		
		$('.right-buttons-bot').live('click',function(){	
			if($('ul#bills li:animated').length>0)return;
			if(curBill==0)
			{
				curBill=(length-1)
				$('ul#switcher li.active').removeClass('active');
				$('ul#switcher li:last').addClass('active');
			}else{
				curBill=(curBill-1);
				$('ul#switcher li.active').removeClass('active').prev().addClass('active');
			}
			$('ul#bills').prepend(content[(curBill==0)?(length-1):(curBill-1)]);
			$('ul#bills li:last').remove();
			$('ul#bills li:first').animate({'width':width},250);

		  });

		$('.left-buttons-bot').live('click',function(){
			if($('ul#bills li:animated').length>0)return;
			if(curBill==(length-1))
			{
				$('ul#switcher li.active').removeClass('active');
				$('ul#switcher li:first').addClass('active');
				curBill=0;
			}else{
				curBill=(curBill+1);
				$('ul#switcher li.active').removeClass('active').next().addClass('active');
			};
			$('ul#bills li:first').animate({'width':0},250,function(){
						$(this).remove();
						$('ul#bills').append(content[(curBill==(length-1))?0:(curBill+1)]);
						$('ul#bills li:last').css('width',width);
			});

		});
		$('ul#switcher li:not(.active)').live('click',function()
		   {
				if($('ul#bills li:animated').length>0)return;
			   var w=145;
			   var cur_numb=0;
			   var now_active;
			   $('ul#switcher li.active').removeClass('active');
			   $(this).addClass('active');
				$('ul#switcher li').each(function(){
					if($(this).is('.active')) now_active=cur_numb;
					cur_numb++;
				});
				if(curBill>now_active){
					curBill=now_active;
					$('ul#bills li:last').replaceWith(content[curBill]);
					$('ul#bills li:last').css('width',width);
					$('ul#bills li:first').animate({'width':0},250,function(){
						$(this).remove();
						$('ul#bills').append(content[(curBill==(length-1))?0:(curBill+1)]);
						$('ul#bills li:last').css('width',width);
					$('ul#bills li:first').replaceWith(content[(curBill==0)?(length-1):(curBill-1)]);
					$('ul#bills li:first').css('width',width);
						})
				}else{
					curBill=now_active;
					$('ul#bills li:first').replaceWith(content[curBill]);
					$('ul#bills li:first').css('width',width);
					$('ul#bills ').prepend(content[(curBill==0)?(length-1):(curBill-1)]);
					$('ul#bills li:first').animate({'width':145},250,function(){
						$('ul#bills li:last').remove();
					$('ul#bills li:last').replaceWith(content[(curBill==(length-1))?0:(curBill+1)]);
					$('ul#bills li:last').css('width',width);
						})

				};
   });

	}
	var show=new showes();

function sendcoment()
{
	var name=$('input[name=data\[name\]]').val();
	if(name.length<1)
	{
		$('input[name=data\[name\]]').css('border','1px solid #510404');
		$('input[name=data\[name\]]').focus();
		return;
	}
	var content=$('textarea').val()
	if(content.length<1)
	{
		$('textarea').css('border','1px solid #510404');
		$('textarea').focus();
		return;
	}
	document.ansver.submit();
}

function mxStopPlayerTop()
{
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	var player = (isIE) ? window['player-top-xml'] : document['player-top-xml'];
	if(player!=undefined)
	{
		player.mxStopPlayerTop();
	}

}

function mxStopPlayerRight()
{
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	var player = (isIE) ? window['player_right'] : document['player_right'];
	if(player!=undefined)
	{
		player.mxStopPlayerRight();
	}
}

function mxStopPlayerContent()
{
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	var player = (isIE) ? window['flashFullPlayer'] : document['flashFullPlayer'];
	if(player!=undefined)
	{
		player.mxStopPlayerContent();
	}
}