/**
*	Check specified IE version
*/

checkIE = function(version) {
	if ($.browser.msie && parseInt(jQuery.browser.version, 10) == version) {
		return true;
	} else {
		return false;	
	}
}


var current_date = new Date();

var date = {
	year: current_date.getFullYear(),
	month: (current_date.getMonth()+1),
	day: current_date.getDate()
}



/**
*	Set no hits text
*/

append_no_hits_text = function () {

	$nohits = $('#no_hits');
	
	if ($nohits.length > 0) {
		no_hits_html	 = '<br /><b>' +
							no_ads_found;
		have_you_tried_html = 	'</b><br /><br />' +
							have_you_tried +
							'<br /><br /><ul id="suggestions">'+
							'</ul>'+
							'<br /><br />';
		
		$nohits.html(no_hits_html);
		$.post('/include/ajax/nohits.php', { defaultValues : defaultValues }, function(data) {
			if(typeof(data.categories) != 'undefined') {
				$nohits.append(have_you_tried_html);
				$nohits.find('#suggestions').append('<li><a href="' + data.categories + '">'+ try_search_in_all_categories +'</a></li>');
			}
			if(typeof(data.regions) != 'undefined') {
				$nohits.append(have_you_tried_html);
				$nohits.find('#suggestions').append('<li><a href="' + data.regions + '">'+ try_search_in_all_regions +' ' + current_country +'</a></li>');
			}
			if(typeof(data.keyword) != 'undefined') {
				$keyword = $('.keywords').children('a');
				if($keyword) {
					if($keyword.text() != '') {
						$nohits.append(have_you_tried_html);
						$nohits.find('#suggestions').append('<li>' + search_on +' <a href="'+ $keyword.attr('href') +'">'+ $keyword.text() +'</a></li>');
					} else {
						$nohits.append('<br /><br />'+ no_hits_sitemap +'');
					}
				} else {
					$nohits.append('<br /><br />'+ no_hits_sitemap +'');
				}
			}
			if(typeof(data.categories) == 'undefined' && typeof(data.regions) == 'undefined' && typeof(data.keyword) == 'undefined') {
				$nohits.append('<br /><br />'+ no_hits_sitemap +'');
			}
		}, 'json');
	}
	
	
	/*
var no_hits_div			= $("#no_hits");
	
	// Check if the no hits div exists
	if (no_hits_div) {
	
		no_hits_html	= '<br /><b>' + no_ads_found + '</b><br /><br />' + have_you_tried +'<br /><br /><ul>'+
		'<li>' + tried_one + '</li></ul><br /><br />';
	}
	
	no_hits_div.html(no_hits_html);
*/
}

show_or_hide_description = function () {
	
	var rowData = new Array();
	var $wrapper = $('.classifieds_wrapper');
	var $row = $('tr.sold');
	
	if ($wrapper.length > 0 && $row.length > 0) {
		$row.live('click', function () {
			
			var $description = $(this).next('tr.description');
			$description.toggle();
			
			var currentRow = $description.nextAll('tr.description').length;
			var rowHeight = $description.outerHeight();
			var wrapperPadding = parseInt($wrapper.css('padding-bottom'));
			
			if($description.is(':visible')) {
				$wrapper.css({ "padding-bottom" : wrapperPadding + rowHeight });
				
				rowData[currentRow] = rowHeight;
			} else {
				$wrapper.css({ "padding-bottom" : wrapperPadding - parseInt(rowData[currentRow]) });
			}
		});
	}
		
	
/*
	var classifieds_wrapper = $(".classifieds_wrapper");
	var sold_tr = $("tr.sold");
	sold_tr.live('click', function () {
		$(this).next('tr.description').toggle();
		var rowheight = $(this).next('tr.description').outerHeight();
		var classifieds_wrapper_padding = parseInt(classifieds_wrapper.css("padding-bottom"));
		
		if( $(this).next('tr.description').is(":visible") ) {
			classifieds_wrapper.css({ "padding-bottom" : classifieds_wrapper_padding + rowheight });
		} else {
			classifieds_wrapper.css({ "padding-bottom" : classifieds_wrapper_padding - rowheight });
		}
	});
*/
}

/**
*	If there is a hash in the URL, redirect to correct URL
*/

redirectHash = function() {
	hash = window.location.hash;
	
	// Only do this if there is an hash and it contains #params
	if (hash.indexOf('#params=') != -1) {
		params = unescape(hash.substr(hash.indexOf('#params=') + 8));
		urls = [];
		
		// Create query string
		$.each($.evalJSON(params), function(i, o) {
			if (o instanceof Array || o instanceof Object) {
				$.each(o, function(j, p) {
					if (p != '') {
						urls.push(i + '[]=' + p);
					}
				});
			} else if (o != '') {
				urls.push(i + '=' + o);
			}
		});
		
		var url = '';
		
		if (urls.length > 0) {
			url = '?' + urls.join('&');
		}
		
		// Get position of hash
		hash_position = location.href.indexOf('#params=');
		
		// Remove hash from href
		redirect_url = location.href.substr(0, hash_position);
		
		// If URL contains a ?, remove everything after it
		if (redirect_url.indexOf('?') != -1) {
			redirect_url = redirect_url.substr(0, redirect_url.indexOf('?'));
		}
		
		// Add new generated query string
		redirect_url += url;
		
		// Redirect to new URL					
		document.location = redirect_url;
	}
}


// Function to handle all types of messages
topLayer = function(data) {
	// If top layer doesn't exists
	if ($('#top-layer').length == 0) {
		// Create top layer background
		$('body').append('<div id="top-layer" onclick="closeTopLayer();"></div>');
		
		// Create top layer content
		$('body').append('<div id="top-layer-content"><a href="javascript:void(0);" onclick="closeTopLayer();" class="close"></a><div class="title"></div><div class="content"></div></div>');
	}
		
	// Set same height as document
	$('#top-layer').css({ 'height' : $(document).height() + 'px' });
	
	// If width is sent into the function
	if (data.width > 0) {
		$('#top-layer-content').css({ 'width' : data.width + 'px' });
	}
		
	if ($('#top-layer-content').height() > $(window).height()) {
		// Set top position for content
		$('#top-layer-content').css({ 'top' : ($(window).scrollTop() + 50) + 'px' });
	} else {
		css_top = $(window).scrollTop() + ($(window).height() / 2) - ($('#top-layer-content').height() / 2);

		// Set top position for content
		$('#top-layer-content').css({ 'top' : css_top + 'px' });
	}
	
	// Set correct content
	$('#top-layer-content div.title').text(data.title);
	
	if (data.html) {
		$('#top-layer-content div.content').html(data.message);
	} else {		
		$('#top-layer-content div.content').text(data.message);
	}
	
	// Show top layer
	$('#top-layer').show();
	$('#top-layer-content').show();
}

closeTopLayer = function() {
	$('#top-layer').hide();
	$('#top-layer-content').hide();
}


/**
*	Open popup to Facebook
*/

shareFacebook = function() {
	url = "http://www.facebook.com/sharer.php?u=" + document.location.href + "&t=" + document.title;
	
	window.open(url, share_on_facebook, "toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, width=550, height=330");
}


/**
*	Bind input text boxes for standard text
*/

bindInput = function(obj, text) {
	// Get object
	object = $(obj);
		
	if (object.attr('type') == 'text') {	
		object.live('focus', function() {
			if ($(this).val() == text) {
				$(this).val('');
			}
		});
		
		object.live('blur', function() {
			if ($(this).val() == '') {
				$(this).val(text);
			}
		});
	}
}


/**
*	Add site to bookmarks
*/

addFavorit = function(url, description) {
	// Firefox
	if (window.sidebar) {
		// Add to bookmarks
		window.sidebar.addPanel(description, url, "");
	// Internet Explorer
	} else if(window.external && navigator.userAgent.toLowerCase().indexOf("chrome") == -1) {
		// Add to favorites
		window.external.AddFavorite(url, description);
	// Opera, Safari or Chrome
	} else if(
		(window.opera && window.print) ||
		navigator.userAgent.toLowerCase().indexOf("webkit") != -1 ||
		navigator.userAgent.toLowerCase().indexOf("chrome") != -1
	) {
		// Check if MAC
		var isMac = (navigator.userAgent.toLowerCase().indexOf("mac") != -1);
		
		// Set name for button
    	var button = isMac ? "Command/Cmd" : "CTRL";
		
		// Display message
		alert(push_first_ok+" " + button + " " + plus_d_add + " " + description + " " + to_your_bookmarks);
	}
}


var DontHideSorter = false;
var HideSorterTimeout;

HideSorter = function() {
	clearTimeout(HideSorterTimeout);
	
	HideSorterTimeout = setTimeout(function() {
		if (DontHideSorter == false) {
			$('#sorter_select').hide();
		}
	}, 300);	
}

centerPage = function() {
	if ($(window).width() < 1252) {
		$('div.page').css({ 'left' : '0', 'margin' : '0 0 0 10px' });
	}
}

var href = [];
var onclick = [];

bindHitlistClick = function() {
	// Reset array
	href = [];
	onclick = [];
	matches = [];
	links = [];
	
	$('table.classifieds tr').each(function(i, o) {
		tr = $(o);
		
		// Find links
		a = tr.find('a').get(0);
		
		// Get link
		link = $(a);
				
		// Get HREF and ONCLICK
		href[i] = link.attr('href');
		onclick[i] = link.attr('onclick');
		links[i] = a;
				
		//pattern = new RegExp(/^(http:\/\/www\.google\.|\/|http:\/\/adsrv\.ads\.eniro\.)/);
		
		pattern2 = new RegExp(/\/click\.php/);
		
		if (pattern2.test(href[i]) && link.length > 0 && href[i] != 'http://www.eniro.se' && href[i] != 'http://www.eniro.se/' && href[i] != 'http://www.eniro.se/?partnerid=agul') {
			if ($.browser.msie) {
				var regex = /trck\(([^,]+), '(.+)', ([^,]+), '(.+)', ([^,]+), '(.+)'\)/i;
			} else {
				var regex = /trck\(([^,]+), "(.+)", ([^,]+), "(.+)", ([^,]+), "(.+)"\)/i;
			}
			
			var tmp = new String(onclick[i]);

			matches[i] = tmp.match(regex);
						
			tr.find('td').each(function(i2, o2) {
				$(o2).click(function() {
					if (!$(o2).hasClass('no-click')) {
						window.open(href[i]);
						trck(matches[i][1], matches[i][2], matches[i][3], matches[i][4], matches[i][5], matches[i][6]);
						
						//setTimeout(function() {
							//window.open(href[i]);
						//}, 100);
					}
				}).css('cursor', 'pointer');
			});
		}
	});
	
	var click_holder;
	
	$('table.classifieds a').hover(
		function() {
			obj = $(this);
			
			td = $(obj.parent('td'));
			td.addClass('no-click');
		},
		
		function() {
			obj = $(this);
			
			td = $(obj.parent('td'));
			td.removeClass('no-click');
		}
	);
}

checkEmptyAdsense = function() {
	var options = {
	  'pubId' 			: 'pub-8323261279972034',
	  'query' 			: adsenseKeywordSecond,
	  'hl' 				: langCode,
	  'siteLinks' 		: false,
	  'instantPreviews' : false,
	  'oe' 				: 'utf-8',
	  'ie' 				: 'utf-8',
	  'adPage' 			: 1,
	  'linkTarget'		: '_blank'
	};
		
	var blocks = [];
		
	if ($('#a_top_box').length > 0 && $('#a_top_box iframe').outerHeight() == 0) {
		blocks.push({ 
		  'container' 			: 'a_top_box',
		  'number' 				: 3,
		  'channel' 			: adsenseChannels.top + '+' + adsenseChannels.second_search,
		  'width' 				: '682px',
		  'fontFamily' 			: 'verdana',
		  'colorTitleLink' 		: '#0082F8',
		  'colorText' 			: '#333333',
		  'colorBackground' 	: '#FFF8DD',
		  'colorBorder' 		: '#FFF8DD',
		  'fontSizeTitle' 		: '14px',
		  'fontSizeDescription' : '12px',
		  'fontSizeDomainLink' 	: '12px',
		  'lines' 				: 2
		});
	} else if ($('#a_top_empty_box').length > 0 && $('#a_top_empty_box iframe').outerHeight() == 0) {
		blocks.push({ 
		  'container' 			: 'a_top_empty_box',
		  'number' 				: 3,
		  'channel' 			: adsenseChannels.no_hits + '+' + adsenseChannels.second_search,
		  'width' 				: '682px',
		  'fontFamily' 			: 'verdana',
		  'colorTitleLink' 		: '#0082F8',
		  'colorText' 			: '#333333',
		  'colorBackground' 	: '#FFF8DD',
		  'colorBorder' 		: '#FFF8DD',
		  'fontSizeTitle' 		: '14px',
		  'fontSizeDescription' : '12px',
		  'fontSizeDomainLink' 	: '12px',
		  'lines' 				: 2
		});
	} else if ($('#a_top_row').length > 0 && $('#a_top_row iframe').outerHeight() == 0) {
		blocks.push({ 
		  'container' 			: 'a_top_row',
		  'number' 				: 3,
		  'channel' 			: adsenseChannels.top + '+' + adsenseChannels.second_search,
		  'width' 				: '702px',
		  'fontFamily' 			: 'verdana',
		  'colorTitleLink' 		: '#0082F8',
		  'colorText' 			: '#333333',
		  'colorAdSeparator' 	: '#e9e9e9',
		  'fontSizeTitle' 		: '13px',
		  'fontSizeDescription' : '12px',
		  'fontSizeDomainLink' 	: '12px',
		  'rolloverAdBackgroundColor' : '#f3f7f8',
		  'lines' 				: 3,
		  'verticalSpacing'		: 12
		});
	} else if ($('#a_top_empty_row').length > 0 && $('#a_top_empty_row iframe').outerHeight() == 0) {
		blocks.push({ 
		  'container' 			: 'a_top_empty_row',
		  'number' 				: 3,
		  'channel' 			: adsenseChannels.no_hits + '+' + adsenseChannels.second_search,
		  'width' 				: '702px',
		  'fontFamily' 			: 'verdana',
		  'colorTitleLink' 		: '#0082F8',
		  'colorText' 			: '#333333',
		  'colorAdSeparator' 	: '#e9e9e9',
		  'fontSizeTitle' 		: '13px',
		  'fontSizeDescription' : '12px',
		  'fontSizeDomainLink' 	: '12px',
		  'rolloverAdBackgroundColor' : '#f3f7f8',
		  'lines' 				: 3,
		  'verticalSpacing'		: 12
		});
	}
	
	if ($('#a_right_box').length > 0 && $('#a_right_box iframe').outerHeight() == 0) {
		blocks.push({ 
		  'container' 			: 'a_right_box',
		  'number' 				: 6,
		  'channel' 			: adsenseChannels.right + '+' + adsenseChannels.second_search,
		  'width' 				: '248px',
		  'fontFamily' 			: 'verdana',
		  'colorTitleLink' 		: '#0082F8',
		  'colorText' 			: '#333333',
		  'colorBackground' 	: '#E8EEFF',
		  'colorBorder' 		: '#E8EEFF',
		  'fontSizeTitle' 		: '14px',
		  'fontSizeDescription' : '12px',
		  'fontSizeDomainLink' 	: '12px',
		  'lines' 				: 3
		});
	}
			
	if (blocks.length == 2) {
		new google.ads.search.Ads(options, blocks[0], blocks[1]);
	} else if (blocks.length == 1) {
		new google.ads.search.Ads(options, blocks[0]);
	}
}

initAdsense = function() {
	if (typeof google != 'object') {
		return false;
	}
	
	if ($('#a_top_box').length > 0 || $('#a_right_box').length > 0 || $('#a_top_empty_box').length > 0 || $('#a_top_row').length > 0 || $('#a_top_empty_row').length > 0) {
		var options = {
		  'pubId' 			: 'pub-8323261279972034',
		  'query' 			: adsenseKeyword,
		  'hl' 				: langCode,
		  'siteLinks' 		: false,
		  'instantPreviews' : false,
		  'oe' 				: 'utf-8',
		  'ie' 				: 'utf-8',
		  'adPage' 			: 1,
		  'linkTarget'		: '_blank'
		};
		
		var blocks = [];
		
		if ($('#a_top_box').length > 0) {
			blocks.push({ 
			  'container' 			: 'a_top_box',
			  'number' 				: 3,
			  'channel' 			: adsenseChannels.top,
			  'width' 				: '682px',
			  'fontFamily' 			: 'verdana',
			  'colorTitleLink' 		: '#0082F8',
			  'colorText' 			: '#333333',
			  'colorBackground' 	: '#FFF8DD',
			  'colorBorder' 		: '#FFF8DD',
			  'fontSizeTitle' 		: '14px',
			  'fontSizeDescription' : '12px',
			  'fontSizeDomainLink' 	: '12px',
			  'lines' 				: 2
			});
		} else if ($('#a_top_empty_box').length > 0) {
			blocks.push({ 
			  'container' 			: 'a_top_empty_box',
			  'number' 				: 3,
			  'channel' 			: adsenseChannels.no_hits,
			  'width' 				: '682px',
			  'fontFamily' 			: 'verdana',
			  'colorTitleLink' 		: '#0082F8',
			  'colorText' 			: '#333333',
			  'colorBackground' 	: '#FFF8DD',
			  'colorBorder' 		: '#FFF8DD',
			  'fontSizeTitle' 		: '14px',
			  'fontSizeDescription' : '12px',
			  'fontSizeDomainLink' 	: '12px',
			  'lines' 				: 2
			});
		} else if ($('#a_top_row').length > 0) {
			blocks.push({ 
			  'container' 			: 'a_top_row',
			  'number' 				: 3,
			  'channel' 			: adsenseChannels.top,
			  'width' 				: '702px',
			  'fontFamily' 			: 'verdana',
			  'colorTitleLink' 		: '#0082F8',
			  'colorText' 			: '#333333',
			  'colorAdSeparator' 	: '#e9e9e9',
			  'fontSizeTitle' 		: '13px',
			  'fontSizeDescription' : '12px',
			  'fontSizeDomainLink' 	: '12px',
			  'rolloverAdBackgroundColor' : '#f3f7f8',
			  'lines' 				: 3,
			  'verticalSpacing'		: 12
			});
		} else if ($('#a_top_empty_row').length > 0) {
			blocks.push({ 
			  'container' 			: 'a_top_empty_row',
			  'number' 				: 3,
			  'channel' 			: adsenseChannels.no_hits,
			  'width' 				: '702px',
			  'fontFamily' 			: 'verdana',
			  'colorTitleLink' 		: '#0082F8',
			  'colorText' 			: '#333333',
			  'colorAdSeparator' 	: '#e9e9e9',
			  'fontSizeTitle' 		: '13px',
			  'fontSizeDescription' : '12px',
			  'fontSizeDomainLink' 	: '12px',
			  'rolloverAdBackgroundColor' : '#f3f7f8',
			  'lines' 				: 3,
			  'verticalSpacing'		: 12
			});
		}
		
		if ($('#a_right_box').length > 0) {
			blocks.push({ 
			  'container' 			: 'a_right_box',
			  'number' 				: 6,
			  'channel' 			: adsenseChannels.right,
			  'width' 				: '248px',
			  'fontFamily' 			: 'verdana',
			  'colorTitleLink' 		: '#0082F8',
			  'colorText' 			: '#333333',
			  'colorBackground' 	: '#E8EEFF',
			  'colorBorder' 		: '#E8EEFF',
			  'fontSizeTitle' 		: '14px',
			  'fontSizeDescription' : '12px',
			  'fontSizeDomainLink' 	: '12px',
			  'lines' 				: 3
			});
		}
				
		if (blocks.length == 2) {
			new google.ads.search.Ads(options, blocks[0], blocks[1]);
		} else if (blocks.length == 1) {
			new google.ads.search.Ads(options, blocks[0]);
		}
		
		/*setTimeout(function() {
			options.query = adsenseKeywordSecond;
			blocks = [];

			if ($('#a_right_box').length > 0) {
				if ($('#a_right_box iframe').css('height') == '0px') {
					blocks.push({ 
					  'container' 			: 'a_right_box',
					  'number' 				: 6,
					  'channel' 			: adsenseChannels.right + '+' + adsenseChannels.second_search,
					  'width' 				: '248px',
					  'fontFamily' 			: 'verdana',
					  'colorTitleLink' 		: '#0082F8',
					  'colorText' 			: '#333333',
					  'colorBackground' 	: '#E8EEFF',
					  'colorBorder' 		: '#E8EEFF',
					  'fontSizeTitle' 		: '14px',
					  'fontSizeDescription' : '12px',
					  'fontSizeDomainLink' 	: '12px',
					  'lines' 				: 3
					});
				}
			}
			
			if ($('#a_top_box').length > 0) {
				if ($('#a_top_box iframe').css('height') == '0px') {
					blocks.push({ 
					  'container' 			: 'a_top_box',
					  'number' 				: 3,
					  'channel' 			: adsenseChannels.top + '+' + adsenseChannels.second_search,
					  'width' 				: '682px',
					  'fontFamily' 			: 'verdana',
					  'colorTitleLink' 		: '#0082F8',
					  'colorText' 			: '#333333',
					  'colorBackground' 	: '#FFF8DD',
					  'colorBorder' 		: '#FFF8DD',
					  'fontSizeTitle' 		: '14px',
					  'fontSizeDescription' : '12px',
					  'fontSizeDomainLink' 	: '12px',
					  'lines' 				: 2
					});
				}
			} else if ($('#a_top_empty_box').length > 0) {
				if ($('#a_top_empty_box iframe').css('height') == '0px') {
					blocks.push({ 
					  'container' 			: 'a_top_empty_box',
					  'number' 				: 3,
					  'channel' 			: adsenseChannels.no_hits + '+' + adsenseChannels.second_search,
					  'width' 				: '682px',
					  'fontFamily' 			: 'verdana',
					  'colorTitleLink' 		: '#0082F8',
					  'colorText' 			: '#333333',
					  'colorBackground' 	: '#FFF8DD',
					  'colorBorder' 		: '#FFF8DD',
					  'fontSizeTitle' 		: '14px',
					  'fontSizeDescription' : '12px',
					  'fontSizeDomainLink' 	: '12px',
					  'lines' 				: 2
					});
				}
			} else if ($('#a_top_row').length > 0) {
				if ($('#a_top_row iframe').css('height') == '0px') {
					blocks.push({ 
					  'container' 			: 'a_top_row',
					  'number' 				: 3,
					  'channel' 			: adsenseChannels.top + '+' + adsenseChannels.second_search,
					  'width' 				: '702px',
					  'fontFamily' 			: 'verdana',
					  'colorTitleLink' 		: '#0082F8',
					  'colorText' 			: '#333333',
					  'colorAdSeparator' 	: '#e9e9e9',
					  'fontSizeTitle' 		: '13px',
					  'fontSizeDescription' : '12px',
					  'fontSizeDomainLink' 	: '12px',
					  'rolloverAdBackgroundColor' : '#f3f7f8',
					  'lines' 				: 3,
					  'verticalSpacing'		: 12
					});
				}
			} else if ($('#a_top_empty_row').length > 0) {
				if ($('#a_top_empty_row iframe').css('height') == '0px') {
					blocks.push({ 
					  'container' 			: 'a_top_empty_row',
					  'number' 				: 3,
					  'channel' 			: adsenseChannels.no_hits + '+' + adsenseChannels.second_search,
					  'width' 				: '702px',
					  'fontFamily' 			: 'verdana',
					  'colorTitleLink' 		: '#0082F8',
					  'colorText' 			: '#333333',
					  'colorAdSeparator' 	: '#e9e9e9',
					  'fontSizeTitle' 		: '13px',
					  'fontSizeDescription' : '12px',
					  'fontSizeDomainLink' 	: '12px',
					  'rolloverAdBackgroundColor' : '#f3f7f8',
					  'lines' 				: 3,
					  'verticalSpacing'		: 12
					});
				}
			}
			
			if (blocks.length == 3) {
				new google.ads.search.Ads(options, blocks[0], blocks[1], blocks[2]);
			} else if (blocks.length == 2) {
				new google.ads.search.Ads(options, blocks[0], blocks[1]);
			} else if (blocks.length == 1) {
				new google.ads.search.Ads(options, blocks[0]);
			}
			
		}, 500);*/
	}
}


$(document).ready(function() {
	setTimeout(checkEmptyAdsense, 1000);
	
	append_no_hits_text();
	show_or_hide_description();
	loadSoldAds();
	
	if (checkIE(6) || checkIE(7)) {
		$("#menu .active .activearrow").css({
			"width" : $("#menu li.active").width()
		});
	}
	
	$(".hitlists_text .image").css({
		"margin-top" : $(".hitlists_text").height() - $(".hitlists_text .image").height()
	});

		
	// Bind Facebook icon in footer
	$('#facebook').click(shareFacebook);
	
	// Bind "add to favorite" icon in footer
	$('#bookmark').click(function() {
		addFavorit('http://' + domain_name, site_name);
	});
	
	if ($("a#more_categories").length > 0) {
		$("a#more_categories").click(function() {
			// Get link object
			more_categories = $('a#more_categories');
			
			// Get class for link object
			more_categories_class = more_categories.attr('class');
			
			if (more_categories_class == ""){
				$("div#hide").animate({ "height" : cat_h }, {
					duration: "slow",
					easing: "jswing",
					complete: function(){
						more_categories.html(lang_less_categories).addClass("active");
					}
				});
			} else {
				$("div#hide").animate({ "height" : "50px" }, {
					duration: "slow",
					easing: "jswing",
					complete: function(){
						more_categories.html(lang_more_categories).removeClass("active");
					}
				});
			}
			
			//return false;
		});
	}
		
	/* Expand footer links */
	$("#footer a.arrow").click(function() {
		$("#footer a.arrow").toggleClass("down", 250);
		
		if ($('#contact').hasClass('up')) {
			$('#contact').removeClass('up');
		} else {
			$("#contact").toggleClass("up", 250);
		}
		
		$("#arrow_slide").toggleClass("up", 250);
	});
	
	// Bind TipTip
	$("#bookmark").tipTip({ 'defaultPosition' : 'top' }); // Bookmark icon in footer
	$('#rss').tipTip({ 'defaultPosition' : 'top' }); // RSS icon in footer
	$('#facebook').tipTip({ 'defaultPosition' : 'top' }); // Facebook icon in footer
	
	$('#what').tipTip(); // What field in search box
	$('#where').tipTip(); // Where field in search box
	
	$('#dating').tipTip(); // Select box dating-tab
	
	var value = [];
	
	$.each($('#contact_form :input'), function(i, o) {
		obj = $(o);
		value[i] = obj.val();
		
		if (obj.attr('type') != 'submit') {
			obj.focus(function() {
				if ($(o).val() == value[i]) {
					$(o).val('');
				}
			}).blur(function() {
				if ($(o).val() == '') {
					$(o).val(value[i]);
				}
			});
		}
		
	});

	// Observe contact form submit
	$('#contact_form_button').click(function() {
		// Get form values
		var name = $('#footer_name').val();
		var email = $('#footer_email').val();
		var message = $('#footer_message').val();
		
		// Error message
		var error = ''
		
		// Check for errors
		if (name == '' || name == your_name)
			error += '<li>' + invalid_name + '</li>';
		
		if (email == '' || email == your_email)
			error += '<li>' + invalid_email + '</li>';
		
		if (message == '' || message == your_message)
			error += '<li>' + invalid_message + '</li>';
		
		if (error != '') {
			topLayer({ 'title' : an_error_occurred, 'message' : this_errors +':<ul style="margin: 5px 0 0 10px;">' + error + '</ul>', 'html' : true});
		} else {			
			$.ajax({
				url : '/include/ajax/contact.php',
				dataType : 'json',
				async : false,
				type : 'POST',
				data: ({ 'name' : name, 'email' : email, 'message' : message, ajax: 1 }),
				complete: function(data) {
					
					var response = data.responseText;
					
					if(response == '+INVALID_EMAIL') {
						topLayer({ 'title' : an_error_occurred, 'message' : invalid_email });
					}else if(response == '+INVALID_NAME') {
						topLayer({ 'title' :an_error_occurred, 'message' : invalid_name });
					}else if(response == '+INVALID_MESSAGE') {
						topLayer({ 'title' : an_error_occurred, 'message' : invalid_message });
					}else{
						// Show message
						topLayer({ 'title' : message_thanks_title, 'message' : message_thanks });
						
						$('#footer_name').val(your_name);
						$('#footer_email').val(your_email);
						$('#footer_message').val(your_message);
					}
				}
			});
		}
	})
	
	
	/* Expanding categories */
	cat_h = eval($("#hide table").height());

	bindHitlistClick();
	
});

/**
 * Load sold ads
 *
 */
loadSoldAds = function () {

	var $container = $('.classifieds_wrapper');
	var $table = $('.solditems .classifieds');
	if($table.length > 0) {
		if($table.find('tr').length < 5) {
			$.ajax('/include/ajax/sold.php', {
				dataType: 'json',
				async : true,
				type : 'POST',
				data: ({ defaultValues : defaultValues, exclude : soldExclude }),
				complete : function (data, status) {
					if(status == 'success') {
						var response = $.evalJSON(data.responseText);
						if(data.responseText != 'false'){
						var rows = $table.find('tr.sold').length;
						var hits = parseInt(rows) + parseInt(response.hits);
						
						$container.removeClass('rows'+rows);
						$container.addClass('rows'+hits);
						
						$table.prepend(response.html);
						$table.find('tr').removeClass('no_top_border');
						$table.find('tr:first').addClass('no_top_border');
						}
					}
				}
			});
		}
	}

	
}

/**
*	Refresh hitlist
*/

var refershHitlistAjax;
var previousFilters;

refreshHitlist = function() {
	// Kill request if there already is one
	if (refershHitlistAjax) {
		refershHitlistAjax.abort();
	}
	
	if($(this).is(':checked')) {
		_gaq.push(['_trackEvent', 'filter', $(this).attr('name'), $(this).parent().parent().parent().find('label').html().replace('&amp;', '&')]);
	}
	
	// Go through all filters and add them to the search
	var filters = [];
	
	$.each($('#filters input[type="checkbox"]'), function(i, o) {
		obj = $(o);
		
		if (obj.is(':checked')) {
			filters.push({ name : obj.attr('name'), value : obj.val() });
		}
	});
	
	
	// Go through all visible sliders and add them to the filter
	$.each($('#filters div.slider_container'), function(i, o) {
		obj = $(o);
		
		if (obj.is(':visible')) {
			// Get name for slider
			name = obj.find('input.slider_name').val();
			
			if (($('#' + name + '_current_min').val() * 1) > ($('#' + name + '_min_formatted').val() * 1)) {
				filters.push({ name : name + '_min', value : $('#' + name + '_current_min').val() });
			}
			
			if (($('#' + name + '_current_max').val() * 1) < ($('#' + name + '_max_formatted').val() * 1)) {
				filters.push({ name : name + '_max', value : $('#' + name + '_current_max').val() });
			}
		}
	});
	
	// If user pressed in pagination
	if (nextPage > 0 && is_defined(nextPage)) {
		// Save as a filter
		filters.push({ name : 'o', value : nextPage });

		$.scrollTo(($('#hitlist_tabs').offset().top - 10), 0);
		
		nextPage = 0;
	}
	
	// Add current sorter
	if ($('#sorter_select a.selected').attr('rel') != '') {
		filters.push({ name : 'sort', value : $('#sorter_select a.selected').attr('rel') });
	}
	
	if (newCompany >= 0 && is_defined(newCompany)) {
		// Save as a filter
		filters.push({ name : 'f', value : newCompany });
	}
	
	currentFilters = $.toJSON(filters);
		
	// If there is exactlly the same filters, don't update hitlist
	if (currentFilters == previousFilters) {
		return false;
	} else {
		previousFilters = currentFilters;
	}
	
	// Remove old loader
	$('#loader_container').remove();
	
	// Display loader
	var hitlist = $('#hitlist');
	var tabs = $('#hitlist_tabs');
	var loader = $('<div id="loader_container"><div class="ajax-loader" style="top: ' + tabs.offset().top + 'px; left: ' + hitlist.offset().left + 'px; width: ' + ((hitlist.width() * 1) + 2) + 'px; height: ' + ((hitlist.height() * 1) + (tabs.height() * 1)) + 'px;"></div><div class="ajax-loader-bar" style="top: ' + ((hitlist.offset().top * 1) + 130) + 'px; left: ' + hitlist.offset().left + 'px;"><center>' + loading_hitlist +'...<br /><img src="/img/hitlist/ajax-loader.gif" alt="'+ loading +'" title="'+ loading +'" align="center" /></center></div></div>');	
	$(document.body).append(loader);
	
	refershHitlistAjax = $.ajax({
		url : '/include/ajax/hitlist.php', 
		dataType : 'json',
		async : true,
		type : 'POST',
		data: ({ defaultValues : defaultValues, filters : filters }),
		
		complete: function(data, status) {
			if (status == 'success') {
				var response = $.evalJSON(data.responseText);
				
				// Create hash0
				if (response.hash != '') {
					location.hash = '#params=' + escape(response.hash);
				} else {
					location.hash = '#';
				}
				
				// Remove text block if it exists
				if ($('#information_text')) {
					$('#information_text').remove();
				}
				
				// Update hitlist HTML
				$('#hitlist').html(response.html);
				
				// Update tabs number
				$.each($('#company_tabs li'), function(i, o) {
					if (i == 0) {
						$(o).find('b').html('<b>(' + number_format(response.hits, 0, '', ' ') + ')</b>');
					}
				});
				
				// Add Google AdSense to hitlist
				/*if ($('#wide_afs_unit')) {
					$('#wide_afs_unit').html(saved_google_ads[0]);
				}*/
				
				if ($('#single_afs_unit')) {
					$('#single_afs_unit').html(saved_google_ads[0]);
					
					if ($('#single_afs_unit img, #single_afs_unit object').length == 0) {
						$('#single_afs_unit').css({ backgroundColor: 'rgb(255, 248, 221)',  padding: '5px 20px 20px 81px', border: '1px solid rgb(255, 233, 147)' });
					} else {
						$('#single_afs_unit').css({ 'text-align' : 'center' });
					}
				}
				
				if ($('#wide_afs_bottom')) {
					$('#wide_afs_bottom').html(saved_google_ads[1]);
				}
				
				// If there is keywords for this search, remove class from title
				if ($('div.keywords').length > 0) {
					$('#title').removeClass('no_keywords');
				}
				
				//loader.remove();
				
				bindHitlistClick();
				append_no_hits_text();
				initAdsense();
				
				// Remove loader screen
				loader.fadeOut('normal', function() { loader.remove(); });
			}
		}
	});
}


/**
*	Bind sorter
*/

bindSorter = function() {
	$('#sorter span').mouseover(function() {
		$('#sorter_select').show();
		DontHideSorter = true;
	}).mouseout(function() {
		DontHideSorter = false;
		HideSorter();
	});
	
	$('#sorter_select').mouseover(function() {
		DontHideSorter = true;
	}).mouseout(function() {
		DontHideSorter = false;
		HideSorter();
	});
	
	$('#sorter_select a').click(function() {
		$('#sorter_select a.selected').removeClass('selected');
		$(this).addClass('selected');
		$('#sorter_select').hide();
		$('#sorter span').html($(this).html());
		
		refreshHitlist();
	});
}



/**
*	Change page and refresh hitlist
*/

var nextPage;

changePage = function(page) {
	nextPage = page;
		
	// Refersh hitlist
	refreshHitlist();
}


/**
*	Change all/private/company ads
*/

var newCompany = -1;

changeCompany = function(company) {
	newCompany = company;
	
	// Set key
	key = company + 1;
	
	// Remove class active from all tabs
	$.each($('#company_tabs li'), function(i, o) {
		if (key == i) {
			$(o).addClass('active');
		} else {
			$(o).removeClass('active');
		}
	});
	
	// Refresh hitlist
	refreshHitlist();
}


/**
*	Put GEO location in top of filter list
*/

setGeo = function(geo) {
	obj = $('#region_filters label[title=\'' + geo + '\']');
	
	if (obj.length > 0) {
		parent_li = obj.parent('li');
		
		// Insert users location on top
		$('<li>' + parent_li.html() + '</li>').insertBefore($($('#region_filters li').get(0)));
		
		// Remove old location
		parent_li.remove();
	}
}


loadRightColumn = function(options) {
	$.ajax({
		url : '/include/ajax/right_column.php',
		dataType : 'html',
		async : false,
		type : 'POST',
		data: ({ options : options, language : langCode }),
		
		complete: function(data) {
			document.write(data.responseText);
			//alert(data.responseText);
			//$('#right_column').html(data.responseText);
			//$(data.responseText).appendTo('#right_column');
		}
	});
}

/**
*	Load filters first time page is loaded
*/

loadFilters = function() {
	$.ajax({
		url : '/include/ajax/filter.php',
		dataType : 'json',
		async : true,
		type : 'POST',
		data: ({ defaultValues : defaultValues, filterCategories : filterCategories }),
		
		complete: function(data) {
			var response = $.evalJSON(data.responseText);
			
			// Print filters
			$('#filters').html(response.html);
			
			// Print tabs
			$('#hitlist_tabs').html(response.tabs);
			
			// Fix everything with the sorters
			bindSorter();
			
			// Set users GEO location on top
			if (response.geo != '' && $('#region_filters').length > 0) {
				setGeo(response.geo);
			}
			
			// Style checkboxes
			$('#filters input[type="checkbox"]').uniform();
			
			// If some changes is made with the checkboxes, referesh hitlist
			$('#filters input[type="checkbox"]').change(refreshHitlist);

			$('#filters input[name="category"]').click(function() {
				var showCarSliders = false;
				var showHouseSliders = false;
				
				$.each($('#filters input[name="category"]:checked'), function(i, o) {
					val = $(o).val();
					
					if (val == 9 || val == 1625 || val == 1623 || val == 1603) {
						showCarSliders = true;
					} else if (val == 33 || val == 1703 || val == 1698 || val == 1699 || val == 1704 || val == 1702 || val == 1701 || val == 1167 || val == 1502 || val == 1501 || val == 1700) {
						showHouseSliders = true;
					}
				});
				
				// Show/hide car sliders
				if (showCarSliders == true) {
					$('#model_year_slider_container').show();
					$('#mileage_slider_container').show();
					
					$('#sorter_select a.car').show();
				} else {
					$('#model_year_slider_container').hide();
					$('#mileage_slider_container').hide();
					
					$('#sorter_select a.car').hide();
				}
				
				def = $.evalJSON(defaultValues);
				
				// Show/hide house sliders
				if (showHouseSliders == true || def.hitlist.id == 3) {
					$('#area_slider_container').show();
					$('#room_slider_container').show();
					
					$('#sorter_select a.house').show();
				} else {
					$('#area_slider_container').hide();
					$('#room_slider_container').hide();
					
					$('#sorter_select a.house').hide();
				}
			});
			
			// Fix all sliders
			$.each($('#filters div.slider_container'), function(i, o) {
				var obj = $(o);
				var name = obj.find('input.slider_name').val();
				
				var slider = $('#' + name + '_slider');
				
				// Inputs with current value
				var current = { min : $('#' + name + '_current_min'), max : $('#' + name + '_current_max') };
				
				// Inputs that displays current value
				var display = { min : $('#' + name + '_current_min_formatted'), max : $('#' + name + '_current_max_formatted') }; 
				
				var extra = $('#' + name + '_extra').val();
				var add_number_format = $('#' + name + '_number_format').val();
				var steps = $('#' + name + '_steps').val();
				var special_steps = $('#' + name + '_special_steps').val();
				
				if (special_steps == 1) {
					steps = $.evalJSON(steps);
				}
				
				var sliderChange = false;
				
				if (slider.length > 0) {
					slider.slider({
						'range' : true,
						'min' : ($('#' + name + '_min').val() * 1),
						'max' : ($('#' + name + '_max').val() * 1),
						'values' : [ (current.min.val() * 1), (current.max.val() * 1) ],
						'step' : steps,
						
						slide: function(event, ui) {
							min = ui.values[0];
							max = ui.values[1];
							
							if (special_steps == 1) {
								min = steps[min];
								max = steps[max];
							}
							
							// Save current value
							current.min.val(min);
							current.max.val(max);
							
							// If number should be formated
							if (add_number_format == 1) {
								min = number_format(min, 0, '', ' ');
								max = number_format(max, 0, '', ' ');
							}
							
							// Add extra
							if (extra != '') {
								min += ' ' + extra;
								max += ' ' + extra;
							}
														
							// Show new information							
							display.min.val(min);
							display.max.val(max);
						}, 
						
						change: function(event, ui) {
							refreshHitlist();
						}
					});
					
					// Add class to right slider holder
					slider.find('a:last-child').addClass('right');
					
					current.min.val($('#' + name + '_min_formatted').val());
					current.max.val($('#' + name + '_max_formatted').val());
				}
			});
		}
	});
}


/**
*	Function to expand/extract filter
*/

extendFilter = function(obj) {

	// Link user pressed
	var extended = $(obj);
	
	// UL list link is in
	var parent = extended.parent().find('ul');
	
	// HTML code in link
	var html = extended.html();

	// Toggle style
	if (parent.css('overflow') == 'hidden') {
		parent.css('overflow', '');
	} else {
		parent.css('overflow', 'hidden');
	}
	
	// Change HTML code
	new_html = html.replace(lang_more, lang_less);
	
	// If there is no changes, do the other change
	if (new_html == html)
		new_html = html.replace(lang_less, lang_more);
	
	// Dispaly new HTML code
	extended.html(new_html);
}


is_object = function(mixed_var){
    if (mixed_var instanceof Array) {
    	return false;
    } else {
        return (mixed_var !== null) && (typeof( mixed_var ) == 'object');
    }
}

is_defined = function(mixed_var) {
	if (typeof(mixed_var) !== 'undefined')
		return true;	
	
	return false;
}

loadDoRunnerValues = function(type) {
	value_id = $('#dr_' + type + ' :selected').val();
	
	var html = ''
	
	if (value_id > 0) {
		$.getJSON('/include/ajax/dorunner.php?' + type + '_id=' + value_id, function(data) {
			html = '<option value="0">' + (type == 'category' ? 'Välj underkategori' : 'Välj kommun') + '</option>'; 
			
			html += '<option value="0" disabled="disabled"></option>';
			
			counter = 0;
			
			$.each(data, function(id, name) {
				html += '<option value="' + id + '">' + name + '</option>';
				counter = 1;
			});
			
			if (counter > 0) {
				$('#dr_sub_' + type).html(html).attr('disabled', '');
			} else {
				$('#dr_sub_' + type).html('<option value="0">Finns inga ' + (type == 'category' ? 'underkategorier' : 'kommuner')).attr('disabled', 'disabled');	
			}			
		});
	} else {
		html = '<option value="0">Välj ' + (type == 'category' ? 'en huvudkategori' : 'ett län') + ' först</option>';
		$('#dr_sub_' + type).html(html).attr('disabled', 'disabled');
	}
}

submitDoRunner = function() {
	var errors = [];
		
	if ($('#dr_category :selected').val() < 1) {
		errors.push('Du måste ange en huvudkategori');
	}
	
	if ($('#dr_sub_category :selected').val() < 1 && !$('#dr_sub_category').attr('disabled')) {
		errors.push('Du måste ange en underkategori');
	}
	
	if ($('#dr_region :selected').val() < 1) {
		errors.push('Du måste ange ett län');
	}
	
	if ($('#dr_sub_region :selected').val() < 1 && !$('#dr_sub_region').attr('disabled')) {
		errors.push('Du måste ange en kommun');
	}
	
	if ($('#dr_description').val().length < 1) {
		errors.push('Du måste skriva en beskrivning');
	}
	
	if ($('#dr_name').val() == '') {
		errors.push('Du måste ange ditt namn');
	}
	
	if ($('#dr_email').val() == '') {
		errors.push('Du måste ange din e-post');
	} else {
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		
		if (!emailReg.test($('#dr_email').val())) {
			errors.push('Du har angett en felaktig e-postadress');
		}
	}
		
	if ($('#dr_phone').val() == '') {
		errors.push('Du måste ange ditt telefonnummer');
	}
		
	if (errors.length == 0) {
		topLayer({ title : 'Din offertförfrågan skickas', message : 'Din offertförfrågan skickas just nu till Dorunner.se, var god vänta...' });
		
		$.ajax({
			url : '/include/ajax/dorunner.php',
			dataType : 'json',
			async : false,
			type : 'POST',
			
			data: ({
				submit : 1,
				category : $('#dr_category :selected').val(),
				sub_category : $('#dr_sub_category :selected').val(),
				region : $('#dr_region :selected').val(),
				sub_region : $('#dr_sub_region :selected').val(),
				description : $('#dr_description').val(),
				pricerange : $('#dr_pricerange :selected').val(),
				timespan : $('#dr_timespan :selected').val(),
				buyertype : $('#dr_buyertype :selected').val(),
				recurring : $('#dr_recurring :selected').val(),
				name : $('#dr_name').val(),
				email : $('#dr_email').val(),
				phone : $('#dr_phone').val()
			}),
			
			complete: function(data) {
				closeTopLayer();
								
				var response = $.evalJSON(data.responseText);
								
				if (response.id > 0) {
					topLayer({ title : 'Din offertförfrågan har skickats', message : 'Din offertförfrågan har nu skickats till Dorunner.se' });
					
					// Clean the form
					$.each($('#dorunner :input'), function(i, o) {
						$(o).val('');
					});
					
					$('#dr_sub_category').html('<option value="0">Välj en huvudkategori först</option>').attr('disabled', 'disabled');
					$('#dr_sub_region').html('<option value="0">Välj ett län först</option>').attr('disabled', 'disabled');
				} else {
					topLayer({ title : 'Felmeddelande', message : 'Det uppstod något fel när offertförfrågan skickades.<br /><br />Stäng detta fönster och testa att skicka igen', html : true });
				}
			}
		});
	} else {
		topLayer({ title : 'Felmeddelande', message : 'Du måste fixa följande fel innan du kan skicka offertförfrågan' + '<ul style="margin: 10px 0 0 15px;"><li>' + errors.join('</li><li>') + '</li></ul>', html : true });
	}
}


/*function clck(linkobject, ad_click_type, ppc, adtype, paying, company) {
	obj = $(linkobject);
	
	td = $(obj.parent('td'));
	td.addClass('no-click');
		
	trck(linkobject, ad_click_type, ppc, adtype, paying, company);
	
	setTimeout(function() {
		window.open(obj.attr('href'));
		
		$('table.classifieds td').removeClass('no-click');
	}, 100);
	
	return false;
}*/


/**
*	Track event with Google Analytics
*/

function trck(linkobject, ad_click_type, ppc, adtype, paying, company) {
	if (adtype == 1) {
		_gaq.push(['_trackEvent', 'external', 'kelkoo', current_categoryname]);

		//if (current_category_id > 0) {
		//	_gaq.push(['_trackEvent', 'kelkoo', 'category', current_categoryname]);
		//}
	// If its not adsense, then go ahead and track
	} else if (adtype != 3) {
		if (ad_click_type == 'payperclick') {
			//if (ppc == 1) {
				//_gaq.push(['_trackEvent', 'payperclick', company, 'ppc']);
				//_gaq.push(['_trackEvent', 'external', company, 'ppc']);
			//} else {
				//_gaq.push(['_trackEvent', 'payperclick', company]);
				_gaq.push(['_trackEvent', 'external', company, 'paying']);
			//}
		} else {
			//if (ppc == 1) {
			//	_gaq.push(['_trackEvent', ad_click_type, company, 'ppc']);
			//} else {
				_gaq.push(['_trackEvent', ad_click_type, company]);
			//}
		}
	
		//if (ad_click_type == 'payperclick' && current_categoryname != '') {
		//	_gaq.push(['_trackEvent', 'payperclick-categories', current_categoryname]);
		//}
	}
	
	var theiframe = document.getElementById('right-bnr');
	
	if(theiframe) {
		theiframe.src = theiframe.src;
	}
	
	return true;
	
	/*if(linkobject) {
		
		var url = linkobject.href;
		
		if (!stristr(url, '/203track.php?url=')) {
			if(adtype == 4) {
				linkobject.href = '/203track.php?url=' + escape(url) + '&atid=' + adtype + '&company=' + company;
			}else{
				linkobject.href = '/203track.php?url=' + escape(url) + '&atid=' + adtype;
			}
		}
	}*/
}


/**
*	Google Analytics Tracking Code
*/

var _gaq = _gaq || [];


_gaq.push(['_setAccount', google_analytics[0]]);

if (typeof current_keyword != 'undefined') {
	_gaq.push(['_setCustomVar', 1, 'views-searches', current_keyword]);
}

if (typeof current_categoryname != 'undefined') {
	_gaq.push(['_setCustomVar', 2, 'views-categories', current_categoryname]);
}

if (typeof current_hitlist != 'undefined') {
	_gaq.push(['_setCustomVar', 3, 'views-hitlist', current_hitlist]);
}

if (typeof current_head_category != 'undefined') {
	_gaq.push(['_setCustomVar', 4, 'views-head-categories', current_head_category]);
}

//_gaq.push(['_setDomainName', 'www.allaannonser.se']);
_gaq.push(['_setDomainName', 'allaannonser.se']);
_gaq.push(['_addIgnoredRef', 'allaannonser.se']);
_gaq.push(['_trackPageview']);

/*if (google_analytics.length == 2) {
	_gaq.push(['secondTracker._setAccount', google_analytics[1]]); 
	_gaq.push(['secondTracker._setDomainName', '.allaannonser.se']);
	_gaq.push(['secondTracker._trackPageview']);
}*/


(function() {
	var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
