// ==UserScript==
// @namespace     http://riddle.pl/-/greasemonkey/google-services.user.js
// @name          Google Services Top Panel
// @author        Piotr Petrus
// @description   http://riddle.pl
// @description   Adds topbar with links to Google Services.
// @description   Doesnt work on GMail and pages with "&" sign 
// @description   (iframes mainly - script doesn't add multiple bars to page).
// @include       http*://*google.*
// @include       http*://*.google.com/*
// @exclude       http*://*mail.google.com/*mail/*
// @date          2006-03-08
// @version       0.1
// @GM_version    0.6.4

// ==/UserScript==

var win = window.location.href;

if ((win.indexOf("&") == -1) && (win.indexOf("adfetch") == -1)) {

var firstElem = document.body.getElementsByTagName("*")[0]; //first element node in body
var panel = document.createElement("div");

with (panel.style) {
	backgroundColor = "#E5ECF9";
	borderBottom = "1px solid #3366CC"
	font = "normal 11px Arial, sans-serif";
	color = "#000";
	position = "absolute";
	width = "100%";
	left = "0";
	top = "0";
	height = "15px";
	padding = "2px 0";
	textIndent = "10px";
}

var ginfo = document.getElementById("global-info");
if (ginfo) {
	ginfo.style.top = "20px;"
	ginfo.style.fontSize = "10px;"
}

var ginfovid = document.getElementsByTagName('iframe')[0];
if (ginfovid) {
	ginfovid.style.marginTop = "27px";
}

var space = document.createElement("div");
space.appendChild(document.createTextNode("PANEL"));

with (space.style) {
	height = "1px";
	marginTop = "35px";
	overflow = "hidden";
	color = "transparent";
}

function linkOver(event) {
	this.style.color = "#008";
	this.style.textDecoration = "underline";
	event.preventDefault();
}

function linkOut(event) {
	this.style.color = "#000";
	this.style.textDecoration = "none";
	event.preventDefault();
}

function createLink(desc,service) {
	var link = document.createElement("a");
	link.appendChild(document.createTextNode(desc));
	link.href = service;
	link.style.color = "#000";
	link.style.textDecoration = "none";
	link.style.marginRight = "10px";
	link.addEventListener('mouseover', linkOver, true);
	link.addEventListener('mouseout', linkOut, true);
	return link;
}

panel.appendChild(createLink('[Account]','https://google.com/accounts/ManageAccount'));
panel.appendChild(createLink('Answers','http://answers.google.com'));
panel.appendChild(createLink('Base','base.google.com'));
panel.appendChild(createLink('Blogs','http://blogsearch.google.com'));
panel.appendChild(createLink('Books','http://books.google.com'));
panel.appendChild(createLink('Code','http://code.google.com'));
panel.appendChild(createLink('Froogle','http://froogle.google.com'));
panel.appendChild(createLink('Groups','http://groups.google.com'));
panel.appendChild(createLink('Labs','http://labs.google.com'));
panel.appendChild(createLink('Mail','http://gmail.google.com'));
panel.appendChild(createLink('Maps','http://maps.google.com'));
panel.appendChild(createLink('Mobile','http://mobile.google.com'));
panel.appendChild(createLink('News','http://news.google.com'));
panel.appendChild(createLink('Reader','http://reader.google.com'));
panel.appendChild(createLink('Search','http://google.com'));
panel.appendChild(createLink('Search [PL]','http://google.pl'));
panel.appendChild(createLink('SMS','http://sms.google.com'));
panel.appendChild(createLink('Video','http://video.google.com'));

firstElem.parentNode.insertBefore(panel,firstElem);
firstElem.parentNode.insertBefore(space,firstElem);

}
