function checkBrowser(){
}

var windowOptions = 'resizable=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes';
var wWith = "660";
var wHeight = "500";
var windowName = 'aWindow';
$(function(){
	
	var agent=navigator.userAgent.toLowerCase();
		var is_iphone = agent.indexOf('iphone')!=-1 || agent.indexOf('ipad')!=-1;
		if(!is_iphone){
			$('#home-link').bind('click',function(){
				$('#pop-up').toggleClass('show');
				if(!$('#pop-up').hasClass('show')) $('#pop-up').animate({marginLeft:-272},'slow');
				else  $('#pop-up').animate({marginLeft:0},'slow');
			});
		}
		
		if (is_iphone) {
			$('#footer').css('position','static');
		}
	
    if ($('ul.tabs li a.selected').size() == 0) 
        $('ul.tabs li a:first').addClass('selected');
    
    $('.home-box a').hover(function(){
        $(this).animate({
            color: '#111',
            backgroundColor: '#f3f3f3',
            borderRightColor: '#222',
            borderLeftColor: '#222',
            borderRightColor: '#222',
            borderTopColor: '#222',
            borderBottomColor: '#222'
        }, 600);
        $(this).parent().parent().find('.label span').fadeIn();
    }, function(){
        $(this).animate({
            color: '#333',
            backgroundColor: '#fff',
            borderRightColor: '#d6d6d6',
            borderLeftColor: '#d6d6d6',
            borderRightColor: '#d6d6d6',
            borderTopColor: '#d6d6d6',
            borderBottomColor: '#d6d6d6'
        }, 600);
        $(this).parent().parent().find('.label span').fadeOut();
    });
    if ($('ul.tabs li a')) {
        $('ul.tabs li a').bind('click', function(ev){
            if ($(this).hasClass('selected')) 
                return false;
            $('ul.tabs').parent().find('.selected').removeClass('selected');
            $(this).addClass('selected');
            
            var fun = function(html){
                $('#footer').fadeOut();
                var aWidth = $('center').width();
                //$('#center').css({width:aWidth});
                $('#center .content').fadeOut('400');
                setTimeout(function(){
                    $('#center .content').html(html);
                    $('.thickbox').bind('click', newWindow);
                }, 500);
                $('#center .content').fadeIn('400');
                $('#center').css({
                    width: 'auto'
                });
                $('#footer').fadeIn();
                
            };
            var hr = this.href;
            if (!hr.match(/\/Apps\/WebObjects\/.*/)) {
                if (hr.match(/^http:\/\/.*/)) {
                    hr = hr.replace(/http\:\/\/[^\/]+\//, '');
                }
                hr = "/Apps/WebObjects/XP.woa/wa/rewrite?name=" + escape(hr);
            }
            //alert(hr);
            $.ajax({
                url: hr,
                data: {
                    'ajax': true
                },
                success: fun
            });
            return false;
        });
    }
    $('.new-window').bind('click', newWindow);
});

function newWindow(ev){
    var anHref = $(this).attr('href');
    var newWindow = window.open(anHref, windowName, windowOptions + ',width=' + wWith + ',height=' + wHeight);
    newWindow.focus();
    return false;
}

$(window).load(function(){
    if ($('.section-titles h3')) 
        setTimeout(function(){
            $('.section-titles h3').fadeIn(400)
        }, 400);
    if ($('.section-titles h4')) 
        setTimeout(function(){
            $('.section-titles h4').fadeIn(400)
        }, 800);
    
});

function newWindowWithURL(el){
    var anHref = $(el).attr('href');
    var newWindow = window.open(anHref, windowName, windowOptions + ',width=' + wWith + ',height=' + wHeight);
    newWindow.focus();
    return false;
}

