$(document).ready(
	function(){
			
	$('.getcontactform') .click(function() {
		$('#povprasevanje').show('slow');
		$('.prejemnik_input').text($(this).text());
		$('input.prejemnik_input').val($(this).text());
	});
			$('#slider').innerfade({
					speed: 1000,
					timeout: 7000,
					type: 'sequence',
					containerheight: '320px'
			});
					
			cycleGallery("div#galerijawrap");
			$('#main_picture_slideshow').cycle({ 
			    fx:     'fade', 
			    speed:   700, 
			    timeout: 5000, 
			    pause:   1 
		    });
			$('#galerija .galerija_slike').corner();
			$('#galerija .slika').corner();
			$('.floor_slika').corner();
			//$('#offer_apartment #stanovanje .stanovanje_slika').corner();
			$("#galerija a.group").fancybox({ 'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': false });
		
		
			$("input.gumb_prijava").click(function(){
				var ime_priimek = $("#contactform input#ime_priimek").val();
				var email = $("#contactform input#email").val();
				var building_id = $("#contactform input#building_id").val();
				
				//alert("ime_priimek="+ime_priimek+"&email="+email+"&building_id="+building_id);
			
				$.ajax({
			       type: "POST",
			       url: "/si/ajax/",
			       data: "ime_priimek="+ime_priimek+"&email="+email+"&building_id="+building_id,
			       async: false,
			       success: function(msg){
			        if (msg == 2) {
			       			$("#contactform .error").html("Ta E-poštni naslov je že prijavljen na obveščanje za ta objekt.");
			       		} else if(msg == 1){
							$("#contactform").fadeOut("slow");
			       		};
			        }
			  	});
			});
		
	 		$("input.gumb_kontakt_stanovanje").click(function(){
				var ime_priimek = $("#povprasevanje input#ime_priimek").val();
				var email = $("#povprasevanje input#email").val();
				var question = $("#povprasevanje textarea#question").val();
				var apartment_id = $("#povprasevanje input#apartment_id").val();
				
				//alert("ime_priimek="+ime_priimek+"&email="+email+"&question="+question+"&apartment_id="+apartment_id);
			
				$.ajax({
			       type: "POST",
			       url: "/si/ajax/",
			       data: "ime_priimek="+ime_priimek+"&email="+email+"&question="+question+"&apartment_id="+apartment_id,
			       async: false,
			       success: function(msg){
			       		if (msg == 1) {
			       			$("#povprasevanje .error").html("Prosimo vpišite vsa polja");
			       		} else if(msg == 2){
			       			$("#povprasevanje h2").html("Hvala za povpraševanje!");
							$("#povprasevanje .formhidenn").fadeOut("slow");
			       		} else if(msg == 3){
			       			$("#povprasevanje h2").html("Stanovanje je že oddano!");
			       			$("#povprasevanje .formhidenn").fadeOut("slow");
			       		};

			        }
			  	});
			});
		$("input.gumb_kontakt").click(function(){
				var ime_priimek = $("#povprasevanje input#ime_priimek").val();
				var email = $("#povprasevanje input#email").val();
				var question = $("#povprasevanje textarea#question").val();
				var prejemnik = $("#povprasevanje input.prejemnik_input").val();
				
				//alert("ime_priimek="+ime_priimek+"&email="+email+"&question="+question+"&apartment_id="+apartment_id);
			
				$.ajax({
			       type: "POST",
			       url: "/si/ajax/",
			       data: "ime_priimek="+ime_priimek+"&email="+email+"&question="+question+"&prejemnik="+prejemnik,
			       async: false,
			       success: function(msg){
			       		if (msg == 1) {
			       			$("#povprasevanje .error").html("Prosimo vpišite vsa polja");
			       		} else if(msg == 2){
			       			$("#povprasevanje h2").html("Hvala za povpraševanje!");
							$("#povprasevanje .formhidenn").slideUp("slow");
			       		}
			        }
			  	});
			});
		});
$.fn.clearForm = function() {
  return this.each(function() {
    var type = this.type, tag = this.tagName.toLowerCase();
    if (tag == 'form')
      return $(':input',this).clearForm();
    if (type == 'text' || type == 'password' || tag == 'textarea')
      this.value = '';
    else if (type == 'checkbox' || type == 'radio')
      this.checked = false;
    else if (tag == 'select')
      this.selectedIndex = -1;
  });
};
$(function() {
			
			$.fn.maphilight.defaults = {
				fill: true,
				fillColor: '333333',
				fillOpacity: 0.5,
				stroke: true,
				strokeColor: 'ffffff',
				strokeOpacity: 0.2,
				strokeWidth: 1,
				fade: true,
				alwaysOn: false
			}
	$('.map_building').maphilight();
});
$(function() {
			
			$.fn.maphilight.defaults = {
				fill: true,
				fillColor: '333333',
				fillOpacity: 0.5,
				stroke: true,
				strokeColor: 'ff0000',
				strokeOpacity: 0.5,
				strokeWidth: 2,
				fade: true,
				alwaysOn: false
			}
	$('.map_floor').maphilight();
});
function cycleGallery(divName)
	{
        $(divName).cycle({ 
        	fx:     'fade', 
        	prev:   '#cycle_left', 
        	next:   '#cycle_right',
        	timeout: 0,
        	speed: 500
        });  
    };

	   


