/* rev 3228 from ux */
/*	requires jQuery and wpmsc_code.js (delivered wpmsc is just for testing 
 	purposes, prefer your own version!) to be loaded beforehand as well as 
 	setting up the variable s_account. Functionality may be rebuilt with other 
 	js libaries	if necessary.
*/
var omniture_prefix;
if (!omniture_prefix) {
	omniture_prefix = 'PROJECTPREFIX'
}

var omniture_head;
if (!omniture_head) {
	omniture_head = {};
}

$.extend(omniture_head,{
	// establish tracking on head elements
	init: function() {
		// submit button click
		$('#headsuche input.head-submit').click(function(e){
			e.preventDefault()
			
			var t = $(this).parent('form')
			,	linkid = t.attr('id')
			,	phrase = t.find('.head-input').val().toLowerCase()
			,	s = s_gi(s_account);
			
			// set tracking values
			wpmsc.prop15 = wpmsc.eVar11 = linkid;
			wpmsc.prop14 = wpmsc.eVar12 = phrase;

			// setup tracking vars
			s.linkTrackVars = s.linkTrackVars+',prop14,prop15,eVar11,eVar12';
			
			// submit tracking values
			s.tl(this,'o','form submit');

			// submit form
			t.submit();
		})
		
		// link click
		$('#postlogo, .head-nav ul a').click(function(e){
			e.preventDefault()

			var t = $(this)
			,	linkid = t.attr('id') || 'Link ID nicht gesetzt'
			,	href = t.attr('href')
			,	chainsign = (href.search(/\?.+=/) != '-1') ? '&' : '?'
			,	s = s_gi(s_account);


			// set tracking values
			wpmsc.prop15 = wpmsc.eVar11 = linkid;

			// setup tracking vars
			s.linkTrackVars = s.linkTrackVars+',prop15,eVar11';
			
			// submit tracking values
			s.tl(this,'e', $(this).text());
			
			//call location (probably enhanced with 'did' param)
			location.href = href + chainsign + 'did=DP-Header_' + omniture_prefix + '_' + linkid;
		})
	}
})
$(omniture_head.init)
