<!--//


// ---------------BROWSER DETECT-------------------
var browserX ;
var versionX;
var osX;

function isIE7() {
	
   if ((browserX == 'Explorer') && (versionX == '7')){
   	//alert('sdfsd1');
   	return true;
   } else {
   	//alert('sdfsd2');
   	return false;
   }
}

function isIE6() {
   if ((browserX == 'Explorer') && (versionX == '6')){
   	return true;
   } else {
   	return false;
   }
}


function isFF() {
   if ((browserX == 'Firefox')){
   	return true;
   } else {
   	return false;
   }
}

















function getUserId(id) {
	if (id != "") {
		return "(" + id + ")";
	}
}





function openKmlWindow(width, height, forDemo) {
  if (screen) {
    y = (screen.availHeight - height)/2;
    x = (screen.availWidth - width)/2;
  }
  var mls = getMlsQ();
  if (forDemo == true) {
  	mls = 'demoMLS';
  }
  var url = 'map.do?command=getKml&mlsId=' + mls;
  popup = window.open(url,'kmlDirections','width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x+',status=no,resizable=no,scrollbars=yes,location=no');
  popup.focus();
}



function submitMlsIdForm() {
    document.forms.mlsIdForm.submit();
}


function openWindow(url, width, height) {
	openNamedWindow(url, width, height, 'pic');
}

function openNamedWindow(url, width, height, windowName) {
  if (screen) {
    y = (screen.availHeight - height)/2;
    x = (screen.availWidth - width)/2;
  }

  popup = window.open(url, windowName,'width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x+',status=yes,resizable=no,scrollbars=yes,location=no');
  popup.focus();
}

function openNamedWindowWithAddress(url, width, height, windowName) {
  if (screen) {
    y = (screen.availHeight - height)/2;
    x = (screen.availWidth - width)/2;
  }

  popup = window.open(url, windowName,'width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x+',status=yes,resizable=no,scrollbars=yes,location=yes');
  popup.focus();
}


function getMlsQ(){
	var m = document.getElementById('mlsId').value;
	return m;
}

function setMlsQ (m) {
	document.getElementById('mlsId').value = m;
}
function launchHelp(width, height, context) {
        var url = "help.do?command=help&helpContext="+context;
		openNamedWindow(url, width, height, 'help');
}

function launchPOIIdea(width, height) {
		var anchor = document.getElementById('currentPoi.poiType').value;
		if (anchor == null || anchor == ''){
			anchor = 'ALLPOIS';
		}
		var url = "admin/poiIdea.jsp#"+anchor;
		openNamedWindow(url, width, height, 'idea');
}



//This is ONLY used on step 4 of maintProp.jsp.. probably shd not be calling it generically.. move to a more efficient place.
function blinklink(){
    if (document.getElementById('blink_link') != null) {
		if (!document.getElementById('blink_link').style.color){
			document.getElementById('blink_link').style.color="red"
		}
		if (document.getElementById('blink_link').style.color=="red"){
			document.getElementById('blink_link').style.color="blue"
		}else{
			document.getElementById('blink_link').style.color="red"
		}
		timer=setTimeout("blinklink()",400)
	}
}

function stoptimer(){
	clearTimeout(timer)
}

function clearField(field){
	document.getElementById('mlsId').value ='';
}

function TipWrapper(text, title, width){
	if (title == 'NEXT STEPS') {
		if (text != null || text != '') {
			return Tip(text, TITLE, title, STICKY, true, WIDTH, width, CLICKCLOSE, true,  CLOSEBTN, true, BGCOLOR, '#FFFF99', FIX, [210, 180]);
		}
	} else {
		return Tip(text, TITLE, title, STICKY, 1, WIDTH, width, CLICKCLOSE, true, CLOSEBTN, true, BGCOLOR, '#FFFF99');
	}
}


function imposeMaxLength(field, maxlen){
	if (field.value.length > maxlen + 1){
		alert('Your input will be truncated! This field only allows ' + maxlen + ' characters.');
	}
	if (field.value.length > maxlen) {
		field.value = field.value.substring(0, maxlen);
	}
}

function checkIfMLSExists(element, propertyId){
	callOut('map.do?command=checkIfMLSExists&mlsId='+ element.value +'&propertyView.propertyId=' + propertyId, 'Please wait...', processCheckIfMLSExists);
}





var opacity = 100;
var aTimer;
var blinkCount = 0;

function setRepeater(repeat, millis) {
	opacity = 100;
	blinkCount = 0;
	aTimer = window.setInterval(repeat,millis);
	return false;
}

function cancelRepeater(t){
	window.clearInterval(t);
	return false;
}

function dimOut() {
	if (document.getElementById('feedbackDiv') != null) {
		if (opacity <= 0) {
			document.getElementById('feedbackDiv').style.display = 'none';
			cancelRepeater(aTimer);
		} else {
			opacity = opacity - 10;
			document.getElementById('feedbackDiv').style.filter = 'alpha(opacity=' + opacity + ');';
			//document.getElementById('feedbackDiv').style.-moz-opacity = (opacity/100);
			document.getElementById('feedbackDiv').style.opacity = (opacity/100);
		}
	}
}

//setRepeater(blinkCount());

function blink(ele, howManyTimes) {
	if (ele != null) {
		//alert ('bc ' + blinkCount);
		if(blinkCount < howManyTimes) {
			flipElement(ele);
			blinkCount = blinkCount + 1;
		} else {
			cancelRepeater(aTimer);
			//Make sure it's visible at end
			if(document.getElementById(ele) != null) {
				document.getElementById(ele).style.visibility = 'visible';
			}
		}
	}
}

function flipElement(element){
	if(document.getElementById(element) != null) {
		var s = document.getElementById(element);
		s.style.visibility=(s.style.visibility=='visible')?'hidden':'visible';
	}
}



//------FOR NEXT STEP div 

var nextStepDivHeight = '180px';

function minimizeNextStepsDiv(){
	if(document.getElementById('nextStepsDiv') != null) {
		document.getElementById('nextStepsDiv').style.height = '20px';
		document.getElementById('nextStepsContent').style.display = 'none';
		document.getElementById('nextStepsMinMax').innerHTML = '<span style="font-size: 150%;"><A href="javascript:maximizeNextStepsDiv()"><b>+</b></A></span>';
		document.getElementById('nextStepsTitle').innerHTML = 'NEXT STEPS...';
		floatingMenu.move();
	}
	
}
function maximizeNextStepsDiv(){
	if(document.getElementById('nextStepsDiv') != null) {
		document.getElementById('nextStepsDiv').style.height = nextStepDivHeight;
		document.getElementById('nextStepsContent').style.display = 'block';
		document.getElementById('nextStepsMinMax').innerHTML = '<span style="font-size: 150%;"><A href="javascript:minimizeNextStepsDiv()"><b>-</b></A></span>';
		document.getElementById('nextStepsTitle').innerHTML = 'NEXT STEPS';
		
	}
	
}

function alertWrapper(x){
	alert(x);
}

function showNextSteps(text){
	
	if(text != null && text != '') {
		
		if(document.getElementById('nextStepsDiv') != null) {
			
			document.getElementById('nextStepsDiv').style.display = 'block';
			
			maximizeNextStepsDiv();
			
			document.getElementById('nextStepsContent').innerHTML = '<BR>' + text;	
			
			//get the length of the text
			var len = text.length;
			//alert('len is ' + len);
			if (len < (8*25)) {
				nextStepDivHeight = '180px';
			} else if ((len > (8*25)) && (len < (18*25))) {
				nextStepDivHeight ='360px';
			} else if (len > (18 * 25)) {
				nextStepDivHeight = '540px';
			}
			
			document.getElementById('nextStepsDiv').style.height = nextStepDivHeight;
		}
	} else {
		document.getElementById('nextStepsDiv').style.display = 'none';
	}
}

function charactersLeft(count,input,limit) {
	  // Get the element where the current count is displayed
	  var countEl = document.getElementById(count);
	  // Get the element where the text is being entered
	  var inputEl = document.getElementById(input);
	  // Get the text from the input element
	  var inputStr = inputEl.value;
	  // # of characters left = max input - current string length
	  var charsLeft = limit - inputStr.length;
	  
	  // Change text color to red if 5 or less characters are left
	  if(charsLeft <= 5) {
	    countEl.style.color = "red";
	  }
	  else {
	    countEl.style.color = "black";
	  }
	  
	  // When 0 characters are left...
	  if(charsLeft <= 0) {
	  	// always set charsLeft to 0 so no negative #'s display
	    charsLeft = 0;
		// trim the extra input off of the input string and push
		// to the input element
	    inputEl.value = inputStr.substring(0,limit);
	  }
	  
	  // push the current count to the count element
	  countEl.innerHTML = charsLeft;
}


function closeAlertBox(id){
	if(document.getElementById(id) != null) {
		document.getElementById(id).style.display = 'none';
	}
}


//-->
