window.addEvent('domready', function() {
	if(document.getElementById("bigimg")){
		//var bigh=$("bigimg").getSize().y;
		//$("bigimg").setStyle("max-height",bigh);
		$$('.smallimg').addEvent('mouseenter',function(){
			$("bigimg").set("src",this.src);
		});
	}

	if(document.getElementById("slider")){
			
		//slider variables for making things easier below
		var itemsHolder = $('container');
		var myItems = $$(itemsHolder.getElements('.item'));
		
		//controls for slider
		var theControls = $('controls1');
		var numNavHolder = $(theControls.getElement('ul'));
	//	var thePlayBtn = $(theControls.getElement('.play_btn'));
	//	var thePrevBtn = $(theControls.getElement('.prev_btn'));
	//	var theNextBtn = $(theControls.getElement('.next_btn'));
		
		
		//create instance of the slider, and start it up		
		var mySlider = new SL_Slider({
			slideTimer: 6000,
			orientation: 'none',      //vertical, horizontal, or none: None will create a fading in/out transition.
			fade: true,                    //if true will fade the outgoing slide - only used if orientation is != None
			isPaused: false,
			container: itemsHolder,
			items: myItems,
			numNavActive: true,
			numNavHolder: numNavHolder,
		});
		mySlider.start();
		
		
		//adding a little animated rollover highlight to the play and prev/next buttons
	//	var origBkgdColor = thePlayBtn.getStyle('background-color');
		var newBkgdColor = "#80301D";
		//var btnArray = new Array(thePlayBtn, thePrevBtn, theNextBtn);
	/*	
		btnArray.each(function(e, i){
			e.set('tween', {duration: 350, transition: 'cubic:out', link: 'cancel'});
			e.addEvents({ 
				'mouseenter' : function() {
					this.tween('background-color', newBkgdColor);
				},
				'mouseleave' : function() {
					this.tween('background-color', origBkgdColor);
				}
			});
		});					 */
	}
	
	


	$$('.subclick').addEvent('click',function(){
		var subel=$("sub"+this.title);
		if(subel.getStyle("display")=="none"){
			subel.setStyle("display","block");
			this.set("html","-");
		}else{
			this.set("html","+");
			subel.setStyle("display","none");
		}
		
		return false;
	});
	
	if(document.getElementById('scrdown')){
		$('scrdown').addEvent('click',function(e){
			el=$('scroll');
			var elsize = el.getScrollSize();
			var elto=el.getScroll();
			var newy=(elto.y+30);
			//alert("H: "+el.getStyle('height')+" SH: "+elsize.y+" CURR: "+elto.y+" NEWY: "+newy);
			el.scrollTo(0,newy);
			return false;
		});
		
		$('scrup').addEvent('click',function(){
			el=$('scroll');
			var elsize = el.getScrollSize();
			var elto=el.getScroll();
			var newy=(elto.y-30);
			//alert("H: "+el.getStyle('height')+" SH: "+elsize.y+" CURR: "+elto.y+" NEWY: "+newy);
			el.scrollTo(0,newy);
			return false;
		});
	}
	$$('.tab').addEvent('mouseover',function(){
			    $$('.tab').each(function(argument, index){
					argument.removeClass('current');
			    });
				this.addClass('current');
				$("showproducts").erase("class");
				$("showproducts").addClass(this.get('href'));
	});
	$$('.tab').addEvent('click',function(){
		return false;
	});
	$$('#anav a').addEvent('mouseover',function(){
		$$('#anav a').each(function(argument, index){
			argument.removeClass('active_hint');
		});
		this.addClass('active_hint');
		$("answers").erase("class");
		$("answers").addClass(this.get('href'));
		return false;
	});

	//brands function
	if (document.getElementById('brandbtn')){
		var brandul=$('brandul');
		var startheight=brandul.getSize().y;
		brandul.setStyle('height',80);
		brandul.setStyle('overflow','hidden');

//		alert(startheight);
		$('brandbtn').addEvent('click', function(){
			var el=brandul;
			var current=el.getStyle('height');
			if(current=='80px'){
				var myEffect = new Fx.Morph(el, {duration: 'long', transition: Fx.Transitions.Sine.easeOut}); 
				myEffect.start({
					'height': [80, startheight] //Morphs the 'height' style from 10px to 100px.
	//				'width': [900, 300]  //Morphs the 'width' style from 900px to 300px.
				});
			}else{
				var myEffect = new Fx.Morph(el, {duration: 'long', transition: Fx.Transitions.Sine.easeOut}); 
				myEffect.start({
					'height': [startheight,80] //Morphs the 'height' style from 10px to 100px.
	//				'width': [900, 300]  //Morphs the 'width' style from 900px to 300px.
				});
			}
			return false;
			
		});

	}
	//
	
	var commentsStatus = false;

	var formStatus = false;

	if (document.getElementById('allcomments'))

	{

		$('allcomments').setStyle('display', 'none');

		$('show_comments').addEvent('click', function(e){

			e.stop();

			if (commentsStatus == false)

			{

				$('allcomments').setStyle('display', 'block');

				$('show_comments').set('html', 'Скрий коментарите');

				commentsStatus = true;

			}

			else

			{

				$('allcomments').setStyle('display', 'none');

				$('show_comments').set('html', 'Покажи всички коментари');

				commentsStatus = false;

			}

		});	

	}

	if (document.getElementById('comments_form'))

	{

		$('comments_form').setStyle('display', 'none');

		$('add_comment').addEvent('click', function(e){

			e.stop();

			if (formStatus == false)

			{

				$('comments_form').setStyle('display', 'block');

				formStatus = true;

			}

			else

			{

				$('comments_form').setStyle('display', 'none');

				formStatus = false;

			}

		});	

		

	}

	new SmartHoverBox({



		yOffset: -260, //set your options in here



		xOffset: -10,



		lockY:'bottom',



		lockX:'left'



	}); 


	$$('#field1, #field2, #field3, #field4, #field5, #field6, #fieldt').addEvents({



		'keydown':function(){



			name=this.id;



			newname=this.id+"-2";



		},



		



		'keyup':function(){



			name=this.id;



			newname=this.id+"-2";



			$(newname).value=this.value;



		},



		



		'blur':function(){



			name=this.id;



			newname=this.id+"-2";



			$(newname).value=this.value;



			$(newname).setStyle('color','#000000');



		},



		



		'focus':function(){



			name=this.id;



			newname=this.id+"-2";



			$(newname).setStyle('color','#ff0000');



		}



	



	});

	

});