// JavaScript Document

// Global variables
var activeElement=0; // Selected element in property list
var activeMenuElementIndex = 0;  //Selected element in menu list
var data; // Ajax returned property data array
var dataL; // Ajax returned property list array
var backPhotosFlag = 0; // Indicates that the back button was clicked
var mapLoadedFlag = 0; // Indacates that the map has loaded upon initial page opening
var imgIndexOffset = 0; //Indes for paging through thumbnail images
var iStart=0; //Starting index for getting thumbnail images
var iEnd=0; //Ending index for getting thumbnail images
var tempTitle; // Stores the last property list tile during featires display
var activeThumb=0; // Currently highlighted thumbnail	
var activePhoto = ""; //Currently displayed main photo
var mapIsOpen = 0; // Flag indicating that the map is open
var map; //Holder for created map
var container; // Holder for property list content
var zoom = 16; // Starting map zoom factor
var requestSent = false; // Ajax process state
var pixelThreshold = 256; // Google map constant
var centerBeforeMove; // Map center location prior to adjustments in location
var timeout; // Map timeout constant
var markerType = 1; // Starting map market selection
var mOpacity = 100; // Starting map opacity
var imgMaxStart = 9;
// Functions

function dataCheck(strData){
	if (!strData || strData =='' || strData == null){
		return '';
		}
	else{
		return strData;
		}
	}	

function formatCurrency(strValue){


	strValue = strValue.toString().replace(/\$|\,/g,'');
	dblValue = parseFloat(strValue);

	blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
	dblValue = Math.floor(dblValue*100+0.50000000001);
	intCents = dblValue%100;
	strCents = intCents.toString();
	dblValue = Math.floor(dblValue/100).toString();
	if(intCents<10)
		strCents = "0" + strCents;
	for (var i = 0; i < Math.floor((dblValue.length-(1+i))/3); i++)
		dblValue = dblValue.substring(0,dblValue.length-(4*i+3))+','+
		dblValue.substring(dblValue.length-(4*i+3));
	return (((blnSign)?'':'-') + '$' + dblValue/* + '.' + strCents*/);
}

function importPropertyData(selectedPropertyID){
    var url = 'http://oc-coastalproperties.com/scripts/propertyInfoPicXMLS3.php?propertyID='+selectedPropertyID;
    var xml = new JKL.ParseXML( url );
    data = xml.parse();
	}
function importPropertyList(statusID){
	var url = 'http://oc-coastalproperties.com/scripts/propertyInfoListS3.php?statusID='+statusID;
    var xml = new JKL.ParseXML( url );
    dataL = xml.parse();
	}
	
function morePhotos(){
	imgIndexOffset += 9;
	clickThumb(document.getElementById("thumbBox_0"),0);
	getImages();
	closeMap();
	}

	
function backPhotos(){
	backPhotosFlag = 1;
	imgIndexOffset -= 9;
	clickThumb(document.getElementById("thumbBox_8"),8);
	getImages();
	closeMap();
	
	}
	
function getImages(){

	imgMax = imgMaxStart;
	iStart = 0;
	
document.getElementById("processingDisplay").style.display="block";
document.getElementById("thumbProcessingDisplay").style.display="block";
if (data.propertySet.property.photoSet&&data.propertySet.property.photoSet.photo[0]){
	
	
	if ((data.propertySet.property.photoSet.photo.length - imgIndexOffset)>9){
		document.getElementById("thumbMorePhotos").style.display = "block";
		}
	else{
		document.getElementById("thumbMorePhotos").style.display = "none";
		}
		
	if (imgIndexOffset>0){
		document.getElementById("thumbBack").style.display = "block";
		}
	else{
		document.getElementById("thumbBack").style.display = "none";
		}
			
	
	for (i=0;i<9;i++){
		document.getElementById("thumbBox_"+i).style.visibility = "hidden";
		}
		
	if ((data.propertySet.property.photoSet.photo.length - imgIndexOffset)<9){
			imgMax = data.propertySet.property.photoSet.photo.length-imgIndexOffset;
			}
	
	if (backPhotosFlag == 0){
		iStart = 0;
		iEnd = imgMax;
		document.images.photoDisplayImg_0.onload = function (){
			document.getElementById("processingDisplay").style.display="none";
			document.getElementById("thumbProcessingDisplay").style.display="none";
			backPhotosFlag = 0;		
			}	
		setThumbOnLoadFunctions();			
		for (z=iStart;z<iEnd;z++){
			getImageSet(z);
			}
		}
	if (backPhotosFlag == 1){
		iStart = 8;
		iEnd = 0;
		document.images.photoDisplayImg_8.onload = function (){	
		document.getElementById("processingDisplay").style.display="none";
		document.getElementById("thumbProcessingDisplay").style.display="none";
		backPhotosFlag = 0;
		}
		setThumbOnLoadFunctions();			
		for (z=iStart;z>iEnd-1;z--){
			getImageSet(z);
			}
		}

	}
else{
	//document.getElementById("photoDisplay_0").innerHTML = '<div id="noPhoto">No photographs currently available.</div>';
	document.getElementById("thumbProcessingDisplay").style.display = "block";
	}
		
}

function setThumbOnLoadFunctions(){

		document.getElementById("thumbBoxImg_0").onload = function(){
			document.getElementById("thumbBox_0").style.visibility = "visible";
			}
		document.getElementById("thumbBoxImg_1").onload = function(){
			document.getElementById("thumbBox_1").style.visibility = "visible";
			}
		document.getElementById("thumbBoxImg_2").onload = function(){
			document.getElementById("thumbBox_2").style.visibility = "visible";
			}
		document.getElementById("thumbBoxImg_3").onload = function(){
			document.getElementById("thumbBox_3").style.visibility = "visible";
			}
		document.getElementById("thumbBoxImg_4").onload = function(){
			document.getElementById("thumbBox_4").style.visibility = "visible";
			}
		document.getElementById("thumbBoxImg_5").onload = function(){
			document.getElementById("thumbBox_5").style.visibility = "visible";
			}
		document.getElementById("thumbBoxImg_6").onload = function(){
			document.getElementById("thumbBox_6").style.visibility = "visible";
			}
		document.getElementById("thumbBoxImg_7").onload = function(){
			document.getElementById("thumbBox_7").style.visibility = "visible";
			}
		document.getElementById("thumbBoxImg_8").onload = function(){
			document.getElementById("thumbBox_8").style.visibility = "visible";
			}	
	}
function getImageSet(z){
	//alert('parent is '+document.getElementById("photoDisplayImg_"+z).parentNode.style.backgroundColor="#ff0000");
	document.getElementById("photoDisplayImg_"+z).src='http://'+z+'media.oc-coastalproperties.com/images/'+data.propertySet.property.propertyID+'/'+data.propertySet.property.photoSet.photo[z+imgIndexOffset].toString();
	document.getElementById("photoDisplayImg_"+z).alt='Photograph of '+data.propertySet.property.address+', '+data.propertySet.property.city+' CA'.toString();	
	document.getElementById("thumbBoxImg_"+z).src='http://'+z+'media.oc-coastalproperties.com/images/'+data.propertySet.property.propertyID+'/'+data.propertySet.property.photoSet.photo[z+imgIndexOffset].replace(/.jpg/,"Thumb.jpg");
	}	


function displayPropertyData(){
	imgIndexOffset = 0;
	getImages();
	if (data.propertySet.property.floorPlans){
		document.getElementById("floorPlans").style.display = "block";
		}
	else{
		document.getElementById("floorPlans").style.display = "none";
		}
	if (data.propertySet.property.videoTour){
		document.getElementById("videoTour").style.display = "block";
		}
	else{
		document.getElementById("videoTour").style.display = "none";
		}
	document.getElementById("activeStatusText").innerHTML = dataCheck(data.propertySet.property.statusText).toString();
	document.getElementById("addressBox").innerHTML = dataCheck(data.propertySet.property.city.toUpperCase())+' : '+dataCheck(data.propertySet.property.community)+' : '+dataCheck(data.propertySet.property.address).toString();
	document.getElementById("descriptiveTextBox").innerHTML = dataCheck(data.propertySet.property.text).toString();
	var priceTxtDisplay = '';
	var l_Price = dataCheck(data.propertySet.property.lowPrice);
	var h_Price = dataCheck(data.propertySet.property.highPrice);
	if ((l_Price>0) && (h_Price>l_Price)) {
		priceTxtDisplay = "Offered Value Range from "+formatCurrency(l_Price)+" to "+formatCurrency(h_Price);
	} else if (l_Price>0) {
		priceTxtDisplay = "Offered at "+formatCurrency(l_Price);
	}
	
	document.getElementById("priceBox").innerHTML = priceTxtDisplay;
	if (data.propertySet.property.coopAgent){	
		document.getElementById("coopAgentBox").innerHTML = "This&nbsp;property&nbsp;marketed<br />in&nbsp;association&nbsp;with<br />"+data.propertySet.property.coopAgent.toUpperCase().toString();
		}
	else{
		document.getElementById("coopAgentBox").innerHTML = '';
		}
		displayPropertyFeatures();
	
	}
	
function displayPropertyFeatures(){
	var sepIndex = 0;
	var strFeatures = dataCheck(data.propertySet.property.features);
	var listFeatures = '<ul class="featuresListBox">';
	
	while (sepIndex>=0){
		sepIndex = 	strFeatures.indexOf(',',0);
		if (sepIndex == -1){
			listFeatures += '<li>'+strFeatures+'</li>';
			}
		else{
			listFeatures += '<li>'+strFeatures.slice(0,sepIndex)+'</li>';
			strFeatures = strFeatures.substring(sepIndex+1);
			}	
		}
	listFeatures += '</ul>';
	document.getElementById("featuresListBox").innerHTML = listFeatures.toString();
	
	}
	

function featuresOver(){
	document.getElementById("propertyListBox").style.display = "none";
	document.getElementById("featuresListBox").style.display = "block";
	tempTitle = document.getElementById("propertyListBoxTitle").innerHTML;
	document.getElementById("propertyListBoxTitle").innerHTML = 'Property<br  />Features';
	document.getElementById("featuresIndicatorBottom").style.display = "block";
	document.getElementById("featuresIndicatorTop").style.display = "block";
	document.getElementById("propertyFeatures").style.borderBottom = "solid 1px #00ff00";
	updatePageCount("features");
	}
	
function featuresOut(){
	document.getElementById("propertyListBox").style.display = "block";
	document.getElementById("featuresListBox").style.display = "none";
	document.getElementById("propertyListBoxTitle").innerHTML = tempTitle;
	document.getElementById("featuresIndicatorBottom").style.display = "none";
	document.getElementById("featuresIndicatorTop").style.display = "none";
	document.getElementById("propertyFeatures").style.borderBottom = "none";
	}
	
function breakout_of_frame(){
	if (top.location != location){
		top.location.href = document.location.href;
		}
	}

function clickThumb(element,thumbId){

	
		activeThumb.className = "thumbBoxOut";
	
	activeThumb = element;
	element.className = "thumbBoxActive";
	activePhoto.style.visibility = "hidden";
	
	activePhoto = document.getElementById("photoDisplay_"+thumbId);
	
	activePhoto.style.visibility = "visible";
	}

function overMenuBorder(element){
	if (element.id.substring(element.id.indexOf('_')+1) != activeMenuElementIndex){
	
		document.getElementById("mask_"+(element.id.substring(element.id.indexOf('_')+1))).className = "menuInfoContainerBorderOver";
		}
	}
	
function outMenuBorder(element){
	if (element.id.substring(element.id.indexOf('_')+1) != activeMenuElementIndex){
		document.getElementById("mask_"+(element.id.substring(element.id.indexOf('_')+1))).className = "menuInfoContainerBorderOut";
		}
	}
	
function openwindow(url,target) { 
				
					var options = 'scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no';
				    options += ',width=' + (screen.availWidth-10)*0.96 + ',height=' + (screen.availHeight)*0.96;
					options += ',screenX=0,screenY=0,top=0,left=0';
					var win = window.open(url,target, options);
					win.focus();
					win.moveTo((screen.availWidth-10)*0.02, 0); 
					}
					
function returnDocument() {
        var file_name = document.location.href;
		var end = (file_name.indexOf("?") == -1) ? file_name.length : file_name.indexOf("?");
        return file_name.substring(file_name.indexOf("//")+2, end);
	
    }

function clickMenuActive(element){
	document.getElementById("mask_"+activeMenuElementIndex).className = "menuInfoContainerBorderOut";
	activeMenuElementIndex = element.id.substring(element.id.indexOf('_')+1);
	document.getElementById("mask_"+activeMenuElementIndex).className = "menuInfoContainerBorderActive";
	//case select action to be performed for the menu selection code goes here
	
	switch(activeMenuElementIndex){
		case '0': // Contact Us
			updatePageCount("contactUs");
			openwindow("/contactus.php");
			break;
		
		case '2': // Property Search
			window.location = "/propertySearch.php";			
			break;
		case '3': // Marketing Your Property
			updatePageCount("MarketingYourProperty");
			window.location="/marketing.php";
			break;
		case '4': // About Allan
			window.location="/aboutallan.php";
			break;
		case '5': // what Clients Are Saying
			window.location="/clientFeedback.php";
			break;
		case '6': // Analysis
			window.location="/analysis.php";
			break;
		case '7': // Coastal Area Info
			updatePageCount("areaInfo");
			window.location="/#areaInfo";
			break;
		case '8': // Price History Charts
			window.location="/coastalAreaMarketHistory.php";
			break;
		case '9': // Sold Gallery
			if (returnDocument()=='oc-coastalproperties.com/'||returnDocument()=='oc-coastalproperties.com/index.php'||returnDocument()=='oc-coastalproperties.com/#'||returnDocument()=='oc-coastalproperties.com/#pageTop'||returnDocument()=='oc-coastalproperties.com/#areaInfo'){
				updatePageCount("sold");
				importPropertyList("Sold")
				generatePropertyListFromSelection('sold');
				displayPropertyData();
				if (mapLoadedFlag == 1){
					changeMapPosition();
					}
				clickThumb(document.getElementById("thumbBox_0"),0);
				}
			else{
				updatePageCount("sold");
				window.location = '/?statusID=Sold';
				}
			break;
		case '10': // The Source
			window.location = "/theSource.php";
			break;
		case '11': // Things To Know
			window.location = "/weblog/";
			break;
		default : // Featured Properties
			if (returnDocument()=='oc-coastalproperties.com/'||returnDocument()=='oc-coastalproperties.com/index.php'||returnDocument()=='oc-coastalproperties.com/#'||returnDocument()=='oc-coastalproperties.com/#pageTop'||returnDocument()=='oc-coastalproperties.com/#areaInfo'){
				updatePageCount("featured");
				importPropertyList("Active")
				generatePropertyListFromSelection('active');
				displayPropertyData();
				if (mapLoadedFlag == 1){
					changeMapPosition();
					}
				clickThumb(document.getElementById("thumbBox_0"),0);
				}
			else {
				updatePageCount("featured");
				window.location = '/';
				}
		}
			
	}

	
function overBorder(element){
	
	if (element != activeElement){
			
		document.getElementById("PLmask_"+element.id.substring(element.id.indexOf("PL_")+3,element.id.lastIndexOf('_'))).className = "propertyInfoBorderOver";
		}
	}
	
function outBorder(element){
	
	if (element != activeElement){
		
		document.getElementById("PLmask_"+element.id.substring(element.id.indexOf("PL_")+3,element.id.lastIndexOf('_'))).className = "propertyInfoBorderOut";
		}
	}
	
function changeMapPosition(){
	point = new GLatLng(data.propertySet.property.pLat,data.propertySet.property.pLng);
	map.clearOverlays();
	pointMarker = new GMarker(point,{title:data.propertySet.property.address,clickable:false,autoPan:false});
	map.addOverlay(pointMarker);
	map.panTo(point);
	}

function clickActive(element){
	document.getElementById("processingDisplay").style.display="block";
	document.getElementById("thumbProcessingDisplay").style.display="block";
	document.getElementById("PLmask_"+element.id.substring(element.id.indexOf("PL_")+3,element.id.lastIndexOf('_'))).className = "propertyInfoBorderActive";
	
	if (activeElement!="" && activeElement!=element){
		document.getElementById("PLmask_"+activeElement.id.substring(activeElement.id.indexOf("PL_")+3,activeElement.id.lastIndexOf('_'))).className = "propertyInfoBorderOut";
		
		}
		
	activeElement = element;
	selectedPropertyID = element.id.substring(element.id.indexOf('/')+1);
	
	updatePageCount(selectedPropertyID);
	importPropertyData(selectedPropertyID);
	displayPropertyData();
	clickThumb(document.getElementById("thumbBox_0"),0);
	if (map && mapIsOpen == 1){
		setTimeout('changeMapPosition()',10);
		}
	}
	
function clickLocationMap(){
	updatePageCount("map");
	document.getElementById("locationMapPanel").style.visibility = "visible";
	document.getElementById("callToday").style.display = "none";
	document.getElementById("activeStatusText").style.display = "none";
	if (mapLoadedFlag == 0){
		mapLoadedFlag = 1;
		setTimeout('doLoad()',10);
		
		}
	else{
		setTimeout('changeMapPosition()',10);
		}
	mapIsOpen = 1;
	}
	
function doLoad() {

	if (GBrowserIsCompatible()) {

		container = document.getElementById('mapDiv');
		map = new GMap2(container, {draggableCursor:'crosshair'});
		map.addMapType(G_PHYSICAL_MAP);
		map.setMapType(G_HYBRID_MAP);
		
		map.addControl(new GScaleControl());
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		//map.addControl(loadingControl);
		point = new GLatLng(data.propertySet.property.pLat, data.propertySet.property.pLng);
		map.setCenter(point, zoom);
		pointMarker = new GMarker(point,{title:data.propertySet.property.address,clickable:false,autoPan:false});
		map.addOverlay(pointMarker);
		
		changeMapPosition();		
		}
	}
	
function closeMap(){
	document.getElementById('locationMapPanel').style.visibility='hidden';
	document.getElementById('callToday').style.display = 'block';
	document.getElementById("activeStatusText").style.display = 'block';
	mapIsOpen = 0;
	}
	

function printMap(){


	var currentCenterPoint = map.getCenter();
	var currentCenterLat = currentCenterPoint.lat();
	var currentCenterLng = currentCenterPoint.lng();
	var currentZoom = map.getZoom();
	
	newWindowHTML = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
	newWindowHTML += 'undefined';
	newWindowHTML += '<head>';
	newWindowHTML += '<title>Location Map</title>';
	newWindowHTML += '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />';
	newWindowHTML == '</head><body>';
	newWindowHTML += '<div style="text-align:center">';
	newWindowHTML += '<img name="staticMap" style="border:solid 1px #aaaaaa" src="http://maps.google.com/staticmap?center='+currentCenterLat+','+currentCenterLng+'&amp;zoom='+currentZoom+'&amp;size=640x400&amp;markers='+data.propertySet.property.pLat+','+data.propertySet.property.pLng+'&amp;sensor=false&amp;key=' + myKey + '" alt="Location map for '+data.propertySet.property.address+', '+data.propertySet.property.city+' CA" />';
	newWindowHTML += '<br /><br /><div style="width:70%;text-align:center;border:solid 1px #aaaaaa;font-family:sans-serif;font-size:14px">Location map for '+data.propertySet.property.address+', '+data.propertySet.property.city+' CA</div>';
	newWindowHTML += '</div>';
	newWindowHTML += '</body></html>';
	mapWindow = window.open("","mapWindow","width=700,directories=no,resizeable=no,location=no,toolbar=1,menubar=1,scrollbars=no,status=no");
	mapWindow.document.open();
	mapWindow.document.write(newWindowHTML);
	mapWindow.document.close();
	mapWindow.print();
	mapWindow.close();
	
	}
	
function printFlyer(){
	updatePageCount("printFlyer");
	mapWindow = openwindow("http://oc-coastalproperties.com/scripts/printFlyer.php?propertyID="+data.propertySet.property.propertyID+"&propertyImg="+data.propertySet.property.photoSet.photo[0]);
	
	}
	
function generatePropertyListFromSelection(status){
	newContent = '';
	startElementId='';
	startElementMaskId='';
	document.getElementById('content').innerHTML = '';
	for (p=0;p<dataL.propertySet.property.length;p++){
		document.getElementById('content').innerHTML += "<div id='PL_"+p+"_/"+dataL.propertySet.property[p].propertyID+"' class='propertyInfoContainer' onmouseover='overBorder(this)' onmouseout='outBorder(this)' onclick='clickActive(this)'><div id='PLmask_"+p+"' class='propertyInfoBorderOut'></div>"+dataCheck(dataL.propertySet.property[p].city).toUpperCase()+" <br />"+dataCheck(dataL.propertySet.property[p].community)+" <br />"+dataCheck(dataL.propertySet.property[p].address)+" <br />"+formatCurrency(dataCheck(dataL.propertySet.property[p].lowPrice))+" </div>",toString();
		document.getElementById('PLmask_'+p).style.top = (document.getElementById('PL_'+p+'_/'+dataL.propertySet.property[p].propertyID).offsetHeight -15)+'px';
		if(dataL.propertySet.property[p].propertyID.toLowerCase() == dataL.propertySet.startID.toLowerCase()){
			startElementId = "PL_"+p+"_/"+dataL.propertySet.property[p].propertyID;
			startElementMaskId = "PLmask_"+p;
			startIndex = p;
			importPropertyData(dataL.propertySet.property[p].propertyID);
			}
		
		}
	
		document.getElementById('propertyListBox').scrollTop = (startIndex*70)-180;
		document.getElementById(startElementMaskId).className = 'propertyInfoBorderActive';
		activeElement = document.getElementById(startElementId);

		switch(status.toLowerCase()){
			case 'inactive':
				document.getElementById("propertyListBoxTitle").innerHTML = "Inactive <br />Properties ".toString();
				break;
			case 'sold':
				document.getElementById("propertyListBoxTitle").innerHTML = "Sold <br />Gallery ".toString();
				break;
			default:
				document.getElementById("propertyListBoxTitle").innerHTML = "Featured <br />Properties ".toString();
			}
			
	}	
	
function logoShadowDisplay(){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="138" height="138">');
    document.write('<param name="movie" value="http://media.oc-coastalproperties.com/images/logoShadow.swf" />');
    document.write('<param name="quality" value="high" />');
    document.write('<param name="wmode" value="transparent" />');
    document.write('<embed src="http://media.oc-coastalproperties.com/images/logoShadow.swf" width="138" height="138" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>');
  	document.write('</object>');
	}
	
function callTodayDisplay(){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="496" height="33">');
    document.write('<param name="movie" value="http://media.oc-coastalproperties.com/images/callToday2.swf" />');
    document.write('<param name="quality" value="high" />');
    document.write('<param name="wmode" value="transparent" />');
    document.write('<embed src="http://media.oc-coastalproperties.com/images/callToday2.swf" width="496" height="33" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>');
  	document.write('</object>');
	}
	
function menuBoxShadowDisplay(){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="160" height="610">');
    document.write('<param name="movie" value="http://media.oc-coastalproperties.com/images/menuShadow.swf" />');
    document.write('<param name="quality" value="high" />');
    document.write('<param name="wmode" value="transparent" />');
    document.write('<embed src="http://media.oc-coastalproperties.com/images/menuShadow.swf" width="160" height="610" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>');
  	document.write('</object>');
	}
	
function mainDisplayShadowDisplay(){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="808" height="608">');
    document.write('<param name="movie" value="http://media.oc-coastalproperties.com/images/mainDisplayShadow.swf" />');
    document.write('<param name="quality" value="high" />');
    document.write('<param name="wmode" value="transparent" />');
    document.write('<embed src="http://media.oc-coastalproperties.com/images/mainDisplayShadow.swf" width="808" height="608" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>');
  	document.write('</object>');
	}
	
function scheduleTourDisplay(){
	//document.getElementById("pageName").setAttribute("src" , "/scripts/pageCntUpdate.php?page=moreInfo&propertyID="+data.propertySet.property.propertyID);
	updatePageCount("moreInfo");
	openwindow('http://oc-coastalproperties.com/inquiry.php?address='+data.propertySet.property.address+'&city='+data.propertySet.property.city);
	}
	
function targetOpen(url,target){
	targetWindow = window.open(url,target,'')
	}
	
function floorPlansDisplay(){
	updatePageCount("floorPlans");
	openwindow(data.propertySet.property.floorPlans,'_blank');
	}
	
function videoTourDisplay(){
	updatePageCount("videoTour");
	openwindow(data.propertySet.property.videoTour,'_blank');
	}
function updatePageCount(pageID){
	if (data && data.propertySet && data.propertySet.property){
		document.getElementById("pageName").setAttribute("src" , "http://oc-coastalproperties.com/scripts/pageCntUpdate.php?page="+pageID+"&propertyID="+data.propertySet.property.propertyID);
		}
	else{
		document.getElementById("pageName").setAttribute("src" , "http://oc-coastalproperties.com/scripts/pageCntUpdate.php?page="+pageID);
		}
	}

function closeWindow(){
	
	if (refPage == 'home'){
		window.close();
		}
	else{
		window.open('http://oc-coastalproperties.com','_self');
		}
	}