// <![CDATA[
var win;

if ($('home')) {
   if (document.images) {
     pic1= new Image(205,20); 
     pic1.src="http://coldwellbankercaine.com/toolTip-bottom.gif";

     pic2= new Image(205,11); 
     pic2.src="http://coldwellbankercaine.com/toolTip-middle.gif";

     pic3= new Image(205,37); 
     pic3.src="http://coldwellbankercaine.com/toolTip-top.gif";

     pic4= new Image(205,20); 
     pic4.src="http://coldwellbankercaine.com/toolTip-bottom.png";

     pic5= new Image(205,11); 
     pic5.src="http://coldwellbankercaine.com/toolTip-middle.png";

     pic6= new Image(205,37); 
     pic6.src="http://coldwellbankercaine.com/toolTip-top.png";
   }
}

function changeMLSdb(){
   document.propertySearchForm.action = '';
   document.propertySearchForm.submit();
}
   
function checkType(){
   document.propertySearchForm.sq_ft.disabled = false;
   if(document.propertySearchForm.property_type.selectedIndex == 2){
      document.propertySearchForm.sq_ft.selectedIndex = 0;
      document.propertySearchForm.sq_ft.disabled = true;
   } if(document.propertySearchForm.property_type.selectedIndex == 4) {
      document.propertySearchForm.sq_ft.selectedIndex = 0;
      document.propertySearchForm.sq_ft.disabled = true;
   } if(document.propertySearchForm.property_type.selectedIndex == 5) {
      document.propertySearchForm.sq_ft.selectedIndex = 0;
      document.propertySearchForm.sq_ft.disabled = true;
   } 
}

// function mClick(loc) {
//    window.location.href = loc;
// }//end mClick


function resetTabs(tabSet) {
    var i = 1;
    var tabName = "tab_" + tabSet + '_' + i;
    if ($(tabName)) { 
      while(document.getElementById(tabName)) {
         $(tabName).removeClassName("tabSelected");
         $(tabName).addClassName("tab");
         //document.getElementById(tabName).className='tab';
         var tabName = "tab_" + tabSet+ '_' + (++i);
      }
   }
}//end resetTabs



function showDiv(divSet,divID) {
   resetDivs(divSet);
   document.getElementById('div_'+divSet+'_'+divID).style.display='block';

}//end showDiv



function resetDivs(divSet) {
   var i = 1;
   var divName = "div_" + divSet + '_' + i;

   if (document.getElementById(divName)) { 
      while(document.getElementById(divName)) {
         document.getElementById(divName).style.display='none';
         var divName = "div_" + divSet+ '_' + (++i);
      }
   }
}//end resetDivs


function CainePopup(wid, hei, urlloc) {
   if (typeof(win) == "object")
      Windows.closeAll();
   
   win = new Window({ className: "alphacube", zIndex: 100,title: "Coldwell Banker Caine", top: 50, left: 50, width: wid, height: hei, resizable: false, minimizable: false, maximizable: false, url: urlloc, showEffectOptions: {duration:.3}, hideEffectOptions: {duration:.3}});
   
   win.show(1);
}//end CainePopup



/* ADDED for May 2007 redesign by NLH
function toggleAreas (target) {
   if($(target).checked == true) {
      Effect.BlindDown('map', { duration: .5 }); 
   } else { 
      Effect.BlindUp('map', { duration: .5 }); 
   }
}//end toggleAreas*/

function toggleAdvOptions() {
   if($('toggleAdvOptions').getStyle('display') == 'none') {
      Effect.BlindDown('toggleAdvOptions', { duration: .25 }); 
      //$('toggleIndicator').update("Hide");
   } else { 
      Effect.BlindUp('toggleAdvOptions', { duration: .25 }); 
      //$('toggleIndicator').update("Show");
   }
}
// Updated for November 2007 redesign by NLH
function toggleAreasAref (target) {
   //alert(target);
   if($(target).rel == 'false') {
      Effect.BlindDown('map', { duration: .5 }); 
      $(target).rel = 'true';
      $('toggleMapTxt').update('Hide');
   } else { 
      Effect.BlindUp('map', { duration: .5 });
     $(target).rel = 'false';
     $('toggleMapTxt').update('Show');
   }
}//end toggleAreas


function protoTipMap (element) {
   var selectedEl = false;
   
   //determine which color to use
   switch (element) {
      case "Greenville_Map":
         selectedEl = $('gville').down('input').checked;
      break;
      case "Spartanburg_Map":
         selectedEl = $('spartan').down('input').checked;
      break;
      case "Anderson_Map":
      case "Pickens_Easley_Map":
      case "Seneca_Oconee_Map":
         selectedEl = $('upstate').down('input').checked;
      break;
   }
   var boxTitle = $(element).readAttribute("rel");
   var boxContent = (!selectedEl) ? '<em>Click</em> to search ' + boxTitle + '.' : '' + boxTitle + ' is your current<br />search area.';//this area
   new Tip(element, boxContent, { title: boxTitle, className: 'mapToolTip'});
   
   //var boxTitle = $(element).readAttribute("rel");
   //var boxContent = (!selectedEl) ? '<em>Click here</em> to search this area.' : 'Currently searching this area.';//this area
   //new Tip(element, boxContent, { title: boxTitle, className: 'mapToolTip'});
}//end protoTipMap



function changeMLSArea (area, mapClicked) {
   var bgColor;
   (mapClicked == null) ? mapClicked = false : "";
   
   //reset all backgroundColors
   $('mlsSource').descendants('div').each(function(el) {
      el.style.backgroundColor = 'transparent';
   });
   
   //determine which color to use
   switch (area) {
      case "gville":
         bgColor = "#B2E0AB";
      break;
      case "spartan":
         bgColor = "#CBBDDC";
      break;
      case "upstate":
         bgColor = "#FFCA99";
      break;
   }
   
   //indicate selected area
   $(area).style.backgroundColor = bgColor;
   if (mapClicked && oldBgColor != bgColor) {
      oldBgColor = bgColor;
      $(area).down('input').checked = 'checked';
      
      //submit form 
      changeMLSdb();
   } else {
      oldBgColor = bgColor;
   }
   
}//end changeMLSArea 

// ]]>
