
$(document).ready(function(){
    $.history.init(_load1);

    $('a').live('click',function(e){

        if( $(this).attr('href').indexOf('http://')!=0 &&  $(this).attr('href').indexOf('#')!=0 && !$(this).attr('target')   && $(this).attr('href').indexOf('mailto:')!=0){

            load($(this).attr('href'))

        }else{
            return true;
        }


        return false;
    })
});



function load(url){

    $.history.load(url);
    //_load1(url)

    //Google Analytics support
    _gaq.push(['_trackPageview',url]);
}


function _load1(url){

    if(!url.length || url.substring(0,1)=='_' || url.charAt(0)!='/')return;


    $('#content').css({
        height:$('#innercontent').height(),
        overflow:'hidden'

    });
    $('#innercontent').fadeOut('fast',function(){
        _load2(url)
        });

}



function _load2(url){
    $.get(url,{
        js:1
    }, function(data) {

        $('#innercontent').html(data);

        $('#content').animate({
            height:$('#innercontent').height()
        },500,'linear',function(){
            $('#innercontent').fadeIn('fast');
			
            $('#content').css({
                height:'auto',
                overflow:'visible'
            });
        });

        // Meta
        var $meta_title = jQuery('#meta_title').val()
        var $meta_keywords = jQuery('#meta_keywords').val();
        var $meta_description = jQuery('#meta_description').val();

        jQuery("title").text("TRINITY AdVENTURE - " + $meta_title);
        jQuery("meta[name=keywords]").attr('content', $meta_keywords);
        jQuery("meta[name=description]").attr('content', $meta_description);        
    });
}




function movie(movieName) 
{
    if (navigator.appName.indexOf("Microsoft") != -1)
    {
        return window[movieName];
    }
    else
    {
        return document[movieName];
    }
}
function selectMenu(i){
    try{
        var m=movie('top');
        if(m)
            m.selectMenuItem(i)
    }catch(e){}
}


