// setCSLoginTrackExt
jQuery.fn.setCSLoginTrackExt= function(e) {
		var oLink=$(this).attr('href');
		if(oLink) {
			var aGetLoginLink=oLink.match(/^(.*)(config.stratoserver.net)(\S*)\s*(.*)$/);
			if(aGetLoginLink) {
				$(this).click( function(event) {
					var emosproKSBLogin={};
					emosproKSBLogin.content='PRO-STRATO/Track-Marker';
					emosproKSBLogin.siteid='www.strato-pro.de';
					emosproKSBLogin.marker='PRO-STRATO/CSLogin'+oVar['path']+oVar['file_index'];
					if(typeof(window.emosPropertiesEvent)=='function') {
						window.emosPropertiesEvent(emosproKSBLogin);
					}
				});
			}
		}
	};

// setOrderTrackExt - bezieht sich auf klassische Anchor mit href
jQuery.fn.setOrderTrackExt= function(e) {
		var oLink=$(this).attr('href');
		var date = new Date();
		var billing_id_fake = date.getTime()+"_"+Math.random();

		if(oLink) {
			var aGetOrderLink=oLink.match(/^(.*)(strato.de\/ordering)(\S*)\s*(.*)$/);
			var checkProduct=new RegExp("Product=([^&]+)","i");
			var checkGroup=new RegExp("Group=([^&]+)","i");
			var checkCategory=new RegExp("Category=([^&]+)","i");
			var aGetProduct=checkProduct.exec(oLink);
			var aGetGroup=checkGroup.exec(oLink);
			var aGetCategory=checkCategory.exec(oLink);
			var oTargetGroup='';
			var oTarget='';
			if(aGetProduct&&aGetProduct[0]&&aGetProduct[1]) {
				var sSetProduct=aGetProduct[1];
			}
			if(aGetGroup&&aGetGroup[0]&&aGetGroup[1]) {
				var sSetGroup=aGetGroup[1];
			}
			if(aGetCategory&&aGetCategory[0]&&aGetCategory[1]) {
				var sSetCategory=aGetCategory[1];
			}
			if(sSetCategory&&sSetGroup&&sSetProduct) {
				oTargetGroup='Category:_'+sSetCategory;
				oTarget='Product:_'+sSetProduct;
			}
			if(sSetCategory&&sSetGroup&&!sSetProduct) {
				oTargetGroup='Category:_'+sSetCategory;
				oTarget='Group:_'+sSetGroup;
			}
			if(!sSetCategory&&!sSetGroup&&!sSetProduct) {
				oTargetGroup='Category:_undefined';
				oTarget='GroupProduct:_undefined';
			}
			if(aGetOrderLink) {
				$(this).click( function(e) {
					var emosproOrder={};
					emosproOrder.content='PRO-STRATO/Track-Marker-Ziele';
					emosproOrder.siteid='www.strato-pro.de';
					emosproOrder.marker='PRO-STRATO/Order-'+oTargetGroup+'/'+oTarget;
					emosproOrder.Target='PRO-STRATO/Order-'+oTargetGroup+'/'+oTarget;
					emosproOrder.billing = [[billing_id_fake,'NULL','DE','NULL']];
					emosproOrder.ec_Event = [['c_add',sSetProduct,sSetProduct,'NULL',sSetCategory+'/'+sSetGroup+'/'+sSetProduct+oVar['path']+oVar['file_index'],'1','NULL','NULL','NULL']];
					var emosproOrderPage={};
					emosproOrderPage.content='PRO-STRATO/Track-Marker-Ziele';
					emosproOrderPage.siteid='www.strato-pro.de';
					emosproOrderPage.marker='PRO-STRATO/OrderPage'+oVar['path']+oVar['file_index']+'/'+oTargetGroup+'/'+oTarget;
					emosproOrderPage.Target='PRO-STRATO/OrderPage'+oVar['path']+oVar['file_index'];
					if(typeof(window.emosPropertiesEvent)=='function') {
						window.emosPropertiesEvent(emosproOrder);
						window.emosPropertiesEvent(emosproOrderPage);
					}
				});
			}
		}
	};// setOrderTrackExt 

// OrderTrack - bezieht sich auf Uebergabe einer Bestell-URL (redirect-ordering)
jQuery.fn.OrderTrack= function(orderURL) {
	
		var date = new Date();
		var billing_id_fake = date.getTime()+"_"+Math.random();

		if(orderURL !== undefined) {
			var aGetOrderLink=orderURL.match(/^(.*)(strato.de\/ordering)(\S*)\s*(.*)$/);
			var aGetProduct= new RegExp("Product=([^&]+)","i").exec(orderURL);
			var aGetGroup= new RegExp("Group=([^&]+)","i").exec(orderURL);
			var aGetCategory= new RegExp("Category=([^&]+)","i").exec(orderURL);
			
			var oTargetGroup='';
			var oTarget='';
			
			if(aGetProduct&&aGetProduct[0]&&aGetProduct[1]) {
				var sSetProduct=aGetProduct[1];
			}
			if(aGetGroup&&aGetGroup[0]&&aGetGroup[1]) {
				var sSetGroup=aGetGroup[1];
			}
			if(aGetCategory&&aGetCategory[0]&&aGetCategory[1]) {
				var sSetCategory=aGetCategory[1];
			}
			if(sSetCategory&&sSetGroup&&sSetProduct) {
				oTargetGroup='Category:_'+sSetCategory;
				oTarget='Product:_'+sSetProduct;
			}
			if(sSetCategory&&sSetGroup&&!sSetProduct) {
				oTargetGroup='Category:_'+sSetCategory;
				oTarget='Group:_'+sSetGroup;
			}
			if(!sSetCategory&&!sSetGroup&&!sSetProduct) {
				oTargetGroup='Category:_undefined';
				oTarget='GroupProduct:_undefined';
			}
			if(aGetOrderLink !== undefined && aGetOrderLink !== null) {
					var emosproOrder={};
					emosproOrder.content='PRO-STRATO/Track-Marker-Ziele';
					emosproOrder.siteid='www.strato-pro.de';
					emosproOrder.marker='PRO-STRATO/Order-'+oTargetGroup+'/'+oTarget;
					emosproOrder.Target='PRO-STRATO/Order-'+oTargetGroup+'/'+oTarget;
					emosproOrder.billing = [[billing_id_fake,'NULL','DE','NULL']];
					emosproOrder.ec_Event = [['c_add',sSetProduct,sSetProduct,'NULL',sSetCategory+'/'+sSetGroup+'/'+sSetProduct+oVar['path']+oVar['file_index'],'1','NULL','NULL','NULL']];
					var emosproOrderPage={};
					emosproOrderPage.content='PRO-STRATO/Track-Marker-Ziele';
					emosproOrderPage.siteid='www.strato-pro.de';
					emosproOrderPage.marker='PRO-STRATO/OrderPage'+oVar['path']+oVar['file_index']+'/'+oTargetGroup+'/'+oTarget;
					emosproOrderPage.Target='PRO-STRATO/OrderPage'+oVar['path']+oVar['file_index'];
					if(typeof(window.emosPropertiesEvent)=='function') {
						window.emosPropertiesEvent(emosproOrder);
						window.emosPropertiesEvent(emosproOrderPage);
					}
			}
		}
	};// OrderTrack
	
// loadTrackExtern - BEGIN
// benoetigt JQuery Library
// benoetigt Plugin JQuery URL Parser
loadTrackExtern();
	function loadTrackExtern() {
		var aDomains=new Array();
		aDomains[0]='strato-pro.de';
		aDomains[1]='www.strato-pro.de';
		var iDomains_max=aDomains.length;
		for(var iLauf=0;iLauf<iDomains_max;iLauf++) {
			if(aDomains[iLauf]!=oVar['host']) {
			} else {
				window.emosTrackVersion=2;
				var emospro={};
				emospro.content=oVar['path']+oVar['file_index'];
				emospro.pageId='PRO'+oVar['path']+oVar['file_index'];
				emospro.siteid='www.strato-pro.de';
				$.getScript("/imperia/md/content/strato_pro/js/emos2.js").complete( function() {
					window.emosPropertiesEvent(emospro);
					var aAnchorTopNav=$('#topnav').find('a');
					var aAnchor=$('a');
					aAnchor.each( function() {
						$(this).setOrderTrackExt();
					});
					aAnchorTopNav.each( function() {
						$(this).setCSLoginTrackExt();
					});					
					
					if (oVar['path'] === '/redirect-ordering.html'){
						$.getScript("/imperia/md/content/strato_pro/js/module/redirect-ordering.js").complete( function() {
						   $.initRedirectOrdering();
						});
					}
			   });
			}
		}
	}
// loadTrackExtern - END
