/**
 * @author DigitalImage
 */
	jQuery(document).ready(function(){
	// Calendar
		var currentTime = new Date();
		var month = currentTime.getMonth()+1;
		var year = currentTime.getFullYear();

		jQuery("#cal-prev").click(function(){
			if (month == 1) {
				year -= 1;
				month = 12;
			} else month -= 1;

			jQuery.get('/nexus.php?act=genCalendar&month='+month+'&year='+year, function(data) {
				jQuery("#calendarz").html(data);
			});			
		});
		jQuery("#cal-next").click(function(){
			if (month == 12) {
				year += 1;
				month = 1;
			} else month += 1;
			
			jQuery.get('/nexus.php?act=genCalendar&month='+month+'&year='+year, function(data) {
				jQuery("#calendarz").html(data);
			});
		});	
		jQuery("#calendarz").ajaxStart(function() { jQuery(this).html('<img src="/images/ajax-loader.gif" class="loader" align="center" />');});
	//#############	
	
	//Lightbox
		jQuery('a[rel*=lightbox]').lightBox({
			keyToClose:"c",
			imageLoading: '/js/libraries/lightbox/images/lightbox-ico-loading.gif',
			imageBtnClose: '/js/libraries/lightbox/images/lightbox-btn-close.gif',
			imageBtnPrev: '/js/libraries/lightbox/images/lightbox-btn-prev.gif',
			imageBtnNext: '/js/libraries/lightbox/images/lightbox-btn-next.gif'			
		}); 
	//############
	
	// Scripturi fisa-ansamblu
	
	jQuery("#tab-ansamblu").click(function(){
		jQuery("#div-ansamblu").show();
		jQuery("#div-unitati,#div-informatii").hide();
	});
	jQuery("#tab-unitati").click(function(){
		jQuery("#div-unitati").show();
		jQuery("#div-ansamblu,#div-informatii").hide();
	});
	jQuery("#tab-informatii").click(function(){
		jQuery("#div-informatii").show();
		jQuery("#div-unitati,#div-ansamblu").hide();
	});
	
	//################################	
	
	// Promovare smart
	jQuery(".div_smart_content").hide();
	
	function showDetails(header,detail)
	{
		jQuery(header).hover( function(){
				jQuery(detail).stop(true,true).show("fast");
			},
			function(){
				jQuery(detail).stop(true,true).hide("fast");
			}
		);
	}
	showDetails("#smart1","#smart1_content");
	showDetails("#smart2","#smart2_content");
	showDetails("#smart3","#smart3_content");	
	//################################	
	
	
	jQuery(".poza_listare").hover(function(){
			jQuery("#primaPoza").attr("src",jQuery(this).attr("alt"));
			jQuery("#primaPoza").parent().attr("href",jQuery(this).parent().attr("href"))			
	});


	// Efect meniu
		// set opacity to nill on page load
		//jQuery(".butoane span").css("opacity","0");
		// on mouse over
		jQuery(".butoane span").hover(function () { 
			// animate opacity to full
			jQuery(this).stop().animate({
				opacity: 1
			}, "slow");
		},
		// on mouse out
		function () {
			// animate opacity to nill
			jQuery(this).stop().animate({
				opacity: 0
			}, "slow");
		});
		
		// Landing page

		jQuery("#cart-container").click(function(e){
			var target = jQuery(e.target);
			
			if(target.hasClass("elimina-comanda")) {
				var deleteId = target.prevAll(".cart-id-hidden").val();
				var deleteTip = target.prevAll(".cart-tip-hidden").val();
				target.parent().fadeOut().remove();
				
				cookieRemoveFromCart(deleteId, deleteTip);
			}
		});
		
		jQuery("#rezerva-acum").click(function(e){
			var formName = jQuery("#form_nume").html();
			var formPret = jQuery("#form_economisire").html();
			var formAnsamblu = jQuery("#form_numeans").html();
			var secretId = jQuery("#form_unitid").html();
			var secretTip = jQuery("#form_unittip").html();
			
			cookieAddToCart({pNume:formName, pretValue:formPret, pAnsamblu:formAnsamblu, secretId:secretId, secretTip:secretTip, formDiv: "cart-container"});
		});		
		
		
		// Despre noi tooltip
		jQuery('#tooltip-misiune').jqm({trigger: '#tooltip-misiuneTrigger'});		
	});
	
	// Fisa Ansamblu poze cycle
	function changePic(nume,id)
	{
		var basePath = "/poze/ansamblu/";
		jQuery("#primaPoza").attr("src",basePath+'thumb_'+nume);
	}