var clientId;

function removeCover(nListId,nClientId){				
	dvNotesCover.style.display = 'none';
	dvNotesNoCover.style.display = 'block';
	clientId = nClientId;
	
	var szInfo = ListingDetail.GetNotes(nListId,nClientId);
	document.getElementById("taNotes").value = szInfo.value;
}

function setCover(){
	dvNotesCover.style.display = 'block';
	dvNotesNoCover.style.display = 'none';
	
	document.getElementById('lnkNotes').href = 'javascript:getLogin()';
}

function updateNotes(nListId){
	var success = ListingDetail.SaveNotes(nListId,clientId,document.getElementById("taNotes").value);
	if (success.value == true){
		alert("Your notes have been successfully saved");
	}
	else {
		alert("There was a problem saving your notes.  Please try again later.");
	}
}

function init(){
	
	if (window.parent != undefined){
		var myWidth = 0;
		var myHeight = 0;
		
		if( typeof( window.innerWidth ) == 'number' ) {
			if (document.getElementById("dvExpired").style.display == 'none'){
				myWidth = document.getElementById("dvMain").scrollWidth;
				myHeight = document.getElementById("dvMain").scrollHeight + 10;
			}
			else {
				myWidth = document.getElementById("dvExpired").scrollWidth;
				myHeight = document.getElementById("dvExpired").scrollHeight + 10;
			}
		}				
		else{
			myWidth = document.body.scrollWidth;
			myHeight = document.body.scrollHeight+10;
		}
		try
		{
			if(parent.resizeFrameOA!=undefined)
			{
				parent.resizeFrameOA(myWidth, myHeight,'listingdetails');
			}
			else if(parent.resizeFrame!=undefined)
			{
				parent.resizeFrame(myWidth, myHeight);
			} 
		}
		catch(e)
		{
		}
	}
}

function getLogin(){
	if (document.getElementById('clientBar') != undefined){
		document.getElementById('clientBar').login();
	}
	else document.getElementById('clientBar2').login();
}

function OpenWindowCentered(szURL, szWindowName, nHeight, nWidth, bytSizable, bytScrollBars)
{
	var intTop = (screen.availHeight - nHeight) / 2;
	var intLeft = (screen.availWidth - nWidth) / 2;
	window.open(szURL, szWindowName, "toolbar=no,  top=" + intTop + ", left=" + intLeft + ", location=no, directories=no, menubar=no, status=no, scrollbars=" + bytScrollBars + ", resizable=" + bytSizable + ", width=" + nWidth + ", height="+ nHeight + "");				
}			

function podcastPopup(nListID, szFileName){
	var pageURL = "/listings/listingdetails/PodCast.aspx?ListId=" + nListID + "&FileName=" + szFileName;
	
	OpenWindowCentered(pageURL, "Podcast", 310, 390, 1, 0);
}

function googleEarthPopup(nListID){
	if (nListID == undefined){
		nListID = 0;
	}
	
	OpenWindowCentered("/listings/listingdetails/VirtualEarthMap.aspx?ListId=" + nListID, "GoogleEarth", 610, 890, 1, 0);
}

function showError(szMainMessage,szSubMessage){	
	OpenWindowCentered("/listings/listingdetails/Error.aspx?Main=" + szMainMessage + "&Sub=" + szSubMessage, "Error", 250, 300, 1, 0);
}


function OpenForm(szURL,szWindowName)
{
	OpenWindowCentered(szURL, szWindowName, 550, 400, 0, 0);		
}

function OpenPrintBrochure(szURL){
	OpenWindowCentered(szURL, 'PrintBrochure', 925, 775, 1, 1);
}

function Open360Tour(szEggFile)
{
	var szURL = "/listings/eggTour/egg.aspx?FileName=" + szEggFile;
	OpenWindowCentered(szURL, "Tour", 330, 450, 1,1);				
}
	
function ImageTour(nListID, szFileName)
{
	var szURL = "/listings/ImageTour/imagetour.aspx?nListID=" + nListID + "&FileName=" + szFileName;
	OpenWindowCentered(szURL, "Tour", 530, 775, 0, 0);
}

function addBookmark(title,url)
{
	if(window.sidebar)
	{
		window.sidebar.addPanel(title, url,""); 
	}
	else if(document.all )
	{
		window.external.AddFavorite(url, title);
	}
	else if( window.opera && window.print )
	{
		return true;
	}
}
function OpenListingPresentation(nListingID, nAuthoringPassportID)
{
	OpenWindowCentered("/Apps/ListingAdmin/ListingAdminPopups/PresentationPlayer.aspx?ListingID=" + nListingID + "&AuthoringPassportID=" + nAuthoringPassportID, "Tour", 500, 660, 1,1);
}

function Open3DTour(szURL)
{
	try
	{
		if(szURL.indexOf('imagetour|') > -1)
		{
			var aSpit = szURL.split("|");
			ImageTour(aSpit[1], 'defaultlistings.x');
		}
		else if(szURL.indexOf('listingpresentation|') > -1)
		{
			var aSpit = szURL.split("|");
			OpenListingPresentation(aSpit[1], aSpit[2])
		}
		else
		{
			if(szURL.indexOf('http') < 0)
			{
				szURL = 'http://' + szURL;
			}
			OpenWindowCentered(szURL, "Tour", 600, 800, 1,1);
		}
	}
	catch(ex){}
}

function resizeClientBar(nClientBarHeight){
	var obj;
	
	if (document.getElementById('clientBar') != undefined){
		obj = document.getElementById('clientBar');
	}
	else {
		obj = document.getElementById('clientBar2');
	}
	obj.height = nClientBarHeight + 10;
}

function resizeBio(newHeight) {
	if (document.getElementById("agentProfile")){
		document.getElementById("agentProfile").height = newHeight;
	} else {
		document.getElementById("agentProfile2").height = newHeight;
	}
}


