var shtml="<div id='fContent' style='z-index:100;display:none;position:absolute;top:15px;left:200px;border:1px solid #FFFFFF;background-color:white;'>" 
				+"<div style='text-align:right;background-color: #FFFFFF'><img src='/engine/images/closelabel.gif' style='cursor:pointer' onclick=\"hideShow('none');\" border=0 alt='Close'></div>" 
				+ "<div id='cartCont'>"
				+ "<iframe src=\"loading.cfm\" frameborder=0 name=\"popURL\" id=\"popURL\"></iframe>"
				+"</div></div>";

document.write(shtml);

function showPh(mid, oid, phone) {
		document.getElementById("phbroker"+mid+ "_"+ oid).innerHTML = "<span class='plainsmalltext'>" + phone + " Phone</span> ";
		objHTTP = getHTTPObject();
		if (objHTTP) {
			objHTTP.open('GET','doBrokerPhone.cfm?officeid='+oid, false);
			objHTTP.send(null);
		}
	}

function getHTTPObject() {
	if(navigator.appName=='Netscape'){
		var objHTTP = new XMLHttpRequest();
	}
	else if (navigator.appName.indexOf("Explorer") > 0) {
		var objHTTP = new ActiveXObject("Microsoft.XMLHTTP");
	}
	return objHTTP;
}

function showdiv(id){
	var elem = document.getElementById(id);
	if (elem) {
		elem.style.display = '';
	}
}
function hidediv(id){
	if (document.getElementById(id)) {
		document.getElementById(id).style.display = 'none';
	}
}

function openWin( windowURL, windowName, windowFeatures ) { 
		return window.open( windowURL, windowName, windowFeatures ) ; 
} 

function popupURL(url,xw,xh){
	
	  document.getElementById("popURL").src=url;
		if(xh!=null){
				document.getElementById("popURL").height=xh + 'px';
				document.getElementById("fContent").style.height=xh + 'px';
		}

		if(xw!=null){
			document.getElementById("popURL").width=xw+ 'px';
			document.getElementById("fContent").style.width=xw+ 'px';
			var divLeft=getWinWidth()/2-(xw/2);
		 	document.getElementById("fContent").style.left=divLeft;

		}
		document.getElementById("fContent").style.top=getWinHeight()+60+"px";
		hideShow('');
}

function getWinWidth(){
	if(navigator.appName.indexOf("Microsoft")==-1){
		return window.innerWidth;           
	}else{
		return document.body.offsetWidth;
	}
}

function getWinHeight(){
	if(navigator.appName.indexOf("Microsoft")==-1){
		return window.pageYOffset;           
	}else{
		return document.documentElement.scrollTop;
	}
}
function hideShow(opt,xw,xj){
	var pobj=document.getElementById("disableDiv");
	var pobj2=document.getElementById("fContent");
	pobj2.style.display=opt;
	pobj.style.display=opt;
	if(opt=="none"){
		document.getElementById("popURL").src="loading.cfm";
	}
}

	function getCount(formElement) {
		var cnt = 0
		for (i=0; i<formElement.options.length; i++){
			if (formElement.options[i].selected == true)	{
				temp = formElement.options[i].text
				pos1 = temp.indexOf('[');
				pos2 = temp.indexOf(']');
				cnt += parseInt(temp.substring(pos1+1, pos2))
			}
		}	  
		return cnt;
	}
	
	
	function Form1_Validator(theFormp){
		var firstn = theFormp.firstname.value.replace(/^\s+|\s+$/g, '');
		var lastn = theFormp.lastname.value.replace(/^\s+|\s+$/g, '');
		var zipcode =theFormp.ZIP.value.replace(/^\s+|\s+$/g, '');
		var lang =	getCount(theFormp.LANGUAGE_ID);
		var cult = getCount(theFormp.CULTURE_ID);
		var dsg = getCount(theFormp.designation);
		//if already select less 200 cnt, let it pass
		if ( (lang>0&&lang<=200) || (cult>0&&cult<=200) || (dsg >0&&dsg<=200) ) {
			return true;
		}
		//alert(theFormp.topZip.value.indexOf(zipcode));
		if (zipcode != "" && theFormp.topZip.value.indexOf(zipcode)==-1) {
			return true;
		}
		// two criteria, let it pass
		var i=0
		if(zipcode != "") i++;
		if(lang > 0) i++;
		if(cult > 0) i++;
		if(dsg > 0) i++;
		if (i==0) {
			if(firstn != "" && firstn.length >=2 ) i++;
			if(lastn != "" && lastn.length >=2) i++;
		} else {
			if(firstn != "") i++;
			if(lastn != "") i++;
		}
		if(i>=2) {return true;}
		
		//only name, then ajax call check record count
		if(firstn != "" || lastn!= "" ){
			theFormp.rowcnt.value = "";
			var xmlhttp=getHTTPObject();
			xmlhttp.open("GET", 'getMemberCnt.cfm?firstname=' + firstn + '&lastname=' + lastn, false);
			xmlhttp.send(null);
			theFormp.rowcnt.value = xmlhttp.responseText;
			if(parseInt(theFormp.rowcnt.value) < 200) {
				return true;
			}
		}
		popupURL('msg.htm', 400, 300)
		return false;
	}
	
	 function Form1_Validator2(theFormp)
  {

  var alertsay = ""; // define for long lines
  // alertsay is not necessary for your code,
  // but I need to break my lines in multiple lines
  // so the code won't extend off the edge of the page

  // check to see if the field is blank
  if (theFormp.SortSequence.value == "" && theFormp.ZIP.value == "")
  {
  alert("You must search by at least an Office Name or Zip Code.");
 // theForm.firstname.focus() || theForm.lastname.focus();
  return (false);
  }
return (true);
 }
 
  
function Form1_Validator4(theFormp)
  {
	  if (theFormp.FirmName.value == "" && theFormp.ZIP.value == "")
	  {
	  alert("You must enter a firm name or zipcode to search.");
	  return (false);
	  }
	return (true);
 }
	 
function Form1_Validator3(theFormp)
  {
  var ifselected = 0;
	for (i=1; i<theFormp.ListCode.options.length; i++){
			if (theFormp.ListCode.options[i].selected == true)	{
				ifselected = 1;
			}
		}
	if (ifselected == 0){
		alert("Please select a type");
		return false;
	}else{
	return true;
	}
 }