var lastDiv = "propdata propdata_pics";
var hideDivList = "accom accom_pics amenities amenities_pics gallery_pics";
var propDivs = new Object;
var winbigpic = null;

propDivs.propdata_nav = "propdata propdata_pics";
propDivs.accom_nav = "accom accom_pics";
propDivs.amenities_nav = "amenities amenities_pics";
propDivs.gallery_nav = "propdata gallery_pics";

function bigpic_rawpopup(url, target, features) {
  if (isUndefined(features)) {
    features = _POPUP_FEATURES;
  }
  if (isUndefined(target)) {
    target = '_blank';
  }
  winbigpic = window.open(url, target, features);
  winbigpic.focus();
  return winbigpic;
}
function callAvol(AOcode){
	return function(e){
		avolPopup(AOcode);
	}
}
function callAvolRes(AOcode){
	return function(e){
		avolResPopup(AOcode);
	}
}
/*
function event_popup_features(features) {
  return function(e) { 
    link_popup(e.currentTarget, features); 
    e.preventDefault(); 
  }
}
function link_popup(src, features) {
  return raw_popup(src.getAttribute('href'),
    src.getAttribute('target') || '_blank',
    features);
}*/

function bigpic_popup(e) {
	var href = e.currentTarget.getAttribute('href');
	var varsarray = e.currentTarget.getAttribute('href').split('?')[1].split('&'); //array of query parms
	for (var i=0; i<varsarray.length; i++) {
		eval("var " + varsarray[i].split('=')[0] + ' = "' + unescape(varsarray[i].split('=')[1].replace(/\+/g," "))+ '"');
	}
	picy = Number(picy) + 16;
	picx = Number(picx);
	if (winbigpic && !winbigpic.closed) {
		winbigpic.close();
	}
	var winprop = "resizable=no,width=" + picx + ",height=" + picy;
	bigpic_rawpopup(href,'bigpic',winprop);
}
function bigpic_test(obj) {
	var href = obj.getAttribute('href');
	var varsarray = href.split('?')[1].split('&'); //array of query parms
	for (var i=0; i<varsarray.length; i++) {
		eval("var " + varsarray[i].split('=')[0] + ' = "' + unescape(varsarray[i].split('=')[1].replace(/\+/g," "))+ '"');
	}
	picy = Number(picy) + 16;
	picx = Number(picx);
	if (winbigpic && !winbigpic.closed) {
		winbigpic.close();
	}
	var winprop = "resizable=no,width=" + picx + ",height=" + picy;
	bigpic_rawpopup(href,'bigpic',winprop);
}
function hideit(objname){
	document.getElementById(objname).style.display="none";
//	alert(objname +" is " + document.getElementById(objname).style.display);
}	
function showit(objname){
	document.getElementById(objname).style.display="";
//	alert(objname +" is now " + document.getElementById(objname).style.display);
}	
function primePage() {
	var hideDivs = hideDivList.split(" ");
	for (var i=0;i<hideDivs.length;i++){
		addClass(document.getElementById(hideDivs[i]),"hidediv");
	}
	addEvent("propdata_nav", "click", divControl('propdata propdata_pics'));
	addEvent("accom_nav", "click", divControl('accom accom_pics'));
	addEvent("amenities_nav", "click", divControl('amenities amenities_pics'));
	addEvent("gallery_nav", "click", divControl('propdata gallery_pics'));
	addEvent("quote_nav", "click", event_popup_features(airquoteParms));
/*	addEvent("avail_nav", "click", event_popup_features(avolResPopupParms));
	addEvent("res_nav", "click", event_popup_features(avolPopupParms));
	addEvent("propdata_nav_ftr", "click", divControl('propdata propdata_pics'));
	addEvent("accom_nav_ftr", "click", divControl('accom accom_pics'));
	addEvent("amenities_nav_ftr", "click", divControl('amenities amenities_pics'));
	addEvent("gallery_nav_ftr", "click", divControl('propdata gallery_pics'));
	addEvent("quote_nav_ftr", "click", event_popup_features(airquoteParms));
	addEvent("avail_nav_ftr", "click", event_popup_features(avolResPopupParms));
	addEvent("res_nav_ftr", "click", event_popup_features(avolPopupParms));*/
	addEvent(getElementsByClass("bigpiclink"),"click",bigpic_popup);
	addClass(document.getElementById("accom"),"hidediv");
	addClass(document.getElementById("amenities"),"hidediv");
	addClass(document.getElementById("accom_pics"),"hidediv");
	addClass(document.getElementById("amenities_pics"),"hidediv");
	addClass(document.getElementById("gallery_pics"),"hidediv");
	propLinkLoad();
	showit("accom");
	showit("amenities");
	showit("accom_pics");
	showit("amenities_pics");
	showit("gallery_pics");
}
addLoadEvent(primePage);
