window.addEvent('domready',function(){
	var myTips = new Tips('.mootip');
	$('ews').setOpacity(0.5);
	$('ews').addEvents({
		mouseenter : function(){this.fade(0.5,1);},
		mouseleave : function(){this.fade(1,0.5);}
	});
	
	var msgDIVS = new Array();
	msgDIVS = $$('.msg');
	for(var i = 0; i<msgDIVS.length;i++){
		var closeBTN = new Element('a', {
		    'class': 'closeIcon',
		    'html': '<img src="images/close.png" alt="" \/>',
		    'title': 'Close this',
		    style : 'float:right;cursor:pointer;'
		});
		closeBTN.inject($(msgDIVS[i]) , 'top');
	}
	$$('a.closeIcon').addEvent('click',function(){
		var div = this.parentNode;
		slideFX = new Fx.Slide(this.parentNode);
		slideFX.slideOut().chain(function(){
			div.destroy();
			});
	});
	
	/* TOPMENU */
	for(var i=0;i<$$('a.tm.active').length;i++){ var t = new Element('img', {src : 'images/header-topmenu-'+$$('a.tm.active')[i].id+'-h.jpg',alt: ''}).inject($$('a.tm.active')[i]); }
	$$('a.tm').addEvents({
		mouseenter : function(){
			if(this.className != "tm active" && this.className == "tm"){
				var t = new Element('img', {'id' : this.id+'IMG',src : 'images/header-topmenu-'+this.id+'-h.jpg',alt: ''});
				t.setOpacity(0);
				t.inject(this);
				var x = new Fx.Tween($(this.id+'IMG'), {duration:100});
				x.start('opacity' , 0 , 1 );
			}
		},
		mouseleave : function(){
			try{
				if(this.className != "tm active" && this.className == "tm"){
					var id = this.id;
					var x = new Fx.Tween($(id+'IMG'), {duration:500});
					x.start('opacity' , 1 , 0 ).chain(function(){$(id+'IMG').destroy();});
				}
			}catch(z){};
		}
	});
	
	
	try{
		$('loginS').addEvents({
			mouseenter : function(){this.src='images/login-submit-h.jpg';},
			mouseleave : function(){this.src='images/login-submit-h.jpg';}
		});
	}catch(z){};
	
	try{
		new FormCheck('srForm');
	}catch(z){};
});

/* FANCY TABLES */
var fancyTables = {
	init: function(){
		try{
			$$('tr.rplThis.odd').addEvents({
				'mouseenter' : function(){
					var rr = this.getElements('td');
					for(var i = 0; i < rr.length; i++){
						var x = new Fx.Tween($(rr[i]),{duration:0});
						x.start('backgroundColor', '#ffffff' , '#ffe9b4');
					}
				},
				'mouseleave' : function(){
					var rr = this.getElements('td');
					for(var i = 0; i < rr.length; i++){
						var x = new Fx.Tween($(rr[i]),{duration:200});
						x.start('backgroundColor', '#ffe9b4' , '#ffffff');
					}
				}
			});
			$$('tr.rplThis.even').addEvents({
				'mouseenter' : function(){
					var rr = this.getElements('td');
					for(var i = 0; i < rr.length; i++){
						var x = new Fx.Tween($(rr[i]),{duration:0});
						x.start('backgroundColor', '#f0e7da' , '#ffe9b4');
					}
				},
				'mouseleave' : function(){
					var rr = this.getElements('td');
					for(var i = 0; i < rr.length; i++){
						var x = new Fx.Tween($(rr[i]),{duration:200});
						x.start('backgroundColor', '#ffe9b4' , '#f0e7da');
					}
				}
			});
		}catch(z){};
	}
}
window.addEvent('domready',fancyTables.init);

/* PRODUCT ELEMENTS */
var highlighter = {
	init : function(){
		try{
			$$('div.pItem').addEvents({
				mouseenter : function(){
					var efx = new Fx.Tween(this, {duration:100});
					efx.start('backgroundColor' , '#f5f5f5' , '#ffffff');
				},
				mouseleave: function(){
					var efx = new Fx.Tween(this, {duration:500});
					efx.start('backgroundColor' , '#ffffff' , '#f5f5f5');
				}
			})
		}catch(z){};
	}
}
window.addEvent('domready',highlighter.init);

//FROMS AND CREATE FORMCHECK
window.addEvent('domready' , function(){
	forms = $$('form');
	for(var i = 0; i < forms.length; i++){
		var idSS = forms[i].get("id");
		new FormCheck(idSS);
	}
} );
