﻿//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;

//loading popup with jQuery magic!
function loadPopup(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		
		
		$("#pop").fadeIn("slow", function(){
			
			
			showApartment();
			
			
		});
		popupStatus = 1;
		
	}
}

//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#pop").fadeOut("slow");
		popupStatus = 0;
	}
}

//centering popup
function centerPopup(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#pop").height();
	var popupWidth = $("#pop").width();
	
	var topDistance = (windowHeight/2-popupHeight/2 > 25) ? windowHeight/2-popupHeight/2 : 25;
	var leftDistance = (windowWidth/2-popupWidth/2 > 25) ? windowWidth/2-popupWidth/2 : 25;
	
	//centering
	$("#pop").css({
		"position": "absolute",
		"top": topDistance,
		"left": leftDistance
	});
	//only need force for IE6
	
}

function getFlashMovie(movieName) {
	
	if (window.document[movieName]) 
  {
      return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }

}

function showApartment(string){
	//createBF(string);
}

function showpopup(){
	centerPopup();
	loadPopup();
}


//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){

	showpopup();

});
