function adjuster(){
	/**
	* Adjusts the navigation menu widths to expand to full width
	* http://stackoverflow.com/questions/1859243/css-fixed-with-horizontal-menu-with-variable-width-tabs-using-ul/1859828#1859828
	**/
	var actualWidth = 680;
	var totalLIWidth = 0;
	// Calculate total width of list items
	var lis = $('ul#nav li a');
	lis.each(function(){
	    totalLIWidth += $(this).width();
	});
	// Work out how much padding we need
	var requiredPadding = Math.round(((actualWidth-totalLIWidth)/lis.length)/2);
	// To account for rounding errors, the error is going to be forced into the first tab.
	var roundingErrorFix = (requiredPadding*lis.length*2)+totalLIWidth-actualWidth;
	// Apply padding to list items
	var isFirst = true;
	lis.each(function() {
		if(isFirst) {
			$(this).css('padding-left',requiredPadding-roundingErrorFix+'px').css('padding-right',requiredPadding-roundingErrorFix+'px');
			isFirst = false;
		} else {
			$(this).css('padding-left',requiredPadding+'px').css('padding-right',requiredPadding+'px');
		}                                                   
	});
};

/**
* Adjusts font size for header
*/
function adjustHeader(){
	var header = $(".pagehead");
    var numChars = header.text().length;
    if ((numChars >= 25) && (numChars < 40)) {
        header.css("font-size", "32px");
    } else if ((numChars >= 40) && (numChars < 100)) {
        header.css("font-size", "28px");
    }
}                         
                             
/**
* Renders the contact maps for
*/
function renderContactMapsLeft(){
	// Creating a map     
	var point = new google.maps.LatLng(55.6150564, 12.9904488);

	var myMapOptions = {
		zoom: 15,
		center: point,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	};

	var map = new google.maps.Map(document.getElementById("mleft"),myMapOptions);
	
	var image = new google.maps.MarkerImage('/wp-content/themes/tictacv2/img/image.png',
		new google.maps.Size(40,40),
		new google.maps.Point(0,0),
		new google.maps.Point(20,40)
	);

	var shadow = new google.maps.MarkerImage('/wp-content/themes/tictacv2/img/shadow.png',
		new google.maps.Size(64,40),
		new google.maps.Point(0,0),
		new google.maps.Point(20,40)
	);

	var shape = {
		coord: [31,13,32,14,33,15,34,16,34,17,35,18,35,19,35,20,35,21,35,22,35,23,35,24,35,25,35,26,34,27,34,28,33,29,32,30,30,31,29,32,27,33,26,34,24,35,23,36,22,37,21,38,21,39,19,39,18,38,17,37,16,36,15,35,13,34,12,33,10,32,9,31,7,30,6,29,5,28,5,27,4,26,4,25,4,24,4,23,4,22,4,21,4,20,4,19,4,18,5,17,5,16,6,15,7,14,8,13,31,13],
		type: 'poly'
	};
	 
	var marker = new google.maps.Marker({
		icon: image,
		shadow: shadow, 
		title:'TicTac Malmö',
		shape: shape,
		map: map,
		position: point
	}); 
	
	var infowindow = new google.maps.InfoWindow({
	    content: '<h3 style="line-height:16px;">Malmö</h3><p>Dockplatsen 1<br />211 19 Malmö<br /></p>'
	});
	
	google.maps.event.addListener(marker, 'click', function() {
	  infowindow.open(map,marker);
	});
};

/**
* Renders the contact maps for
*/
function renderContactMapsRight(){
	// Creating a map     
	var point = new google.maps.LatLng(59.3420541, 18.0394915);

	var myMapOptions = {
		zoom: 15,
		center: point,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	};

	var map = new google.maps.Map(document.getElementById("mright"),myMapOptions);
	
	var image = new google.maps.MarkerImage('/wp-content/themes/tictacv2/img/image.png',
		new google.maps.Size(40,40),
		new google.maps.Point(0,0),
		new google.maps.Point(20,40)
	);

	var shadow = new google.maps.MarkerImage('/wp-content/themes/tictacv2/img/shadow.png',
		new google.maps.Size(64,40),
		new google.maps.Point(0,0),
		new google.maps.Point(20,40)
	);

	var shape = {
		coord: [31,13,32,14,33,15,34,16,34,17,35,18,35,19,35,20,35,21,35,22,35,23,35,24,35,25,35,26,34,27,34,28,33,29,32,30,30,31,29,32,27,33,26,34,24,35,23,36,22,37,21,38,21,39,19,39,18,38,17,37,16,36,15,35,13,34,12,33,10,32,9,31,7,30,6,29,5,28,5,27,4,26,4,25,4,24,4,23,4,22,4,21,4,20,4,19,4,18,5,17,5,16,6,15,7,14,8,13,31,13],
		type: 'poly'
	};
	 
	var marker = new google.maps.Marker({
		icon: image,
		shadow: shadow, 
		title:'TicTac Stockholm',
		shape: shape,
		map: map,
		position: point
	});
	var infowindow = new google.maps.InfoWindow({
	    content: '<h3 style="line-height:16px;">Stockholm</h3><p>Gästrikegatan 20<br />113 62Stockholm<br /></p>'
	});
	
	google.maps.event.addListener(marker, 'click', function() {
	  infowindow.open(map,marker);
	});
	
};

$(document).ready(function(){ 
	$("a[href^='http:']").not("[href*='tictac.se']").attr('target','_blank');
	setTimeout("adjuster()", 11);
	adjustHeader();
	if(isSingle && $('#nav_346').length){
		$('#nav_346').addClass('active');
	}
	setTimeout("adjuster()", 1000);
	
	if($('#mleft').length){
		renderContactMapsLeft();
		renderContactMapsRight();
	} 
	
	$('#international').mouseover(function(){       
		$('#intpic').attr('src',imgPath + '/img/international_on.png');
		$('#inthover').show();
	});
	$('#international').mouseout(function(){       
		$('#intpic').attr('src',imgPath + '/img/international.png');
		$('#inthover').hide();
	});

});
