var jsBDInfo;
//<!-- Show photo gallery popup BEGIN--!>
function showPGWindow(lnk){	
 myWindow = window.open(lnk,'Galerie_Foto', 'resizable=no,width=730,height=520' );
 if(myWindow != null) myWindow.focus();
return false;
}

//<!-- Show photo gallery popup END--!>

//<!-- Show housing book now popup BEGIN--!>
function showHousingBookNowWindow(lnk)
{
 //myWindow = window.open(lnk,'Book_Now', 'resizable=no,width=650,height=360' );
 myWindow = window.open(lnk,'Book_Now', 'resizable=no,width=650,height=450' );
 if(myWindow != null) myWindow.focus();
 return false;
}
//<!-- Show housing book now popup popup END--!>
function showTourBookNowWindow(ID)
{
lnk = "/?loadPage=book_tour&id="+ID;
	myWindow = window.open(lnk,'Book_Now', 'resizable=no,width=650,height=420' );
	if(myWindow != null) myWindow.focus();
	return false;

}
function openCustomOfferWidow()
{
	myWindow = window.open("/?loadPage=personalized_offer",'custom_offer', 'resizable=no,width=500,height=300' );
	if(myWindow != null) myWindow.focus();
	return false;
}

function openHtmlGrid(idhousing, id_grid) {
	lnk = "/?loadPage=popup_html_prices&id="+idhousing+"&idgr="+id_grid;
	myWindow = window.open(lnk,'HousingGrid', 'resizable=yes,width=750,height=750' );
	if(myWindow != null) myWindow.focus();
	return false;
}


/************ COMBO -*****************************/
function showHideComboList(mode, clistName)
{
	var clist =  document.getElementById(clistName);
	if (mode == -1)
	{
		clist.style.visibility = 'hidden';
		return true;
	}

	if (mode == 1)
	{
		clist.style.visibility = 'visible';
		return true;
	}
	if (clist.style.visibility == 'hidden')
	{
		clist.style.visibility = 'visible';
	} else
	{
		clist.style.visibility = 'hidden';
	}
}

function  comboHoverStyle(isHover, trid)
{
	var myTr =  document.getElementById(trid);
	if(isHover == 1)
	{
		myTr.className ='comboStlOver';
	} else
	{
		myTr.className ='comboStl';
	}
}

/*******REDIRECT*/
function goTo(address){location.href = address;}


function changeSmenuBtnFace(id_smenu, state)
{
	var lnkObj = document.getElementById("lnk_sm_"+id_smenu);
	if (state==1)
	{
		lnkObj.className = 'menu_scat_linkh';
	} else
	{
		lnkObj.className = 'menu_scat_link';
	}

}
function changeMenuBtnFace(id_smenu, state)
{
	var lnkObj = document.getElementById("lnk_m_"+id_smenu);
	if (state==1)
	{
		lnkObj.className = 'menu_cat_linkh';
	} else
	{
		lnkObj.className = 'menu_cat_link';
	}
}

function isNLValidEmail() {if (/^\w+([\.\-]?\w+)*@\w+([\.\-]?\w+)*(\.\w{2,4})+$/.test(document.getElementById("NL_email").value))	return true; else {alert("Email invalid!");return false;}}

function runLoadRoutines() {
	if(document.getElementById('tickerBand') != undefined)	{
		tickerStart();
	}
	if(document.getElementById('menuLeft') != undefined) {
		initLeftMenu();
	}	
}

function getObj(id) {return document.getElementById(id);}
function hideDiv(divID){ var dv = document.getElementById(divID);dv.className = "LMNpopup";}
function showDiv(divID){var dv = document.getElementById(divID);dv.className = "LMNpopupOn";}

function initLeftMenu() {
	var ml	= getObj('menuLeft');
	var lis=ml.getElementsByTagName("DIV");
    for (i=0; i<lis.length; i++) {
		var dv = lis[i];
		if(dv.id != "")
		dv.onmouseout=leftMenu_overContainer;				
	}
}

function leftMenu_overContainer(e) {
	var keycode;
	if (window.event) 	e = window.event;
	var srcEl = e.srcElement? e.srcElement : e.target
	var  theElId ;
	if(srcEl.tagName == "A")
	 theElId = getParentElement(srcEl, 1).id;
	else
	 theElId = srcEl.id;
	 
	theElId = theElId.replace('leftMenuC', 'leftMenu')
	hideDiv(theElId);
}


function getParentElement(obj, level) {
	var result = (document.all) ? obj.parentElement:obj.parentNode;
	if(level != 1) {
		return getParentElement(result, level-1);
	} else	return result;
}

/*--------------------  LEFT MENU ----------------------*/

jQuery(document).ready(
		function($){
			$("#mn_LeftMenu a.fldr").mouseover(function(e) {
					if(($(this).next().length > 0) && ($(this).next().get(0).className == 'cont')) mnShow(this);
				});
			$("#mn_LeftMenu a.fldr").mouseout(function(e) {
				if(($(this).next().length > 0) && ($(this).next().get(0).className == 'cont'))mnHide($(this).next().children("div:first")[0]);
				});
			$("#mn_LeftMenu div").mouseout(function(e) {mnHide(this);});
			$("#mn_LeftMenu div").mouseover(function(e) {mnShowMe(this);});
		}
	);
	
function mnShow(sender) {mnShowMe($(sender).next().children("div:first"));}
function mnShowMe(elem) { var dv = $(elem); clearTimeout(dv.parents('div').attr('timeout')); clearTimeout(dv.attr('timeout'));if(dv.css('display') == 'none')	dv.show(250); }

function mnHide(sender) {if(sender.id == '') return; var toVar = setTimeout("mnRealyHide('"+sender.id+"')", 50); $(sender).attr('timeout', toVar);}
function mnRealyHide(dvId) { $("#"+dvId+":visible").hide(150);}
jQuery(document).ready(function($){	$("#mn_LeftMenu a.mn_noLink").click(function(e){return false;});
});

/*--------------------  //LEFT MENU ----------------------*/
/*--------------------  //TOUR COMBO ----------------------*/
jQuery(document).ready(function($){
	/* target blank simulator*/
	$("#tourComboLbl").click(function(e){	
		$('#tourCombo').slideDown(100); 
		return false;
	});
	$("#tourComboLbl").mouseover(function(e){clearTimeout($('#tourCombo').attr('to'));});
	$("#tourComboLbl").mouseout(function(e){var toVar = setTimeout("hideTc()", 200);$('#tourCombo').attr('to', toVar);});
	$('#tourCombo').mouseover(function(e){clearTimeout($('#tourCombo').attr('to'));	$('#tourCombo').slideDown(200);});	
	$('#tourCombo').mouseout(function(e){var toVar = setTimeout("hideTc()", 200);$('#tourCombo').attr('to', toVar);});
	$('#tourCombo a').click(function(e){	$('#tourCombo').slideUp(100);});
	
});
function hideTc() {	$('#tourCombo').slideUp(200);}

/*--------------------  //TOUR COMBO ----------------------*/
jQuery(document).ready(function($){
	/* target blank simulator*/
	$("a.targetBlank").click(function(e){
		window.open(this.href); return false;
	});
	/* assign on click events to elements*/
	$("#newsletterBoxSubmit").click(function(e){
		if(isNLValidEmail()) $('#formNewsletter').submit();return false;
	});
});

/* ----------------------** sizes *-------------------------------------------------***/
$(document).ready(function() {
	matchColSize();
	sizeToFillAreas();	
});
function sizeToFillAreas() {
	$(".stretchToFill").each(function() {
			
			var totH= 0;
			var ph = $(this).parent().height();
			$(this).parent().children(":not(.stretchToFill)").each(
			function(){			
				totH += $(this).outerHeight();
			});
			var d = $(this).outerHeight()-$(this).innerHeight();
			$(this).height(ph-totH-d) ;	
		//	alert($(this).attr('id')+" => "+$(this).height()+
		//			"\n parend=" +$(this).parent().attr('id')+"="+$(this).parent().height());
		//	alert("\nph="+ph+"\ntotH=-"+totH+"\nd=-"+d);
	});
}

function outHeight(jObj, val) {
function _parseInt(v) {var i =parseInt(v, 10);return (isNaN(i))?0:i;}
if(arguments.length == 2) {
val -= _parseInt(jObj.css("padding-top")) + _parseInt(jObj.css("padding-bottom"));
val -= _parseInt(jObj.css("borderTopWidth")) + _parseInt(jObj.css("borderBottomWidth"));
jObj.height(val);val -= _parseInt(jObj.css("margin-top")) + _parseInt(jObj.css("margin-bottom"));jObj.height(val);
}  
else {
var totalWidth = _parseInt(jObj.height()); 
totalWidth += _parseInt(jObj.css("padding-top")) + _parseInt(jObj.css("padding-bottom")); 
totalWidth += _parseInt(jObj.css("borderTopWidth")) + _parseInt(jObj.css("borderBottomWidth")); 
return totalWidth;}
}

function matchColSize(){
var l = outHeight($("#leftCol"));var r = outHeight($("#rightCol"))-outHeight($("#headRow"));	
var c = outHeight($("#CntrCntntBox"));
var mx = l;mx = (r>mx)?r:mx;mx = (c>mx)?c:mx;
//outHeight($("#leftCol"),mx);
outHeight($("#CntrCntntBox"),mx);//outHeight($("#rightCol"),mx+outHeight($("#headRow")));
}

