// JavaScript Document

// Hilite TR/TD
function highlight(tr,s,o,c){
	if (o == undefined) o = '';
	if (s==1) {
		c = (c == null) ? "#FFFFFF" : c;
		window.status=o;
		tr.style.cursor = "pointer";
		tr.style.backgroundColor = c;
	} else {
		c = (c == null) ? "#EEEEEE" : c;
		window.status='';
		tr.style.cursor = "";
		tr.style.backgroundColor = c;
	}
}

// Popup Window
var popUpWin=0;
function popUpWindow(imgStr,width, height) {
	if(popUpWin) {
		if(!popUpWin.closed) popUpWin.close();
	}
	var left = screen.availWidth/2 - width/2;
	var right = screen.availHeight/2 - height/2;
	popUpWin = open('viewer.php?image=' + imgStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,copyhistory=no,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

// Disallow Letters in inputs
function checkKey(keyCode, notAllowedKeys) {
	var letter = String.fromCharCode(keyCode); 
	for(i=0; i<notAllowedKeys.length; i++) {
		if (notAllowedKeys.charAt(i) == letter) {
			alert ("The following Characters are not allowed in this field\n\n    " + notAllowedKeys);
			return false;
		}
	}
}

function showElement(element) {
	var x = document.getElementById(element);
	x.style.display = 'block';
}
function hideElement(element) {
	var x = document.getElementById(element);
	x.style.display = 'none';
}

function tabBox(element, flag) {
		if (flag) {
			element.style.backgroundColor = "#FFEEEE";
			element.style.color = "#000000";
		} else {
			element.style.backgroundColor = "#FFFFFF";
			element.style.color = "#666666";
		}
}

//SAME AS POPUPWIN -- only for tor
var popUpWin=0;
function loadTour(realtor,tour) {

	var width = 750;
	var height = 500;
	var left = screen.availWidth/2 - width/2;
	var top = screen.availHeight/2 - height/2;
	var URLStr = "../tour.php?realtor=" + realtor + "&tour=" + tour;

	if(popUpWin) {
		if(!popUpWin.closed) popUpWin.close();
	}
	popUpWin = open(URLStr, 'TourManager', 'toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no, copyhistory=no,width='+width+',height=' +height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
	popUpWin.focus();
}