function WriteEmail(user, dom, tld) {
	m = user+"@"+dom+"."+tld;
	$('span#email').html('<a href="mailto:'+m+'">'+m+'</a>');
}

function openEvent(id) {
	window.location = "?pg=det&lang="+lang+"&id="+id;
}

function download(orderid, t) {
	window.location.href = "modules/download.tickets.php?i="+orderid+"&t="+t;
}

var is_mobile = false;

function gotoDetails(id, lang) {
	redir_url = (!is_mobile) ? "../entered.php?pg=det&lang="+lang+"&id="+id : "../mobile/?t=det&l="+lang+"&i="+id;
	setTimeout("window.location.href = redir_url", 5000);
}

function gotoFac(id, lang, target) {
	redir_url = (!is_mobile) ? "../entered.php?pg=fac&lang="+lang+"&order="+id : "../mobile/?t=fac&l="+lang+"&i="+id;
	if (target == undefined)
		window.location.href = redir_url;
	else
		target.window.location.href = redir_url;
}

function ShowCompat() {
	h = '<table width="400" height="120">';
		h += '<tr>';
			h += '<td align="center"><img src="images/firefox.png" height="64" /><br/>Firefox 5</td>';
			h += '<td align="center"><img src="images/IE.png" height="64" /><br/>IE 9</td>';
			h += '<td align="center"><img src="images/Safari.png" height="64" /><br/>Safari 5</td>';
			h += '<td align="center"><img src="images/chrome.png" height="64" /><br/>Chrome 12</td>';
			h += '<td align="center"><img src="images/opera.png" height="64" /><br/>Opera 11</td>';
		h += '</tr>';
	h += '</table>';
	$.fancybox("Tested with:<br/>"+h, {
		'centerOnScroll': true
	});
}

function ChangeDOM() {
	$(document).ready(function(){
		$(".tixTblView tr").slice(1).hover(
			function() { $(this).addClass('tix_hover') },
			function() { $(this).removeClass('tix_hover') }
		);
		$('a.buy').fancybox({
			'centerOnScroll': true,
			'hideOnOverlayClick': false,
			'hideOnContentClick': false,
			'enableEscapeButton': true,
			'width': 710,
			'height': 700,
			'autoDimensions': false,
			'type': 'iframe'
		});
		$('a.mainnav').hover(
			function() { $('#navtext').html("----- " + $(this).attr("data-title") + " -----"); },
			function() { $('#navtext').html(''); }
		);
		$(window).keydown(function(e){
			SetWindowScroll(e, 150, {
				easing: 'swing',
				axis: 'y'
			});
		});
		$(window).scroll(function(){
			start_scroll = 100;
			if ($(this).scrollTop() > start_scroll) {
				new_topmargin = $(this).scrollTop() - start_scroll + 10;
				$('.sideelements').stop().animate({
					"marginTop": new_topmargin+"px"
				}, 1500);
			}
			else {
				$('.sideelements').stop().animate({
					"marginTop": "0px"
				});
			}
		});
	});
}

function checkIt(string){
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

function clickCheckbox() {
	if ($('#check_sms').attr('checked')) {
		insertMobile();
		updateMobile('');
	}
	else {
		deleteMobile();
		$('#check_sms').val(0);
	}
}

function insertMobile() {
	$('#tr_mobile').show(0);
	control = 0;
}

function updateMobile(val) {
	$('#mobileNbr').val(val);
}

function deleteMobile() {
	$('#tr_mobile').hide(0);
	control = 1;
}

function SetWindowScroll(e, speed, options) {
	evt = e || window.event;
	kc = evt.keyCode;
	if (kc == 40) { // down key
		evt.preventDefault();
		$.scrollTo('+=100px', speed, options);
	}
	else if (kc == 38) { // up key
		evt.preventDefault();
		$.scrollTo('-=100px', speed, options);
	}
	else if (kc == 34) { // pg down key
		evt.preventDefault();
		$.scrollTo('+=600px', speed, options);
	}
	else if (kc == 33) { // pg up key
		evt.preventDefault();
		$.scrollTo('-=600px', speed, options);
	}
}

function OpenPress(id, lang) {
	$.fancybox({
		centerOnScroll: true,
		autoDimensions: true,
		href: "modules/press.php?i="+id+"&l="+lang,
		type: "ajax"
	});
}

function WarnCookie() {
	txt = 'Please note that NO COOKIE could be set. Please recheck your browser configuration, without cookies this site will not work properly.';
	cookie = document.cookie.split("; ");
	if (cookie[0] != "cookies=1") { 
		$.jGrowl('<center><img src="/v2/images/messagebox_warning.png" /></center><br/>'+txt, { life: 3000, sticky: true });
	}
}
