/* launch popup window */
function launch(newURL, newName, newFeatures, orgName) {
  var remote = open(newURL, newName, newFeatures);
  if (remote.opener == null)
	remote.opener = window;
  remote.opener.name = orgName;
  return remote;
}

function switchVisibility(element)
{
	var curDisp = document.getElementById(element).style.display;
	if (curDisp == "" || curDisp == "inline") {curDisp = "none";} else {curDisp = "inline";}
	document.getElementById(element).style.display = curDisp;

    return curDisp != "none"
}

/* Goto Virtual Tour in new window */
function goVirtualTour(url, mediaType) {
	// If starts with leading slash, assume local IPIX Viewer.
	if (url.charAt(0) == '/') {
		if (mediaType == 0) {
			url = 'http://www.coldwellbanker.com/servlet/PropertyListing?action=virtualTour&ComColdwellbankerDataProperty_id=13224232&ComColdwellbankerDataMedia_id=27816430';
		} else if (mediaType == 1) {
			url = '';
		} else if (mediaType == 2) {
			url = '';
		}
		launch(url, "IPIX", "height=320,width=500,channelcountryId=0,dependent=1,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=0,status=1,toolbar=0", "parentWindow");
	} else {
		launch(url, "IPIX", "height=400,width=600,channelcountryId=0,dependent=1,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0", "parentWindow");
	}
}

function viewSlideshow() {
	return false;
	//window.open('http://www.coldwellbanker.com/servlet/SearchProperty?action=viewSlideshow&ComColdwellbankerDataProperty_id=13224232&brand=CB', 'Slideshow', 'width=370px,height=325px,resizable=no,scroll=no,status=no;');
}

function enlargeImage() {
	var imgSrc = document.images.mainImage.src;
	var w = window.open('', 'Image',"width=800, height=600");
	w.document.open();
	var t="";
	t+='<HTML>\n<TITLE>'+imgSrc+'</TITLE>\n';
	t+='<HEAD>';
	t+='<SCRIPT LANGUAGE="Javascript">\n';
	t+='\<!--\n';
	t+='function enlarge() {\n';
	t+=' var pic=new Image;\n';
	t+=' pic.src="'+imgSrc+'";\n';
	t+=' document.getElementById("img").src=pic.src;\n';
	t+='}\n';
	t+='\/\/-->\n';
	t+='<\/SCRIPT>\n';
	t+='</HEAD>\n';
	t+='<BODY onLoad="enlarge();" style="margin:0;padding:0;">\n';
	t+='<IMG ID="img" ALT="'+imgSrc+'" title="Left-click to close window." style="width: 800; height: 600; cursor:pointer;" onclick="window.close();">\n';
	t+='</BODY>\n</HTML>\n';
	w.document.write(t)
	w.document.close();
	w.focus();
}

function changeImage(imagesrc,enhanced,imagecaption) {
	if(enhanced){
		var mainimagetext = '<img name="mainImage" id="mainimage" src="'+imagesrc+'" style="cursor:pointer; border: 1px solid White; width: 266; height: 200" onclick="enlargeImage();">';
	} else {
		var tempimage = new Image();
		tempimage.src = imagesrc;
		if(tempimage.width > 266){
			var mainimagetext = '<img name="mainImage" id="mainimage" src="'+imagesrc+'" width="266" height="200" style="cursor:pointer; border: 1px solid White;" onclick="enlargeImage();">';
		}else{
			var mainimagetext = '<img name="mainImage" id="mainimage" src="'+imagesrc+'" style="cursor:pointer; border: 1px solid White;" onclick="enlargeImage();">';
		}
	}
	document.getElementById('lyrMainImage').innerHTML = mainimagetext;
}

function menu(whichMenu, whatState) {
	document.getElementById(whichMenu).style.visibility = whatState;
}

