// Haiz Design scripts 24/11/11
/***********************************************
* Smooth Navigational Menu- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
$(document).ready(function() {
  
  // drop menus
   ddsmoothmenu.init({
   	mainmenuid: "smoothmenu1", //menu DIV id
   	orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
   	classname: 'ddsmoothmenu', //class added to menu's outer DIV
   	//customtheme: ["#1c5a80", "#18374a"],
   	contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
    });
  
  // homepage slideshows
  $('#slideshow').cycle({
    fx:'fade',
    timeout: 7000,
    after: function() {
      $('#caption').html(this.alt);
      }
  });
  
  // homepage images mouseover
  $('.home-box a').hover(function(){   
    $(this).fadeTo('fast', '.6'); 
  }); 
  $('.home-box a').mouseout(function(){   
    $(this).fadeTo('slow', '1'); 
  }); 
  
  // home page featured box last item
  $('#home-featured div.clearfix:last-child').css('margin-right', '0px');
  
  // buying guide slideshow
  $('#mini-slideshow').cycle({
    fx:'scrollDown',
    timeout: 2000,
    after: function() {
      $('#caption').html(this.alt);
    }
    });
  
  // add line break after room list on results page
  $('.clearfix ul.roomList').insertAfter('<br />');
  
  // form backgrounds
  $('.form-input-text').css('background-color', '#fcfcfc');
  $('.form-input-text-sm').css('background-color', '#fcfcfc');
    
  //  tooltips
  $('.location').click(function(e){
  	e.preventDefault(); /* stops null-link jumping to top  */
  	});
  
  $('.location').hover(function(e){
    // Hover over code
    var titleText = $(this).attr('title');
    $(this)
      .data('tipText', titleText)
      .removeAttr('title');
      
    $('<p class="tooltip"></p>')
      .text(titleText)
      .appendTo('body')
      .css('top', (e.pageY - 20) + 'px')
      .css('left', (e.pageX + 20) + 'px')
      .fadeIn('slow');
  }, function() {
    // Hover out code
    $(this).attr('title', $(this).data('tipText'));
    $('.tooltip').remove();
  }).mousemove(function(e){
    // Mouse move code
    $('.tooltip')
      .css('top', (e.pageY - 20) + 'px')
      .css('left', (e.pageX + 20) + 'px');
  });
  
//  hide/show valuation request on forms
	$("#position").change(function(){
	 
	        if ($(this).val() == "Property-to-sell")
	        {	 
	            $("#hide-valuation").slideDown('fast'); //Slide Down Effect	 
	        } else {	 
	            $("#hide-valuation").slideUp('fast');    //Slide Up Effect	 
	        }
	    });
// lettings hidden options

//  hide/show domestic couple
	$("#domestic_status").change(function(){
	 
	        if ($(this).val() == "Couple")
	        {	 
	            $("#hide-domestic-couple").slideDown('fast'); //Slide Down Effect	 
	        } else {	 
	            $("#hide-domestic-couple").slideUp('fast');    //Slide Up Effect	 
	        }
	    });
//  hide/show domestic sharers
	$("#domestic_status").change(function(){
	 
	        if ($(this).val() == "Sharers")
	        {	 
	            $("#hide-domestic-sharers").slideDown('fast'); //Slide Down Effect	 
	        } else {	 
	            $("#hide-domestic-sharers").slideUp('fast');    //Slide Up Effect	 
	        }
	    });
//  hide/show domestic family
	$("#domestic_status").change(function(){
	 
	        if ($(this).val() == "Family")
	        {	 
	            $("#hide-domestic-family").slideDown('fast'); //Slide Down Effect	 
	        } else {	 
	            $("#hide-domestic-family").slideUp('fast');    //Slide Up Effect	 
	        }
	    });	    
  
});

//  preload and swap images
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}




