// *** PopUp Function **  //
var newwindow=null;
function popitup(url,w,h,scroll,Tpos,Lpos,mb)
{
	settings='width='+w+ ', height='+h+',top='+Tpos+',left='+Lpos+',scrollbars='+scroll+',menubar='+mb ;
	newwindow=window.open(url,'name',settings);
	if (window.focus) {newwindow.focus()}
	return false;
}
// example link:  <a href="test.html" onClick="return popitup('test.html', 500, 200, 'yes', 50, 50, 'yes' )">Link to popup</a>

// strip whitespace on front and rear end of string
function trim(value) {
   var temp = value;
   var obj = /^(\s*)([\W\w]*)(\s*)$/;
   if (obj.test(temp)) { temp = temp.replace(obj, '$2'); }
   return temp;
}

function siteStats(type,i){
	url = "http://pruagent.evisitanalyst.com/evaagent/loginagent.php?" + type + "=" + i;
	settings="";
	newwindow=window.open(url,'stats',settings);
	if (window.focus) {newwindow.focus()}
	return false;
}

function DisplayNewsletterIssue(issueID){ // must accessible be in ALL WebTop pages
	window.open('/newsletter/preview.aspx?home=&ID=' + issueID, 'viewNewsletter', 'top=0,left=0,width=630,height=500,resizable,scrollbars,menubar').focus();
}

function TOU(){
	var myX = 50;
	var myY = 50;
	if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
		myX = screenLeft;
		myY = screenTop;
	}
	else {
		myX = window.screenX;
		myY = window.screenY;
	}
	var url ="/tou.asp";
	settings='width=630,height=500,top=' + myY + ',left=' + myX + ',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,modal=yes';
	newwindow=window.open(url,'TOU',settings);
	if (window.focus) {newwindow.focus()}
	return false;
}


function popupHelp(strFeature, strPage, strItem){
	var myX = 50;
	var myY = 50;
	if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
		myX = screenLeft;
		myY = screenTop;
	}else{
		myX = window.screenX;
		myY = window.screenY;
	}
	if((strItem != null) && (strItem.length > 0)){
		winName="help"
		url = "/help.asp?Feature=" + strFeature + "&Page=" + strPage + "&Field=" + strItem;;
		w = 300;
		h = 200;
		more = ',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,modal=yes';
	}else{
		winName="pagehelp"
		url = "/pagehelp.asp?Feature=" + strFeature + "&Page=" + strPage;
		w = 465;
		h = 480;
		more = ',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,modal=yes';
	}

	settings='width=' + w + ',height=' + h + ',top=' + myY + ',left=' + myX + more;
	newwindow=window.open(url,winName,settings);
	if (newwindow) { 
		newwindow.focus(); 
	}else{
		alert('Please configure your popup blocker to allow popups from this site.')
	}
	
	return false;
}



var popupWindow = '';
function closePopup() {
    if (popupWindow && popupWindow.open && !popupWindow.closed) popupWindow.close();
}
function openPopup(url, scrollBar, resizable, width, height) {
    //closePopup();
    var myX = (640 - width)/2
    var myY = (480 - height)/2;
    if (screen) {
        myY = (screen.availHeight - height)/2;
        myX = (screen.availWidth - width)/2;
    }


    var settings = 'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=' + scrollBar + ',resizable=' + resizable + ',width=' + width + ',height=' + height + 'screenY=' + myY + ',screenX=' + myX + ',top='+ myY + ',left='+ myX;
    popupWindow = window.open(url, 'popupWindow', settings);

    if (popupWindow) { 
		popupWindow.focus(); 
	}else{
		alert('Please configure your popup blocker to allow popups from this site.')
	}	

}

function openAgentFinderPopup(url){
    //closePopup();
    var width=1000;
    var height=700;
    
    var myX = (640 - width)/2
    var myY = (480 - height)/2;
    if (screen) {
        myY = (screen.availHeight - height)/2;
        myX = (screen.availWidth - width)/2;
    }

    var settings = 'menubar=no,toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,width=' + width + ',height=' + height + 'screenY=' + myY + ',screenX=' + myX + ',top='+ myY + ',left='+ myX;
    agentFinderPopupWindow = window.open('/tools/agentFinder.asp', 'agentFinderPopupWindow', settings);
    if (agentFinderPopupWindow) { 
		agentFinderPopupWindow.focus(); 
	}else{
		alert('Please configure your popup blocker to allow popups from this site.')
	}	
}


function openWebtopPopup(url){
	openPopup(url, 'yes', 'yes', 1000, 700);
}
function openWebtopSystemMsg(url){
	//openPopup(url, 'yes', 'no', 640, 480);
	popoup = "<div id=wtSysMsgBox><span class=left>Webtop Message</span><span class=right onclick=Effect.Fade($('wtSysMsgBox'))><img src='/images/toolbarIcons/ico_remove.gif'></span>"
	popoup += "<iframe id=wtSysMsg align=center src="
	popoup += url
	popoup += " width=640 height=480"
	popoup += "></iframe></div>"
	document.write(popoup)
}
function openPopupCal(url){
	openPopup(url, 'no', 'yes', 180, 180);
}
function openRapidResponse(url){
	openPopup(url, 'no', 'yes', 660, 450);
}
function openGoMobileDemo(url){
	openPopup(url, 'no', 'yes', 490, 430);
}
function openWebTour(url){
	openPopup(url, 'no', 'yes', 780, 650);
}
function openTalkingTour(url){
	openPopup(url, 'no', 'yes', 645, 440);
}
function openShowingTime(url){
	openPopup(url, 'yes', 'yes', 770, 840);
}
function openFloorPlanTour(url){
	openPopup(url, 'yes', 'yes', 620, 600);
}
function openOtherTour(url){
	openPopup(url, 'yes', 'yes', 780, 650);
}
function openEmail(url){
	openPopup(url, 'yes', 'yes', 1000, 700);
}
function openSlideShow(url){
	openPopup(url, 'yes', 'yes', 770, 600);
}
function openWTEmail(url){
	openPopup(url, 'yes', 'yes', 550, 350);
}
function openWTEmailVendor(url){
	openPopup(url, 'yes', 'yes', 550, 350);
}
function openWTVideoTraining(url,id){
	var vdoURL = "/interMediaPage.aspx?vdoUrl=" + url + "&mmID=" + id;
	openPopup(vdoURL, 'yes', 'yes', 580, 480);
}
function openUsefulDocsUploadRules(){
	openPopup("UploadRules.asp", 'no', 'yes', 500, 330);
}
function qsGoTo(destination){
	url = location.toString();
	elem = url.split("?");
	if (elem.length > 0) {
		pathLen = elem[0].length;
		location = destination + url.substring(pathLen); 
		return false;
	}
	location = destination; 
	return false;
}
//NOTE:   this function causes IE6 to bring CPU to 100% in some systems
function DocumentDotWriteThisText(objectText){
	//useful to work around IE control activation
	document.write(objectText)
}
function NAEditMode(){
	alert('This item is not available while in Edit mode.')
}
function DeleteCookie(name, path) 
{
	if (readCookie(name) != null ) document.cookie = name + "=" +
	( ( path ) ? ";path=" + path : "") +
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
function readCookie(name) 
{

	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}


function gotoForeclosureLogin(){
	document.location.href="foreclosurelogin.aspx";
}
function gotoForeclosureSignUp(){
	document.location.href="foreclosuresignup.aspx";
}

