

$(document).ready(function() { 

	$(document.createElement('div')).css({'clear': 'both'}).insertAfter(".left_site_container");
	
	// round corners
	//$('.foto_mare_sec').corner("3px");
	//$('.foto_mare_art').corner("3px");
	
	// color bg la option selected
	$("select option:selected").css({backgroundColor: '#e1e1e1'});
	
	// erori , mesaje server - animatie
	$('.listare_eroare, .listare_mesaj').css({'opacity':0,'display':'block'});
	setTimeout(function() { $('.listare_eroare, .listare_mesaj').animate({opacity: 1}, "slow");}, 50); 
	
//FORMULAR INREGISTRARE:
	
	
	// tip cont + date firma
	$("#date_reg_firma").css({'display':'none'})
	
	if ($("input[name='MembruPersJuridic']:checked").val() == 'firma')
		$("#date_reg_firma").slideDown(1000); //Slide Down Effect  
    else
		$("#date_reg_firma").slideUp(1000);  //Slide Up Effect 
			
	$("input[name='MembruPersJuridic']").click(function(){
		if ($("input[name='MembruPersJuridic']:checked").val() == 'firma')
			$("#date_reg_firma").slideDown(1000); //Slide Down Effect  
    	else
			$("#date_reg_firma").slideUp(1000);  //Slide Up Effect  
	});
	
	// tip livrare + adresa livrare
	$("#adresa_livrare").css({'display':'none'})
	
	if ($("input[name='MembruDeliverTip']:checked").val() == 'diferita')
		$("#adresa_livrare").slideDown(1000); //Slide Down Effect  
    else
		$("#adresa_livrare").slideUp(1000);  //Slide Up Effect 
			
	$("input[name='MembruDeliverTip']").click(function(){
		if ($("input[name='MembruDeliverTip']:checked").val() == 'diferita')
			$("#adresa_livrare").slideDown(1000); //Slide Down Effect  
    	else
			$("#adresa_livrare").slideUp(1000);  //Slide Up Effect  
	});
	
	


		
		

	
	
	
// help
	$('.helptips').bt({
		trigger: 		['focus'],
		shrinkToFit: 	true,
		positions: 		['right'],
		ajaxPath: 		["'../e_cms/help_ajax.asp?element='+$(this).attr('rel')"],
		ajaxCache:		false,
		fill:			"rgba(255, 255, 204, .8)",
		strokeStyle: 	"#cc9933",
		cornerRadius: 	0,
		spikeLength: 	10, 
		spikeGirth: 	20,
		padding: 		10,
		clickAnywhereToClose: true,
		closeWhenOthersOpen: true
	});
	$('span.helptips').bt({
		trigger: 		['hoverIntent'],
		shrinkToFit: 	true,
		positions: 		['right'],
		ajaxPath: 		["'../e_cms/help_ajax.asp?element='+$(this).attr('rel')"],
		ajaxCache:		false,
		fill:			"rgba(255, 255, 204, .8)",
		strokeStyle: 	"#cc9933",
		cornerRadius: 	0,
		spikeLength: 	10, 
		spikeGirth: 	20,
		padding: 		10,
		clickAnywhereToClose: true,
		closeWhenOthersOpen: true
	});
	
	//noajax:
	
	$('.helptips_noajax').bt({
		trigger: 		['focus'],
		shrinkToFit: 	true,
		positions: 		['right'],
		//ajaxPath: 		["'../xdata/help_ajax<%=app_lang%>.asp?element='+$(this).attr('rel')"],
		//ajaxCache:		false,
		fill:			"rgba(255, 255, 204, .8)",
		strokeStyle: 	"#cc9933",
		cornerRadius: 	0,
		spikeLength: 	10, 
		spikeGirth: 	20,
		padding: 		10,
		clickAnywhereToClose: true,
		closeWhenOthersOpen: true
	});
	$('span.helptips_noajax').bt({
		trigger: 		['hoverIntent'],
		shrinkToFit: 	true,
		positions: 		['right'],
		//ajaxPath: 		["'../xdata/help_ajax<%=app_lang%>.asp?element='+$(this).attr('rel')"],
		//ajaxCache:		false,
		fill:			"rgba(255, 255, 204, .8)",
		strokeStyle: 	"#cc9933",
		cornerRadius: 	0,
		spikeLength: 	10, 
		spikeGirth: 	20,
		padding: 		10,
		clickAnywhereToClose: true,
		closeWhenOthersOpen: true
	});

	

}); 


// TABLESORTER
//-------------------------------------------------------------------

$('.tablesorter').livequery(function () {
	$('.tablesorter').tablesorter();
});

// TABLEHOVER
//-------------------------------------------------------------------

$('.tablehover').livequery(function () {
	$('.tablehover').tableHover({
		rowClass : 'hoverClass',
		clickClass : 'clickclass'
	});
});


	
 


// TOOLTIP
//-------------------------------------------------------------------
$(function() {
	$('.tooltip').tooltip({
		track: true,
		delay: 0,
		showURL: false,
		showBody: " - ",
		fade: 100
	});
});




// Increase Font Size
//-------------------------------------------------------------------
$(document).ready(function(){

  // originalFontSize
 var originalFontSize = $('.increase_fontsize').css('font-size');
 var maxFontSize = '20';
 // originalLineHeight
 var originalLineHeight = $('.increase_fontsize').css('line-height');
 
  //$("#font_size_t").click(function(){ 
  $('#font_size_t').live("click", function(){	
	// increase font size
	var currentFontSize = $('.increase_fontsize, .increase_fontsize *').css('font-size');
	var currentFontSizeNum = parseFloat(currentFontSize, 10);
	var newFontSize = currentFontSizeNum*1.2;
	$('.increase_fontsize, .increase_fontsize *').css('font-size', newFontSize);
	// increase line-height
	var currentLineHeight = $('.increase_fontsize, .increase_fontsize *').css('line-height'); 	
	var currentLineHeightNum = parseFloat(currentLineHeight, 10);   
	var newLineHeight = 2;
	$('.increase_fontsize, .increase_fontsize *').css('line-height', newLineHeight);	
	
	// reset
	if (newFontSize >= maxFontSize) {
			$('.increase_fontsize, .increase_fontsize *').css('font-size', originalFontSize);
			$('.increase_fontsize, .increase_fontsize *').css('line-height', originalLineHeight);
		}
		
	return false;	
  });
  
});


// Add to fav
//-------------------------------------------------------------------
$(document).ready(function(){
	$('#add_fav_t').jFav();
});








// mousewheel - Whell suport
//-------------------------------------------------------------------
$(document).ready(function() { 
    $('.clasa_div_cu_scroll.....').bind('mousewheel', function(e, delta)  { 
			var dir = delta > 0 ? '-=20px' : '+=20px';
			$(this).scrollTo( dir, 30, {axis:'x'}  );
			return false;

        });
});


// external links open in new window
//-------------------------------------------------------------------
$(document).ready(function(){
	$("a[href*='http://']:not([href*='"+location.hostname+"'])").attr({target: "_blank", title: "Open in new window"}).append('^');
});


// 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).css({'background':'#e8e7e7','border-bottom':'none','color':'#009999'});
				
				$(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
					if ($('#container_'+modul_id).is('div')) {
							$('#container_'+modul_id).load(""+modul_url+"").slideDown(500); 
						}
						else {
							$('#container_'+modul_id).css({'display':'block'});
							$('#container_'+modul_id).attr("src",""+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).css({'background':'#e8e7e7','border-bottom':'none','color':'#009999'});
				$(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); 
			$(this).css({'background':'#e1e1e1','border-bottom':'1px solid #666666','color':'#333333'});
			$.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
				$(this).css({'background':'#e8e7e7','border-bottom':'none','color':'#009999'});
				if ($('#container_'+modul_id).is('div')) {
							$('#container_'+modul_id).load(""+modul_url+"").slideDown(500); 
						}
						else {
							$('#container_'+modul_id).attr("src",""+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:
// #######################################################

