$(document).ready(function() {
/* Collapse / expand */

		function dropList(root) {
		    // added option to show / hide first item - this defaults to true.
		    // just add the class 'collapsed' to the ul and the first question will be hidden.
			var showFirst = true;
			if ( $("."+root).attr('class') ) {
				if ( $('.'+root).attr('class').search('collapsed') >=0) {
				showFirst = false;
				}
			}
		    
		    //if js is on, hide our content div's apart from the first child -
			$('.'+root+' p, .'+root+' ul').hide();
		    
		    //if (showFirst) {
		    //$('.'+root+' p:eq(0)').show().parent().addClass('Expand');
		    //}
			
			
		    //wrap our H3 in A tags
		    $('.'+root+' h6').wrap('<a class="dropper"></a>');
		
		   
		    //add a plus / minus icon
		   $('.'+root+' h6').addClass('Collapsed');
		   
		    //set href attribute and on click toggle display and anchor class
		    $('.'+root+' a.dropper').attr({href:'#'}).click(function() {
		        $(this).toggleClass('dropOn');
		        //target sibling element - the following content div
		        $(this).next().toggle();
		        $(this).parent().toggleClass('Expand');
		        return false;
		        
		    })
		}
		
		if ($(".collapse")) { 
			dropList('collapse');
		}
		
		if ($(".middle img") && ($('#gallery').length == 0)    && ( $('#house1').length==0)  ) {
			
			var append = '';
			
			$('.middle img').each( function() {
			
				if ($(this).attr('id') != 'shareHeader') {
				
					if ($(this).css('float')  == 'left') {
					append = ' float: left; margin: 10px 10px 10px 0; width: '+($(this).width()+36)+'px';
					} else {
					append = 'width: '+($(this).width()+36)+'px';	
					}
					
			
				$(this).wrap('<div class="inlineFrame" style="'+append+'">')
					$(this).wrap('<div class="wrapperLeft">')
				$(this).wrap('<div class="wrapperRight">')
				
				// IE doesn't appear to apply sIFR to post-rendered tags so we can't use this feature
				//$(this).parent().append('<p class="imgtitle">brief image title</p>');
				$(this).parent().parent().append('<div class="btm"><div class="left"><div class="right">')
				}
				
				
			}
			
			);
			
			
			if ($('.middle .inlineFrame p')) {
				
			 
				sIFR.replace(kids, {
				  selector: 'p.imgtitle',
				  css: ['.sIFR-root { background-color: transparent; color: #555555; font-size:13px; border-bottom: none;text-align: center;  }'],
				        wmode: 'transparent',
				        forceSingleLine: 'true'

				});
			}
			
		}
		
		
		

			   $("#searchkw").Watermark("Search");
			   $("#newsletter").Watermark("Your email");
	
		
		
			   
		    
		
});	


function  newsSubmit() {
    var email = $("#newsletter").val();
    if(email==''){
        $('#errnews').html("Please your email address");
        return false;
    }
    else if(isValidEmailAddress(email)){
        $.ajax({
            url: '/index/signup/email/'+email,
            type: 'POST',
            success: function(resp) {
                $('#errnews').html('<span style="color: #333; font-weight: bold; font-family: \'Lucida Grande\', Verdana, Sans-Serif; font-size: 11px; line-height: 15px">'+resp+'</span>');
                $('#newsletter').val('Thank you!')
                $('#newsletter').css('color','#999999')
                $('#newsletter').attr('disabled', true)
                  $('#newsubmit').attr('disabled', true)
        }
         });
     }
    else{
        $('#errnews').html("Please enter a valid email address");
        return false;
        }
    
    return false;
}

