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);
		});
	}
	$$('.banlink').addEvent('mouseover',function(){
		var ban="ban"+this.rel;
		var rel=this.rel;
		$$('.banlink').each(function(a,i){
			if(a.rel==rel){
				a.addClass("curr");	
			}else{
				a.removeClass("curr");	
			}
		});
		$$('.banner').each(function(a,i){
			if(a.id!=ban){
				a.setStyle("display","none");
			}
		});
		if($(ban).getStyle("display")=="none"){
			$(ban).setStyle("opacity",0);
			$(ban).fade('in');
			$(ban).setStyle("display","block");
		}
		
	});
	$$('.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;
	});


	//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;

			}

		});	
		
		
		
		    $('show_comments2').addEvent('click', function(e){

			//e.stop();

			if (commentsStatus == false)

			{

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

				commentsStatus = true;

			}

		});	

	}

	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;

			}

		});	
		
		
		
		
		
		
		$('add_comment2').addEvent('click', function(e){

			//e.stop();

			if (formStatus == false)
			{

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

				formStatus = true;

			}

		});
	}

	new SmartHoverBox({



		yOffset: 5, //set your options in here



		xOffset: 0,



		lockY:'bottom',



		lockX:'left',

		smartBoxSuffix  : '_smarthbox'


	}); 


	$$('#field1, #field2, #field3, #field4, #field5, #field6').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','#2a9fd6');



		}



	



	});

	

});