$(function() {
	$('#menu li').each(function() { 
		var src=$(this).find('img').attr('src');
		var img=new Image();
		img.src=src;
	});
	$('#menu li:not(".active")').hover(function() { 
		var imgSrcNew=$(this).find('img').attr('src').replace(/(\d*)(\.gif)/,"$1Act$2")
		$(this).find('img').attr('src', imgSrcNew)
	}, 
	function() { 
		var imgSrcNew=$(this).find('img').attr('src').replace(/(\d*)(Act)/,"$1")
		$(this).find('img').attr('src', imgSrcNew)
	});
	$('#menu').find('li.active a').append('<i></i>');
	$('#submenu').find('li.active a').append('<i></i>');
	$('.categMenu').find('ul li.active a').append('<i></i>');
	$('#subsubmenu').find('li a').append('<i></i>');
	$('#gallery ul').jcarousel({scroll:4});
	$('.thumbs-gallery ul').jcarousel({scroll:5});
	$('.bigGallery ul').jcarousel({scroll:1,initCallback: mycarousel_initCallback});
	$('.csc-mailform input:submit').addClass('send');
	$('input:text, input:password, .comunity-form textarea').each(function(){
		var iV = $(this).val();
		$(this).focus(function(){ if($(this).val() == iV) $(this).attr('value','');})
			   .blur(function(){ if($(this).val() == '') $(this).attr('value',iV);})
	});
	$('a.mail').click(function(){ overHeight();$('#bigOverlay').show();$('#tipafriendlayout').fadeIn(function(){scrollME()})});
	$('#tipafriendlayout').find('.close a').live('click',function(){$('#tellafriendform').siblings().remove().end().remove();$('#tipafriendlayout').fadeOut();$('#bigOverlay').hide();});
	
	//Cufon.replace('#tabs-menu ul li a, .footer-list h4, #left .comments-top .comments-number h3, #articol #left h4, #subsubmenu li a, .style-menu h3, #style #sticky .list p, .horoscop-anual, .right-content h2, .footer-bottom ul li a, .right-content .box-r h4.red, #sticky .horoscop-single .content h4', { hover:true, fontFamily:'Existence Light' })
	Cufon.replace('.footer-list h4, #style #sticky .style-menu h3, #forum-title a, #horoscop-page .horoscop-anual a', { hover:true, fontFamily:'Existence Light' })
	
	var hI = $('#home #sticky .img').find('img').height();
	var hL = $('#home #sticky').find('.list').height();
	if(hL < hI)$('#home #sticky').find('.list').css('min-height',hI-35)
	if((hL < hI)&&($.browser.msie) && ($.browser.version <= 6))$('#home #sticky').find('.list').css('height',hI-35)
	
	/*$('#subsubmenu ul').find('li').each(function(){
		$(this).click(function(){	
			var sV = $(this).find('.cufon-alt').text()
			$(this).find('a').children('span').remove().end().text(sV)
			Cufon.replace('#subsubmenu li a', { hover:true, fontFamily:'Existence Light' });
			$(this).find('a').append('<i></i>')
		});
	});*/
		
	var vsI = $('#video #sticky .img:first').find('img').height()
	$('#video #sticky .img:first').find('a:first').height(vsI)
	$('#video #sticky .categorii').find('.img a').each(function(){
		var vsI2 = $(this).height()
		$(this).height(vsI2)
	});
		
	$('.pager').scrollTo('li:eq(0)',100)
	check();
	$(window).resize(function() { 
		check();
	});
	
	$('.intrebare').find('input:file').addClass('input-file')
	//$('#formular .box-wrap .img:empty, #formular .intrebare .error:empty, .pager:empty').hide()	
	$('.more').hover(function(){$('.box-content').hide().show()},function(){$('.box-content').hide().show()});
		
	setTimeout("$('#home #sticky .list table').find('tr:first').addClass('on')",3500);
	$('#home  #sticky .list table').find('tr').each(function(){$(this).hover(function(){
		if(!$(this).is('on')){
			$(this).parent().find('tr.on').removeClass('on')
			$(this).addClass('on')
		}
		var aH = $(this).find('.img a').attr('href')
		var iS = $(this).find('.img a').attr('rel')
		var bH = $(this).find('.txt h6 a').attr('href')
		var bT = $(this).find('.txt h6 a').text()	
		$('#home #sticky > .img').find('a').attr('href',aH).end().find('img').attr('src',iS)
		$('#home #sticky .list').find('h1 a').attr('href',bH).end().find('h1 a').text(bT)
	},function(){});})
	
	$('#home #sticky .list table').find('tr').each(function(){$(this).click(function(){
		var aH = $(this).find('.img a').attr('href')
		var iS = $(this).find('.img a').attr('rel')
		var bH = $(this).find('.txt h6 a').attr('href')
		var bT = $(this).find('.txt h6 a').text()	
		$('#home #sticky > .img').find('a').attr('href',aH).end().find('img').attr('src',iS)
		$('#home #sticky .list').find('h1 a').attr('href',bH).end().find('h1 a').text(bT)
	});})
	
	if($('#home #sticky .list').length > 0) { var x=setTimeout("slideShow()", 3500); }

	/*Hover articol*/
	
	/*$('#categorie #sticky .list ul').find('li').each(function(){$(this).hover(function(){
		var aH2 = $(this).find('.img a').attr('href');
		var iS2 = $(this).find('.img a img').attr('src');
		var aT2 = $(this).find('.img a').attr('title');
		var bH2 = $(this).find('.txt h3 a').attr('href');
		var bT2 = $(this).find('.txt h3 a').attr('title');
		var bTx2 = $(this).find('.txt h3 a').text();		
		var pTx = $(this).find('.txt p').html()			
		var aH3 = $('#categorie #sticky #sticky-wrap > .img').find('> a').attr('href');
		var iS3 = $('#categorie #sticky #sticky-wrap > .img').find('> a img').attr('src');
		var aT3 = $('#categorie #sticky #sticky-wrap > .img').find('> a').attr('title');
		var bH3 = $('#categorie #sticky #sticky-wrap .descr').find('h2 a').attr('href');
		var bT3 = $('#categorie #sticky #sticky-wrap .descr').find('h2 a').attr('title');
		var bTx3 = $('#categorie #sticky #sticky-wrap .descr').find('h2 a').text();	
		var pTx2 = $('#categorie #sticky #sticky-wrap .descr').find('p').html();	
		$(this).find('.img a').attr({href:aH3, title:aT3}).end().find('.img img').attr('src',iS3)
		$(this).find('.txt h3 a').attr({href:bH3, title:bT3}).text(bTx3).end().find('.txt p').replaceWith('<p>'+pTx2+'</p>')
		$('#categorie #sticky #sticky-wrap > .img').find('> a').attr({href:aH2, title:aT2}).end().find('> a img').attr('src',iS2)
		$('#categorie #sticky #sticky-wrap .descr').find('h2 a').attr({href:bH2, title:bT2}).text(bTx2).end().find('p').replaceWith('<p>'+pTx+'</p>')
	}
	,function(){});});*/
	
	setTimeout("$('#categorie #sticky .list ul').find('li:first').addClass('on')",3500);
	$('#categorie #sticky .list ul').find('li').each(function(){$(this).hover(function(){
		if(!$(this).is('on')){
			$(this).parent().find('li.on').removeClass('on')
			$(this).addClass('on')
		}
		var aH = $(this).find('.img a').attr('href')
		var iS = $(this).find('.img a').attr('rel')
		var bH = $(this).find('.txt h3 a').attr('href')
		var bT = $(this).find('.txt h3 a').text()	
		var bP = $(this).find('.txt p').html()	
		$('#categorie #sticky #sticky-wrap > .img').find('a').attr('href',aH).end().find('img').attr('src',iS)
		$('#categorie #sticky #sticky-wrap > .img .descr').find('h2 a').attr('href',bH).text(bT).end().find('p').replaceWith('<p>'+bP+'</p>')
	},function(){});})
	
	$('#categorie #sticky .list ul').find('li').each(function(){$(this).click(function(){
		var aH = $(this).find('.img a').attr('href')
		var iS = $(this).find('.img a').attr('rel')
		var bH = $(this).find('.txt h3 a').attr('href')
		var bT = $(this).find('.txt h3 a').text()	
		var bP = $(this).find('.txt p').html()
		$('#categorie #sticky #sticky-wrap > .img').find('a').attr('href',aH).end().find('img').attr('src',iS)
		$('#categorie #sticky #sticky-wrap > .img .descr').find('h2 a').attr('href',bH).text(bT).end().find('p').replaceWith('<p>'+bP+'</p>')
	});})
	
	if($('#categorie #sticky .list').length > 0) { var x=setTimeout("slideShow2()", 3500); }
	
	$('.videolist li:nth-child(3n)').addClass('no-pd')
	//$('#tagcloud li:nth-child(4n)').addClass('no-pd')
	/*Cufon.replace('#tabs-menu ul li a', { hover:true, fontFamily:'Existence Light' });
	Cufon.replace('h5 span', { hover:true, fontFamily:'Existence Light' });
	Cufon.replace('.box-r h6', { hover:true, fontFamily:'Existence Light' });
	Cufon.replace('#right .box2 h4', { hover:true, fontFamily:'Existence Light' });
	Cufon.replace('.footer-list h4', { hover:true, fontFamily:'Existence Light' });
	Cufon.replace('#articol #left .comments-number h3', { hover:true, fontFamily:'Existence Light' });
	Cufon.replace('#articol #left h4', { hover:true, fontFamily:'Existence Light' });
	Cufon.replace('#subsubmenu li a', { hover:true, fontFamily:'Existence Light' });
	Cufon.replace('.style-menu h3', { hover:true, fontFamily:'Existence Light' });
	Cufon.replace('#style #sticky .list p', { hover:true, fontFamily:'Existence Light' });
	Cufon.replace('.horoscop-anual', { hover:true, fontFamily:'Existence Light' });
	Cufon.replace('.right-content h2', { hover:true, fontFamily:'Existence Light' });
	Cufon.replace('.redtitle', { fontFamily:'Existence Light' });
	Cufon.replace('.horoscoptitle', { fontFamily:'Existence Light' });
	Cufon.replace('#blank .search label', { fontFamily:'Existence Light' });*/
	
	$('#subsubmenu ul > li').find('a').click(function(){
		$(this).parents('#subsubmenu').find('li.active').removeClass('active')
		$(this).parent().addClass('active')
	})

	
	/*
	* Forum
	*/
	
	$('#forum-main').find('tr').each(function(){
		if($(this).next().is('.hidden-content')){
			$(this).find('td h2').click(function(){
			var tR = $(this).parents('tr') 	
			if(!tR.is('.active')){
				tR.addClass('active').next().show()
				} else {
				tR.removeClass('active').next().hide()
				tR.hide().show()
				}
			});
		}
	});
	//Cufon.replace('#forum-title, #comunitate #left h3 span, #comunitate #right h3', { hover:true, fontFamily:'Existence Light' });
	if($('a[rel*=facebox]').length > 0)
		$('a[rel*=facebox]').facebox() 
});

function mycarousel_initCallback(carousel) {
    $('.thumbs-gallery ul').find('table').each(function(){$(this).find('a').bind('click', function() {
        carousel.scroll($.jcarousel.intval($(this).parent().parent().parent().parent().parent().attr('jcarouselindex')));
        return false;
    });});
};

function overHeight(){
	if(($.browser.msie) && ($.browser.version <=6)) {
		var H = $('body').outerHeight();
		$('#bigOverlay').height(H);
	}
}

function scrollME(){
	var windowH = $.browser.msie ? document.documentElement.scrollTop : window.pageYOffset;
	var windowW = $.browser.msie ? document.documentElement.scrollLeft : window.pageXOffset;
	var fwH = $('#tipafriendlayout').height();
	var fwW = $('#tipafriendlayout').width();
	var docH = parseInt($(window).height())/2;
	var docW = parseInt($(window).width())/2;
	var top=$('#tipafriendlayout').css('top');
	var newTop = docH-(fwH/2);
	var newLeft = docW-(fwW/2) ;
	$('#tipafriendlayout').css({top:newTop+windowH,left:newLeft+windowW});
	$(window).scroll(function(){
		windowH=$.browser.msie ? document.documentElement.scrollTop : window.pageYOffset;
		$('#tipafriendlayout').animate({top:parseInt(newTop)+parseInt(windowH)},{ duration:'normal', queue: false });
	});
}

function printLink(url) {

	window.open(url,'PrintPage','scrollbars=1,width=810,height=500');
	
}
(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);

function check() {
	if($(window).width() <= 1024 ){
		$('#header-top #menu-border').addClass('r1024')
		$('#header-top #search').addClass('r1024')
	} else if ($(window).width() > 1024){
		$('#header-top #menu-border').removeAttr('class')
		$('#header-top #search').removeAttr('class')
	} 
}

function slideShow() { x=setTimeout('slideShow()', 3500); goNext(); $('#home #sticky .list table tr').hover(function() {  clearTimeout(x); x=setTimeout('slideShow()', 3500); },function(){})}
function slideShow2() { x=setTimeout('slideShow2()', 3500); goNext2(); $('#categorie #sticky .list ul li').hover(function() {  clearTimeout(x); x=setTimeout('slideShow2()', 3500); },function(){})}

function goNext() { 
	if($('#home #sticky .list table tr.on').is(':last-child')) { 
	$('#home #sticky .list table tr.on').removeClass();
	$('#home #sticky .list table tr:first-child').addClass('on');
	$('#home #sticky .list table tr.on').trigger('click') 
	}
	else {
		$('#home #sticky .list table .on').next().addClass('on').end().removeClass();  
		$('#home #sticky .list table .on').trigger('click') 
	}	
}

function goNext2() { 
	if($('#categorie #sticky .list ul li.on').is(':last-child')) { 
	$('#categorie #sticky .list ul li.on').removeClass();
	$('#categorie #sticky .list ul li:first-child').addClass('on');
	$('#categorie #sticky .list ul li.on').trigger('click') 
	}
	else {
		$('#categorie #sticky .list ul .on').next().addClass('on').end().removeClass();  
		$('#categorie #sticky .list ul .on').trigger('click') 
	}		
}

function deleteUserActivityLog(url) {
	var answer = confirm("Sunteti sigur ca doriti sa stergeti inregistrarea?")
	if (answer){
		 
		window.location = url;
	}
	
}



	

