// ----- Server Definitions -----------------------------------------
var
	sLocal  = "/"                           
	,sSwitch = "http://cmls.marketlinx.net/"
	,sStaff  = "/"
	,sTips   = "http://cmls.marketlinx.net/" 
	,isCMLS = true;

// ----- Navigation Base Functions ----------------------------------
function GoTo        (ser,add)  {parent.location.href      = ser + add;} // blow away any frames
function GoToDocument(ser,add)  {document.location.href = ser + add;} // load in frame
function GoToNewUI   (ser,add)  {top.main.location.href = ser + add;} // blow away any frames

function Replace(ser, add)		{document.location.replace(ser+add);} // replace in history
function Redirect(ser, add)		{Replace(ser, add); document.location.reload();} //redirect a page. 

function PopupNewWindow(ser,add) 
{
	var url = ser + add;
	window.open(url, "CMLS");
	return;
}

function PopupReportListing(proptype, mlsNumber) 
{
	PopupNewWindow(sLocal, GetSearchDetailPath()+"Scripts/PrtAgtFul/PrtAgtFul.asp"
		+"?MlsNumList=" +mlsNumber
		+"&EditMode=true"
		+"&prp=" +proptype);
}

function PopupNewWindowSmall(ser,add) 
{
	var url = ser + add;
	window.open(url, "CMLSSmall","width=500,height=600,scrollbars=1,resizable=1");
	return;
}

// Determine whether we are old or new ui
bNewUI = true;

// ----- Specific Web Navigation Functions ---------------------------
function GetAddEditWeb() 
{
	GoToNewUI(sLocal, "Edit/NewUI.html");
	top.menu.changeVariable("edit");
	top.menu.activateCell(1);
	return;
}

function GetAgent(pubID)          { PopupNewWindowSmall(sLocal, GetRosterPath()+"Scripts/Member.asp?pubID="+pubID); }
function GetBroker(BkrCode)       { PopupNewWindowSmall(sLocal, GetRosterPath()+"Scripts/OfficeSrhPopUp.asp?OfficeID="+BkrCode); }

function GetBrokerHeadWeb() 
{
	GoToNewUI(sLocal, "BrokerHead/Default.htm");
	top.menu.changeVariable("headbroker");
	top.menu.activateCell(1);
	return;
}

function GetBrokerOfficePath()    { return "BrokerOffice/"; }

function GetBrokerOfficeWeb() 
{
	GoToNewUI(sLocal, "BrokerOffice/Default.htm");
	top.menu.changeVariable("officebroker");
	top.menu.activateCell(1);
	return;
}

function GetBrokerOfficeWebEdit() { GoTo(sLocal,GetBrokerOfficePath() + 'Scripts/BrokerEdit.idc' ); }
function GetCustomSearch(sid)     { GoToDocument(sLocal, GetSearchPath()+"Scripts/CSS/CusSrh.asp?Id=" + sid); }
// This next function is only used in Prospects/Scripts/ProspectShow.asp. We do not use prp anymore.
function GetCustomPrpSearch(prp, sid) { return GetCustomSearch(sid); }
function GetDiscussionWeb()       { GoTo(sLocal,"Discussion/Default.htm"); }
function GetDownloadAction()      { return sLocal + GetSearchPath()+"Scripts/Download/Information.asp"; }
function GetEmailWeb()            { return sLocal + "Email/Scripts/EmailForm.asp"; }
function GetFinancialWeb()        { GoTo(sLocal,"Financial/Default.htm"); }
function GetImailWeb()            { PopupNewWindow("","http://mail.cbr.com:8383/"); }
function GetInfoWeb()             { GoTo(sLocal,"Info/default.htm"); }
function GetMlsNo()               { GoToDocument(sLocal,GetSearchPath()+"Mls.htm"); }
function GetNewsLetterWeb()       { GoTo(sTips,"NewsLetter/newsletter/pageone.htm"); }
function GetMyPageWeb()           { GoTo(sLocal,"Subscriber/MyPage.asp"); }
function GetPartnersWeb()         { GoTo(sLocal,"Partners/Default.htm"); }
function GetPrintListing(prp, mls) { return GetSearchDetailPath()+"Scripts/PrtAgtFul/PrtAgtFul.asp?MlsNumList=" +mls+ "&prp=" +prp; }
function GetProspectsWeb()        { GoTo(sLocal,"Prospects/Default.htm"); }
function GetReportsPath()         { return "Reports/"; }
function GetReportsMenu()         { GoToDocument(sLocal,GetReportsPath() + "Scripts/Default.asp"); }
function GetReportsWeb()          { GoTo(sLocal,GetReportsPath() + "Default.htm"); }
function GetReportsWebAct()       { GoTo(sLocal,GetReportsPath() + "Act.htm"); }
function GetRosterPath()          { return  "Roster/"; }           
function GetRosterWeb()           { GoTo(sLocal, GetRosterPath() + "Default.htm"); }
function GetRTHome()              { GoTo(sLocal,"Subscriber/DefaultSubscriber.htm"); }
function GetSearchDetailPath()    { return "SearchDetail/"; }
function GetSearchDetailWeb()     { GoTo(sLocal,GetSearchDetailPath() + "Default.htm"); }
function GetSearchMenu()          { GoToDocument(sLocal,GetSearchDetailPath() + "DefaultMenu.htm"); }
function GetSearchPath()          { return "Search/"; }
function GetSearchWeb()           { GoTo(sLocal,GetSearchDetailPath() + "Default.htm"); }

function GetStf() 
{
	GoToNewUI(sLocal, "StfMaint/Default.asp");
	top.menu.changeVariable("staff");
	top.menu.activateCell(1);
	return;
}

function GetStfMaint()            { GoTo(sStaff,"StfMaint/default.asp"); }
function GetStfPicturesPath()     { return "StfPictures"; }
function GetStfPictures()         { GoTo(sStaff,GetStfPicturesPath()+"/default.asp"); }
function GetTaxWeb()              { GoTo("","/Custom/ShareServer/RealistHome.asp"); }
function GetThirdParty()          { return "/ThirdParty/"; }
function GetFullThirdParty()      { return "/ThirdParty/Scripts/CMLS_GetData.asp"; }
function ReturnTaxWeb()           { return(sLocal + "Tax/"); }
function GetTipsPath()            { return (sTips + "Tips/"); }
function GetTipsWeb()             { GoTo(sTips,"Tips/Default.htm"); }
function GetTipsWelcome()         { return GetTipsPath() + "Welcome.htm"; }
function RedirectSearch()		  { Redirect(sLocal,GetSearchDetailPath() + "Default.htm");}
function RedirectBrokerHead()	  { GetBrokerHeadWeb(); }
function RedirectBrokerOffice()	  { GetBrokerOfficeWeb(); }
function RedirectReports()		  { Redirect(sLocal,GetReportsPath() + "Default.htm");}		

// ----- Functions Which Do Specific Tasks --------------------------
// This functions builds the url string necessary to display
// an agent quarter page w/o photo.
function GetPrtNoP4(mls, prp) 
{
	var RetVal = "/" + GetSearchDetailPath() + "Scripts/PrtNoP4/PrtNoP4.asp";
	RetVal += "?prp="+prp;
	RetVal += "&MlsNumList="+mls;
	return (RetVal);
}

function PrintListing(proptype, mlsNumber) 
{
	GoToDocument(sLocal, GetSearchDetailPath()+"Scripts/PrtAgtFul/PrtAgtFul.asp?MlsNumList=" +mlsNumber+ "&prp=" +proptype     );
}

function PrintEditListing(proptype, uid) 
{
	PopupNewWindow(sLocal, GetSearchDetailPath()+"Scripts/PrtAgtFul/PrtAgtFul.asp"
		+"?uidlist=" +uid
		+"&EditMode=true"
		+"&prp=" +proptype);
}

// ----- Client Side functions to print HTML ------------------------ 
var thisDD = new Date();

function GetCopyright() 
{
	return('<font face="arial" Size=1><img src ="/share/images/miscellaneous/tempotransparent.gif" border="0">Software Copyright &copy; MarketLinx, Inc. 1997-'+thisDD.getFullYear()+' All Rights Reserved</font><br>');
}

function GetDataCopyright() 
{
	return('<font face="arial" size="1">Data Copyright &copy; Carolina Multiple Listing Services, Inc. '+thisDD.getFullYear()+' All Rights Reserved<br>  Support: <a href="mailto:support@carolinahome.com">support@carolinahome.com</a>   Suggestions: <a href="mailto:suggestions@carolinahome.com">suggestions@carolinahome.com</a></Font>');
}

function PrintCopyright() 
{
	document.write('<p align="center">'+GetCopyright()+GetDataCopyright()+'</p>');
}

function PrintDataCopyright() 
{
	//   document.write('<p align="center">'+GetDataCopyright()+'</p>');
}

function GetLogo()  
{
	return('<img src="/Custom/Images/Headers/PageLogo.gif">')
}

function PrintGetLogo() 
{
	document.write(GetLogo());
}

function GetProSub() 
{
	return ('<img src="/Share/Images/Headers/ProSub.jpg">')
}

function PrintGetProSub() 
{
	document.write(GetProSub());
}

function GetProHeader() 
{
	return ('<img src="/Share/Images/Headers/ProHeader.jpg">')
}

function PrintGetProHeader() 
{
	document.write(GetProHeader());
}

// ----- Help Page Functions ----------------------------------------

// check to make sure that we should include help 
// vHelpPage is include in the 'outside' page to indicate
// if help should be included or not.  
// If it is defined and blank, then use our standard naming convention of 
// <basefilename>help.htm
// If it is defined and not blank, then use its value as our help file to open

// This function will open the specific page given to it based
// on the current web location. Meaning it takes the page url
// such as "/Edit/Scripts/Hidden.asp", removes the "Hidden.asp"
// part and appends the url passed in. It then opens it in a new
// window.
function OpenHelpWindow(szPageUrl) 
{
	var wAttrib = "width=500,height=400,toolbar=0,status=0,location=0,directories=0,menubar=0,scrollbars=1,resizable=1";
	var szTmp = new String(location.pathname);
	szTmp = szTmp.substring( 0, szTmp.lastIndexOf('/')+1);
	window.open(szTmp + szPageUrl, "Help", wAttrib);
}

var helpURL;

function Click4Help()
{
	var wAttrib = "'width=500,height=400,scrollbars=1,resizable=1'"
	helpURL = helpURL + ",'Help'," + wAttrib;
	eval("window.open("+helpURL+");");
}

function OpenHelp(overrideURL) 
{
	// this does not work if parameters are passed
	if((overrideURL=="undefined")||(overrideURL=='')) 
	{
		// default action
		helpURL = new String(self.location.href);
		if(helpURL.indexOf("?")>0) 
		{
			helpURL = helpURL.substring(0, helpURL.indexOf("?"));
		}
		if(helpURL.lastIndexOf(".")>0) 
		{
			helpURL = helpURL.substring(0, helpURL.lastIndexOf("."));
		}
		helpURL += "help.htm";
	}
	else 
	{
		helpURL = overrideURL;
	}
	// add ' to front and back of URL
	helpURL = "'"+helpURL+"'";
	var wAttrib = "'width=500,height=400,scrollbars=1,resizable=1'";
	document.write ('<a href="javascript: Click4Help()" >');
	document.write ('<img src="/Share/images/Navigation/BBHelpRed.jpg" alt="Help with this Page" border="0" width="63" height="72"></a>')
}  

function HelpFooter() 
{
	document.write(
		'<form method="POST">\
		<div align="center"><p><input onClick="window.close()"\
		type="button" value="Close Window" name="close">');
	// flag for browser type.
	var bNetscape = (navigator.appName == "Netscape") ? true : false;
	if (bNetscape == true) 
	{
		document.write(' <input onClick="window.print()" type="button" ');
		document.write('value="Print" name="close"></p>');
	}
	else 
	{
		document.write('<p><font size=2 color="#OOOOFF">To <font size=4><b>PRINT</b></font>, right click and select "Print"</font></p>');
	}
	document.write('</div></form>');
}

// More hacked code in the locator file!

function isExplorer5()
{
	// convert all characters to lowercase to simplify testing 
	var agt=navigator.userAgent.toLowerCase(); 
	// *** BROWSER VERSION *** 
	// Note: On IE5, these return 4, so use is_ie5up to detect IE5.
	var is_major = parseInt(navigator.appVersion); 
	var is_ie   = (agt.indexOf("msie") != -1); 
	var is_ie3  = (is_ie && (is_major < 4)); 
	var is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")==-1) ); 
	var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4); 
	return is_ie5up
}

function PopUp(url)
{
	window.open(url,"PopUp","height=350,width=200,scrollbars=yes");
	return;
}

function GetListPopUp(ListBox,FormVar)
{
	window.open('/Search/ListPopUp.asp?ListBox=' + ListBox + '&amp;FormVar=' + FormVar,'ListBox','height=350,width=600,scrollbars=yes'); 
}
