//jQuery.noConflict();
var confirmareAbonare = 0;
var pornesteSudokuClasic = 0;
var exoLoadJoc = 0;
$(document).ready(function(){
	
	
	$(".tease_trigger_abonat").click(function(){alert('Pentru a avea acces la aceasta resursa \ntrebuie sa fiti abonat si autentificat.');});
	$(".tease_trigger_membru").click(function(){alert('Pentru a avea acces la aceasta resursa \ntrebuie sa fiti inregistrat si autentificat.');});
	
	$(".ceeBoxu").ceebox();
	
	$("img[src$='.png']").ifixpng(); 
	
	//var ppup = $('#content_popup_abonament').html(); $.fn.ceebox.popup(ppup, '');
	//$(".ceeBoxPopupAbonament").ceebox({width:400, height:600});
	$(".ceeBoxPopupAbonament").click(function(){
		 $.fn.ceebox.popup("<a href='/inregistrare/popup_abonament.php?riveran'>link</a>",{htmlWidth:680, htmlHeight:395, borderWidth: '3px', margin:0, overlayColor:'#fff', borderColor:'#81c9c8'});
		 setTimeout('$("#cee_title h2").html("Autentificare necesara in cont abonat!").addClass("ceeTitle").addClass("ceeTitleWarning")', 3000);
	});
	$(".ceeBoxPopupMembru").click(function(){
		 $.fn.ceebox.popup("<a href='/inregistrare/popup_abonament.php?vizitator'>link</a>",{htmlWidth:250, htmlHeight:305, borderWidth: '3px', margin:0, overlayColor:'#fff', borderColor:'#81c9c8'});
	});
	$(".ceeBoxPopupLogat").click(function(){
		 //$.fn.ceebox.popup("<a href='http://strada.4mobil.ro/inregistrare/popup_abonament.php?vizitator'>link</a>",{htmlWidth:250, htmlHeight:305, borderWidth: '3px', margin:0, overlayColor:'#fff', borderColor:'#81c9c8'});
		 location.href='/?abonament';
	});
	//$.fn.ceebox.popup("<a href='http://someurl.com'>link</a>", options)
	$(".goToLogin").click(function(){ location.href='/?info_abonament'; });
	
	if(confirmareAbonare == 1){
		$.fn.ceebox.popup("<a href='/inregistrare/popup_confirmare.php'>link</a>",{htmlWidth:300, htmlHeight:230, borderWidth: '3px', margin:0, overlayColor:'#fff', borderColor:'#81c9c8'});
	}
	
	
	
	if(sesiuneDuplicatWarning==1){
		$.fn.ceebox.popup("<a href='/inregistrare/popup_delogare_sesiune_multipla.php'>link</a>",{htmlWidth:300, htmlHeight:350, borderWidth: '3px', margin:0, overlayColor:'#fff', borderColor:'#81c9c8'});
	}
	
	
	$("#myFrontpageScroll").mbScrollable({
        width:671,
        elementsInPage:4,
        elementMargin:2,
        /*shadow:"#999 2px 2px 2px",*/
        /*height:"auto",*/
		height: 198,
        controls:"#controls",
        slideTimer:600,
        autoscroll:true,
        scrollTimer:4000
      });
	
	$(".scroll_craft_craciun").mbScrollable({
        width:530,
        elementsInPage:4,
        elementMargin:2,
        /*shadow:"#999 2px 2px 2px",*/
        /*height:"auto",*/
		height: 105,
        controls:"#controls",
        slideTimer:600,
        autoscroll:true,
        scrollTimer:2500
      });
	  
	  $(".scroll_dreapta_noutati").mbScrollable({
        width:218,
        elementsInPage:1,
        elementMargin:2,
        /*shadow:"#999 2px 2px 2px",*/
        /*height:"auto",*/
		height: 200,
        controls:"#controls",
        slideTimer:600,
        autoscroll:true,
        scrollTimer:2500
      });
	  
	  var acc4 = location.href;
	  if(acc4.indexOf('preview')>0){
		  $("#sample-bar").jixedbar();
	  }
	  
	  //pentru afisarea thumbs de la PDF-uri
	  //$(".cuPDFoverlay").parent().
	  $(".thbPdfImg").css('opacity', .5);
	  $(".cuPDFoverlay").css('opacity', 1);
	  $(".cuPDFoverlay").mouseover(function(){
		  $(this).css({'background-image': 'url(/images/icons/pdfsmall.png)', 'background-position': 'center center'});
	  });
	  $(".cuPDFoverlay").mouseout(function(){
		  $(this).css({'background-image': 'url(/images/icons/pdfbig.png)', 'background-position': 'center center'});
	  });
	  
	  //news ticker in header, sus de tot
	$('#ndsp_header1').vTicker({
		speed: 500,
		pause: 3000,
		showItems: 1,
		animation: 'fade',
		mousePause: true,
		height: 0,
		direction: 'up'
	});
	//asta trebuie sa-l scot odata cu punerea noului header, cu iconite

	$("#sir_iconite_desene_buffer").load('/header_desene_icons.php', function(){
			$("#sir_iconite_desene").html($("#sir_iconite_desene_buffer").html());
			$("#sir_iconite_desene").mbScrollable({
				width:884,
				elementsInPage:17,
				elementMargin:1,
				/*shadow:"#999 2px 2px 2px",*/
				height: 50,
				controls:"#controls",
				slideTimer:600,
				autoscroll:false,
				scrollTimer:2500
			  });
		});
		
	$.datepicker.setDefaults({
	   dayNames: ['Duminica', 'Luni', 'Marti', 'Miercuri', 'Joi', 'Vineri', 'Sambata'],
	   dayNamesMin: ['Du', 'Lu', 'Ma', 'Mi', 'Jo', 'Vi', 'Sa'],
	   firstDay: 1,
	   changeMonth: true,
		changeYear: false,
		numberOfMonths: 1,
	   dateFormat: 'yy-mm-dd'
	   });
	$( ".datepicker_confirmpayment" ).datepicker( {minDate: -30, maxDate: "+1D"} );
	
	/*$("#nh_slide_wrp").carouFredSel();	//{*/
    /*    items               : 4,
        direction           : "left",
        scroll : {
            items           : 1,
            easing          : "easeOutBounce",
            duration        : 1000,                        
            pauseOnHover    : true
        }                  
    });*/
	/*$("#nh_slide_wrp").carouFredSel({
		width: 640,
		align: "left",
		height: 245,
		items: {
			visible: 1,
			width: 640,
			height: 245
		},
		direction	: "down",
		scroll: {
			fx: "crossfade",
			duration: 300,
			pauseOnHover: true
		},
		auto: {
			delay: 30
		},
		pagination	: {
			container		: "#nh_slide_wrp_navig",
			anchorBuilder	: function( nr, item ) {
				var src = $("img", item).attr( "src" );
					src = src.replace( "/large/", "/small/");
				return '<img src="' + src + '" />';
			}
		}
	});*/
	
	$("a[id^='nmhsc']").click(function(){ 
		clearInterval(t_slider);
		var id = $(this).attr('id');
		id = id.replace('nmhsc', '');
		id = parseInt(id);
		slide2show = id;
		slide_mh(id);
		t_slider = setInterval("xslide_mh();  ", 6000);
	});
	
	/*$("#mh_slides a").mouseover(function(){
		clearInterval(t_slider);
		});
	$("#mh_slides a").mouseout(function(){
		//t_slider = setInterval("xslide_mh();  ", 6000);
		});*/
		
	
	t_slider = setInterval("xslide_mh();  ", 6000);
	
	//add small pics to header slider nav menu
	/*$("a[id^='mh_slide']").each(function(){
		var aidicur = $(this).attr('id');
		var isc = $("#"+aidicur+" img").attr('src');
		nsc = isc.replace('.png', '_small.png');
		aidicur = aidicur.replace('mh_slide', '');
		//$("#nmhsc"+aidicur+" img").attr('src', nsc);
		$("#nmhsc"+aidicur).append('<img src="'+nsc+'" alt="" />');
	});*/
	
	//fac incarcare asincrona a chcestiei de la Facebook, ca incetineste site-ul altfel
	/*$("#loc_de_dat_cu_facebooku").html($("#loc_de_parcat_facebooku".html());
	$("#loc_de_parcat_facebooku".html('');*/
	
	if(pornesteSudokuClasic==1){
		sudoku_init();	
	}
	
	//exercitii online
	if(exoLoadJoc == 1) { loadJoc('resetare'); }
	
//	$(".root_modificat").click(function(){
//										//var tasu = $(this + ":parent");
//										$(this).parent().("ul").toggle();
//										//$("#"+this.id+" ul").toggle();
//										var auci = $(this).attr('id');
//										$("#"+auci).css('background', 'url(/images/new/bulina_tree_close.jpg) 10px 2px no-repeat #fff');
//										if($("#"+this.id+" ul").css("display") != 'none'){
//											$("#"+this.id).css('background', 'url(/images/new/bulina_tree_open.jpg) 10px 2px no-repeat #fff');
//										}
//										});
});

var t_slider = 0;
var slide2show = 1;
	
function xslide_mh(){
	id = slide2show;
	id = parseInt(id);
	id = id + 2 - 1;
	slide2show = id;
	slide_mh(slide2show);
}

function slide_mh(id){
	var a = 0;
	$("a[id^='nmhsc']").each(function(){
									 a = a + 2 - 1;
									 //return a;
									 $(this).removeClass('mh_sliders_control2');
									 $(this).addClass('mh_sliders_control');
									 });
	if(id<=0){ id = a; }
	//var nrSlidesR = $("[id^='mhsc']");
	var nrSlides = $("[id^='nmhsc']").length;
	if(id>a) { id = 1; }
	slide2show = id;
	$("a[id^='mh_slide']").not(['id='+id]).hide(); ;//'[id='mh_slide'"+id+"]))").hide();
	//$("a[id^='mh_slide']").fadeOut('slow'); ;//'[id='mh_slide'"+id+"]))").hide();
	$("#mh_slide"+id).fadeIn('slow');
	$("#nmhsc"+id).addClass('mh_sliders_control2');
}


