document.write('<style type="text/css">body.home #wrap-main { background:none; } </style>');
$(document).ready(function() {


    $("#divAdminLoginHolder input").keypress(function (e) {
        if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
            $('.rmAdminLoginButton').click();
            return false;
        } else {
            return true;
        }
    });


    //accordion
    $('.accordion h2').remove();
    
    $('.accordion').accordion({
        autoHeight: false,
        active: false,
        active: 'h3.show-first',
        selectedClass: 'accordion-on',
        collapsible: true,
        navigation: true
    });
		
  $('#offices-worldmap li a').each(function() {
    	var href = $(this).attr('href');
    	href = href.substr((href.indexOf('#')+1));
			$(this).click(function() {
				$('.accordion h3 a').each(function(i) {
					var parent = this.parentNode;
					if (href==$(this).attr('id')) {
						if ($(parent).hasClass('ui-state-active')) {
							return false;
						}
						$( '.accordion' ).accordion('activate', i );
					}
					else {
						var div = $(parent).next()[0];
						$(div).find('a').each(function() {
							if (href==$(this).attr('id')) {
								if ($(parent).hasClass('ui-state-active')) {
									return false;
								}
								$( '.accordion' ).accordion('activate', i );
							}
						});
					}
				});
			});
		});
		
		$('.accordion.accordion-numeric').each(function(){
			$(this).find('h3 a').each(function(i){
	    	$(this).prepend('<span>'+(i+1)+'.</span>');
			});
		});
		
		if (eMap = $('#googlemap')[0]) {
			displayMap(eMap, latLng, 15);
		}
		
		var $tabs = $("#tabs").tabs();
		
		$('.tab-link').each(function(){
			var u = $(this).attr('href');
			var i = u.substr((u.indexOf('#')+1));
			$(this).click(function() {
				$tabs.tabs('select', i);
				return false;
			});
		});
    
    

    //open in a new window
    $('a.new-win').attr('target','_blank');
    
    $('.pagination a').each(function() {
			if ($(this).attr('disabled')) {
				$(this).addClass('disabled');
			}			
		});
		
		$('.generic-table').each(function() {
		
			$(this).find('tr').each(function(i) {
				if(!$(this).find('th')[0]) {
					if ((i+1)%2) {
						$(this).addClass('row-grey');
					}
				}
			});
		
		});

});
/* 
document.write('<!--[if IE ]>');
document.write('<style type="text/css">');
document.write('body.landing #headings h1, #headings span.section-heading, body.home #content .modules-4col .module h3.top span');
document.write('{ text-indent:-9999px; }');
document.write('</style>');
document.write('<![endif]-->');
*/
Cufon.replace('body.landing #headings h1');
Cufon.replace('#headings span.section-heading');
Cufon.replace('body.home #content .modules-4col .module h3.top span');


/* fix enter */
function doClick(buttonName, e) 
{
    //debugger;
    var key;

    if (window.event)
        key = window.event.keyCode;     //IE
    else
        key = e.which;     			  //firefox

    if (key == 13) {
        var btn = document.getElementById(buttonName);
        if (btn != null) {
            btn.click();
            event.keyCode = 0
        }
    }
}

/* open new window */
function externalLinks() 
{
    if (!document.getElementsByTagName)
        return;
    
    var anchors = document.getElementsByTagName("a");
    
    for (var i = 0; i < anchors.length; i++) 
    {
        var anchor = anchors[i];
        if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") 
        {
            anchor.target = "_blank";
        }
    }
}
window.onload = externalLinks;
	
	
