function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }

function extractPageName(hrefString)
{
	var arr = hrefString.split('.');
	arr = arr[arr.length-2].split('/');
	return arr[arr.length-1].toLowerCase();		
}

function setActiveMenu(arr, crtPage)
{
	for(var i=0; i < arr.length; i++)
		if(extractPageName(arr[i].href) == crtPage)
		{
			arr[i].className = "current";
			arr[i].parentNode.className = "current";
		}
}

function setPage()
{
	if(document.location.href) 
		hrefString = document.location.href;
	else
		hrefString = document.location;

	if (document.getElementById("menu")!=null) 
		setActiveMenu(document.getElementById("menu").getElementsByTagName("a"), extractPageName(hrefString));
}
function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        auto: 3,
		scroll: 1,
        wrap: 'last',
        initCallback: mycarousel_initCallback
    });
});

$(window).load(function () {
						 
	//$('.propertyImages').fadeIn();	
	//$('.propertyImages').cycle('fade');		
	$("#featuredSlide").show();
	$("#featuredSlide").cycle();
	
	
	$(".propertyImages").show();
	$(".propertyImages").cycle({
        speed:       800,
		timeout:       4000,
        pager:      '#nav',
		pause:  true,
		pauseOnPagerHover: true,
		pagerEvent: 'mouseover',
 
    pagerAnchorBuilder: function(idx, slide) { 
        // return selector string for existing anchor 
        return '#nav li:eq(' + idx + ') a'; 
    } 
    });
	
$('a.jt').cluetip({
  cluetipClass: 'jtip', 
  arrows: true, 
  dropShadow: false,
  hoverIntent: false,
  sticky: true,
  closePosition:    'bottom',
  mouseOutClose: true
});

	
	
	/*
	    $("select#proptype ").change(function () {
          var str = "";
          $("select#proptype option:selected").each(function () {
                if ($(this).text() == "Industrial" || $(this).text() == "Office" || $(this).text() == "Retail"){
					str = "Building Size From: <input type='text' ";	
				}else if ( $(this).text() == "Land"){
					str = "Land Size:";	
				}
              });
          $("div#sizes").text(str);
        })
        .change();

	*/
	
    $("select#searchtype ").change(function () {
        	
			//$("div#sizes").text($("select#searchtype option:selected").val());
			register();
        })
        //.change();
	
		function register(){
				$.ajax({
					type: "GET",
					url: "getSuburbs.php",
					data: 	"searchtype=" + $("select#searchtype option:selected").val(),
					success: function(html){
						$("select#suburb").html(html);
					}
				});
				
		}
	
						 		
});