function initialize() {
	var latlng = new google.maps.LatLng(-34.397, 150.644);
	var myOptions = {
		zoom: 8,
		center: latlng,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	};
	var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
function hireSign() {
	$("#hiring").animate({top: "-20px"}, 1000, function(){ 
		$("#hiring").animate({opacity: 1}, 700)
	});
}

//              _                       _
//             (_)                     | |
//   ___  ____  _        ___  _____  __| |
//  / _ \|  _ \| |      / _ \(____ |/ _  |
// | |_| | | | | |_____| |_| / ___ ( (_| |
//  \___/|_| |_|_______)\___/\_____|\____|
//

$(function() {
	$('.top').addClass('hide').click(function(e){
		e.preventDefault();
		$.scrollTo("0px", 1000, {axis:'y'})
	}).hover(function(){
		$(this).animate({right: "0px"});
	}, function(){
		$(this).animate({right: "-15px"});
	});
	var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));  
	if (!mobile) {
		$.waypoints.settings.scrollThrottle = 30;
		$('#container').waypoint(function(event, direction) {
			$('.top').toggleClass('hide', direction === "up");
		}, {
			offset: '-30%'
		}).find('#subnav').waypoint(function(event, direction) {
			$(this).parent().toggleClass('sticky', direction === "down");
			event.stopPropagation();
		});
	}
	$("#email").focus(function () {
		$("#question-input").slideDown(600);
		$("#footer-people").animate({
			opacity: 0.8,
			marginTop: 100
		}, 500 );
		return false;
	});
	$('img[class^=partnerlogo], img[class^=top]').mouseover(function(){
		var src = $(this).attr('src');
		var newsrc = src.replace('.png', '-active.png');
		$(this).attr('src', newsrc);
	}).mouseout(function(){
		var src = $(this).attr('src');
		var newsrc = src.replace('-active.png', '.png');
		$(this).attr('src', newsrc);
	});
	$('a[rel="external"]').click(function(){
		window.open($(this).attr('href'));
		try {
			var pageTracker=_gat._getTracker("UA-585221-13");
			pageTracker._trackEvent("External", $(this).attr('href'));
		} catch(err){}
		return false;
	});
	
	setTimeout(hireSign,1200);
	$('#hiring').hover(function(){
		$(this).animate({top: "-10px"}, 500);
	}, function(){
		$(this).animate({top: "-20px"}, 500);
	});

	if((window.location.href).split('/')[3] == "") {
		$('.yourbusiness-local').attr('href',$('.yourbusiness-local').attr('href').replace('?','#'));
		$('.yourbusiness-affiliate').attr('href',$('.yourbusiness-affiliate').attr('href').replace('?','#'));
		$('.yourbusiness-classified').attr('href',$('.yourbusiness-classified').attr('href').replace('?','#'));
		$('.yourbusiness-mobile').attr('href',$('.yourbusiness-mobile').attr('href').replace('?','#'));
	};

//  _     _                      ______             _                       
// | |   | |                    (____  \           (_)                      
// | |___| | ___  _   _  ____    ____)  )_   _  ___ _ ____  _____  ___  ___ 
// |_____  |/ _ \| | | |/ ___)  |  __  (| | | |/___) |  _ \| ___ |/___)/___)
//  _____| | |_| | |_| | |      | |__)  ) |_| |___ | | | | | ____|___ |___ |
// (_______|\___/|____/|_|      |______/|____/(___/|_|_| |_|_____|___/(___/
//

	if(((window.location.href).split('/')[3]).indexOf("yourbusiness") !== -1){
		if(((window.location.href).split('/')[3]).indexOf("yourbusiness#") !== -1) $.scrollTo("0px", 1000, {axis:'y'});

		$("#ul-first li:nth-child(1n+2)").click(function(e){
			var footerTrigger = $(this).text().replace(/ /g,"-").toLowerCase();
			$("#subnav-"+ footerTrigger).trigger("click");
			$.scrollTo($(".columns.advertiser").position().top-80, 1000, { axis:'y' });
		});

		$('#subnav-local-search').attr('href',$('#subnav-local-search').attr('href').replace('?','#'));
		$('#subnav-affiliate-marketing').attr('href',$('#subnav-affiliate-marketing').attr('href').replace('?','#'));
		$('#subnav-classified-media').attr('href',$('#subnav-classified-media').attr('href').replace('?','#'));
		$('#subnav-mobile-advertising').attr('href',$('#subnav-mobile-advertising').attr('href').replace('?','#'));
		if((window.location.href).indexOf("?") !== -1) window.location.href = (window.location.href).replace("?","#");

		if(window.location.hash == "#local-search") setTimeout('$("#subnav-local-search").trigger("click")',500);
		if(window.location.hash == "#affiliate-marketing") setTimeout('$("#subnav-affiliate-marketing").trigger("click")',500);
		if(window.location.hash == "#classified-media") setTimeout('$("#subnav-classified-media").trigger("click")',500);
		if(window.location.hash == "#mobile-advertising") setTimeout('$("#subnav-mobile-advertising").trigger("click")',500);

		$("#sub-navigation a").bind('click', function(e){
			var vertAff = "Affiliate Marketing";
			var vertCla = "Classified Media";
			var vertLoc = "Local Search";
			var vertMob = "Mobile Advertising";

			var clicked = $(this).text().replace(/ /g,"-").toLowerCase();
			var clearElem = "a.local-search h3, a.affiliate-marketing h3, a.classified-media h3, a.mobile-advertising h3";

			$.ajax({
				url: 'txt/advertiser/'+$(this).text().replace(vertAff,"affiliate-advertisers").replace(vertCla,"classified-advertisers").replace(vertLoc,"local-advertisers").replace(vertMob,"mobile-advertisers")+'.php',
				cache: false,
				success: function(data) {
					$('.columns.advertiser').html(data).hide().fadeIn();
				}
			});

			$.ajax({
				url: 'txt/advertiser/'+$(this).text().replace(vertAff,"affiliate-advertisers").replace(vertCla,"classified-advertisers").replace(vertLoc,"local-advertisers").replace(vertMob,"mobile-advertisers")+'-illustration.php',
				cache: false,
				success: function(data) {
					$('#advertiser-illustration').html(data).hide().fadeIn();
				}
			});

			$.ajax({
				url: 'txt/adnetwork/'+$(this).text().replace(vertAff,"affiliate-networks").replace(vertCla,"classified-platforms").replace(vertLoc,"search-agencies").replace(vertMob,"mobile-ad-networks")+'.php',
				cache: false,
				success: function(data) {
					$('.columns.adnetwork').html(data).hide().fadeIn();
				}
			});
			$.ajax({
				url: 'txt/publisher/'+$(this).text().replace(vertAff,"affiliate-publishers").replace(vertCla,"classified-publishers").replace(vertLoc,"directory-publishers").replace(vertMob,"mobile-publishers")+'.php',
				cache: false,
				success: function(data) {
					$('.columns.publisher').html(data).hide().fadeIn();
				}
			});

			$(clearElem).css({"font-style":"normal", "border":"5px solid transparent", "background":"none", "color":"#333"});
			$("a." + clicked + " h3").css({"font-style":"italic", "border":"5px solid #a8d1f1", "background":"#a8d1f1", "color":"#FFF"});

		});
		$("#subnav-local-search, #subnav-affiliate-marketing, #subnav-classified-media, #subnav-mobile-advertising").click(function(e){
			$("#subnav-local-search, #subnav-affiliate-marketing, #subnav-classified-media, #subnav-mobile-advertising").css("color","#3a8ede");
			$(this).css("color","#333");
		});


		if(window.location.hash && window.location.hash != "#local-search" && window.location.hash != "#affiliate-marketing" && window.location.hash != "#classified-media" && window.location.hash != "#mobile-advertising") $.scrollTo($(".columns.advertiser").position().top-80, 1000, { axis:'y' });
		if(window.location.hash == "") $('#subnav-local-search').trigger('click');
	};
});
