function PageLoad(){
	
	Nifty("div.bubble","big");
	Nifty("div#logo-box","big fixed-height");
	
};

function SplashPageLoad(){
	
	Nifty("div.bubble","big");
	
};

function PageLoadWithPuff(){
	
	PageLoad();
	new Effect.BlindUp("flash-content",{delay:5.0, duration:1.0});
	//new Effect.Fade("flash",{delay:5.0, duration:1.0});
	
};

var selectedLocation = true;

function selectLocation(id) {
	
	if(selectedLocation != id && $('form-location-control-'+selectedLocation)){
		
		$('form-location-control-'+selectedLocation).style.background = '#FFFFFF';
		
	}
	
	$('property_location_id').value = id;
	$('form-location-control-'+id).style.background = '#5284CC';
	selectedLocation = id;
	
};

var Slide = new Image();
var SlideShow = {
	start: function(slide,nextSlidePath){
		if(this.currentSlide == null){
			this.currentSlide = slide;
			Slide.src = nextSlidePath;
		}
		if(this.slideExecuter != null){
			this.stop();
			
		}
		$('slide-control').innerHTML = this.slideStopText();
		$('slide-control').onclick = function(){SlideShow.stop(); return false;};
		this.nextSlide;
		this.slideExecuter = new PeriodicalExecuter(this.nextSlide,10);
	},
	stop: function(){
		$('slide-control').innerHTML = this.slideStartText();
		$('slide-control').onclick = function(){SlideShow.start(0); return false;};
		if(this.slideExecuter){
			this.slideExecuter.stop();
			this.currentSlide = null;
		}
	},
	nextSlide: function(){
		if(Slide.complete){
			new Ajax.Request('/photo/next_slide_show/'+SlideShow.currentSlide,{asynchronous:true,evalScripts:true});
		}
	},
	setNextSlide: function(id){
		this.currentSlide = id;
	},
	slideStopText:function(){
		switch(this.determineLanguage()){
			case "en":
				return "Stop SlideShow";
				break;
			case "fr":
				return "Arrêter";
				break;
		}
	},
	slideStartText:function(){
		switch(this.determineLanguage()){
			case "en":
				return "Start SlideShow";
				break;
			case "fr":
				return "Jouer";
				break;
		}
	},
	determineLanguage:function(){
		switch($('slide-control').innerHTML){
			case "Start SlideShow":
			case "Stop SlideShow":
				return "en";
				break;
			case "Jouer":
			case "Arrêter":
				return "fr";
				break;
		}
	},
	currentSlide: null,
	slideExecuter: null
	
}

function emptySelectField(element){
        for(var i = $(element).childNodes.length - 1; i >= 0 ; i-- ){
                removeChild($(element).childNodes[i]);
        }
}

function checkRef(){
	if($('property_reference').value != ''){
		new Ajax.Request('/property/ref_check/?reference='+$('property_reference').value,{asynchronous:true,evalScripts:true});
	}
}

function checkTitle(){
	if($('property_title').value != ''){
		new Ajax.Request('/property/title_check/?title='+$('property_title').value,{asynchronous:true,evalScripts:true});
	}
}

function AddOption(e,o){
	if(/MSIE/.test(navigator.userAgent)){
		e.options[e.length] = o;
	} else {
		e.add(o,null);
	}
}

function removeChild(c){
        c.parentNode.removeChild(c);
}
