function offAll(){
	for(var i=1;i<4;i++){
		document.getElementById("item_"+i).className="";	
	}
}

function siteSearch(sform){
	if(sform.quickSearch.value=="" || sform.quickSearch.value=="Enter Keyword(s) To Begin Your Search"){
		alert("Please enter a search term to search!");
		return false;
	}
	sform.action="http://members.har.com/search/default.cfm?cx=015562241301924267570:ltykoyducjs&cof=FORID:11&q="+sform.quickSearch.value;
	return true;
}

function domainsearch() {
		if (document.msearch.quickSearch.value == "" || document.msearch.quickSearch.value =="Enter Address or Street Name or MLS Number or Zip Code") {
			changeStyle("waitDiv","display","none");
			alert( "Please enter Address or Street Name or MLNUM Number or Zip Code");
		}
		else{
			changeStyle("searchResult","display","none");
			changeStyle("waitDiv","display","block");
			loadData('Ajaxcall/mainSearch.cfm?mainsearch='+ document.msearch.quickSearch.value, 'searchResult','changeStyle("waitDiv","display","none")');		
		}

	return false;
}

function retData(hObj,tabName){
	offAll();
	hObj.className="selected";
	waitGen("dcHolder");
	
	var url="Ajaxcall/getData.cfm?contentName="+tabName+"&nc="+Math.random();
	loadData(url,"dcHolder");
}

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='/images/closelabel.gif' style='cursor:pointer' onclick=\"hideShow('none');\" border=0 alt='Close'></div>" 
				+ "<div id='cartCont'>"
				+ "<iframe src=\"Ajaxcall/loading.cfm\" frameborder=0 name=\"popURL\" id=\"popURL\"></iframe>"
				+"</div></div>";

document.write(shtml);


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 popupURL(url,xw,xh){
	
	  document.getElementById("popURL").src=url;
		if(xh!=null){
				document.getElementById("popURL").height=xh + 'px';
				document.getElementById("fContent").style.height=eval(xh+25) + '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=eval(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="Ajaxcall/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", 'Ajaxcall/getMemberCnt.cfm?firstname=' + firstn + '&lastname=' + lastn, false);
			xmlhttp.send(null);
			theFormp.rowcnt.value = xmlhttp.responseText;
		//	alert(theFormp.rowcnt.value);
			if(parseInt(theFormp.rowcnt.value) < 200) {
				return true;
			}
		}
		popupURL('Ajaxcall/msg.htm', 400, 250)
		return false;
}
	
	
 
