$(document).ready(function(){
	var zaehler = 1;
	var trialtypes = /\/(products\/personal\/titanium-product-selector)/i;
		$('a').each(function(){
			var href = $(this).attr('href');
			if(href != undefined) {
				if (href.match(trialtypes)){

					var klasse = 'link_select';
					$(this).addClass(klasse);
					zaehler++;
					if (!($.browser.msie && $.browser.version<=7)) {
						$('.'+klasse).colorbox({width:"1000px", height:"700px", iframe:true});
					} else {
						$('.'+klasse).colorbox({width:"1050px", height:"750px", iframe:true});
					}
				}
			}
		});
	var zaehler1 = 1;
	/*
    var trialtypes1 = /\/(products\/personal\/trial)\//i;
		$('a').each(function(){
			var href1 = $(this).attr('href');
			if(href1 != undefined) {
				if (href1.match(trialtypes1)){

					var klasse1 = 'link'+zaehler1;
					$(this).addClass(klasse1);
					zaehler1++;
					
					var filePath_Array = [];
					var filePath = href1.replace(/^https?\:\/\/(de|fr|emea|it|es|uk|ru)\.trendmicro\.com/i, '');
					filePath_Array = filePath.split("/");
					$(this).attr('href', '/'+filePath_Array[1]+'/sso/customerForm.php?product='+getUrlVars(href1)["product"]);
					
					if (!($.browser.msie && $.browser.version<=7)) {
						$('.'+klasse1).colorbox({width:"950px", height:"620px", iframe:true});
					} else {
						$('.'+klasse1).colorbox({width:"1000px", height:"670px", iframe:true});
					}
				}
			}
		});*/
	
	var zaehler2 = 1;
	var trialtypes2 = /\/(newsletter\.php)/i;
		$('a').each(function(){
			var href2 = $(this).attr('href');
			if(href2 != undefined) {
				if (href2.match(trialtypes2)){

					var klasse2 = 'newsletter'+zaehler1;
					$(this).addClass(klasse2);
					zaehler2++;
					if (!($.browser.msie && $.browser.version<=7)) {
						$('.'+klasse2).colorbox({width:"300px", height:"220px", iframe:true});
					} else {
						$('.'+klasse2).colorbox({width:"310px", height:"230px", iframe:true});
					}
				}
			}
		});
		
	if ($('#countrySelect').length) {	
		var currUrl = window.location.href;
		var href2 = $('#countrySelect').attr('href');
		
		var filePath2 = href2.replace(/^https?\:\/\/(de|fr|emea|it|es|uk|ru)\.trendmicro\.com\/emea\//i, '');
		var filePath3 = currUrl.replace(/^https?\:\/\/(imperia|de|fr|emea|it|es|uk|ru)\.trendmicro(|-europe)\.com/i, '');
		
		var filePath_Array2 = [];
		filePath_Array2 = filePath2.split("/");
		
		var filePath_Array3 = [];
		filePath_Array3 = filePath3.split("/");
			
		$('#countrySelect').attr('href', '/'+filePath_Array3[1]+'/'+filePath2);
		if (!($.browser.msie && $.browser.version<=7)) { 
			$('#countrySelect').colorbox({width:"620px", height:"270px", iframe:true}); 
		} else { 
			$('#countrySelect').colorbox({width:"670px", height:"320px", iframe:true});
		} 
	}
	if ($("a.callbackBox").length) {
		$("a.callbackBox").fancybox({ 'titleShow': false, 'width':495, 'height':420, 'type': 'iframe'});
	}			
});


function getUrlVars(ref) {
	var vars = {};
	var parts = ref.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
		vars[key] = value;
	});
	return vars;
}
