/**
 * @author 	Joe McCann
 * @website http://www.subprint.com
 * @contact joe@subprint.com
 * @desc	Global settings and functions for the site.
 */
var ie6 = false;
var ieFlag = false;
var title = "<h2>Headache and Pain Center</h2>";
var loc = [30.286353, -97.812915];

($.browser.msie) && ( /MSIE 6\.0/i.test(window.navigator.userAgent) ) && !(/MSIE 7\.0/i.test(window.navigator.userAgent) ) ? ie6 = true : ie6 = false;
($.browser.msie) ? ieFlag = true : ieFlag = false;

function fixIEPng()
{
    $("#h1").css(
    {
        background: "none",
        filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../../img/h1.png', sizingMethod='image');"
    });
    
    $("#main").css(
    {
        background: "none",
        filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../../img/cont850.png', sizingMethod='image');"
    });
    
}

function fixUnload()
{
    if (document.readyState == 'interactive') 
    {
        function stop()
        {
            document.detachEvent('onstop', stop);
            unload();
        }
        document.attachEvent('onstop', stop);
        window.setTimeout(function()
        {
            document.detachEvent('onstop', stop);
        }, 0);
    }
}

function unload()
{
    GUnload();
}

$().ready(function()
{

	$.preloadCssImages(); 

	$('a.blank').each(function(){
		$(this).attr('target', '_blank');
	});
	
	$('#location').css("opacity","1");
	
    // Function required in scope..
    var checkBlock = function()
    {
        if (($('#location').css('display') == 'block') && $('#mapFrame').css('position') != 'relative') 
        {
        
            // Create the map with default level 10 zoom.
            
            $("#mapFrame").jmap(
            {
                mapZoom: 13,
                mapEnableKey: false,
                mapCenter: [30.285988, -97.813333]
            });
            
            /* Create custom camera icon object.  TODO:  Add shadow gif file. */
            
            var crossIcon = $.jmap.createIcon(
            {
                iconImage: "img/cross.gif",
                iconSize: new GSize(34, 32),
                iconAnchor: new GPoint(0, 0)
            });
            
            // Add the central marker to the map based on the address.
            
            $("#mapFrame").jmap("addMarker", 
            {
                pointLatLng: [30.285988, -97.813333],
                pointHTML: title,
                centerMap: true,
                pointIcon: crossIcon
            });
            
			// Attach click handler...
			$('#submit').click(function()
            {
                $('#mapFrame').jmap("searchDirections", 
                {
                    fromAddress: $('#address').val(),
                    toAddress: "4407 Bee Caves Road Austin, Texas 78746",
                    directionsPanel: "directions"
                });
            });
			// Attach hover events...
            $('#submit').hover(function()
            {
                $(this).css('background-image', 'url(img/submitHover.gif)');
            }, function()
            {
                $(this).css('background-image', 'url(img/submit.gif)');
            });
            // Clear the Interval
            var clearCheckBlock = clearInterval(mapper);
            
        } // End if display block
    };
 
    // No frames check...
    if (self != top) 
    {
        parent.location.href = self.location.href;
    }
    
    // Tabs Functionality
    $('#nav > ul').tabs(
    {
        fx: 
        {
            opacity: 'toggle'
        },
        selected: 0
    });

    var mapper = setInterval(checkBlock, 50);
    
$(window).load(function(){

});
    
}); // End DOM Ready
$(window).unload(function()
{
    GUnload();
});
