﻿$(document).ready(function(){
	//						  
});

$(window).load(function(){
						
	/*
	NEW BUILDING
	*/
	$("a.newbuilding").prepend('<div class="bloc-nou-overlay"></div>');
						
	/*
	ACTIVE MAIN MENU
	*/
	$.each($("#main-menu li"), function(){
		url = $(this).find("a").attr("href");
		if(url == location.href)
		{
			$(this).addClass("active");	
		}
	});
	
	/*
	ACTIVE SECONDARY MENU
	*/
	$.each($("#small-menu li"), function(){
		url = $(this).find("a").attr("href");
		if(url == location.href)
		{
			$(this).addClass("active");	
		}
	});
	
	/*
	SELECTOR
	*/
	$("form.jqtransform").jqTransform();
	
	/*
	PAGINATION fixes
	*/
	var last_pagination_element_top = $("div.pagination-wrap-top div.pagination-wrap  .r ul li:last");
	var last_pagination_element_bottom = $("div.pagination-wrap-bottom div.pagination-wrap  .r ul li:last");
	$(last_pagination_element_top).addClass("paglastright");
	$(last_pagination_element_bottom).addClass("paglastright");
	//
	
	/*
	PHOTO ZOOM
	*/
	$("a[rel^='prettyPhoto']").prettyPhoto({
		animationSpeed: 'normal', /* fast/slow/normal */
		padding: 40, /* padding for each side of the picture */
		opacity: 0.35, /* Value between 0 and 1 */
		showTitle: false, /* true/false */
		allowresize: true, /* true/false */
		counter_separator_label: ' din ', /* The separator for the gallery counter 1 "of" 2 */
		theme: 'facebook', /* light_rounded / dark_rounded / light_square / dark_square */
		callback: function(){}
	});	


	/*
	OFF DETAILS FORM
	*/
	$("#off_details_form #trimite").click(function(event){
		event.preventDefault();	
		
		var nume 	= jQuery.trim($("#off_nume").val());
		var telefon = jQuery.trim($("#off_telefon").val());
		var email 	= jQuery.trim($("#off_email").val());
		var cod 	= jQuery.trim($("#off_cod").val());
		var mesaj 	= jQuery.trim($("#off_mesaj").val());
		
		if(nume == "" || telefon == "" || cod == "")
		{
			//alert ("Completeaza tot ce trebuie acolo!");
			$(".offer-contact-info-status").html("Vă rugăm completaţi toate câmpurile marcate cu (*). Mesajul NU a fost trimis.");
			$(".offer-contact-info-status").addClass("offer-contact-info-status-error");
			$(".offer-contact-info-status").slideDown("slow");
			setTimeout(function() {
				$('.offer-contact-info-status').slideUp('fast');
			}, 5000);
		}
		else
		{
			var data_string = "nume=" + nume + "&telefon=" + telefon + "&email=" + email + "&cod=" + cod + "&mesaj=" + mesaj + "&checked=true";

			$.ajax({
			  type: "POST",
			  url: $("#off_details_form").attr("action"),
			  data: data_string,
			  success: function() {
				$("#off_nume").val("");  
				$("#off_telefon").val("");  
				$("#off_email").val("");  
				$("#off_mesaj").val("");  
				
				$(".offer-contact-info-status").html("Vă mulţumim, mesajul a fost trimis şi veţi fi în curând contactat.");
				$(".offer-contact-info-status").removeClass("offer-contact-info-status-error");
				$(".offer-contact-info-status").slideDown("slow");
			  }
			 });
		}
	});
	
	/*
	SIDE BANNER ROTATOR
	*/
	var banner_rotator_length = $("#sidebanner-rotator li").length; 
	var rand_no = Math.floor(banner_rotator_length * Math.random());
	$("#sidebanner-rotator li").eq(rand_no).show();
	
	/*
	CONTACT PAGE
	*/
	$("#contact-right img").hover(function(){
		$(this).addClass("imghover");									   
	},function(){
		$(this).removeClass("imghover");	
	});


	/*
	BUTTON HOVERS
	*/
	$("#selector_search, #selector_search_cod").hover(function(){
		$(this).addClass("selector-btn-hover");														   
	},function(){
		$(this).removeClass("selector-btn-hover");	
	});
	
	$("#trimite").hover(function(){
		$(this).addClass("trimite-btn-hover");														   
	},function(){
		$(this).removeClass("trimite-btn-hover");	
	});

});

