$(document).ready(function(){

	var do_rounded_corners = 1;
	var do_window_location = 0;
	if($.browser.msie){
		if(parseInt($.browser.version.substr(0,1)) < 7){
			do_rounded_corners = 0;
		}
		if(parseInt($.browser.version.substr(0,1)) < 8){
			do_window_location = 1;
		}
	}
	
	if(do_rounded_corners == 1){
		// Rounded edges on hp dev nav images:
		$('.property_blocks').find('img').each(function() {
		
			var window_location_markup = '';
			var pointer_style_css = '';
			if($(this).parent().attr('href')){
				pointer_style_css = ' cursor: pointer;';
				if(do_window_location == 1){
					window_location_markup = ' onClick=\'window.location="' + $(this).parent().attr('href') + '"\' ';
				}
			}
			markup = '<span class="rimgbg" style="width: 185px; height: 100px; margin: 0 0 10px 0; padding: 0;' + pointer_style_css + '"' + window_location_markup + '>';
			markup += '<img src="' + $(this).attr('src') + '" alt="' + $(this).attr('alt') + '" style="width: 185px; height: 100px; position: absolute; top: 0; left: 0; border: 0; margin: 0; padding: 0;" />';
			markup += '<span class="rimtl"> </span>';
			markup += '<span class="rimtr"> </span>';
			markup += '<span class="rimbl"> </span>';
			markup += '<span class="rimbr"> </span>';					
			markup += '</span>';
			//alert($(this).parent().html());	
			//alert($(this).parent().attr('href'));	
			$(this).parent().html(markup); 
		});
					
		// Rounded edges on dev nav images:
		$('.devleft').find('img').each(function() {
		
			var window_location_markup = '';
			var pointer_style_css = '';
			if($(this).parent().attr('href')){
				pointer_style_css = ' cursor: pointer;';
				if(do_window_location == 1){
					window_location_markup = ' onClick=\'window.location="' + $(this).parent().attr('href') + '"\' ';
				}
			}
			markup = '<span class="rimgbg" style="width: 185px; height: 100px; margin: 0 0 10px 0; padding: 0;' + pointer_style_css + '"' + window_location_markup + '>';
			markup += '<img src="' + $(this).attr('src') + '" alt="' + $(this).attr('alt') + '" style="width: 185px; height: 100px; position: absolute; top: 0; left: 0; border: 0; margin: 0; padding: 0;" />';
			markup += '<span class="rimtl"> </span>';
			markup += '<span class="rimtr"> </span>';
			markup += '<span class="rimbl"> </span>';
			markup += '<span class="rimbr"> </span>';					
			markup += '</span>';	
			$(this).replaceWith(markup); 
		});			
		
		$('.rounded_corners').each(function() {
		
			var window_location_markup = '';
			var pointer_style_css = '';
			if($(this).parent().attr('href')){
				pointer_style_css = ' cursor: pointer;';
				if(do_window_location == 1){
					window_location_markup = ' onClick=\'window.location="' + $(this).parent().attr('href') + '"\' ';
				}
			}
			markup = '<div class="rimgbg" style="margin: 0 0 0 0; padding: 0;' + pointer_style_css + '"' + window_location_markup + '>';
			markup += '<img src="' + $(this).attr('src') + '" alt="' + $(this).attr('alt') + '" style="position: absolute; top: 0; left: 0; border: 0; margin: 0; padding: 0;" />';
			markup += '<div class="rimtl"> </div>';
			markup += '<div class="rimtr"> </div>';
			markup += '<div class="rimbl"> </div>';
			markup += '<div class="rimbr"> </div>';					
			markup += '</div>';			
			$(this).html(markup); 	
		});
	}
	
	randHeader();
	setInterval('randHeader()' , 5000);
	
});

function randHeader(){
	//alert('headtop' + String(rand(12)-1) + '.jpg');
	//$('#header').css('background' , 'url(\'/layout/headtop' + String(rand(12)-1) + '.jpg\') 0px 0px no-repeat;');

	url = '/layout/headtop' + String(rand(12)-1) + '.jpg';
	newimg = new Image();
	$(newimg)
	.load(function(){
		$('#header').css('background-image' , 'url(\'' + url + '\')');
	})
	.attr('src' , url);
}

function rand (n){
  return ( Math.floor ( Math.random ( ) * n + 1 ) );
}
