var originalImage;

function embedFlash(asset, width, height, bgcolor)  {		
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" ');
	document.write('height="' + height + '"');
	document.write('width="' + width + '" id="objFlash" loop="true">');
	document.write('<param name="src" value="' + asset + '">');
	document.write('<param name="allowScriptAccess" value="always" />');
	document.write('<param name="align" value="middle">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="wmode" value="window">');
	document.write('<param name="bgcolor" value="' + bgcolor + '">');
	document.write( '<embed ' );
	document.write( '  src="' + asset + '" ' );
	document.write( '  width="' +width + '" ' );
	document.write( '  height="' +height+ '" ' );
	document.write( '  align="middle" ' );
	document.write( '  quality="high" ' );
	document.write( '  wmode="window" ' );
	document.write( '  allowScriptAccess="always" ' );
	document.write( '  scale="showall" ' );
	document.write( '  loop="true" ' );
	document.write( '  pluginspage="http://get.adobe.com/flashplayer/" ' );
	document.write( '  bgcolor="' + bgcolor + '" ' );
	document.write( '  type="application/x-shockwave-flash" name="objFlash">' );
	document.write( '</embed>' );
	document.write('</object>');
}


function loadFeaturedContent(html) {
	document.getElementById("featureLayer").innerHTML=html;
	
	var getLocation=document.getElementById("flFrame").src;
	
	if (getLocation.indexOf("/Listings/tabid/56/Default.aspx") > -1) {
		
	}
	
	if (getLocation.indexOf("/ViewProperty/tabid/59/Default.aspx") > -1 ) {
		setOriginalImage();
		imagePreview();
		checkVideo();
	}
}

function showImage(img, text) {
	var getCaptionWindow=document.getElementById("imageCaption");
	getCaptionWindow.innerHTML = document.getElementById(text).innerHTML;;
	
	
	var getMainImage=document.getElementById("mainImg");
	getMainImage.src="/Portals/0/Upload/"+img;	
}

function resetImage() {
	var getMainImage=document.getElementById("mainImg");
	getMainImage.src=originalImage;
}

function setOriginalImage() {	
	document.getElementById("thumbImg0").style.border="2px solid red"; 
	document.getElementById("imageCaption").innerHTML=document.getElementById("captionPhoto0").innerHTML;
	
	var getMainImage=document.getElementById("mainImg");
	originalImage=getMainImage.src;
	
	showThumbnails();
	
	var getTD=document.getElementsByTagName("TD");
	for (i=0; i<getTD.length;i++) {
		if (getTD[i].className=="containerrow1_white") {
			getTD[i].style.display="none";
		}
	}
}

function setCurrentImage(img, imgNum) {
	originalImage="/Portals/0/Upload/"+img;
	document.getElementById("mainImg").src=originalImage;
	
	var getImg=document.getElementsByTagName("IMG");
	for (i=0; i<getImg.length; i++) {
		if (getImg[i].id.indexOf("thumb") > -1) {
			getImg[i].style.border="2px solid #666666";
		}
	}
	document.getElementById("thumbImg"+imgNum).style.border="2px solid red";
	document.getElementById("thumbImg"+imgNum).className="brightImg";
	
	document.getElementById("imageCaption").innerHTML=document.getElementById("captionPhoto"+imgNum).innerHTML;
}

function showThumbnails() {
	var getTD=document.getElementsByTagName("TD");
	for (i=0; i<getTD.length; i++) {
		if (getTD[i].className=="imageContainer") {
			if (getTD[i].innerHTML.length > 0) {
				getTD[i].innerHTML="<img src='/Portals/0/Upload/"+getTD[i].innerHTML+"' />";
				getTD[i].style.visibility="visible";
				getTD[i].style.width="155px";
			}else{
				getTD[i].style.display="none";
			}
		}
	}
}

function loadNewsletterList(getHtml) {
	document.getElementById("newsletterLayer").innerHTML=getHtml;
}

function loadNews(getHtml) {
	document.getElementById("newsLayer").innerHTML=getHtml;
}

function setHeading(num) {
	if (num == 0) {
		document.getElementById("pageHeader").innerHTML="<h1>Featured Listings</h1>";
	}
	if (num == 1) {
		document.getElementById("pageHeader").innerHTML="&laquo; <a href='/staticsite/featuredlistings.html'>Back to <strong>Listings</strong></a>";
	}
}

function embedFlashVideo(targetDiv, videoSrc) {
	var bgcolor="#FFFFFF";
	var text="";
	
	text += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" ';
	text += 'height="324"';
	text += 'width="400" id="objFlash" loop="true">';
	text += '<param name="src" value="' + videoSrc + '">';
	text += '<param name="allowScriptAccess" value="always" />';
	text += '<param name="align" value="middle">';
	text += '<param name="quality" value="high">';
	text += '<param name="wmode" value="transparent">';
	text += '<param name="bgcolor" value="' + bgcolor + '">';
	text +=  '<embed ' ;
	text +=  '  src="' + videoSrc + '" ';
	text +=  '  width="400" ' ;
	text +=  '  height="324" ' ;
	text +=  '  align="middle" ' ;
	text +=  '  quality="high" ' ;
	text +=  '  wmode="transparent" ' ;
	text +=  '  allowScriptAccess="always" ' ;
	text +=  '  scale="showall" ' ;
	text +=  '  loop="true" ' ;
	text +=  '  pluginspage="http://get.adobe.com/flashplayer/" ' ;
	text +=  '  bgcolor="' + bgcolor + '" ' ;
	text +=  '  type="application/x-shockwave-flash" name="objFlash">' ;
	text +=  '</embed>' ;
	text += '</object>';
	
	document.getElementById(targetDiv).innerHTML=text;
}