function RunSearch()
{
	document.forms.frmSearch.a.value = 'search'; 
	document.forms.frmSearch.SearchFor.value = document.getElementById('ctlSearchFor').value; 
	if(document.getElementById('ctlSearchField')!=undefined)
		document.forms.frmSearch.SearchField.value = document.getElementById('ctlSearchField').options[document.getElementById('ctlSearchField').selectedIndex].value; 
	if(document.getElementById('ctlSearchOption')!=undefined)
		document.forms.frmSearch.SearchOption.value = document.getElementById('ctlSearchOption').options[document.getElementById('ctlSearchOption').selectedIndex].value; 
	else
		document.forms.frmSearch.SearchOption.value = "Contains"; 
	document.forms.frmSearch.submit();
}


function GetGotoPageUrlString (nPageNumber,sUrlText)
{
	return "<a href='JavaScript:GotoPage(" + nPageNumber + ");' style='TEXT-DECORATION: none;'>" + sUrlText 
	+ "</a>";
}

function WritePagination(mypage,maxpages)
{
	if (maxpages > 1 && mypage <= maxpages)
	{
			document.write("<table rows='1' cols='1' align='center' width='95%' border='0'>"); 
			document.write("<tr valign='center'><td align='center'>"); 
			var counterstart = mypage - 9; 
			if (mypage%10) counterstart = mypage - (mypage%10) + 1; 
 
			var counterend = counterstart + 9; 
			if (counterend > maxpages) counterend = maxpages; 
 
			if (counterstart != 1) document.write(GetGotoPageUrlString(1,TEXT_FIRST)+"&nbsp;:&nbsp;"+GetGotoPageUrlString(counterstart - 1,TEXT_PREVIOUS)+"&nbsp;"); 
 
			document.write("<b>[</b>"); 
		
		var pad="";
		var counter	= counterstart;
		for(;counter<=counterend;counter++)
		{
			if (counter != mypage) document.write("&nbsp;" + GetGotoPageUrlString(counter,pad + counter));
			else document.write("&nbsp;<b>" + pad + counter + "</b>");
		}
		document.write("&nbsp;<b>]</b>");
		if (counterend != maxpages) document.write("&nbsp;" + GetGotoPageUrlString (counterend + 1,TEXT_NEXT) + "&nbsp;:&nbsp;" + GetGotoPageUrlString(maxpages,TEXT_LAST))
			
		document.write("</td></tr></table>");		
	}
}


    var rowWithMouse = null;

    function gGetElementById(s) {
      var o = (document.getElementById ? document.getElementById(s) : document.all[s]);
      return o == null ? false : o;
    }

    function rowUpdateBg(row, myId) 
    {
        row.className = (row == rowWithMouse) ? 'rowselected' : ( (myId&1) ? '' : 'shade' );
    }

    function rowRollover(myId, isInRow) {
      // myId is our own integer id, not the DOM id
      // isInRow is 1 for onmouseover, 0 for onmouseout
      var row = document.getElementById('tr_' + myId);
      rowWithMouse = (isInRow) ? row : null;
      rowUpdateBg(row, myId);
    }



function BuildSecondDropDown(arr, SecondField, FirstValue)
{
	document.forms.editform.elements[SecondField].selectedIndex=0;

	document.forms.editform.elements[SecondField].options[0]=new Option(TEXT_PLEASE_SELECT,'');

	var i=1;
	for(ctr=0;ctr<arr.length;ctr+=3)
	{
		if (FirstValue.toLowerCase() == arr[ctr+2].toLowerCase())
		{
			document.forms.editform.elements[SecondField].options[i]=new Option(arr[ctr+1],arr[ctr]);
			i++;
		}
	}
	document.forms.editform.elements[SecondField].length=i;
	if(i<3 && i>1 && !bLoading)
		document.forms.editform.elements[SecondField].selectedIndex=1;
	else
		document.forms.editform.elements[SecondField].selectedIndex=0;
}

function SetSelection(FirstField, SecondField, FirstValue, SecondValue, arr)
{
	var ctr;

	BuildSecondDropDown(arr, SecondField, FirstValue);	 
	if(SecondValue=="" && document.forms.editform.elements[SecondField].length<3)
		return;
	for (ctr=0; ctr<document.forms.editform.elements[SecondField].length; ctr++)
	 if (document.forms.editform.elements[SecondField].options[ctr].value.toLowerCase() == SecondValue.toLowerCase() )
	 	 {
		  document.forms.editform.elements[SecondField].selectedIndex = ctr;
		  break;
		 }
}
function padDateValue(value,threedigits)
{
	if(!threedigits)
	{
		if(value>9)
			return ''+value;
		return '0'+value;
	}
	if(value>9)
	{
		if(value>99)
			return ''+value;
		return '0'+value;
	}
	return '00'+value;
}

function getTimestamp()
{
	var ts = "";
	var now = new Date();
	ts += now.getFullYear();
	ts+=padDateValue(now.getMonth()+1,false);
	ts+=padDateValue(now.getDate(),false)+'-';
	ts+=padDateValue(now.getHours(),false);
	ts+=padDateValue(now.getMinutes(),false);
	ts+=padDateValue(now.getSeconds(),false);
	return ts;
}

function addTimestamp(filename)
{
	var wpos=filename.lastIndexOf('.');
	if(wpos<0)
		return filename+'-'+getTimestamp();
	return filename.substring(0,wpos)+'-'+getTimestamp()+filename.substring(wpos);
}

function create_option( theselectobj, thetext, thevalue ) 
{
theselectobj.options[theselectobj.options.length]= new Option(thetext,thevalue);
}

function SetToFirstControl()
{
  var bFound = false;

  // for each form
  for (f=0; f < document.forms.length; f++)
  {
    // for each element in each form
    for(i=0; i < document.forms[f].length; i++)
    {
      // if it's not a hidden element
      if (document.forms[f][i].type != "hidden")
      {
        // and it's not disabled
        if (document.forms[f][i].disabled != true)
        {
	try
		{
	            // set the focus to it
        	    document.forms[f][i].focus();
	            var bFound = true;
		}
	catch(er)
		{
		} 
       }
      }
      // if found in this element, stop looking
      if (bFound == true)
        break;
    }
    // if found in this form, stop looking
    if (bFound == true)
      break;
  }
}

///// adding div nevigation start 120607////////////////////////////////////////


var arrDesig = [["ABR","Accredited Buyer Representative","Look first for the Accredited Buyer’s Representative (ABR&reg;) designation when looking for a home. REALTORS&reg; with ABR&reg; after their name have met strict educational and practical requirements set by the Real Estate Buyer’s Agent Council (REBAC) to help guide you in your successful home purchase."],
                ["ABRM","Accredited Buyer Representative Manager","Geared to real estate firm brokers, owners and managers that have or wish to incorporate buyer representation into their daily practice, designees have taken and passed both the ABR&reg; and ABRM SM course and provided documentation of past management experience."],
                ["AHWD","At Home With Diversity","Relays to the public that those certified have been professionally trained in and are sensitive to a wide range of cultural issues."],
                ["ALC","Accredited Land Consultant","Experts recognized in land brokerage transaction areas of five specialized types: (1) farms and ranches; (2) undeveloped tracts of land; (3) transitional land; (4) subdivision and wholesaling of lots; and (5) site selection and assemblage of land parcels."],
                ["CCIM","Certified Commercial Investment Member","CCIMs are recognized experts in commercial real estate brokerage, leasing, asset management valuation and investment analysis. The CCIM business network includes more than 5,000 designees and 5,000 candidates principally in North America."],
                ["CIPS","Certified International Property Specialist","Many REALTORS&reg; work with buyers and sellers from different countries or cultures. CIPS designees have demonstrated their international experience and participate in international programs offered by the National Association of REALTORS&reg;."],
                ["CPM","Certified Property Manager","Acquire valuable real estate management skills through educational offerings leading to the CPM&reg; designation. CPM&reg; members have the competitive edge in every area of real estate management from residential to commercial to industrial."],
                ["CRB","Certified Real Estate Brokerage Manager","With more than 7,000 brokerage owners and managers nationwide enjoying the benefits of membership, the Real Estate Brokerage Managers Council is recognized throughout the industry as the professional peer organization for real estate's leaders. Real estate brokerage owners and managers will be ready to meet their personal and professional challenges when they earn the CRB designation."],
                ["CRE","Counselor of Real Estate","The Counselor of Real Estate - or CRE - is a member of the Counselors of Real Estate, an international group of recognized professionals who provide seasoned, objective advice on real property and land-related matters. Only 1,000 practitioners throughout the world carry the CRE designation. Membership is by invitation only."],
                ["CRS","Certified Residential Specialist","Agents will maximize their profit by joining this network of over 35,000 top professionals. CRS Designees complete advanced study in residential listing and selling and meet established production levels. There are different programs based on years of experience."],
                ["e-PRO","Internet Professional","e-PRO Certification is a revolutionary new training program, presented entirely online, to certify real estate agents and brokers as Internet Professionals. Comprehensive and educational, e-PRO is the only certification program of its kind that is recognized and endorsed by the NATIONAL ASSOCIATION OF REALTORS&reg;."],
                ["GAA","General Accredited Appraiser","Certified general appraisers wishing to increase their visibility should consider pursuing the GAA designation. The GAA designation is awarded to appraisers whose education and experience exceed state appraisal certification requirements and is supported by the National Association of REALTORS&reg;."],
                ["GRI","Graduate, REALTOR&reg; Institute","Members primarily involved in residential real estate wanting to increase their knowledge and skills in a broad array of technical subjects and the fundamentals of real estate participate in the REALTOR&reg; Institute, graduate program to earn the GRI designation. The program also provides opportunities to develop important business contacts. The GRI is a nationally recognized designation of the National Association of REALTORS&reg;."],
                ["PMN","Performance Management Network","Performance Management Network (PMN) Designees have the skills, the experience and the tools to keep them out front and on top of the changing and competitive real estate market. Earning the PMN requires a blend of coursework in real estate business skills and networking experience, a performance mix that builds their careers and elevates the level of service they are able to provide their clients."],
                ["RAA","Residential Accredited Appraiser","Certified residential appraisers wishing to increase their visibility should consider pursuing the RAA designation. The RAA designation is awarded to appraisers whose education and experience exceed state appraisal certification requirements and is supported by the National Association of REALTORS&reg;."],
                ["RSPS","Resort & Second Home Property Specialist","REALTORS&reg; specializing in the resort and second-home market.  The certification is education-based and REALTORS&reg; gain valuable knowledge to facilitate the buying, selling or management of properties for investment, development, retirement or second homes in a resort, recreational and/or vacation destination."],
                ["SIOR","Society of Industrial and Office REALTORS&reg; ","Individuals certified with the SIOR designation are top producers in industrial and office real estate brokerage, representing more than 800 offices in over 350 cities worldwide. The Society's mandatory recertification requirement assures clients of the designee's excellence in the fast changing commercial brokerage field."],
                ["xRRG","Risk Reduction Graduate; ","This program is specifically designed to help REALTORS® understand and interpret contracts and the laws that govern them. Membership in the Risk Reduction Graduate™ Society will keep you apprised of risk management, current legal and legislative issues and as a sidebar, your Brokerages'  E & O premium may also be favorably affected. RRG CE credits are also applicable to the GRI Designation."],
                ["xSRES","Seniors Real Estate Specialist; ","The SRES® Designation course seeks to instill knowledge and understanding of and empathy for 50+ real estate clients and customers. Develop the business building skills and resources needed for specialization in the 50-plus real estate market."],
                ["xASR","Accredited Seller Representative; ","Progressive, professional agents need to stand above the crowd of millions of agents and show that they can offer the seller a better service. The Accredited Seller Representative®, which carries the ASR® designation, answers the need and adds that dimension of knowledge, refinement and refocus necessary to put one on top."],
                ["xALHS","Accredited Luxury Home Specialist; ","Join the most elite agents in the country who are now specializing in the luxury home market. Increase your knowledge, and hone your skills when working with upper-tier buyers and sellers."],
                ["xCNS","Certified Neighborhood Specialist; ","Being an ‘Expert” is more than knowing MLS Statistics. As a Certified Neighborhood Specialist (CNS), you learn how to easily uncover the details, information and benefits of a neighborhood.  This will allow you to tailor your marketing to those that would be more interested in purchasing a home in your neighborhood for a specific reason."],
                ["xAHS","Accredited Home-Staging Specialist; ","Providing brokers and agents with a comprehensive overview of the concepts and principles of staging, examining both the interior and exterior as well as assisting them in putting together their team of resources and sub contractors to help with staging their client’s home."],
                ["xEcoBroker"," ","Offers innovative energy, environmental, and green strategies and tools for real estate professionals. Learn to reduce liabilities and increase buyer and seller satisfaction. Becoming an EcoBroker(R) is a great opportunity for you to benefit your community and the planet, while broadening your base of training and earning more business."]
               ];


document.write('<div id="designationDiv" style="position:absolute;display:none;background-color:#c2c2c2;z-index:10001;">' +
	       '<div style="position:relative;left:-4px;top:-4px;background-color:#EDF3FF;width:380px;border:solid 1px #000000;">' +
	       '<div style="margin:5px;">' +
	       '<div id="desig" style="float:left;color:#000000;font:bold 10px verdana;"></div>' +
	       '<div id="desigImage"></div>' +
	       '<div id="desigDescription" style="clear:both;color:#000000;font:normal 9px verdana;line-height:16px;"></div>' +
	       '</div>' +
	       '</div>' +
	       '</div>')

var desigDiv = document.getElementById("designationDiv");
var desig = document.getElementById("desig");
var desigImage = document.getElementById("desigImage");
var desigDescription = document.getElementById("desigDescription");
var bodyWidth = 770;
var contentWidth = 630;
var displayOffset = 15;
var bodyX;
var absoluteX;
var absoluteY;
var relativeX;
var relativeY;
var maxXRange;

function showDesigPanel(e,strDesig,strLogo){
    // calculate center context X position
    bodyX = (document.body.clientWidth - bodyWidth)/2;

    if(bodyX < 0){
        bodyX = 0;
    }

    mstrDesig = "x" + strDesig;

    // calculate max width range for displaying div
    maxXRange = bodyX + contentWidth;

	if(arguments.length > 1){

		for(var i=0;i<arrDesig.length;i++){
			if(arrDesig[i][0] == strDesig){
				desig.innerHTML = arrDesig[i][0] + ", " + arrDesig[i][1];
	           desigDescription.innerHTML =  arrDesig[i][2] ;
			   desigDescription.innerHTML = '<img src="http://img.REALTOR.com/Images/FindReal/'+ strDesig + '_logo.gif" border="0" align="right" />' + arrDesig[i][2] ;
			}
		}

		for(var i=0;i<arrDesig.length;i++){
			if(arrDesig[i][0] == mstrDesig){
				desig.innerHTML = strDesig + ", " + arrDesig[i][1];
	           desigDescription.innerHTML =  arrDesig[i][2] ;
			   desigDescription.innerHTML = '<img src="desig_logos/'+ strDesig + '_logo.gif" border="0" align="right" />' + arrDesig[i][2] ;
			}
		}

		desigDiv.style.display = 'block';


		// caputure positions relative to document and screen
		if (document.all) {
			absoluteX = event.clientX + document.body.scrollLeft;
		    absoluteY = event.clientY + document.body.scrollTop;
  		    relativeX = event.clientX;
  		    relativeY = event.clientY;
		}else {
		    // mozilla
		    absoluteX = e.pageX;
		    absoluteY = e.pageY;
  		    relativeX = e.clientX;
  		    relativeY = e.clientY;
  		}

  		// adjust display x position
  		if((relativeX + desigDiv.offsetWidth) <= maxXRange){
		    desigDiv.style.left = absoluteX + "px";
		}else{
		    desigDiv.style.left = absoluteX - ((absoluteX + desigDiv.offsetWidth) - maxXRange) + "px"
		}

		// adjust display y position
		if((relativeY + desigDiv.offsetHeight) >= document.body.clientHeight){
		    desigDiv.style.top = absoluteY - desigDiv.offsetHeight - displayOffset + "px"
			//desigDiv.style.top = absoluteY + displayOffset + "px";
			
		}else{
		      
		desigDiv.style.top = absoluteY + displayOffset + "px";
		}

	}else{

		desigDiv.style.display = 'none';

	}
}




function preview() {
	
/////Image type cheking strat///////////////
	extArray = new Array(".jpg", ".gif");
    var form='editform';
    var file=document.editform.photoupload.value;
    allowSubmit = false;
    if (!file) return;
    while (file.indexOf("\\") != -1)
    file = file.slice(file.indexOf("\\") + 1);
    ext = file.slice(file.indexOf(".")).toLowerCase();
    for (var i = 0; i < extArray.length; i++) {
		
    if (extArray[i] == ext) { allowSubmit = true; break; }
    }
    if (allowSubmit) 
	{
		
		field = document.getElementById( 'photoupload' ).value;
	image = document.getElementById( 'previewIMG' );
	path = 'file:///'+ field;
	path = path.replace(/\\/, '/'); // Fix Windows paths
	image.src = path;
	image.style.display = 'block';
	//image.style.width = "150px";
	//image.style.height = "150px";
		
		}
    else
	{
    alert("Please only upload files that end in types:  "
    + (extArray.join("  ")) + "\nPlease select a new "
    + "file to upload.");
    return false;
	}
	
/////Image type cheking end///////////////
}

///// adding div nevigation end 120607////////////////////////////////////////// 