$(document).ready(function() {

	if (isiPhone())
	{
		$('#nav > li > a').css({'height':'8px', 'border-bottom':'20px solid  rgba(0,0,0,0)'});

	    $('#nav > li').live('mouseenter',function(e) {
	        $(this).addClass('over');
			$(this).children('ul').css({'opacity':'1'});
	    });
	    
	    $('#nav li.over')
	        .live('mouseleave',function(e) {
	            $(this).removeClass('over');
	    });
	        
	    $('#nav li.over > ul').live('mouseout',function() {
	    });
		
		$('#nav li ul li, #nav > li > a').live('mouseover',function() {
		   $(this).parent().parents('li').addClass('over');
	    });
		
		// special case for webkit browser
		if ($.browser.webkit)
		{
			$('#nav ul li').css('padding-top', '0');
			$('#nav ul li').css('border-top', '0');
		}	
		
		$('#nav > li > a').click(function(e){
			e.preventDefault();
		});
	}
	else if ($.browser.msie)
	{
	    $('#nav > li > a').css({'height':'8px', 'border-bottom':'20px solid white','filter':'chroma(color=white)'});

	    $('#nav > li').live('mouseenter',function(e) {
	        $(this).addClass('over');
			//$(this).children('ul').css({'filter':'alpha(opacity=100)'});
			//$(this).css({'filter':'progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr=#DDD1AE, endColorstr=#EEECDA)',
			//'-ms-filter': 'progid:DXImageTransform.Microsoft.gradient (GradientType=0, startColorstr=#DDD1AE, endColorstr=#EEECDA)'});
	    });
		
		$('#nav > li > a').live('mouseover',function(e) {
			/*$(this).parent().css({'filter':'progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr=#DDD1AE, endColorstr=#EEECDA)',
			'-ms-filter': 'progid:DXImageTransform.Microsoft.gradient (GradientType=0, startColorstr=#DDD1AE, endColorstr=#EEECDA)'});
	        */
			
			//$(this).parent().addClass{'over');
			//$(this).parent().css({'background-color':'red'});
			//alert("trap");
			
	    });

	    $('#nav li.over')
	        .live('mouseleave',function(e) {
	            $(this).removeClass('over');
	    });
	        
	    $('#nav li.over > ul').live('mouseout',function() {
	        //$(this).parent().removeClass('over');
	    });
		
		//$('#nav ul li:first-child').css('border-top-color', '#EFEDD8');
		//$('<div style="height:5px;filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=\'#CBC1A6\', endColorstr=\'#EFEDD8\',GradientType=0 );zoom:1;"></div>').insertBefore('#nav ul li:first-child');
		
		$('#nav li ul li').live('mouseover',function() {
		   $(this).parent().parents('li').addClass('over');
	    });
		
	} else if ($.browser.mozilla || $.browser.webkit || $.browser.opera)
	{
		$('#nav > li > a').css({'height':'8px', 'border-bottom':'20px solid  rgba(0,0,0,0)'});

	    $('#nav > li').live('mouseenter',function(e) {
	        $(this).addClass('over');
			$(this).children('ul').css({'opacity':'1'});
	    });
	    
	    $('#nav li.over')
	        .live('mouseleave',function(e) {
	            $(this).removeClass('over');
	    });
	        
	    $('#nav li.over > ul').live('mouseout',function() {
	    });
		
		$('#nav li ul li, #nav > li > a').live('mouseover',function() {
		   $(this).parent().parents('li').addClass('over');
	    });
		
		// special case for webkit browser
		if ($.browser.webkit)
		{
			$('#nav ul li').css('padding-top', '0');
			$('#nav ul li').css('border-top', '0');
		}
		
	}
	
	
	
	/*** anchor to interior and exterior home showcase ***/
	$('#home_showcase').click(function(e) {
		
		var win_loc_href = window.location.href;
		var is_found = win_loc_href.lastIndexOf('/homes/index-b.cfm');
		if (is_found != -1) {
			e.preventDefault();
			$('#tabs').tabs('select', 1);
		}
		
	});
	
	$('#interior_anchor').click(function(e) {
		
		var win_loc_href = window.location.href;
		var is_found = win_loc_href.lastIndexOf('/homes/index-b.cfm');
		if (is_found != -1) {
			e.preventDefault();
			$('#tabs').tabs('select', 1);
		}
		
	});
	
	$('#exterior_anchor').click(function(e) {
		
		var win_loc_href = window.location.href;
		var is_found = win_loc_href.lastIndexOf('/homes/index-b.cfm');
		if (is_found != -1) {
			e.preventDefault();
			$('#tabs').tabs('select', 0);
		}
		
	}); 

	$(window).load(function (e) {
		
		var win_loc_href = window.location.href;
    	var tab_name = win_loc_href.substring(win_loc_href.lastIndexOf('#') + 1);

		if (tab_name == "interior-tab" || tab_name == "exterior-tab") {
			window.scrollTo(0,0);
			
			if ($.browser.msie) {
				setTimeout('$(window).scrollTop(-300)', 555);
			}
			
		}
		
	});
	/*** /anchor to interior and exterior home showcase ***/
	
});

function isiPhone(){
    return (
        //Detect iPhone
        (navigator.platform.indexOf("iPhone") != -1) ||
        //Detect iPod
        (navigator.platform.indexOf("iPod") != -1) ||
        //Detect iPad
        (navigator.platform.indexOf("iPad") != -1)
    );
}

