




$(document).ready(function(){
	
	// create CLEAR div after FLOAT columns
	$(document.createElement('div')).css({'clear': 'both'}).insertAfter(".left_site_container");
	
	// erori , mesaje server - animatie
	$('.listare_eroare, .listare_mesaj').css({'opacity':0,'display':'block'});
	setTimeout(function() { $('.listare_eroare, .listare_mesaj').animate({opacity: 1}, "slow");}, 50); 
	
	
});	




// thickbox
//-------------------------------------------------------------------
$(document).ready(function(){
	$(".linkopengal").each(function() {	//deschide galerie multimedia
		$(this).attr("href", $(this).attr("href") + "&KeepThis=true&TB_iframe=true&height=530&width=850");
	});
});




// thickbox live in module
//-------------------------------------------------------------------
$('.linkopengal').live("click", function () {
		$(this).addClass("thickbox");
		$(this).attr("href", $(this).attr("href") + "&KeepThis=true&TB_iframe=true&height=530&width=850");
		var t = this.title || this.name || null;
		var a = this.href || this.alt;
		var g = this.rel || false;
		tb_show(t,a,g);
		this.blur();
		return false;
});

$('.linkopenimg').live("click", function () {
		var t = this.title || this.name || null;
		var a = this.href || this.alt;
		var g = this.rel || false;
		tb_show(t,a,g);
		this.blur();
		return false;
});

// Scroll to topLink
//-------------------------------------------------------------------
$(function(){$.fn.scrollToTop=function(options){if(options){var speed=options.speed;var ease=options.ease;}else{var speed="slow";var ease="jswing";}var scrollDiv=$(this);$(this).hide().removeAttr("href");if($(window).scrollTop()!="0"){$(this).fadeIn("slow");}$(window).scroll(function(){if($(window).scrollTop()=="0"){$(scrollDiv).fadeOut("slow");}else{$(scrollDiv).fadeIn("slow");}});$(this).click(function(event){$("html, body").animate({scrollTop:"0px"},speed,ease);});}});
$(function() {
	$("#toTop").scrollToTop({
		speed:500
		//ease:"easeOutBounce"
	});
});


// Smooth Scrolling  internal page links
//-------------------------------------------------------------------
$(function(){

    $('a[href*=#]').click(function() {
    
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
        && location.hostname == this.hostname) {
        
            var $target = $(this.hash);
            
            $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
            
            if ($target.length) {
            
                var targetOffset = $target.offset().top;
                
                $('html,body').animate({scrollTop: targetOffset}, 1000);
                    
                return false;
                
            }
            
        }
        
    });
    
});


// MODULE:
// #######################################################


// TABS module
// ==========================================
$(document).ready(function() {
   
   $('.modul_title_tab').parent().parent().parent().tabs({ 
   		//selected: 1 ,
		cookie: { expires: 30 } ,
		cache: true,
		collapsible: true,
		fx: { height: 'toggle'}				
	});
   
});


// TOGGLE module
// ==========================================
$(document).ready(function(){  
	$('.modul_title_toggle',this).toggle(  
		function () {
			
			var modul_id = $(this).attr('id');
			var modul_title = $(this).attr('title');
			var modul_url = $(this).attr('rel');
			if (modul_url == null) {
				modul_url = '';
			};
			
			
			// LA DESCHIDERE:
			//-----------------------------
			// la prima incarcare...
			if($('#container_'+modul_id).text() == '') {  
					
				$(this).html(modul_title+" <span title='inchide'>[-]</span>").append("<img class='loading_mod_img' src='../res_img/utils/loading6.gif'>");
				if (modul_url != '') { // daca avem modul_url ... il incarcam
					$('#container_'+modul_id).load(""+modul_url+"").slideDown(500); 
				} else { // altfel.. deschidem restrictNote
					$('#container_'+modul_id).slideDown(500); 
				};
				$(".loading_mod_img").fadeTo(1000, 0);
				$.cookie('#container_'+modul_id, 'expanded');  // write COOKIES

			// daca a mai fost incarcat odata ...
			} else { 
				$(this).html(modul_title+" <span title='inchide'>[-]</span>");  
				$('#container_'+modul_id).slideDown(500); 
				$.cookie('#container_'+modul_id, 'expanded');  // write COOKIES
			}  
		},  
		
		// LA INCHIDERE:
		//-----------------------------
		function () {  
			var modul_id = $(this).attr('id');
			var modul_title = $(this).attr('title');
			$(this).html(modul_title+" <span title='deschide'>[+]</span>");  
			$("#container_"+modul_id).slideUp(500); 
			$.cookie('#container_'+modul_id, 'collapsed');  // write COOKIES
		}  
	);

	// READ COOKIES
	//-----------------------------
	$(".modul_title_toggle").each(function(i) {
		var modul_id = $(this).attr('id');
		var modul_title = $(this).attr('title');
		var modul_url = $(this).attr('rel');
		if (modul_url == null) {
				modul_url = '';
			};

		if ($.cookie('#container_'+modul_id) == 'expanded') {
			$(this).html(modul_title+" <span title='inchide'>[-]</span>").append("<img class='loading_mod_img' src='../res_img/utils/loading6.gif'>");
			if (modul_url != '') { // daca avem modul_url ... il incarcam
				$('#container_'+modul_id).load(""+modul_url+"").slideDown(500); 
			} else { // altfel.. deschidem restrictNote
				$('#container_'+modul_id).slideDown(500); 
			};
			$(".loading_mod_img").fadeTo(1000, 0);
		}
	});
	
});  


// thickbox
//-------------------------------------------------------------------
$(document).ready(function(){
	$(".linkopengal").each(function() {	//deschide galerie multimedia
		$(this).attr("href", $(this).attr("href") + "&KeepThis=true&TB_iframe=true&height=530&width=850");
	});
});




// thickbox live in module
//-------------------------------------------------------------------
$('.linkopengal').live("click", function () {
		$(this).addClass("thickbox");
		$(this).attr("href", $(this).attr("href") + "&KeepThis=true&TB_iframe=true&height=530&width=850");
		var t = this.title || this.name || null;
		var a = this.href || this.alt;
		var g = this.rel || false;
		tb_show(t,a,g);
		this.blur();
		return false;
});

$('.linkopenimg').live("click", function () {
		var t = this.title || this.name || null;
		var a = this.href || this.alt;
		var g = this.rel || false;
		tb_show(t,a,g);
		this.blur();
		return false;
});


// /END MODULE:
// #######################################################


