if (!window.idxBrochures)
	idxBrochures = {};
	
function wwlBrochure(){

	this.brochure = function(idxObj,IDX){
		var a;
		var optObj = optObj || {}
		var insertDiv = optObj.insertDiv || document.body;
		var x = idxObj;
		
		x.YEARB = x.YEARB || '----';
		
		var extra_images = [x.IMAGE,x.IMAGE2,x.IMAGE3,x.IMAGE4,x.IMAGE5,x.IMAGE6];
		var html_images = [];
		var counter = 1;
		for(var y = 0;y<extra_images.length;y++) {
			if (extra_images[y] > '') {
				if (counter == 1) {
					var margins = 'margin-top:5px;';
				} else if (counter == 2) {
					var margins = 'margin-left:5px;margin-top:5px;';
				} else if (counter == 3) {
					var margins = 'margin-left:5px;margin-top:5px;';
				}
				html_images.push('<div style="width:85px;height:65px;overflow:hidden;float:left;'+margins+'"><img src="'+idxBoardsX[x.BOARDID].IMAGEPATH+extra_images[y]+'" width="85" class="extra_photo" style="cursor:pointer;"></div>');
				
				if (counter==3) {counter=1;}else{counter++;}
			}
		}
		
		
		a=['<div style="width:777px;height:400px;overflow:hidden;background-repeat:no-repeat;background-image:url(/wwwroot/t/tricityidx/formats/images/michiganwaterfront_brochure.png);font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;position:relative;">'
		,'	<div style="padding:15px;">'
		,'	<table width="100%" border="0" cellspacing="0" cellpadding="0" style="font-size:12px;">'
		,'		<tr>'
		,'			<td width="40%" valign="top"  rowspan="2">'
		,'				<div id="'+x.PROPID+'_photo" style="width:300px;height:199px;overflow:hidden;"></div>'
		,html_images.join('')
		,'			</td>'
		,'			<td align="left" style="color:#133e54;font-weight:bold;font-size:18px;" valign="top">'
		,'				$'+x.PRICE.format()
		,'			</td>'
		,'			<td align="right" valign="top">'
		,'				<div style="color:#666;padding-bottom:5px;text-align:right;font-size:14px;font-weight:bold;">'+x.STREETNUM+' '+x.STREETDIR+' '+x.STREETNAME+'</div>'
		,'				<div style="color:#999;font-size:11px;padding-bottom:10px;">'+x.ATTR+'</div>'
		,'			</td>'
		,'		</tr>'
		,'		<tr>'
		,'			<td valign="top" colspan="2">'
		
		,'					<table border="0" width="100%" cellspacing="0" cellpadding="0">'
		,'						<tr>'
		,'							<td valign="top" width="28%" style="font-weight:bold;color:#677c84;">'
		,'								Listing Agent'
		,'								<div style="padding-top:3px;font-weight:normal;font-size:11px;color:#666;">'+x.LISTINGAGENT+'</div>'
		,'							</td>'
		,'							<td valign="top" style="width:26%;font-weight:bold;color:#677c84;">'
		,'								Agent Phone #'
		,'								<div style="padding-top:3px;font-weight:normal;font-size:11px;color:#666;">'+x.LISTINGAGENTPHONE+'</div>'
		,'							</td>'
		,'							<td valign="top" style="font-weight:bold;color:#677c84;">'
		,'								Listing Company'
		,'								<div style="padding-top:3px;font-weight:normal;font-size:11px;color:#666;">'+x.LISTINGCOMPANYNAME+'</div>'
		,'							</td>'
		,'						</tr>'
		,'					</table>'
		
		,'				<div style="color:black;text-align:justify;line-height:145%;font-size:11px;color:#666;padding-top:12px;">'+x.PROPDESC+'</div>'
		,'				<table width="100%" border="0" style="font-size:11px;" cellpadding="0" cellspacing="3">'
		,'					<tr>'
		,'						<td width="25%"  style="font-weight:bold;color:#677c84;">'
		,'							<strong>MLS #:</strong>'
		,'						</td>'
		,'						<td style="color:#999;">'
		,'							SWR'+x.MLS
		,'						</td>'
		,'						<td width="25%"  style="font-weight:bold;color:#677c84;">'
		,'							<strong>Bathrooms</strong>'
		,'						</td>'
		,'						<td style="color:#999;">'
		,'							'+x.FULLBATHS
		,'						</td>'
		,'					</tr>'
		,'					<tr>'
		,'						<td  style="font-weight:bold;color:#677c84;">'
		,'							<strong>Year Built:</strong>'
		,'						</td>'
		,'						<td style="color:#999;">'
		,'							'+x.YEARB
		,'						</td>'
		,'						<td  style="font-weight:bold;color:#677c84;">'
		,'							<strong>Sq. Feet:</strong>'
		,'						</td>'
		,'						<td style="color:#999;">'
		,'							'+parseInt(x.SQFEET).format()
		,'						</td>'
		,'					</tr>'
		,'					<tr>'
		,'						<td  style="font-weight:bold;color:#677c84;">'
		,'							<strong>Bedrooms:</strong>'
		,'						</td>'
		,'						<td  style="color:#999;">'
		,'							'+x.BEDROOMS
		,'						</td>'
		,'						<td  style="font-weight:bold;color:#677c84;">'
		,'							<strong>Schools</strong>'
		,'						</td>'
		,'						<td style="color:#999;">'
		,'							'+(x.SCHOOLS || '-------')
		,'						</td>'
		,'					</tr>'
		
		//,'					<tr>'
		//,'						<td colspan="2" style="font-size:9px;color:#8b2f4d" colspan="2">'
		//,'							Listed by:<br>'
		//,'							<strong>'+x.LISTINGCOMPANYNAME+'</strong>'
		//,'						</td>'
		//,'						<td colspan="2">'
		//,'						   <div class="noprint">	'
		//,'							<div onclick="popForm();" style="margin-left:10px;float:right;width:80px;color:white;height:31px;font-size:10px;font-weight:bold;text-align:center;line-height:31px;text-decoration:underline;cursor:pointer;cursor:hand;background-image:url(/wwwroot/t/tricityidx/formats/images/close_maroon.jpg);"><div style="margin-left:20px;cursor:hand;cursor:pointer;color:white;">Close</div></div>'
		//,'							<div class="brochurePrint" style="float:right;width:80px;color:white;height:31px;font-size:10px;font-weight:bold;text-align:center;line-height:31px;text-decoration:underline;cursor:pointer;cursor:hand;background-image:url(/wwwroot/t/tricityidx/formats/images/print_maroon.jpg);" ><div style="margin-left:20px;cursor:hand;cursor:pointer;color:white;">Print</div></div>'
		//,'						   </div>'
		//,'						</td>'
		//,'					</tr>'
		,'				</table>'
		,'			</td>'
		,'		</tr>'
		,'		<tr>'
		,'			<td colspan="3" style="padding-top:10px;">'
		
		,'			</td>'
		,'		</tr>'
		,'	</table>'
		,'	<div style="position:absolute;top:292px;right:50px;z-index:999;height:99px;width:400px;text-align:center;" class="noprint">'
		,'		<img src="/wwwroot/t/tricityidx/formats/images/michiganwaterfront_print.png" style="cursor:pointer;" class="brochurePrint"><img src="/wwwroot/t/tricityidx/formats/images/michiganwaterfront_contact.png" style="cursor:pointer;" class="contactagent"><img src="/wwwroot/t/tricityidx/formats/images/michiganwaterfront_close.png" style="cursor:pointer" onclick="popForm(1);">'
		,'	</div>'
		,'	</div>'
		,'</div>'
		/*,'	<div class="print" style="border:2px solid black;width:700px;margin-top:20px;padding:4px;">'
		,'		<table align="center" width="100%">'
		,'			<tr>'
		,'				<td style="font-size:18px;color:#8a2f4e;" align="center">'
		,'					To schedule a showing or receive more details on this property, please contact:'
		,'					<table style="font-family:verdana;">'
		,'						<tr>'
		,'							<td colspan="2" style="font-size:14px;padding-top:10px;font-weight:bold;">'+companyInfo.name+'</td>'
		,'						</tr>'
		,'						<tr>'
		,'							<td style="font-size:11px;" width="80"><strong>Phone:</strong></td>'
		,'							<td style="font-size:11px;">'+companyInfo.phone+'</td>'
		,'						</tr>'
		,'						<tr>'
		,'							<td style="font-size:11px;"><strong>E-mail:</strong></td>'
		,'							<td style="font-size:11px;">'+companyInfo.email+'</td>'
		,'						</tr>'
		,'						<tr>'
		,'							<td style="font-size:11px;"><strong>Web site:</strong></td>'
		,'							<td style="font-size:11px;">'+companyInfo.homepage+'</td>'
		,'						</tr>'
		,'					</table>'
		,'				</td>'
		,'			</tr>'
		,'		</table>'
		,'	</div>'*/]
		
		/*a=['<div style="width:777px;height:356px;overflow:hidden;background-image:url(/wwwroot/t/tricityidx/formats/images/michiganwaterfront_brochure.png);font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;">'
		,'	<table width="100%" border="0" cellspacing="0" cellpadding="0" style="font-size:12px;">'
		,'		<tr>'
		,'			<td style="color:#8a2f4e;font-weight:bold;font-size:16px;">'+x.STREETNUM+' '+x.STREETDIR+' '+x.STREETNAME+'</td>'
		,'			<td align="left" style="color:#453c2a;font-weight:bold;font-size:14px;padding-bottom:3px;">'
		,'				$'+x.PRICE.format()
		,'			</td>'
		,'			<td align="right" style="color:#453c2a;font-weight:bold;font-size:11px;">'
		,'				<div >'+x.ATTR+'</div>'
		,'			</td>'
		,'		</tr>'
		,'		<tr>'
		,'			<td width="40%" valign="top" id="'+x.PROPID+'_photo">'
		,'				'
		,'			</td>'
		,'			<td valign="top" colspan="2">'
		,'				<div style="color:black;text-align:justify;line-height:135%;">'+x.PROPDESC.toLowerCase()+'</div>'
		,'			</td>'
		,'		</tr>'
		,'		<tr>'
		,'			<td colspan="3" style="padding-top:10px;">'
		,'				<table width="100%" border="0" style="font-size:11px;" cellpadding="3">'
		,'					<tr>'
		,'						<td width="25%">'
		,'							<strong>MLS #:</strong>'
		,'						</td>'
		,'						<td>'
		,'							SWR'+x.MLS
		,'						</td>'
		,'						<td width="25%">'
		,'							<strong>Bathrooms</strong>'
		,'						</td>'
		,'						<td>'
		,'							'+x.FULLBATHS
		,'						</td>'
		,'					</tr>'
		,'					<tr>'
		,'						<td>'
		,'							<strong>Year Built:</strong>'
		,'						</td>'
		,'						<td>'
		,'							'+x.YEARB
		,'						</td>'
		,'						<td>'
		,'							<strong>Sq. Feet:</strong>'
		,'						</td>'
		,'						<td>'
		,'							'+parseInt(x.SQFEET).format()
		,'						</td>'
		,'					</tr>'
		,'					<tr>'
		,'						<td>'
		,'							<strong>Bedrooms:</strong>'
		,'						</td>'
		,'						<td>'
		,'							'+x.BEDROOMS
		,'						</td>'
		,'						<td>'
		,'							<strong>Schools</strong>'
		,'						</td>'
		,'						<td>'
		,'							'+(x.SCHOOLS || '-------')
		,'						</td>'
		,'					</tr>'
		,'					<tr>'
		,'						<td style="font-size:9px;color:#8b2f4d" colspan="2">'
		,'							Listed by:<br>'
		,'							<strong>'+x.LISTINGCOMPANYNAME+'</strong>'
		,'						</td>'
		,'						<td colspan="2">'
		,'						   <div class="noprint">	'
		,'							<div onclick="popForm();" style="margin-left:10px;float:right;width:80px;color:white;height:31px;font-size:10px;font-weight:bold;text-align:center;line-height:31px;text-decoration:underline;cursor:pointer;cursor:hand;background-image:url(/wwwroot/t/tricityidx/formats/images/close_maroon.jpg);"><div style="margin-left:20px;cursor:hand;cursor:pointer;color:white;">Close</div></div>'
		,'							<div class="brochurePrint" style="float:right;width:80px;color:white;height:31px;font-size:10px;font-weight:bold;text-align:center;line-height:31px;text-decoration:underline;cursor:pointer;cursor:hand;background-image:url(/wwwroot/t/tricityidx/formats/images/print_maroon.jpg);" ><div style="margin-left:20px;cursor:hand;cursor:pointer;color:white;">Print</div></div>'
		,'						   </div>'
		,'						</td>'
		,'					</tr>'
		,'				</table>'
		,'			</td>'
		,'		</tr>'
		,'	</table>'
		,'	<div id="email_form" class="noprint" style="border-top:2px solid black;margin-top:5px;padding-top:5px;"></div>'
		,'</div>'
		,'	<div class="print" style="border:2px solid black;width:700px;margin-top:20px;padding:4px;">'
		,'		<table align="center" width="100%">'
		,'			<tr>'
		,'				<td style="font-size:18px;color:#8a2f4e;" align="center">'
		,'					To schedule a showing or receive more details on this property, please contact:'
		,'					<table style="font-family:verdana;">'
		,'						<tr>'
		,'							<td colspan="2" style="font-size:14px;padding-top:10px;font-weight:bold;">'+companyInfo.name+'</td>'
		,'						</tr>'
		,'						<tr>'
		,'							<td style="font-size:11px;" width="80"><strong>Phone:</strong></td>'
		,'							<td style="font-size:11px;">'+companyInfo.phone+'</td>'
		,'						</tr>'
		,'						<tr>'
		,'							<td style="font-size:11px;"><strong>E-mail:</strong></td>'
		,'							<td style="font-size:11px;">'+companyInfo.email+'</td>'
		,'						</tr>'
		,'						<tr>'
		,'							<td style="font-size:11px;"><strong>Web site:</strong></td>'
		,'							<td style="font-size:11px;">'+companyInfo.homepage+'</td>'
		,'						</tr>'
		,'					</table>'
		,'				</td>'
		,'			</tr>'
		,'		</table>'
		,'	</div>']*/
		
		brochureDiv.innerHTML = a.join('');
		
		//brochureDiv.setStyle({zIndex:9999,visibility:'visible',position:'absolute',top:'100px',left:'100px'});
		
		Event.observe(brochureDiv.getElementsByClassName('brochurePrint')[0],'click',	this.printBrochure = function(){
			var contactInformation;
			var brochureWindow = window.open("", "brochureWindow", "toolbar=no, location=no, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=yes, copyhistory=no, width=100, height=100")			
			var myHtml = "<html><style type='text/css'>.noprint {display:none;} .print {display:block;}</style><body onload='print();window.close();'>" + this.innerHTML + "</body></html>"	
			brochureWindow.document.open()
			window.focus();
			brochureWindow.document.write(myHtml);		
			brochureWindow.document.close();
		}.bind(brochureDiv))

		
		var _extraImages = $(brochureDiv).select('.extra_photo');
		for(var y = 0;y<_extraImages.length;y++) {
			Event.observe(_extraImages[y],'click',function() {
				$('mainbrochurephoto').src = this.src;
		  	});
		}
		
		//CSSRule ('.mailForm',{border:'0px',backgroundColor:'transparent',padding:'6px'});
		//CSSRule ('.e_pop table', {color:'black',fontSize:'12px',marginLeft:'180px',marginTop:'20px'});
		
		Event.observe(brochureDiv.getElementsByClassName('contactagent')[0],'click',function() {
				if (!$('mailformdiv')) {
					var newdiv = $(document.createElement('div'));
					newdiv.setAttribute('id','mailformdiv');
					newdiv.setStyle({position:'absolute',display:'none',width:'400px',height:'425px',backgroundColor:'white',overflow:'hidden'});
					document.body.appendChild(newdiv);
				}
				
				mailForm({
					propid : x.PROPID
					,boardid : x.BOARDID
					,idxcomp_id : 0
					,agentEmail : x.LISTINGAGENTEMAIL
					,sendTo : x.LISTINGAGENT
					,subject : IDX.formatAddr(x)
					,insertElm: $('mailformdiv')
					,divStyle	:	{border:'0px',backgroundColor:'transparent',padding:'6px'}
					,tableStyle	:	{color:'black',fontSize:'12px',margin:'20px'}
				});
				$('mailformdiv').setStyle({display:''});
				pushForm($('mailformdiv'),{opacity:.25})
        }.bind(this));
		
		/*mailForm({
			propid : x.PROPID
			,boardid : x.BOARDID
			,idxcomp_id : companyInfo.comp_id
			,sendTo : companyInfo.name
			,subject : IDX.formatAddr(x)
			,insertElm: $('email_form')
			,divStyle	:	{border:'0px',backgroundColor:'transparent',padding:'6px'}
			,tableStyle	:	{color:'black',fontSize:'12px',marginLeft:'180px',marginTop:'20px'}
		})*/

		imageDiv = document.getElementById(x.PROPID+'_photo');		
		image = document.createElement('img');
		image.setAttribute('id','mainbrochurephoto');
		image.onload = function(brochureDiv){
			if (this.width > 265) {
				this.width = 265;
			}
		}.bind(image,brochureDiv)
		image.onerror = function(){
			imageDiv.style.display = 'none';
		}.bind(image)
		imageDiv.appendChild(image);
		var dir = x.MLS.substr(x.MLS.length-2,2);
		image.src = idxBoardsX[x.BOARDID].IMAGEPATH+x.IMAGE;
		
		
		pushForm(brochureDiv,{opacity:0.3,color:'black'});
	}
	
}

idxBrochures['WWL'] = (new wwlBrochure());