/* ../../js/omniture_head.js */
/*	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 = 'Rentenservice'
}

;(function($){
	// establish tracking on head elements

	// 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;
	});
	
	// STARTSEITE

	$('a.eVar44').click(function(e) {
		e.preventDefault();
		var t = $(this)
		,	linkid = t.attr('id') || 'Link ID nicht gesetzt'
		,	href = t.attr('href')
		,	chainsign = (href.search(/\?.+=/) != '-1') ? '&' : '?'
		,	wpmsc = s_gi(s_account);
	
		// set tracking values
		wpmsc.prop41 = wpmsc.eVar44 = linkid;
		
		// setup tracking vars
		wpmsc.linkTrackVars = wpmsc.linkTrackVars+',prop41,eVar44';
		
		// submit tracking values
		wpmsc.tl(this,'e', $(this).text());
		
		//call location (probably enhanced with 'did' param)
		location.href = href;
	});
	
	// AUSWAHLSEITE
		
	$('a.eVar45').click(function(e) {
		e.preventDefault();
		var t = $(this)
		,	linkid = t.attr('id') || 'Link ID nicht gesetzt'
		,	href = t.attr('href')
		,	chainsign = (href.search(/\?.+=/) != '-1') ? '&' : '?'
		,	wpmsc = s_gi(s_account);
	
		// set tracking values
		wpmsc.prop42 = wpmsc.eVar45 = linkid;
		
		// setup tracking vars
		wpmsc.linkTrackVars = wpmsc.linkTrackVars+',prop42,eVar45';

		// submit tracking values
		wpmsc.tl(this,'e', $(this).text());
		
		//call location (probably enhanced with 'did' param)
		location.href = href;
	});
	
	// TOGGLE BOX 
	
	$('h3.rs_toggle-handle_js').click(function() {
		var t = $(this)
		,	linkid = t.attr('id') || 'Link ID nicht gesetzt'
		,	wpmsc = s_gi(s_account);
		if(!$(this).parents('li').hasClass('rs_toggle-active_js')) {
			// set tracking values
			wpmsc.prop42 = wpmsc.eVar45 = linkid;
			
			// setup tracking vars
			wpmsc.linkTrackVars = wpmsc.linkTrackVars+',prop42,eVar45';

			// submit tracking values
			wpmsc.tl(this,'e', $(this).text());
		}
	});
	
	// AENDERUNGS BOX 
	
	$('#rs_changemessages-box button').click(function(e){
		e.preventDefault();
		
		var t = $(this).parent('form')
		,	linkid = $(this).attr('id') || 'Link ID nicht gesetzt'
		,	s = s_gi(s_account);
		
		// set tracking values
		wpmsc.prop42 = wpmsc.eVar45 = linkid;

		// setup tracking vars
		wpmsc.linkTrackVars = wpmsc.linkTrackVars+',prop42,eVar45';
		
		// submit tracking values
		wpmsc.tl(this,'o','form submit');
		
		// submit form
		t.submit();
	});
	
	// TIPPS UND SERVICES

	$('a.eVar46').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.prop43 = wpmsc.eVar46 = linkid;
		
		// setup tracking vars
		wpmsc.linkTrackVars = wpmsc.linkTrackVars+',prop43,eVar46';
		
		// submit tracking values
		wpmsc.tl(this,'e', $(this).text());
		
		//call location (probably enhanced with 'did' param)
		location.href = href;
	});
	
	// NEWSLETTER
	
	$('#rs_newsletter-abo button').click(function(e){
		e.preventDefault();
		
		var t = $(this).parent('form')
		,	linkid = $(this).attr('id') || 'Link ID nicht gesetzt'
		,	wpmsc = s_gi(s_account);
		
		// set tracking values
		wpmsc.events = "event2";
		wpmsc.prop43 = wpmsc.eVar46 = linkid;

		// setup tracking vars and events
		wpmsc.linkTrackVars = wpmsc.linkTrackVars+',prop43,eVar46,events';
		wpmsc.linkTrackEvents = "event2";

		// validate the form then submit tracking and form
		if( validateNLSubscription(t) ) {		
			// submit tracking values
			wpmsc.tl(this,'o','form submit');
			
			// submit form
			t.submit();
		}
	});
})(jQuery);
