goog.provide('tommed.header')
goog.require('goog.dom')
var STATIC_URL = "http://static.tommed.co.uk"

tommed.header.create = function(canvasElement, isSimple) {
  canvasElement.style.height = "141px"
  canvasElement.style.minWidth = "650px"
  canvasElement.style.position = "relative"
  canvasElement.style.backgroundImage = "url("+STATIC_URL+"/images/tommed-bg-repeat.jpg)"

  var title = goog.dom.createDom('img', {src:STATIC_URL+'/images/tommed-bg-logo.png'}, '')
  canvasElement.appendChild(title)

  var rightPattern = goog.dom.createDom('img', {src:STATIC_URL+'/images/tommed-bg-right.png', style:'float:right'}, '')
  canvasElement.appendChild(rightPattern)

  var socialList = goog.dom.createDom('ul', {style:'position:absolute;top:10px;right:10px;list-style:none'}, [
	goog.dom.createDom('li', {style:'float:left'}, [
	  	goog.dom.createDom('a', {href:'http://blog.tommed.co.uk/articles.rss'}, [
			goog.dom.createDom('img', {src:STATIC_URL+'/images/RSS.png', style:'border:0'}, '')
		])
	]),
	goog.dom.createDom('li', {style:'float:left'}, [
	  	goog.dom.createDom('a', {href:'http://twitter.com/tmedhurst'}, [
			goog.dom.createDom('img', {src:STATIC_URL+'/images/Twitter.png', style:'border:0'}, '')
		])
	]),
	goog.dom.createDom('li', {style:'float:left'}, [
	  	goog.dom.createDom('a', {href:"javascript:(function(){f='http://delicious.com/save?url='+encodeURIComponent(window.location.href)+'&title='+encodeURIComponent(document.title)+'&v=5&';a=function(){if(!window.open(f+'noui=1&jump=doclose','deliciousuiv5','location=yes,links=no,scrollbars=no,toolbar=no,width=550,height=550'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()"}, [
			goog.dom.createDom('img', {src:STATIC_URL+'/images/Delicious.png', style:'border:0'}, '')
		])
	])		 
  ])
  canvasElement.appendChild(socialList)


  if (isSimple) {
    tommed.header.createCSSLink()
  }
}

tommed.header.skin = function(header) {
  header.style.backgroundImage = "url(http://static.tommed.co.uk/images/tommed-bg-repeat.jpg)"
  header.style.backgroundRepeat = "repeat-x"
  header.style.height = "141px"
  header.style.padding = "0px"

  var title = goog.dom.createDom('img', {src:'http://static.tommed.co.uk/images/tommed-bg-logo.png'}, '')
  header.appendChild(title)
}

tommed.header.createCSSLink = function() {
  var head = document.getElementsByTagName("head")[0]
  head.appendChild(goog.dom.createDom('link', {rel:"stylesheet", href:"http://static.tommed.co.uk/css/tommed.css"}, ''))
}

