function addLoadEvent(func){if (window.addEventListener){window.addEventListener('load', func, false);return true;}else if (window.attachEvent){var result = window.attachEvent('onload', func);return result;}else{window['onload'] = func;}}
// JavaScript Document
    simplePreload('images/main_menu/btn.gif');
    function simplePreload()
    {
     var args = simplePreload.arguments;
      document.imageArray = new Array(args.length);
          for(var i=1; i<args.length; i++)
        {
            document.imageArray[i] = new Image;
            document.imageArray[i].src = args[i];
        }
    }

    var item = new Array();
    var number = 1;
	/*item[number++] = '<li><a href="#" class="active">Home</a></li>';*/
    item[number++] = '<li><a href="#">For Sale</a></li><li class="splitter">|</li><li><a href="#">For Rent</a></li><li class="splitter">|</li><li><a href="#">International Properties</a></li><li class="splitter">|</li><li><a href="#">Commercial Properties</a></li><li class="splitter">|</li><li><a href="#">Featured Properties</a></li><li class="splitter">|</li><li><a href="#">Open Houses</a></li>';
    item[number++] = '<li><a href="#">Manhattan</a></li><li class="splitter">|</li><li><a href="#">Brooklyn</a></li>';
    item[number++] = '<li><a href="#">Global Services</a></li><li class="splitter">&nbsp;</li>';
    item[number++] = '<li><a href="#">Requirements</a></li><li class="splitter">|</li><li><a href="#">Paper Work</a></li><li class="splitter">|</li><li><a href="#">Guarantor</a></li><li class="splitter">|</li><li><a href="#">Referrals</a></li><li class="splitter">|</li><li><a href="#">Partners</a></li>';
    item[number++] = '<li><a href="#">Who we are</a></li><li class="splitter">|</li><li><a href="#">Why Merit Group Realty</a></li><li class="splitter">|</li><li><a href="#">History</a></li><li class="splitter">|</li><li><a href="agents.html">Our Agents</a></li>';
    item[number++] = '<li><a href="#" class="active">Contact Us</a></li><li class="splitter">|</li><li><a href="my_dream_home.html">My Dream Home</a></li><li class="splitter">|</li><li><a href="list_with_us.html">List With Us</a></li>';


    function changeItem(){
        for( var i=1; i<6; i++){
            //document.getElementById(i).innerHTML=item[i];
        }
    }

    function displayItem(show, target){
		if (show) {
			document.getElementById(target).style.display = "block";
			document.getElementById(target).style.zIndex = "999";
			if(cur_p != 7)document.getElementById(cur_p).style.display = "none";
		} else {
			document.getElementById(target).style.display = "none";
			document.getElementById(target).style.zIndex = "9";
			if(cur_p != 7)document.getElementById(cur_p).style.display = "block";
		}
    }

    function changeTypeSale()
    {
        if (document.getElementById('ctl00_ContentPlaceHolder1_SideSearch_TypeRentals').checked) {
            $('#ctl00_ContentPlaceHolder1_SideSearch_propertycurrRPrice').val(document.getElementById('ctl00_ContentPlaceHolder1_SideSearch_maxPriceRentals').value);
            document.getElementById('ctl00_ContentPlaceHolder1_SideSearch_propertymaxprice').value = document.getElementById('ctl00_ContentPlaceHolder1_SideSearch_maxPriceRentals').value;
            document.getElementById('ctl00_ContentPlaceHolder1_SideSearch_propertystepprice').value = document.getElementById('ctl00_ContentPlaceHolder1_SideSearch_stepPriceRentals').value;
        }
        else if (document.getElementById('ctl00_ContentPlaceHolder1_SideSearch_TypeSale').checked) {
            $('#ctl00_ContentPlaceHolder1_SideSearch_propertycurrRPrice').val(document.getElementById('ctl00_ContentPlaceHolder1_SideSearch_maxPriceSale').value);
            document.getElementById('ctl00_ContentPlaceHolder1_SideSearch_propertymaxprice').value = document.getElementById('ctl00_ContentPlaceHolder1_SideSearch_maxPriceSale').value;
            document.getElementById('ctl00_ContentPlaceHolder1_SideSearch_propertystepprice').value = document.getElementById('ctl00_ContentPlaceHolder1_SideSearch_stepPriceSale').value;
        }
        if (document.getElementById('ctl00_ContentPlaceHolder1_SideSearch_propertymaxprice').value.length > 0)
        {
            document.getElementById('propertypricelabel').innerHTML = '$0 to $' + document.getElementById('ctl00_ContentPlaceHolder1_SideSearch_propertymaxprice').value;
        }
        else
        {
            document.getElementById('ctl00_ContentPlaceHolder1_SideSearch_propertypricelabel').innerHTML = '$0 to No limit';
        }
        $('#propertycurrRPrice').val(document.getElementById('ctl00_ContentPlaceHolder1_SideSearch_propertymaxprice').value);
        initPriceRange();
    }

    addLoadEvent(function(){
        changeTypeSale();
        initBeds();
        initBaths();
        initSquare();
    });
    
    //parseInt($('#ctl00_ContentPlaceHolder1_SideSearch_propertycurrLPrice').val())
    //parseInt($('#ctl00_ContentPlaceHolder1_SideSearch_propertycurrRPrice').val())
   function initPriceRange()
   {
       var rightLimit = parseInt($('#ctl00_ContentPlaceHolder1_SideSearch_propertymaxprice').val());
       var step = parseInt($('#ctl00_ContentPlaceHolder1_SideSearch_propertystepprice').val());
       $('#divPriceRange').trackbar({
           onMove : function() {
               if (this.rightValue == rightLimit) $('#divPriceRangeRightLimit').html('No Limit');
               else $('#divPriceRangeRightLimit').html('$' + addCommas(this.rightValue.toString()));
               $('#divPriceRangeLeftLimit').html('$' + addCommas(this.leftValue.toString()));
               $('#divPriceRangeLeftValue').html('');
               $('#divPriceRangeRightValue').html('');
               $('#ctl00_ContentPlaceHolder1_SideSearch_propertycurrLPrice').val(this.leftValue);
               $('#ctl00_ContentPlaceHolder1_SideSearch_propertycurrRPrice').val(this.rightValue);
           },
           width : 110,
           leftLimit : 0,
           leftValue: 0,
           rightLimit : rightLimit,
           rightValue: 0,
           roundUp: step,
           clearLimits : true,
           clearValues : false,
           objectId: 'divPriceRange'
       });
   }

   function initBeds()
   {
       var rightLimit = parseInt($('#ctl00_ContentPlaceHolder1_SideSearch_propertymaxbeds').val());
       $('#divBedroom').trackbar({
           onMove : function() {
               if (this.rightValue == rightLimit) $('#divBedroomRightLimit').html('No Limit');
               else $('#divBedroomRightLimit').html(''+this.rightValue);
               $('#divBedroomLeftLimit').html(''+this.leftValue);
               $('#divBedroomLeftValue').html('');
               $('#divBedroomRightValue').html('');
               $('#ctl00_ContentPlaceHolder1_SideSearch_propertycurrLbeds').val(this.leftValue);
               $('#ctl00_ContentPlaceHolder1_SideSearch_propertycurrRbeds').val(this.rightValue);
           },
           width : 110,
           leftLimit : 0,
           leftValue: parseInt($('#ctl00_ContentPlaceHolder1_SideSearch_propertycurrLbeds').val()),
           rightLimit : rightLimit,
           rightValue: parseInt($('#ctl00_ContentPlaceHolder1_SideSearch_propertycurrRbeds').val()),
           roundUp: 1,
           clearLimits : true,
           clearValues : false,
           objectId: 'divBedroom'
       });
   }

   function initBaths()
   {
       var rightLimit = parseInt($('#ctl00_ContentPlaceHolder1_SideSearch_propertymaxbaths').val());
       $('#divBathroom').trackbar({
           onMove : function() {
               if (this.rightValue == rightLimit) $('#divBathroomRightLimit').html('No Limit');
               else $('#divBathroomRightLimit').html(''+this.rightValue);
               $('#divBathroomLeftLimit').html(''+this.leftValue);
               $('#divBathroomLeftValue').html('');
               $('#divBathroomRightValue').html('');
               $('#ctl00_ContentPlaceHolder1_SideSearch_propertycurrLbaths').val(this.leftValue);
               $('#ctl00_ContentPlaceHolder1_SideSearch_propertycurrRbaths').val(this.rightValue);
           },
           width : 110,
           leftLimit : 0,
           leftValue: parseInt($('#ctl00_ContentPlaceHolder1_SideSearch_propertycurrLbaths').val()),
           rightLimit : rightLimit,
           rightValue: parseInt($('#ctl00_ContentPlaceHolder1_SideSearch_propertycurrRbaths').val()),
           roundUp: 1,
           clearLimits : true,
           clearValues : false,
           objectId: 'divBathroom'
       });
   }

   function initSquare()
   {
       var rightLimit = parseInt($('#ctl00_ContentPlaceHolder1_SideSearch_propertymaxsqft').val());
       $('#divSquare').trackbar({
           onMove : function() {
               if (this.rightValue == rightLimit) $('#divSquareRightLimit').html('No Limit');
               else $('#divSquareRightLimit').html('' + addCommas(this.rightValue.toString()));
               $('#divSquareLeftLimit').html('' + addCommas(this.leftValue.toString()));
               $('#divSquareLeftValue').html('');
               $('#divSquareRightValue').html('');
               $('#ctl00_ContentPlaceHolder1_SideSearch_propertycurrLsquare').val(this.leftValue);
               $('#ctl00_ContentPlaceHolder1_SideSearch_propertycurrRsquare').val(this.rightValue);
           },
           width : 110,
           leftLimit : 0,
           leftValue: parseInt($('#ctl00_ContentPlaceHolder1_SideSearch_propertycurrLsquare').val()),
           rightLimit : rightLimit,
           rightValue: parseInt($('#ctl00_ContentPlaceHolder1_SideSearch_propertycurrRsquare').val()),
           roundUp: 500,
           clearLimits : true,
           clearValues : false,
           objectId: 'divSquare'
       });
   }