/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);
/**
 * jQuery Color Animations
 * Copyright 2007 John Resig
 * Released under the MIT and GPL licenses.
 */
(function(jQuery){jQuery.each(['backgroundColor','borderBottomColor','borderLeftColor','borderRightColor','borderTopColor','color','outlineColor'],function(i,attr){jQuery.fx.step[attr]=function(fx){if(fx.state==0){fx.start=getColor(fx.elem,attr);fx.end=getRGB(fx.end)}fx.elem.style[attr]="rgb("+[Math.max(Math.min(parseInt((fx.pos*(fx.end[0]-fx.start[0]))+fx.start[0]),255),0),Math.max(Math.min(parseInt((fx.pos*(fx.end[1]-fx.start[1]))+fx.start[1]),255),0),Math.max(Math.min(parseInt((fx.pos*(fx.end[2]-fx.start[2]))+fx.start[2]),255),0)].join(",")+")"}});function getRGB(color){var result;if(color&&color.constructor==Array&&color.length==3)return color;if(result=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))return[parseInt(result[1]),parseInt(result[2]),parseInt(result[3])];if(result=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))return[parseFloat(result[1])*2.55,parseFloat(result[2])*2.55,parseFloat(result[3])*2.55];if(result=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))return[parseInt(result[1],16),parseInt(result[2],16),parseInt(result[3],16)];if(result=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))return[parseInt(result[1]+result[1],16),parseInt(result[2]+result[2],16),parseInt(result[3]+result[3],16)];return colors[jQuery.trim(color).toLowerCase()]}function getColor(elem,attr){var color;do{color=jQuery.curCSS(elem,attr);if(color!=''&&color!='transparent'||jQuery.nodeName(elem,"body"))break;attr="backgroundColor"}while(elem=elem.parentNode);return getRGB(color)};var colors={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]}})(jQuery);
var addthis_localize = {
	share_caption: "Recomanda LifeCare",
	email_caption: "Trimite pagina pe e-mail",
	email: "Prin e-mail",
	favorites: "Semn de carte", 
	more: "Mai multe&hellip;"
};
jQuery.fn.rdy = function(func){this.length && func.apply(this);return this}
var ie  = $.browser.msie && $.browser.version < 8;
var ie6 = ie ? $.browser.version == 6 : false;
var ie7 = ie ? $.browser.version == 7 : false;
var opera = $.browser.opera;

$(function()
{
	$('a[rel~=external]').attr('target','_blank');
	if ($.fn.jScrollPane) {
		$.extend($.fn.jScrollPane.defaults, {
			showArrows: true,
			arrowSize: 12,
			dragMinHeight: 50
		});
	}
	
	
	$('#lat-st-cautare').click(function(){
		$(this).parent().find('label[for=lat-st-cautare]').fadeOut('fast');
	}).blur(function(){
		if ( $(this).val() == '' )
			$(this).parent().find('label[for=lat-st-cautare]').fadeIn('fast');
	});

	
	// sÄ nu Č›ipe cÄ nu existÄ window.console dacÄ nu suntem Ă®n Firefox + Firebug Č™i uitÄm cĂ˘te-un console.x
	if (!window.console || !console.firebug) {
		var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
		window.console = {};
		for (var i = 0; i < names.length; ++i) {
			window.console[names[i]] = function () {}
		}
	}
	
	var ecran = {
		w: $(window).width(),
		h: $(window).height()
	}
	
	$(window).resize(function(){
		ecran.w = $(window).width()
		ecran.h = $(window).height()
		if ( ecran.w < 1100 ) {
			$('body').addClass('mic'); // activÄm CSS pentru versiunea micÄ
			if ( typeof(jScrollPane) === 'function' ) // nu merge jScrollPane, aČ™a cÄ nu facem nimic
				$('#nav-beneficii .c').show().find('.jScrollPaneContainer').parent().show().end().css('width',500).find('.drop-c-scroll').css('width',485).jScrollPane().end().parent().hide().parent().parent().find('.drop-c-tab:first-child').css('display','block').parent().parent().hide();
			if ( ecran.w > 980 && ie ) $('body').css('overflow-x','hidden')
			else $('body').removeAttr('style')
		}
		else{
			$('body').removeClass('mic').removeAttr('style'); // dezactivÄm CSS pentru versiunea micÄ
			if ( typeof(jScrollPane) === 'function' ) // nu merge jScrollPane, aČ™a cÄ nu facem nimic
				$('#nav-beneficii .c').show().find('.jScrollPaneContainer').parent().show().end().css('width',510).find('.drop-c-scroll').css('width',495).jScrollPane().end().parent().hide().parent().parent().find('.drop-c-tab:first-child').css('display','block').parent().parent().hide();		
			if ( ie7 ) $('body').css('overflow-x', 'hidden');
		}
		
	});
	if ( ecran.w < 1100 ) {
		$('body').addClass('mic');
		if ( ecran.w > 980 && ie ) $('body').css('overflow-x','hidden')
		else $('body').removeAttr('style');
	}
	else{
		$('body').removeClass('mic').removeAttr('style');
		if ( ie7 ) $('body').css('overflow-x', 'hidden');
	}
	
	if (opera) $('body').addClass('opera');
	
	
	$.tools.overlay.conf.speed = 50;
	$.tools.overlay.conf.opacity = 0.6;
	$.tools.overlay.conf.expose = {
		onBeforeLoad:function(){
			//if ( $( t.getTrigger() ).is('.inactiv') ) return false;
		}, 
		onLoad:function(){
			var t = this; 
			$( t.getExposed() ).addClass('modal-vizibil');
			$( t.getExposed() ).find('a[rel^=#]').click(function(){
				t.close();
			});
			
			window.step = 1;
		}, 
		onClose: function(){
			$( this.getExposed() ).removeClass('modal-vizibil');
			$('.print-inv').removeClass('print-inv');
		}, 
		color: '#000',
		loadSpeed:150,
		closeSpeed:150, 
		opacity: 0.6,
		absolute:false,  
		api:true
	};
	
	$('#posturi .post').each(function(){
		$(this).find('.desc').hide();
		$(this).find('.t').click(function(e){
			e.preventDefault();
			$(this).parent().find('.desc').toggle();
		});
	});
	
	if( $('#afisaj').length ) {
		var afis = $('#afisaj');
		afis.find('.but-hover').hide().end().cycle({
			timeout: 10000, 
			prev: '#afis-inapoi', 
			next: '#afis-inainte', 
			slideExpr: 'li:not(.but-hover)', 
			pause: true, 
			fastOnEvent: 500
		});
		
		if ($('#alege').length)
			$('#alege').hover(function() {
				//$('.afis-nav:visible').stop().fadeOut(250);
			}, function(){
				//$('.afis-nav:hidden').stop().fadeTo(250,1);
			}).find('li').hover(function() {
				afis.cycle('pause').find('#banner-' + $(this).attr("id").replace("alege-", "")).fadeIn(250);
			}, function() {
				afis.cycle('pause').find('#banner-' + $(this).attr("id").replace("alege-", "")).fadeOut(500);
			});
	}
	
	if( $('#pt1').is('.sel') ){
		$('#promo,#promo .in').css({
			'-webkit-border-bottom-left-radius':0,
			'-moz-border-radius-bottomleft':0,
			'border-radius-bottomleft':0
		});


	}	
	
	$('li:first-child').addClass('pri');
	$('li:last-child').addClass('ult');
	var limbaDeschide = function(){
		$('#limbi').addClass('deschis').animate({
			'height'		:	'115px'
		}, 200, function(){
			
		});

	};
	var limbaInchide = function(){
		$('#limbi').animate({
			'height'		:	'45px'
		}, 200, function(){
			$(this).removeClass('deschis');
		});
	};
	var limba = {
		sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
		interval: 200, // number = milliseconds for onMouseOver polling interval    
		over: limbaDeschide, // function = onMouseOver callback (REQUIRED)    
		timeout: 500, // number = milliseconds delay before onMouseOut    
		out: limbaInchide // function = onMouseOut callback (REQUIRED)
	};

	$('#alege-limba').hoverIntent(limba);

	var dropHover = {
		sensitivity: 3, 
		interval: 200, 
		timeout: 500, 
		over: function()
		{
			var t = $(this);
			var lateloading = false;
			
			/////////////////////////////////////////////////////
			
			if (t.context.id == 'nav-egeszseg')
			{
				var ajaxurl = "ajax/ajax_categories.php?category=8";
				var container = '#egeszsegContainer';
				var loadingCheck = sanatateLoaded;
				
				lateloading = true;
			}
			else
			if (t.context.id == 'nav-szepseg')
			{
				var ajaxurl = "ajax/ajax_categories.php?category=7";
				var container = '#szepsegContainer';
				var loadingCheck = frumuseteLoaded;
				
				lateloading = true;
			}
			else
			if (t.context.id == 'nav-haz')
			{
				var ajaxurl = "ajax/ajax_categories.php?category=3";
				var container = '#hazContainer';
				var loadingCheck = casaLoaded;
				
				lateloading = true;
			}
			
			if (lateloading)
			{
				if (!loadingCheck)
				{
					$.ajax({
						method: "get", url: ajaxurl,
						beforeSend: function() { t.find(container).html("<div class='loading-data'><img src='images/spinner.gif' align='absmiddle' /> terhelési adatok...</div>") }, 
						complete: function() {}, 
						success: function(html)
						{
							t.find(container).html(html);
							
							//if ( ie6 ) $('#continut select').each(function(){ t.hide() });
							var c = t.find('.c');
							c.each(function()
							{
								$(this).show();
								$(this).find('.drop-c-tab').each(function()
								{
									if ($(this).find('>.jScrollPaneContainer').length) return;
									
									if (!ie6) $(this).wrapInner('<div class="drop-c-scroll"></div>').find('.drop-c-scroll').jScrollPane({});
								}).end().hide();
							}).find('.drop-tabs').tabs('.drop-c-tab', {
								'current'	:	'sel'
							});
							t.find('h4').addClass('z');
							c.fadeIn(100, function(){
								t.addClass('drop-h');
								var c = t.find('.drop-c-col');
								var h = Math.max( c.height() );
								c.height( h );
							});
							
							$('#nav .cat-t').parent().hoverIntent(nivel);
						}
					});
					
					if (t.context.id == 'nav-beneficii')
						beneficiiLoaded = true;
					else
					if (t.context.id == 'nav-sanatate')
						sanatateLoaded = true;
					else
					if (t.context.id == 'nav-frumusete')
						frumuseteLoaded = true;
					else
					if (t.context.id == 'nav-casa')
						casaLoaded = true;
				}
			}
			
			//if ( ie6 ) $('#continut select').each(function(){ t.hide() });
			var c = t.find('.c');
			c.each(function(){
				$(this).show();
				$(this).find('.drop-c-tab').each(function()
				{
					if ($(this).find('>.jScrollPaneContainer').length) return;
					
					if (!ie6) $(this).wrapInner('<div class="drop-c-scroll"></div>').find('.drop-c-scroll').jScrollPane({});
				}).end().hide();
			}).find('.drop-tabs').tabs('.drop-c-tab', {
				'current'	:	'sel'
			});
			t.find('h4').addClass('z');
			c.fadeIn(100, function(){
				t.addClass('drop-h');
				var c = t.find('.drop-c-col');
				var h = Math.max( c.height() );
				c.height( h );
			});
		}, 
		out: function(){
			var t = $(this);
			//if ( ie6 ) $('#continut select').each(function(){ t.show() });
			var c = t.find('.c');
			t.find('h4').removeClass('z');
			c.fadeOut(150, function(){
				t.removeClass('drop-h');
				c.find('ul').removeAttr('style').end().find('.cat-t-sel').removeClass('cat-t-sel');
			});
		}
	};
	$('.drop').hoverIntent(dropHover);
	
	$('a[rel^=#]').each(function()
	{
		if ($($(this).attr('rel') + '').length)
			$(this).overlay(
			{
				absolute:false, 
				onBeforeLoad:function()
				{
					this.getContent().find('.pas').hide().eq(0).show();
					
					if ( $(this.getTrigger() ).is('.inactiv')) return false;
					
					var webkit = $.browser.webkit;
					if (webkit) return;
					var wh = $(window).height();
					var mh = this.getContent().height();
					if (wh > mh + 60) {
						var scr = $(window).scrollTop();
						$('body').data('scroll-top',scr);
						$('html,body').css('overflow', 'hidden');
						$(window).scrollTop(scr);
					}
					
					if ( !ie6 ) return;
					$('#continut select').hide();
				}, 
				
				onLoad:function()
				{
					var c = this.getContent();
					var t = this.getTrigger();
					c.find('.close').attr('title','szoros');
					if (c.find('input[type=text]').length > 0) {
						c.find('input[type=text]')[0].focus();
					}
					
					var wh = $(window).height();
					var mh = this.getContent().height();
					var top = this.getContent().css('top');
					if ( wh < mh + 60 ) this.getContent().css('top',top-20)
					
				}, 
				
				onBeforeClose:function()
				{
					$('html,body').removeAttr('style');
					var webkit = $.browser.webkit;
					if (webkit) return; 
					var scroll_top = $('body').data('scroll-top');
					if (scroll_top) $(window).scrollTop(scroll_top);
					
					resetRegisterForm();
				},
				
				onClose:function()
				{
					if (!ie6) return;
					$('#continut select').show();
				}, 
				api:true
			});
	});
		
	$(':input').live('focus', function(){
		$(this).parents('label, .label').addClass('h');
	}).live('blur', function(){
		$(this).parents('label, .label').removeClass('h');
	});
	
	$('.campuri .stea').attr('title','Camp necesar');
	$('.campuri label small.info a').attr('tabindex',-1);
	
	$('.reg-anulare').click(function(e){
		e.preventDefault();
		$(this).parents('.modal').find('.close').click();
	}); 
	
	$('#mesajele-tale .titlu-mesaj').click(function(e){
		e.preventDefault();
		$(this).css('outline',0).parent().parent().toggleClass('deschis');
	});
	
	if ( $('.pret').length ) $('.pret').hoverIntent({
		sensitivity: 3, 
		interval: 200, 
		timeout: 500, 
		over:function(){
			var d = $(this).parent().find('.pret-d');
			if ( d.find('li').length > 3 ) d.addClass('pret-d-mare');
			if ( d.find('li').length < 3 ) d.addClass('pret-d-doua');
			d.fadeIn(100).mouseleave(function(){$(this).fadeOut('fast')});
		}, 
		out:function(){
			$(this).parent().find('.pret-d').hover(function(){}, function(){
				$(this).fadeOut('fast');
			});
		}
	});
	
	/*
	 * 	AdÄugare Ă®n coČ™
	 */
	$('.buton-incepe, .btn-adauga-in-cos, .productcolor,  .btn-adauga-in-wishlist, input[value="Kosárba tesz"], .adauga-wishlist, .adauga-com-auto, .action').live('click', function(e)
	{
		e.preventDefault();
		
		$.tools.expose.conf.color = '#f0eee1';
		
		var but = $(this);
		var wishlist = but.is('.adauga-wishlist, .btn-adauga-in-wishlist');
		var com_auto = but.is('.adauga-com-auto');
		var com_rapida = but.is('.adauga-com-rapida');
		var actiune = but.is('.action');
		var text_actiune = actiune ? but.attr('rel') : '';
		var butid = actiune ? but.attr('id') : '';
		var butincepe = but.is('.buton-incepe');
		var prod_color = but.is('.productcolor');
		var divculori = but.is('.productcolor');
		
		
		if (butid != '' && butid == canceledButton)
			return;
		
		var produs = but.parents('.produs').find('.titlu-prod h5 a').text();
		produs = produs.length == 0 ? $('#prod-detalii .titlu-mag .t').text() : produs; 
		produs = produs.length == 0 ? but.parents('.b-det').find('.t a').text() : produs;
		produs = produs ? produs : '';
		
		var info = '<div class="anunt anunt-cos" id="info-box"><div class=in>terhelési adatok...</div></div>';
		info = wishlist ? '<div class="anunt anunt-cos anunt-wishlist"><div class=in><h4 class=t>Ai adaugat produsul in <a href="' + (typeof(catalog) != "undefined" ? '../wishlist.html" onclick="window.opener.location.href=\'../sajat-iroda/rendelesek/wishlist.html\'; return false;' : 'wishlist.html') + '" title="vezi wishlist-ul tau">Wishlist-ul tau</a></h4><p>' + '<strong>' + produs + '</strong>'+ ' a fost adaugat in wishlist-ul tau.</p><a class="inchide" href="#" title="szoros">szoros</a></div></div>' : info;
		info = com_auto ? '<div class="anunt anunt-cos anunt-com-auto"><div class=in><h4 class=t>Ai adaugat produsul in <a href="' + (typeof(catalog) != "undefined" ? '../sajat-iroda/rendelesek/automatikus-vezerlest.html" onclick="window.opener.location.href=\'../sajat-iroda/rendelesek/automatikus-vezerlest.html\'; return false;' : 'sajat-iroda/rendelesek/automatikus-vezerlest.html') + '" title="vezi comanda ta automata">Comanda ta automata</a></h4><p>' + '<strong>' + produs + '</strong>'+ ' a fost adaugat in comanda ta automata.</p><a class="inchide" href="#" title="szoros">szoros</a></div></div>' : info;
		info = actiune ? '<div class="anunt anunt-cos anunt-actiune"><div class=in><h4 class=t>' + text_actiune + '</h4><a class="inchide" href="#" title="szoros">szoros</a></div></div>' : info;
		info = butincepe ? '<div class="anunt anunt-cos1"><div class=in><h4 class=t>Produsele au fost adaugate in <a href="../bevasarlokosar.html" ' + '" title="vezi cosul tau de cumparaturi" class="cos-teste">Cosul tau</a></h4><a class="inchide" href="#" title="szoros">szoros</a></div></div>' : info;
		
		var matrice = but.parents('.opt-matrice').length > 0;
		var lista   = but.parents('.opt-lista').length > 0; 
		var detalii = but.parents('#prod-detalii').length > 0;
		var detalii_alt = detalii ? but.parents('.b-det').length > 0 : false;
		var cat = but.parents('#prdcat').length > 0;
		var p = but.parents('.produs').find('.p-img');
		

		p = detalii_alt ? but.parents('.b-det').prev() : p;
		p = actiune ? $('#cos').length > 0 ? $('#cos') : $('#continut') : p;
		
		p = p.length == 0 ? but.parents('.prod') : p;
		p = p.length == 0 ? $('#prod-detalii .prod-img') : p;
		p = p.length == 0 ? but : p;
		p = (divculori ? $('#color_container') : p);
		
		var pl = p.offset().left;
		var pt = p.offset().top;
		var ph = p.height();
		var pw = p.width(); 

		var stanga = matrice ? pl -20 : detalii_alt ? pl + pw - 150 : pl + pw - 10;
		var sus = detalii ? pt + ph - 90 : lista ? pt + ph + 10 : pt + ph - 30;
		
		stanga = actiune ? pl + pw / 2 - 200 : stanga;
		sus = actiune ?  pt + 145 : sus;
		
		stanga = cat ? pl - 30 : stanga;
		sus = cat ? pt + 30 : sus;
		sus = divculori ?  pt + 345 : sus;
		
		$(info).hide().appendTo('body').css({'left':stanga, 'top':sus}).fadeIn('fast', function(){
			$.fn.inchide = function(cum){$(this).fadeOut(cum, function(){$(this).remove()})}
			var t = $(this);
			t.find('.inchide').click(function(e){e.preventDefault(); t.inchide('fast')})
			var timpInchidere = setTimeout(function(){t.inchide(1500)}, 3000);
			t.mouseover(function(){
				clearTimeout(timpInchidere);
				t.stop().animate({opacity:1},150);
			})
			t.mouseenter(function(){
				clearTimeout(timpInchidere);
				t.stop().animate({opacity:1},150);
			}).mouseleave(function(){
				t.stop();
				var timpInchidere = setTimeout(function(){t.inchide(500)}, 1500);
			});
			
		});
		
	});
/*
 * 	AdÄugare culoare
 */
	$('.btn-selecteaza-culoare').live('click', function(e)
	{
		e.preventDefault();
		
		$.tools.expose.conf.color = '#f0eee1';
		
		var but = $(this);
		var butculoare = but.is('.btn-selecteaza-culoare');
		var actiune = but.is('.action');
		var text_actiune = actiune ? but.attr('rel') : '';
		var butid = actiune ? but.attr('id') : '';
		var butincepe = but.is('.buton-incepe');
		
		if (butid != '' && butid == canceledButton)
			return;
		
		var produs = but.parents('.produs').find('.titlu-prod h5 a').text();
		produs = produs.length == 0 ? $('#prod-detalii .titlu-mag .t').text() : produs; 
		produs = produs.length == 0 ? but.parents('.b-det').find('.t a').text() : produs;
		produs = produs ? produs : '';
		
		
		var info1 = butculoare ? '<div class="anunt anunt-cos2" id="color_container"><div class=in><h4 class=t>Alege culoarea produsului: </h4><p id="culori"> </p><a class="inchide" href="#" title="szoros">szoros</a></div></div>' : info1;
		
		var matrice = but.parents('.opt-matrice').length > 0;
		var lista   = but.parents('.opt-lista').length > 0; 
		var detalii = but.parents('#prod-detalii').length > 0;
		var detalii_alt = detalii ? but.parents('.b-det').length > 0 : false;
		var cat = but.parents('#prdcat').length > 0;
		var p = but.parents('.produs').find('.p-img');
		p = detalii_alt ? but.parents('.b-det').prev() : p;
		p = actiune ? $('#cos').length > 0 ? $('#cos') : $('#continut') : p;
		
		p = p.length == 0 ? but.parents('.prod') : p;
		p = p.length == 0 ? $('#prod-detalii .prod-img') : p;
		p = p.length == 0 ? but : p;
		var pl = p.offset().left;
		var pt = p.offset().top;
		var ph = p.height();
		var pw = p.width(); 

		var stanga = matrice ? pl -20 : detalii_alt ? pl + pw - 150 : pl + pw - 10;
		var sus = detalii ? pt + ph - 90 : lista ? pt + ph + 10 : pt + ph - 30;
		
		stanga = actiune ? pl + pw / 2 - 200 : stanga;
		sus = actiune ?  pt + 145 : sus;
		
		stanga = cat ? pl - 30 : stanga;
		sus = cat ? pt + 30 : sus;
			//alert("stanga" + stanga + "top" + sus);			
		$(info1).hide().appendTo('body').css({'left':stanga, 'top':sus}).fadeIn('fast', function(){
			$.fn.inchide = function(cum){$(this).fadeOut(cum, function(){$(this).remove()})}
			var t = $(this);
			t.find('.inchide').click(function(e){e.preventDefault(); t.inchide('fast')})
			
		});
	});
	$('.cos-teste').click(function(e)
	{
		e.preventDefault();
		//alert('aaaa');
	});  
	/*
	 * Zoom pe imaginea micÄ Ă®n listÄ de produse
	 */
	var quickViewOpen = function(){
		
		var t = $(this);
		
		//var src='uploads/produse/prod02.jpg';
		var src1 = t.find('img');
		var src = t.find('img').context.src; 
		src = src.replace('thumb-', 'medium-');
		//var src = t.find('img').attr('src'); src = src.substr(0,src.indexOf('-small')) + '.jpg';
		src = 'thumbs/200/160/' + src.substr(src.indexOf('userfiles/productsnew/'));
		
		var stg = Math.floor(t.offset().left);
		var sus = Math.floor(t.offset().top);
		var w = t.width();
		var h = t.height();
		var p = t.parent().is('a') ? t.parent() : null; 
		var titlu = '';
		var url = '';  
		if (p.length > 0) {
			titlu = p.attr('title');
			url = p.attr('href');
		}
		var img = new Image();
		var imgW, imgH;
		img.src = src;
		$(img).load(function(){
			
			var t = $(this);
			t.appendTo('body');
			
			url = url ? url : '';
			
			imgW = $(this).width();
			imgH = $(this).height();
			
			imgW = imgW<200 ? 200 : imgW;
			imgH = imgH<140 ? 140 : imgH;  
			
			imgW = imgW / 2;
			imgH = imgH / 2;
			
			var qX = stg + w/2 - imgW + 5;
			var qY = sus + h/2 - imgH;
			var v = $(this).height() < 140 ? 70 - $(this).height() / 2 : 0;
			
			$(this).css( 'margin-top', v );
			var link = $('<a href="' + url + '" title="' + titlu + '"></a>').append(img);
			$('<div id="quickView"></div>').append(link).appendTo('body').hide().css({left:qX, top:qY}).fadeIn('fast').mouseout(function(){$(this).fadeOut('fast', function(){$(this).remove(); t.remove()});}).mouseleave(function(){$(this).fadeOut('fast', function(){$(this).remove(); t.remove()})});;
			
		});
		
	}
	var quickViewClose = function(){};
	$('.p-img-list .cr-i a img, .p-img .cr-i a img').hoverIntent({
		sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
		interval: 400, // number = milliseconds for onMouseOver polling interval    
		over: quickViewOpen, // function = onMouseOver callback (REQUIRED)    
		timeout: 500, // number = milliseconds delay before onMouseOut    
		out: quickViewClose // function = onMouseOut callback (REQUIRED)		
	});
	
	
	
	/*
	 * Arata poza produs optiune culoare
	 */
	var colorViewOpen = function(){
		var t = $(this);
		document.productpic.src = 'thumbs/200/196/' + t.context.rel;
	}
	var colorViewClose = function(){
		document.productpic.src = window.productImage;
	};
	$('.colorhover').hoverIntent({
		sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)    
		interval: 100, // number = milliseconds for onMouseOver polling interval    
		over: colorViewOpen, // function = onMouseOver callback (REQUIRED)    
		timeout: 98, // number = milliseconds delay before onMouseOut    
		out: colorViewClose // function = onMouseOut callback (REQUIRED)		
	});
	/*$('#faqs-categ').tabs('#faqs > div', {
		current:'sel'
	}).find('a').click(function(e){
		e.preventDefault();
	});*/
	$('#faqs h4 a').click(function(e){
		e.preventDefault();
		$(this).parent().parent().toggleClass('sel');
	});
	
	// Produs - notarea produsului 
	if ( $('.nota').length ) $('.nota').each(function(i){
		var n = $(this);
		var a = $(this).find('a');
		var nr = i;
		var clasa = n.attr('class'); 
		a.hover(function(e){
			var cateStele = $( e.target ).text();
			var clasaNoua = clasa.substr( 0, clasa.length - 1 ) + cateStele; 
			n.attr('class', clasaNoua);
		}, function(){
			n.attr('class', clasa); 
		});
	});
	
	if ( $('.file-c .meniu-file').length)
		$('.file-c .meniu-file').each(function()
		{
			var file = $(this).parent().find(' > .file > .fila ');
			var i = $(this).find('li:not(.inactiv)').index();
			
			$(this).tabs( file, {
				tabs	:	'li', 
				current	:	'sel', 
				initialIndex: i // activÄm primul tab care nu e inactiv
			});
		});
	
	if ( $('.scr-c').length ) $('.scr-c').each(function(){
		
		var t = $(this);
		if ( t.parents().hasClass('mag_fila_prod') ){
			if (t.find('>ul>li').size() > 3) {
				t.addClass('c3').scrollable({
					items: '>ul',
					next: '.dr',
					prev: '.st',
					loop: false,
					size: 3,
					speed: 250,
					disabledClass: 'oprit',
					keyboard: false,
					clickable: false
				});
			}
			else 
				t.parent().addClass('farascroll');
		}
		
		if ( t.parents().hasClass('lista-prod-alt') ){
			
			if (t.find('>ul>li').size() > 2) {
				t.addClass('c2').scrollable({
					items: '>ul',
					next: '.dr',
					prev: '.st',
					loop: false,
					size: 2,
					speed: 250,
					disabledClass: 'oprit',
					keyboard: false,
					clickable: false
				});
			}
			else 
				t.parent().addClass('farascroll');
		}
		
		else
			if ( t.parents().hasClass('ct') )
				t.addClass('c3').scrollable({
					items			:	'ul', 
					next			:	'.dr', 
					prev			:	'.st',
					loop			:	false, 
					size			:	3, 
					speed			:	250, 
					disabledClass	:	'oprit', 
					keyboard		:	false, 
					clickable		:	false
				});
			else
				t.addClass('c1').scrollable({
					items			:	'ul', 
					next			:	'.dr', 
					prev			:	'.st',
					loop			:	false, 
					size			:	1, 
					speed			:	250, 
					disabledClass	:	'oprit', 
					keyboard		:	false, 
					clickable		:	false
				});
	});
	
	$('.q-control').live('click', function(e){
		e.preventDefault();
		var t = $(this);
		var inp = t.parent().find('.q-input');
		var v = parseInt( inp.val() );
		if ( v != '' && !isNaN(v) ) {
			if ( t.hasClass('q-sus') && v < 99 )
				inp.val( v + 1 );
			else if ( t.hasClass('q-jos') && v > 1 )
				inp.val( v - 1 );
		}
		else if ( t.hasClass('q-sus') ) inp.val('1');
	});
	if ( $('.opt-sel').length ) $('.opt-sel').click(function(e){
		var t = $(e.target);
		if (t.is('.optiuni li a')){
			/*var r = $(this).find('.t .rez').size() > 0 ? $(this).find('.t .rez') : $(this).find('.t');
			var b = t.parent().parent().find('b');
			
			if (b.size() > 0) {
				var bText = b.text();
				b.replaceWith('<a href="#">' + bText + '</a>');
			}
			
			var v = t.text();
			t.replaceWith('<b>' + v + '</b>');
			
			r.html( v );
			o.hide();*/
			
			//location.href = t.attr('href');
			return true;
		}
		e.preventDefault();
		var o = t.find('.optiuni');
		if ( t.is('.t') ) {
			var l = $(this).find('.t'); 
			var i = $('.opt-sel .t').index();
			var alte = $('.opt-sel .optiuni').filter(function(index){ return index != i });
			alte.hide();
			l.next().toggle();
		}
	});
	
	
	$('body').click(function(e){
		var t = $(e.target);
		if ( !t.parents().is('.opt-sel') )
			$('.opt-sel .optiuni').hide();
		if ( !t.parents('.anunt').length && !$(this).is('.anunt') )
			$('.anunt').fadeOut(100, function(){$(this).remove()});
	});
	
	$('.terms-c').each(function(){
		var t = $(this);
		if( t.is('.modal div') ){
			var modal = t.parents('.modal');
			var form = t.parents('form.inv');
			modal.show();form.show();
			t.jScrollPane();
			modal.hide();form.hide();
		}
		else 
			t.jScrollPane();
	});
	
	
	$('.box').hover(function(){
		$(this).addClass('rc-o');
	}, function(){
		$(this).removeClass('rc-o');
	});
	
	$('.lista-comenzi .comanda, .lista-comenzi-alt .comanda, li.partener').click(function(e){
		var link = $(this).find('.arr a');
		if ( !link.length )
			link = $(this).find('a.link');
		if ( link.length ) 
			window.location = link.attr('href');
	});
	
	$('.wish-lista li.prod').each(function(){
		//if ( !ie ) return; 
		var t = $(this);
		if ( t.is(':nth-child(odd)') )
			t.addClass('impar');
		else
			t.addClass('par');
	})
	
	$('.partener').each(function(){
		var t = $(this);
		var nume = t.find('.pers a').attr('title'); 
		if ( nume )
			t.attr( 'title', nume );
	});
	
	if ( !ie6 && !ie7 ) $('.rand').not('#harta-site .rand').each(function(){
		var t = $(this);
		var col = t.find('>.col');
		var h_titlu = 0;
		var max = 0;
		if (!col.length) {
			col = t.find('.produs');
			var produse = true;
		}
		col.each(function(){
			max = $(this).height() > max ? $(this).height() : max; 
			max = produse ? max - 40 : max;/* padding top Č™i bottom */
		});
		if ( max > 218 )
			col.css('cssText', 'height: ' + max + 'px !important');
		t.find('.p-tit').each(function(){
			if ( $(this).height() > h_titlu ) h_titlu = $(this).height();
		});
		t.find('.p-tit').css({'cssText':'height: ' + h_titlu + 'px !important'});
		var matrice = t.parents('.opt-matrice').length > 0;
		if ( matrice ) {
			var img = t.find('.cr-i img');
			var a   = img.parent().is('a') ? img.parent() : null;
			img.load(function(){
				var t  = $(this);
				var ha = a.height();
				var hi = t.height();
				if ( hi < ha ) t.css( 'margin-top', ha / 2 - hi / 2 );
			}).each(function(){ // cache
				var t = $(this);
				if ( t.height() > 0 && !t.attr('style') ){
					var ha = a.height();
					var hi = t.height();
					if ( hi < ha ) t.css( 'margin-top', ha / 2 - hi / 2 );
				}
			});
		}
	});
	
	
	
	
	$('.anunt-com-rapida .t a[rel=#comanda-rapida]').live('click', function(e){
		var o = $(this).overlay({api:true});
		o.load();
		e.preventDefault();
	});
	
	
	$('td.p-calc td:first-child').addClass('pri');
	
	$('.file-c .meniu-file li.inactiv a').each(function(){
		$(this).attr('tabindex', -1).css('cursor','default');
	}).click(function(e){
		e.preventDefault(); return false; e.stopImmediatePropagation();
	});
	
	$('body#magazin.magazin .in>.c:last-child .ct').css({
		'border-bottom':'none', 
		'position':'relative',
		'top':4
	});
	
	$('.modal').each(function(){
		var t = $(this);
		var f = t.find('form');
		var p = f.find('.pas');
		
		if ( p.length < 1 ) return;
		
		p.hide().eq(0).show().end().find('.urmator').click(function(e)
		{
			e.preventDefault();
			if ( typeof(verifyFieldsStep) === 'undefined' || verifyFieldsStep() )
				$(this).parents('.pas').hide().next().show().find('input:first').focus();
		}).end().find('.inapoi').click(function(e){
			window.step--;
			
			e.preventDefault();
			$(this).parents('.pas').hide().prev().show();
		});
	
		t.find('.urmator, .urmator1, .inapoi').click(function()
		{
			var pv = p.find(':visible');
			var wh = $(window).height();
			var ph = $('.pas:visible').parents('.modal').height() + 60;
			
			if (wh < ph) {
				$('.modal:visible').css('top', 20);
				$('html,body').css('cssText', 'overflow-y:auto; overflow-x:hidden');
			}
		});
	});
	
	$('.modal-vizibil').live('click', function(){
		var p = $(this).find('.pas');
		var pv = p.find(':visible');
		var wh = $(window).height();
		var ph = $('.pas:visible').parents('.modal').height() + 60;
		ph = ph > 60 ? ph : $(this).height() + 120;
		
		if (wh < ph) {
			$('.modal:visible').css('top', 20);
			$('html,body').css('cssText', 'overflow-y:auto; overflow-x:hidden');
		}
	});
	
	$('.campuri input.f').focus(function(){
		$(this).parents('label').addClass('h');
	}).blur(function(){
		$(this).parents('label').removeClass('h');
	});
	
	$('.btn-despre-brand, .brandstory').click(function(e){
		e.preventDefault();
		$('.modal#branduri').overlay({ 
			onBeforeLoad:function(){
				if ( !ie6 ) return;
				$('#continut select').hide();
			}, 
			onLoad:function(){
				this.getContent().find('.close').attr('title','szoros');
				var branduri = $('#c-branduri .in div').scrollable({
					activeClass		:	'sel', 
					items			:	'ul', 
					nextPage		:	'.dr', 
					prevPage		:	'.st',
					loop			:	false, 
					size			:	7, 
					speed			:	250, 
					disabledClass	:	'oprit', 
					clickable		:	true, 
					keyboard		:	true, 
					api				:	true
				});
				
				branduri.click((window.brandIndex ? window.brandIndex : 0));
				
				$('#c-branduri .in div li a').click(function(e)
				{
					e.preventDefault();
					var brandnode = e.currentTarget.attributes[(e.currentTarget.attributes[1].nodeValue == "return false;" ? 0 : 1)].nodeValue;
					var brand = brandnode.replace('markak/', '').replace('/', '');
					
					$.ajax({
						method: "get", url: "ajax/ajax_brand.php", data: "brand=" + brand,
						success: function(html) { $(".continut .brand").html(html); }
					});
					
					
				});
			}, 
			onClose:function(){
				if ( !ie6 ) return;
				$('#continut select').show();
			}, 
			api: true
		}).load();
	});
	
	$('#sponsor-p-da').parents('li').click(function(e){
		var s = $('#sponsor-p-da');
		if ($(e.target).parents('.sp-opt').length > 0){ 
			if ( s.data('farafocus') ) {
				s.removeData('farafocus');
				return;
			}; 
			$('#sponsor-cod').focus();
		}
		else {
			s.data('farafocus',true).click();
		}
	});
	
	if ( ie6 ){
		$('#branduri .c-nav a').each(function(){
			var t = $(this);
			if ( t.hasClass('st') ){
				t.attr('id', 'brand-nav-st');
			}
		})	
	}
	
	/*
	$('#porneste-afacere a, #nav-afacere a, #alege-afacere a').click(function(e)
	{
		e.preventDefault();
		var t = $(this);
		var h = t.attr('href');
		h = h != '#' && h != '' ? h : 'porneste-o-afacere/';
		var fs = '';
		var l = screen.width;
		var i = screen.height;
		var x = l/2 - 504;
		var y = i/2 - 382;
		if ( i < 800 ) fs = ',fullscreen=yes';
		alert(h);
		window.open(h, 'pornesteAfacere', 'resizable=0,status=0,toolbar=0,scrollbars=0,width=1000,height=700,left=' + x + ',top=' + y + fs);
	});
	*/
	
	$('#descarca-program').click(function(e){
		e.preventDefault();
		var t = $(this);
		var h = t.attr('href');
		h = (h != '#' && h != '' ? h : 'rapoarte.life-care.ro/');
		var l = screen.width;
		var i = screen.height;
		var x = l/2 - 504;
		var y = i/2 - 330;
		window.open(h, 'rapoarte', 'resizable=0,status=0,toolbar=0,scrollbars=0,width=1000,height=700,left=' + x + ',top=' + y);
	});
	
	$('#nav .cat-t').each(function(){
		var t = $(this);
		if ( t.next().children().length < 1 ) t.addClass('cat-t-single');
	});
	
	var deschideNivel = function(){
		var t = $(this).find('>.cat-t'), n = t.next(), p = t.parent(), n1=t.parents('.nivel-1'), h1 = n1.height(), h2 = n.height(), w=n1.width(), w1 = t.width(), w2 = n.width();
		if ( n.length > 0 && n.is(':visible') ) { return; }
		if ( n.length == 0 ){
			var nivel = p.parent().attr('class');
			if (nivel == 'nivel-1') {
				n1.width(190);
				p.siblings().removeClass('sel').find('>.cat-t-sel').removeClass('cat-t-sel');
				$('.nivel-2, .nivel-3').hide();
				n1.removeAttr('style');
				return;
			}
			if (nivel == 'nivel-2') {
				n1.width(380);
				p.siblings().removeClass('sel').find('>.cat-t-sel').removeClass('cat-t-sel');
				$('.nivel-3').hide();
				return;
			}
			if (nivel == 'nivel-3') {
				n1.width(570);
				return;
			}
		}
		var nivel = n.attr('class');  
		if( nivel == 'nivel-2') n1.width(380);
		if( nivel == 'nivel-3') n1.width(570);
		
		if ( h2 > h1 ){
			var h = n1.height();
			n1.data('h', h);
			h2 = h2 - 1; 
			n1.height(h2);
		}
		else{
			if ( n1.data('h') && nivel == 'nivel-2' ){
				n1.height(n1.data('h'));
			}
			else if ( nivel == 'nivel-3' ){
				
			}
		}
		
		$('.' + nivel + '').hide().parent().removeClass('sel').parent().find('.cat-t-sel').removeClass('cat-t-sel');
		if ( nivel == 'nivel-3' ){
			var i = 0, h = $.each(p.prevAll(), function(){
				i = i + $(this).height();
			});
			n.css('top', -i );
		}

		n.show().parent().addClass('sel');
		t.addClass('cat-t-sel');
		
	};

	var inchideNivel = function(){
		var t = $(this).find('.cat-t'), p = t.parent(), n = t.next(), n1 = t.parents('.nivel-1');
		var nivel = n.attr('class');
		if ( nivel == 'nivel-1' ) n1.removeAttr('style');
	};
	var nivel = {
		sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
		interval: 10, // number = milliseconds for onMouseOver polling interval    
		over: deschideNivel, // function = onMouseOver callback (REQUIRED)    
		timeout: 500, // number = milliseconds delay before onMouseOut    
		out: inchideNivel // function = onMouseOut callback (REQUIRED)
	};	
	$('#nav .cat-t').parent().hoverIntent(nivel)
	
	//.not('#buton-cadou')
	$('a.inactiv, .inactiv a').not('.meniu-file a').not('#act-programeaza').not('#buton-felicitare').not('#buton-ambalaj').not('#act-programeaza').unbind('click').live('click',function(e){
		e.stopImmediatePropagation();
		e.preventDefault();
	});
	
	/*if ( $('#m-alege-cadou').length > 0 ) 
	$('#m-alege-cadou').overlay({
		api:true, 
	}).load();
	*/
	
	$('.pay-det-list li input:disabled').each(function()
	{
		$(this).parent().addClass('inactiv');
	});
	
	$('.pcol-prod li, .pay-det-list li').click(function(e)
	{
		var t = $(this);
		var i = t.find(':input');
		//alert('aaa');
		if (i.is(':disabled')) return; 
		
		if (!$(e.target).is(':input'))
		{
			e.stopImmediatePropagation();
			e.preventDefault();
			
			if ( !i.is(':checked') )
			{
				i.click().focus();
				
				//updateProdusCadou(i);
			}
		}
		
		t.parents('ul').find('.h').not($(this)).not($(this).children()).removeClass('h');
		
		$(this).find(':input').unbind('blur');
	});
	$('.pay-det-list li input:checked, .pcol-prod input:checked').each(function(){
		$(this).parents('li,label').addClass('h');
	});
	
	
	
	var url = document.location.hash.substr(1);
	if (url === 'inregistrare-partener')
	{
		$('#inregistrare-partener').overlay({
			onBeforeLoad:function(){
				this.getContent().find('.pas').hide().eq(0).show();
				if ( !ie6 ) return;
				$('#continut select').hide();
			}, 
			onLoad:function()
			{
				var c = this.getContent();
				c.find('.close').attr('title','szoros');
				if (c.find('input[type=text]').length > 0) {
					c.find('input[type=text]')[0].focus();
				}
				c.find('.campuri label small.info a').attr('tabindex',-1);
				var sy = c.css('top') - 30;
				window.scroll(0,sy);
				window.step = 1;
			}, 
			onClose:function(){
				if ( !ie6 ) return;
				$('#continut select').show();
				document.inregistrare_form.reset();
			}, 
			api:true
		}).load();
	}
	
	var url = document.location.toString();
	if (url.indexOf('resetare-parola') != -1)
	{
		$('#change-password').overlay({
			onBeforeLoad:function(){
				this.getContent().find('.pas').hide().eq(0).show();
				if ( !ie6 ) return;
				$('#continut select').hide();
			}, 
			onLoad:function()
			{
				var c = this.getContent();
				c.find('.close').attr('title','szoros');
				if (c.find('input[type=text]').length > 0) {
					c.find('input[type=text]')[0].focus();
				}
				c.find('.campuri label small.info a').attr('tabindex',-1);
				var sy = c.css('top') - 30;
				window.scroll(0,sy);
				window.step = 1;
			}, 
			onClose:function(){
				if ( !ie6 ) return;
				$('#continut select').show();
			}, 
			api:true
		}).load();
	}
	/*else
	if (url.indexOf('confirmare-inregistrare') != -1)
	{
		$('#change-password').overlay({
			onBeforeLoad:function(){
				this.getContent().find('.pas').hide().eq(0).show();
				if ( !ie6 ) return;
				$('#continut select').hide();
			}, 
			onLoad:function()
			{
				var c = this.getContent();
				c.find('.close').attr('title','szoros');
				if (c.find('input[type=text]').length > 0) {
					c.find('input[type=text]')[0].focus();
				}
				c.find('.campuri label small.info a').attr('tabindex',-1);
				var sy = c.css('top') - 30;
				window.scroll(0,sy);
				window.step = 1;
			}, 
			onClose:function(){
				if ( !ie6 ) return;
				$('#continut select').show();
			}, 
			api:true
		}).load();
	}
	*/
	
	$('.buton-inapoi-la-cos').click(function(e)
	{
		e.preventDefault();
		$(this).parents('.modal').find('.close').click();
	});
	
	$('#m-alege-cadou #pcol-cadouri input:radio').click(function(){
		var t = $(this);
		var ul = t.parents('ul');
		var img = ul.next().is('.prod-img') ? ul.next() : null;
		var i = t.parents('li').index();
		
		var src = $('#c-img-' + t[0].value).length > 0 ? $('#c-img-' + t[0].value).attr('src').replace('thumb-', 'medium-') : '';
		if (src != '')
			src = 'thumbs/200/160/' + src.substr(src.indexOf('userfiles/productsnew/'));
		
		var url = '#';
		
		var p = '<div class="prod-img"><div class="cr-t lines"></div><div class="cr-i lines">';
		p = p + '<img alt="" src="' + src + '">';
		p = p + '</div><div class="cr-b lines"></div><div class="clear"></div></div>';
		
		if(img)img.remove();
		ul.parent().append(p);
		
	});
	
	 var pcolCadouri = $("#pcol-cadouri").scrollable({
	 	size: 5, 
		vertical: true, 
		keyboard: false
	}).mousewheel();
	
	/*
	$('#promo-products #promo-products-list input:radio').click(function()
	{
		var t = $(this);
		var ul = t.parents('ul');
		var img = ul.next().is('.prod-img') ? ul.next() : null;
		var i = t.parents('li').index();
		
		var src = $('#pp-img-' + t[0].value).length > 0 ? $('#pp-img-' + t[0].value).attr('src').replace('thumb-', 'medium-') : '';
		if (src != '')
			src = 'thumbs/200/160/' + src.substr(src.indexOf('userfiles/productsnew/'));
		
		var url = '#';
		
		var p = '<div class="prod-img"><div class="cr-t lines"></div><div class="cr-i lines">';
		p = p + '<img alt="" src="' + src + '">';
		p = p + '</div><div class="cr-b lines"></div><div class="clear"></div></div>';
		
		if(img)img.remove();
		ul.parent().append(p);
		
	});
	
	 var pcolPromoProd = $("#pcol-promo-prods").scrollable({
	 	size: 5, 
		vertical: true, 
		keyboard: false
	}).mousewheel();
	 */
	 
	 
	$('#m-alege-felicitare #pcol-felicitari input:radio').click(function(){
		var t = $(this);
		var ul = t.parents('ul');
		var img = ul.next().is('.prod-img') ? ul.next() : null;
		var i = t.parents('li').index();
		
		var src = $('#cf-img-' + t[0].value).length > 0 ? $('#cf-img-' + t[0].value).attr('src').replace('thumb-', 'medium-') : '';
		if (src != '')
			src = 'thumbs/200/160/' + src.substr(src.indexOf('userfiles/productsnew/'));
		
		var p = '<div class="prod-img"><div class="cr-t lines"></div><div class="cr-i lines">';
		p = p + '<img alt="" src="' + src + '">';
		p = p + '</div><div class="cr-b lines"></div><div class="clear"></div></div>';
		
		if (img) img.remove();
		ul.parent().append(p);
	});
	
	var pcolFelicitari = $("#pcol-felicitari").scrollable({
	 	size:5, 
		vertical:true, 
		keyboard:false
	}).mousewheel();
	 
	$('#m-alege-ambalaj #pcol-ambalaje input:radio').click(function(){
		var t = $(this);
		var ul = t.parents('ul');
		var img = ul.next().is('.prod-img') ? ul.next() : null;
		var i = t.parents('li').index();
		
		var src = $('#ca-img-' + t[0].value).length > 0 ? $('#ca-img-' + t[0].value).attr('src').replace('thumb-', 'medium-') : '';
		if (src != '')
			src = 'thumbs/200/160/' + src.substr(src.indexOf('userfiles/productsnew/'));
		
		var p = '<div class="prod-img"><div class="cr-t lines"></div><div class="cr-i lines">';
		p = p + '<img alt="" src="' + src + '">';
		p = p + '</div><div class="cr-b lines"></div><div class="clear"></div></div>';
		
		if (img) img.remove();
		ul.parent().append(p);
	});
	
	 var pcolAmbalaj = $("#pcol-ambalaje").scrollable({
	 	size:5, 
		vertical:true, 
		keyboard:false
	 }).mousewheel();
	 
	 //$('#pcol-cadouri li:first-child').click();
	 
	 $('.btn-adauga-adresa-noua').click(function(e){
	 	e.preventDefault();
		$('#adauga-adresa').overlay({
			api:true, 
			absolute:true, 
			onLoad:function(){
				this.getContent().find(':input:visible:first').focus();
			}
		});
	 });
	 
	$('#niciun-produs, .afisare-produse, #magazin #mag_detail_wrap #continut .c-in, #compania #continut, .promotii#magazin #continut>.in>.c , body.cautare #continut>.in>.c').each(function(){
		var t = $(this);
		var singur = $(this).parent().find('>.c').length <= 1;
		var co = t.is('#compania #continut');
		
		var dr = $('#lat_dr').height() - 90;
		var st = $('#lat_st').height() - 50;
		dr = co ? dr + 120 : dr;
		var h = Math.max( dr, st );
		
		if ( h && h > 700 && singur ) $(this).css('cssText', 'min-height: ' + h + 'px; height:auto !important; height:' + h + 'px');
	});
	
	/*$('.cautare #rezultate-produse').each(function(){
		var t = $(this), li = t.find('>li'), l = li.length; 
		li.filter(function(){
			var i = $(this).parent().find('>li');
			var l = i.length;
			var cate = l % 3 === 0 ? 3 : l % 3;
			var nr = l - cate;
			if ( $(this).index() >= l - cate ){
				return $(this)
			}
			
		}).css({
			'border-bottom':'none',
			'margin-bottom':1
		})
	})*/
	
	/*
	 * Tooltip
	 */
	
	if ($('.infotip').length)
	{
		//$('body').append('<div class="infotip-content" style="display:none">&nbsp;</div>');
		
		$('.infotip').tooltip(
		{
			cancelDefault:true,
			effect	:	'slide',  
			offset	:	[-12, 0],
			predelay:	250, 
			delay	:	250,
			tip		:	'.infotip-content', 
			events	:	{
				def		:	"mouseover,mouseout", 
				input	:	'mouseover,mouseout', 
				widget	:	"focus mouseover,blur mouseout", 
				tooltip	:	"mouseover,mouseout"
			}, 
			
			onBeforeShow: function()
			{
				var t = this.getTip();
				var c = this.getConf();
				var tr = this.getTrigger();
				c.relative = $(t).prev().hasClass('infotip') ? true : false;
				
				//if (tr.parents('.p-bifa').length > 0 || tr.hasClass('rel'))
				//	t.text(tr.attr('rel'));
				
				t.append('<b class="arr"></b>');
				
				if (tr.is('.wishlist .p-bifa label'))
				{
					var offset = tr.is('th label') ? [5,0] : [30,0];
					c.offset = offset;
				}
			}, 
			api: true
		});
		
		$('.infotip-content').hide();
	}
	
	if ($('.infotipin').length)
	{
		$('body').append('<div class="infotip-content-in" style="display:none">&nbsp;</div>');
		
		$('.infotipin').tooltip(
		{
			cancelDefault:true,
			effect	:	'slide',  
			offset	:	[-12, 0],
			predelay:	250, 
			delay	:	250,
			tip		:	'.infotip-content-in', 
			events	:	{
				def		:	"mouseover,mouseout", 
				input	:		'mouseover,mouseout', 
				widget	:	"focus mouseover,blur mouseout", 
				tooltip	:	"mouseover,mouseout"
			}, 
			
			onBeforeShow: function()
			{
				var t = this.getTip();
				var c = this.getConf();
				var tr = this.getTrigger();
				c.relative = $(t).prev().hasClass('infotipin') ? true : false;
				
				if (tr.parents('.p-bifa').length > 0 || tr.hasClass('rel'))
					t.text(tr.attr('rel'));
				
				t.append('<b class="arr"></b>');
				
				if (tr.is('.wishlist .p-bifa label'))
				{
					var offset = tr.is('th label') ? [5,0] : [30,0];
					c.offset = offset;
				}
			}, 
			api: true
		});
		
		$('.infotip-content-in').hide();
	}
	
	
	// dacÄ sunt doar douÄ preČ›uri, sÄ le afiČ™Äm mai ordonat Ă®n pagina produsului
	var preturiDetaliiProdus = function(){
		var t = $('.prod-price table');
		var r = t.find('tr').length; 
		var c = r === 2 ? 'doua-randuri' : r === 3 ? 'trei-randuri' : '';
		if ( c ) t.addClass( c );
	}();
	
	$('br.linie').replaceWith('<div class="br"></div>');
	
	$.fn.activeaza = function(){
		if ( $(this).length > 0) {
			$(this).removeClass('inactiv').attr('href', '#');
			if ($(this).attr('rel').indexOf('#') === 0) 
				return;
			$(this).addClass('action')
		}
	}
	$.fn.dezactiveaza = function(){
		if ( $(this).length > 0 )
		$(this).addClass('inactiv').removeAttr('href').removeClass('action');
	}
	
	var bifeazaToate = function()
	{
		var t = $('.p-bifa input[type=checkbox]');
		var i = t.parents('table').find('tbody input[type=checkbox]');
		
		var act_mutaInCos = $('#act-muta-in-cos');
		var act_mutaInComAuto = $('#act-muta-in-com-auto');
		var act_sterge = $('#act-sterge');
		var act_modifica = $('#act-modifica');
		var act_programeaza = $('#act-programeaza');
		
		i.each(function()
		{
			if ($(this).is(':checked'))
			{
				act_mutaInCos.activeaza();
				act_mutaInComAuto.activeaza();
				act_sterge.activeaza();
				act_programeaza.activeaza();
				act_modifica.activeaza();
			}
		});
		
		t.each(function()
		{
			var t = $(this);
			
			if (t.is(':checked'))
			{
				if (t.is('#p-bifa-toate'))
					t.attr('rel', 'debifeaza toate produsele');
				else
					t.attr('rel', 'debifeaza acest produs');
			}
			else
			{
				if ( t.is('#p-bifa-toate') )
					t.attr('rel', 'bifeaza toate produsele');
				else
					t.attr('rel', 'bifeaza acest produs');
			}
			
			$(this).click(function(e)
			{
				if (t.is(':checked'))
				{
					if (t.is('#p-bifa-toate'))
					{
						i.attr('checked', true).attr('rel','debifeaza acest produs');
						t.attr('rel', 'debifeaza toate produsele');
					}
					else 
						t.attr('rel', 'debifeaza acest produs');
						
					act_mutaInCos.activeaza();
					act_mutaInComAuto.activeaza();
					act_sterge.activeaza();
					act_programeaza.activeaza();
					act_modifica.activeaza();
				}
				else
				{
					if (t.is('#p-bifa-toate'))
					{
						i.attr('checked', false).attr('rel', 'bifeaza acest produs');
						t.attr('rel', 'bifeaza toate produsele');
					}
					else 
						t.attr('rel', 'bifeaza acest produs');
					
					var debif = true;
					
					i.each(function()
					{
						if ( $(this).is(':checked') ) debif = false;
					});
					
					if ( !debif ) return; 
					
					act_mutaInCos.dezactiveaza();
					act_mutaInComAuto.dezactiveaza();
					act_sterge.dezactiveaza();
					act_programeaza.dezactiveaza();
					act_modifica.dezactiveaza();
				}
			});
		});

	}();
	
	var bifeazaToateAdr = function()
	{
		var t = $('.p-bifa input[type=checkbox]');
		var i = t.parents('table').find('tbody input[type=checkbox]');
		var act_sterge = $('#act-sterge-adr');
		
		i.each(function()
		{
			if ($(this).is(':checked'))
				act_sterge.activeaza();
		});
		
		t.each(function()
		{
			var t = $(this);
			
			if (t.is(':checked'))
			{
				if (t.is('#p-bifa-toate-adr'))
					t.attr('rel', 'debifeaza toate adresele');
			}
			else
			{
				if (t.is('#p-bifa-toate-adr'))
					t.attr('rel', 'bifeaza toate adresele');
			}
			
			$(this).click(function(e)
			{
				if (t.is(':checked'))
				{
					if (t.is('#p-bifa-toate-adr'))
					{
						i.attr('checked', true);
						t.attr('rel', 'debifeaza toate adresele');
					}
					
					act_sterge.activeaza();
				}
				else
				{
					if (t.is('#p-bifa-toate-adr'))
					{
						i.attr('checked', false);
						t.attr('rel', 'bifeaza toate adresele');
					}
					
					var debif = true;
					
					i.each(function()
					{
						if ($(this).is(':checked'))
							debif = false;
					});
					
					if (debif)
						act_sterge.dezactiveaza();
				}
			});
		});

	}();
	
	$('a[class*="reset-password"]').click(function(e){
		$(this).parents('.pas').hide().siblings('#login-parola').show().find(':input:first').focus();
		e.preventDefault();
	});
	
	$('a[class*="remember-user"]').click(function(e){
		$(this).parents('.pas').hide().siblings('#login-datele').show().find(':input:first').focus();
		e.preventDefault();
	});
	
	$('a[class*="login-user"]').click(function(e){
		$(this).parents('.pas').hide().siblings('#login-main').show().find(':input:first').focus();
		e.preventDefault();
	});
	
	$('.icn-imprimare').click(function(e){
		e.preventDefault();
		if ( $(this).parents('.modal').length > 0 ){
			$('body>*').addClass('print-inv');
		}
		window.print();
	})
	
	$('.lista-info').each(function(){
		var t = $(this);
		var l = t.find('.rc');
		var m = 0;
		var s = l.find('strong');
		if ( s.length === 0 ) return;
		l.each(function(){
			var s = $(this).find('strong');
			var w = s.width();
			if ( w > m ) m = w;
		});
		s.width(m);
		
	});
	
	$('#util-limba').each(function(){
		if ( $.browser.webkit ) return;
		var t = $(this).addClass('icn');
		var v = t.val();
		var schimbaLimba = function(){
			var t = $('#util-limba');
			var v = t.val();
			var l = v === 'English' ? 'opt-en' : v === 'Magyar' ? 'opt-hu' : 'opt-ro';
			t.attr('class','f icn ' + l);
		};
		schimbaLimba();
		t.change(function(){
			schimbaLimba()
		})
	});
	
	$('#utiliz a[href=#actiune-imagine]').click(function(e){
		e.preventDefault();
		var t = $(this);
		var s = $(window).scrollTop();
		
		var h = $('#actiune-imagine').height(); 
		var w = $('#actiune-imagine').width();
		
		var stanga = t.offset().left - w/2 + 24;
		var sus = t.offset().top - $(window).scrollTop() - h - 53;
		
		$('#actiune-imagine').overlay({
			absolute:true, 
			left: stanga, 
			top: sus, 
			expose:false, 
			api:true
		}).load();
	});
	
	$('#sterge-imaginea').click(function(e){
		e.preventDefault();
		$(this).parents('.infotip-content').overlay({api:true}).close();
		$('#info-sistem').hide().find('.info-in').html('<p><b>Imaginea de utilizator a fost stearsa.</b></p>').end().fadeIn('fast');
	});
	
	/*$('a[class*="rasfoieste-online"], a[class*="link-catalog"], a:contains("rasfoieste online"), a[href~=brosuri], a[href~=catalog], a[href=catalog]').click(function(e)
	{
		e.preventDefault();
		var url = $(this).attr('href');
		url = 'http://www.life-care.com/' + (url === '#' ? '/catalog/index.html' : url);
		
		var l = screen.width;
		var i = screen.height;
		var h = 700;
		var x = l/2 - 504;
		var y = i/2 - h/2 - 30;
		window.open(url, 'catalogOnline', 'resizable=0,status=0,toolbar=0,scrollbars=0,width=1000,height=' + h + ',left=' + x + ',top=' + y);
	});
	
	$('a[href=/catalog/]').click(function(e)
	{
		e.preventDefault();
		var url = $(this).attr('href');
		url = 'http://www.life-care.com/catalog/';
		
		var l = screen.width;
		var i = screen.height;
		var h = 700;
		var x = l/2 - 504;
		var y = i/2 - h/2 - 30;
		window.open(url, 'catalogOnline', 'resizable=0,status=0,toolbar=0,scrollbars=0,width=1000,height=' + h + ',left=' + x + ',top=' + y);
	});
	*/
	
	$('.filtru-sel .meniu .toggle').jScrollPane({
		scrollbarWidth:7,
		arrowSize:6,
		scrollbarMargin:0
	});
	
	$('a[href=quiz/]').live('click',function(e){
		e.preventDefault();
		var url = $(this).attr('href'), fs = '';
		var l = screen.width, i = screen.height;
		var x = l/2 - 504, y = i/2 - 382;
		if ( i < 800 ) fs = ',fullscreen=yes';
		window.open(url,'quiz', 'resizable=0,status=0,toolbar=0,scrollbars=0,width=900,height=700,left=' + x + ',top=' + y + fs);
	});
	
	$('a[href=quiz2/]').live('click',function(e){
		e.preventDefault();
		var url = $(this).attr('href'), fs = '';
		var l = screen.width, i = screen.height;
		var x = l/2 - 504, y = i/2 - 382;
		if ( i < 800 ) fs = ',fullscreen=yes';
		window.open(url,'quiz2', 'resizable=0,status=0,toolbar=0,scrollbars=0,width=900,height=700,left=' + x + ',top=' + y + fs);
	});
	
	if ( ie6 && $('#hero.mic').length ) {
		$('#hero.mic').addClass('hero-mic').find('>.in').attr('id','hero-mic');
	}
	if ( $('#mag_detail_wrap').length && $('#hero').length && (ie6 || ie7) ){
		$('#continut').addClass('cu-hero-cos');
	}
	
	$('.s .v a').click(function(e)
	{
		
		var t = $(this);
		//var i = Number(t.parents('li').index()) + 1;
		var i = t.attr('id').replace('item', '');
		var tt= t.text();
		var flv = t.attr('href');
		flv = flv.indexOf('http://') >= 0 ? flv : 'http://www.life-care.com/' + flv;
		
		if ( !$('#m_clip_' + i).length)
			$('body').append('<div id="m_clip_' + i + '" class="modal" style="width:730px"><h3>' + tt + '</h3><div id="swf_' + i + '" style="padding:18px 0 0"></div></div>');
		
		$('#m_clip_' + i).overlay({
			api:true, 
			onLoad:function(){
				if ( !$('#swf_' + i).length ) return false
				$('#swf_' + i).flashembed({
					src		 : 'http://www.life-care.com/player_materiale.swf', 
					menu		 : 'false', 
					scale	 : 'exactfit', 
					wmode	 : 'opaque', 
					width	 : 730, 
					height	 : 400, 
					quality	 : 'autolow', 
					flashvars : 'flv=' + flv
				});
			}
		}).load();
		e.preventDefault();
	});

	$('#materials .ct .v a').click(function(e)
	{
		var t = $(this);
		//var i = Number(t.parents('li').index()) + 1;
		var i = t.attr('id').replace('item', '');
		var tt= t.text();
		var flv = t.attr('href');
		flv = flv.indexOf('http://') >= 0 ? flv : 'http://www.life-care.com/' + flv;
		
		if ( !$('#m_clip_' + i).length)
			$('body').append('<div id="m_clip_' + i + '" class="modal" style="width:730px"><h3>' + tt + '</h3><div id="swf_' + i + '" style="padding:18px 0 0"></div></div>');
		
		$('#m_clip_' + i).overlay({
			api:true, 
			onLoad:function(){
				if ( !$('#swf_' + i).length ) return false
				$('#swf_' + i).flashembed({
					src		 : 'http://www.life-care.com/player_materiale.swf', 
					menu		 : 'false', 
					scale	 : 'exactfit', 
					wmode	 : 'opaque', 
					width	 : 730, 
					height	 : 400, 
					quality	 : 'autolow', 
					flashvars : 'flv=' + flv
				});
			}
		}).load();
		e.preventDefault();
	});

		
	$('#materiale #prezentare_swf').flashembed({
		src		 : 'http://www.life-care.com/userfiles/video/prezentare_video.swf', 
		wmode	 : 'opaque', 
		width	 : 784, 
		height	 : 336, 
		align	 : 'center', 
		flashvars : 'flv=http://www.life-care.com/userfiles/video/life-care_full.flv'
	});
}); // end document.ready

$(window).load(function(){
	var zoomProdus = function(){
		var imagineaMare = $('.fotoProdus').attr('src')
		if (imagineaMare == null) return;
		if ( $.browser.msie && $.browser.version < 7)
			$('#prod-detalii .prod-img .cr-i').hover(function(){$('#continut select').hide()}, function(){$('#continut select').show()})
		imagineaMare =  imagineaMare ? imagineaMare.substr(0,imagineaMare.length - 4) + '.' + imagineaMare.substr(imagineaMare.length-3) : false;
		imagineaMare = imagineaMare ? imagineaMare.replace('medium-', '') : false;
		imagineaMare = imagineaMare.substr(imagineaMare.indexOf('userfiles/productsnew/'));
		if (!imagineaMare) return;
		MojoZoom.makeZoomable( $('.fotoProdus')[0], imagineaMare, $('#fotoProdus_zoom')[0] );
	}();
});



function resetRegisterForm()
{
	if (!document.inregistrare_form)
		return;
	
	document.inregistrare_form.reset();
	
	$('#are_sponsor_details').show();
	$('#nu_are_sponsor_details').hide();
}


function initPromoOverlay(promoId)
{
	$((promoId ? '#' + promoId : '.promomodal')).overlay(
	{
		absolute:false, 
		onBeforeLoad:function()
		{
			this.getContent().find('.pas').hide().eq(0).show();
			
			if ( $(this.getTrigger() ).is('.inactiv')) return false;
			
			var webkit = $.browser.webkit;
			if (webkit) return;
			var wh = $(window).height();
			var mh = this.getContent().height();
			if (wh > mh + 60) {
				var scr = $(window).scrollTop();
				$('body').data('scroll-top',scr);
				$('html,body').css('overflow', 'hidden');
				$(window).scrollTop(scr);
			}
			
			if ( !ie6 ) return;
			$('#continut select').hide();
		}, 
		
		onLoad:function()
		{
			var c = this.getContent();
			var t = this.getTrigger();
			c.find('.close').attr('title','inchide');
			if (c.find('input[type=text]').length > 0) {
				c.find('input[type=text]')[0].focus();
			}
			
			var wh = $(window).height();
			var mh = this.getContent().height();
			var top = this.getContent().css('top');
			if ( wh < mh + 60 ) this.getContent().css('top',top-20)
			
		}, 
		
		onBeforeClose:function()
		{
			$('html,body').removeAttr('style');
			var webkit = $.browser.webkit;
			if (webkit) return; 
			var scroll_top = $('body').data('scroll-top');
			if (scroll_top) $(window).scrollTop(scroll_top);
			
			resetRegisterForm();
		},
		
		onClose:function()
		{
			if (!ie6) return;
			$('#continut select').show();
		}, 
		api:true
	});
}

