// JavaScript Document

path="";

/** for light box in apt.cfm*/
$(function() {
	if($('#gallery a').length){
		$('#gallery a').lightBox({
			imageLoading: 'images/lightbox/loading.gif',
			imageBtnClose: 'images/lightbox/close.gif',
			imageBtnPrev: 'images/lightbox/prev.gif',
			imageBtnNext: 'images/lightbox/next.gif'
		});
	}
});

function setPath(_path){
	path = _path;
}

function writeHeader(){
	document.write("<div class= \"leftList\">");
	document.write("<span class=\"headerColumnListing\">FEATURED LISTINGS<\/span>");
	document.write("<span class=\"headerColumn1\"><script type=\"text\/javascript\" src=\"javascript\/scroller.js\"><\/script><\/span>");
	document.write("<\/div>");
	
    document.write("<div class= \"rightList\">");
	document.write("<span class=\"headerColumnQuickSearch\">QUICK SEARCH<\/span>");

    document.write("<div id=\"price\"><span class=\"noBolder\">");
    document.write("<form method=\"POST\" action=\"search_result.cfm\" name=\"mylist\">");
	document.write("<input type=\"hidden\" value=\"A\" name=\"bldg_price\">");
	document.write("<input type=\"hidden\" value=\"0001\" name=\"bldg_price\">");
	document.write("<input type=\"submit\" value=\"Under $2500\" name=\"B1\">");
	document.write("<\/form>");
	document.write("<\/span>");
	
	document.write("<span class=\"quick\">");
	document.write("<form method=\"POST\" action=\"search_result.cfm\" name=\"mylist2\">");
	document.write("<input type=\"hidden\" value=\"A\" name=\"bldg_price\">");
	document.write("<input type=\"hidden\" value=\"2500\" name=\"bldg_price\">");
	document.write("<input type=\"hidden\" value=\"3000\" name=\"bldg_price\">");
	document.write("<input type=\"submit\" value=\"$2500 to $3499\" name=\"B1\">");
	document.write("<\/form>");

	

	document.write("<form method=\"POST\" action=\"search_result.cfm\" name=\"mylist3\">");
	document.write("<input type=\"hidden\" value=\"A\" name=\"bldg_price\">");
	document.write("<input type=\"hidden\" value=\"3500\" name=\"bldg_price\">");
	document.write("<input type=\"hidden\" value=\"4000\" name=\"bldg_price\">");
	document.write("<input type=\"submit\" value=\"$3500 to $4999\" name=\"B1\">");
	document.write("<\/form>");

	

	document.write("<form method=\"POST\" action=\"search_result.cfm\" name=\"mylist4\">");
	document.write("<input type=\"hidden\" value=\"A\" name=\"bldg_price\">");
	document.write("<input type=\"hidden\" value=\"5000\" name=\"bldg_price\">");
	document.write("<input type=\"hidden\" value=\"6000\" name=\"bldg_price\">");
	document.write("<input type=\"submit\" value=\"$5000+\" name=\"B1\">");
	document.write("<\/form>");
document.write("<\/span><\/div>");

	document.write("<\/div>");		

}

function createScroller(){
	   /*
	   var pausecontent=new Array()
       pausecontent[0]='<a href=""+path+"bldg_detail.cfm?BID=1">Upper West Side - West End Towers</a>'
       pausecontent[1]='<a href=""+path+"apt_detail.cfm?ID=3113">Midtown West - 2 BR Penthouse/2 Baths</a>'
       pausecontent[2]='<a href=""+path+"apt_detail.cfm?ID=2887">Battery Park City - Studio/1 Bath</a>'
       pausecontent[3]='<a href=""+path+"latest-developments.htm">CHELSEA ENCLAVE - An Enclave of Serenity in the Heart of Chelsea</a> '
       new pausescroller(pausecontent, "pscroller1", "headerColumn1", 5000)*/
	}

/*function writeLogo(){
	document.write("<a href=\""+path+"index.htm\" title=\"\"><img src=\""+path+"images\/brodsky-logo.png\" \/><\/a>");
}
*/
function writeLogo(){
	document.write("<div id= \"logoSWF\"><\/div>");
	var params = {};
	params.menu = "true";
	params.scale = "noscale";
	params.wmode = "transparent";
	params.swliveconnect = "true";
	params.allowfullscreen = "true";
	params.allowscriptaccess = "always";
	params.allownetworking = "all";
	var attributes = {};
	attributes.id = "logoSWF";
	attributes.name = "logoSWF";
	swfobject.embedSWF("swf/logo.swf", "logoSWF", "650", "70", "9", path+"swf/expressInstall.swf", {}, params, attributes);	
	//document.write("<a href=\""+path+"index.htm\" title=\"\"><img src=\""+path+"images\/brodsky-logo.png\" \/><\/a>");
}

function goHome(){
	window.location.href = "index.cfm";
}

function writeBgImg(){
/*
var backgr1="images/about/brodsky_bg1.jpg"
var backgr2="images/about/brodsky_bg2.jpg"
var backgr3="images/about/brodsky_bg3.jpg"
var backgr4="images/about/brodsky_bg4.jpg"
var backgr5="images/about/brodsky_bg5.jpg"
var backgr6="images/about/brodsky_bg6.jpg"
var backgr7="images/about/brodsky_bg7.jpg"
*/
var cur=Math.floor(4*Math.random())
/*if (cur<=1)
backgr=backgr1
else if (cur<=7)
backgr=backgr2
else
backgr=backgr3*/
document.write('<body background="images/about/brodsky_bg'+cur+'.jpg" bgcolor="#cccccc">');
}

function writeContentMenu(n){
	document.write("<ul>");
	document.write("<li><a href=\""+path+"search.cfm\">SEARCH FOR APARTMENTS<\/a><\/li>");
	document.write("<li><a href=\""+path+"rentals.htm\">RENTALS<\/a><\/tr>");
	document.write("<li><a href=\""+path+"condominiums.htm\">CONDO & CO-OP<\/a><\/li>");
	document.write("<li><a href=\""+path+"retail.htm\">RETAIL<\/a><\/li>");
	document.write("<li><a href=\""+path+"latest-developments.htm\">LATEST DEVELOPMENTS<\/a><\/li>");
	document.write("<li><a href=\""+path+"about.htm\">ABOUT<\/a><\/li>");
	document.write("<li><a href=\""+path+"contact.htm\">CONTACT<\/a><\/li>");
	document.write("<\/ul>");
	if(n>0){
		$('div#contents .menu ul li:eq('+(n-1)+') a').css("color","#069");
		$('div#contents .menu ul li:eq('+(n-1)+') a').hover(
			function(){
				$(this).css('color', '#FFF');
			},
		    function(){
			  $(this).css('color', '#069');
		    });
	}
}

function writeFooter(){
	document.write("<span class=\"columnContact\"><b>The Brodsky Organization</b>&nbsp;400 West 59th St. New York, NY 10019 &nbsp;T:212.315.5555 &nbsp;   F:212.315.5963<\/span>");
	document.write("<span class=\"addthis_button\"><a href=\"http://www.addthis.com/bookmark.php?v=250&amp;pub=mosesbunny\"><img src=\""+path+"images\/share-icon.gif\" \/><\/a><\/span>");
	document.write("<script type=\"text\/javascript\" src=\"http:\/\/s7.addthis.com\/js\/250\/addthis_widget.js?pub=mosesbunny\"><\/script>");
	document.write("<span class=\"opportunity\">An Equal Housing Opportunity<\/span>");
	document.write("<span class=\"policy\"><a href=\""+path+"terms-of-use.htm\">Terms of Use<\/a>  |  <a href=\""+path+"privacy.htm\">Privacy Policy<\/a><\/span>");
}

function writeSWF(url,divId,width,height){
	var params = {};
	params.menu = "true";
	params.scale = "noscale";
	params.wmode = "transparent";
	params.swliveconnect = "true";
	params.allowfullscreen = "true";
	params.allowscriptaccess = "always";
	params.allownetworking = "all";
	var attributes = {};
	attributes.id = divId;
	attributes.name = divId;
	swfobject.embedSWF(url, divId, width, height,
	"9", path+"swf/expressInstall.swf", flashvars, params,
	attributes);	
}

//for map temporary use
function linkTo(_zone, _spot){
	flashvars = {};
	flashvars.zone = _zone;  ///zoneName
	flashvars.spot = _spot;   //spot id
	if(_spot!=""){
		window.location.href = path+"bldg_detail.cfm?BID="+_spot;
	}else{
		window.location.href = path+String(_zone).toLowerCase()+".cfm";
	}
}


function checkBrowser(){
	fixLayout();
}

function fixLayout(){
	if($('#blodgColumnRight').length){
		if($('#blodgColumnRight').height()<$('#blodgColumnMid').height()){
			$('#blodgColumnMid').css("height","190px");
		}else if($('#blodgColumnRight').height()>$('#blodgColumnMid').height() && $('#blodgColumnRight').height()<190){
			$('#blodgColumnMid').css("height","190px");
		}else{
			$('#blodgColumnMid').css("height",$('#blodgColumnRight').height());
		}
		if($('#blodgColumnRight').height()<$('#blodgColumnMid').height()){
			if($('#blodgColumnMid').height()<190){
				$('#blodgColumnMid').css("height","190px");
				$('#blodgColumnRight').css("height","190px");
			}else{
				$('#blodgColumnRight').css("height",$('#blodgColumnMid').height());
			}	
		}else{
			if($('#blodgColumnRight').height()>190){
				$('#blodgColumnMid').css("height",$('#blodgColumnRight').height());
			}else{
				$('#blodgColumnMid').css("height","190px");
				$('#blodgColumnRight').css("height","190px");
			}				
		}
	}
	
	if($('#bldgRight').length){
		if($('#bldgRight').height()>(358+$('#bldgOutlink').height()+5)){
			//$('#bldgRight').css("height", $('#bldgRight').height()+50);
			//$('#bldgRight').css("height", $('#bldgRight').height()+$('#bldgOutlink').height()+5);
		}else{
			$('#bldgRight').css("height", 358+$('#bldgOutlink').height()+5);
		}		
	}
	
	if($('#ct').height() < 220){
		$('#CondRight').css("height",$('#CondPic').height());
	}else{
		$('#CondRight').css("height",$('#ct').height()+160);
		//$('#CondLeft').css("height",$('#CondRight').height());
	}
	
	if($('#slideshowLeft').height()==0){
		$('#slideshowRight').css("height","358px");
	}else if($('#slideshowRight').height()<=$('#slideshowLeft').height()){
		$('#slideshowRight').css("height",$('#slideshowLeft').height());
	}
	
	if($('#threeColumnContainer').height() < 400){
		$('#threeColumnMid').css("height","400px");
		$('#threeColumnRight').css("height","400px");
	}else{
		$('#threeColumnMid').css("height",$('#threeColumnContainer').height());
		$('#threeColumnRight').css("height",$('#threeColumnContainer').height());	
	}
	if($('#contents').height() < 451){
		$('#contents .content').css("height","358px");
	}
	if($('#formContainer').length){
		$('#liste2ColumnLeft').css("height","480px");
		$('#liste2ColumnRight').css("height","480px");	
		$('#contents .content').css("height","480px");
	}
}

