$.noConflict();
jQuery('document').ready(function($){
	$('.ajo-ohje a:first').click(function(event){
	    event.preventDefault();
	    var tunnus=$(this).attr('href').split('tpid=')[1];
	    if(tunnus=="") var tunnus=$(this).attr('href').split('tpid=')[1];
   	    var lang=window.location.pathname.split('/')[1];
	    if(lang=="en" || lang=="ee" || lang=="ru") var locale='en-US';
	    else if(lang=="se") var locale='sv-SE';
	    else locale="fi-FI";

	    if(tunnus==undefined) {
	  	  //var tunnus = $(this).attr('href').match(/focus=([0-9]{1,20})&/)[1];
	  	  var url = $(this).attr('href');
	 	  var w = window.open(url,"","location=0,status=0,scrollbars=0,width=995,height=623");
	    }
	    else {
	      var w = window.open("http://karttapalvelu.s-kanava.net/kartta/map.html?tpid="+tunnus+"&locale="+locale,"","location=0,status=0,scrollbars=0,width=995,height=623");
	    }
	    w.focus();
	    return false;
	});
	
	$.get('fileadmin/template/datetime.php', function(data){
		if(data==1){ 
			var lang=window.location.pathname.split('/')[1];
			if(lang=='en') $('#booking_box').html('<img src="fileadmin/template/kuvat/huoltokatko_eng_uusi.jpg" style="padding-bottom: 60px;" />');
			else if(lang=='se') $('#booking_box').html('<img src="fileadmin/template/kuvat/huoltokatko_sv_uusi.jpg" style="padding-bottom: 60px;" />');
			else if(lang=='ru') $('#booking_box').html('<img src="fileadmin/template/kuvat/huoltokatko_ru_uusi.jpg" style="padding-bottom: 60px;" />');
			else $('#booking_box').html('<img src="fileadmin/template/kuvat/huoltokatko_uusi.jpg" style="padding-bottom: 60px;" />');
		}
	}); 
	
	$.get('http://www.sokoshotels.fi/fileadmin/template/popup/setcookie.php', function(data){
		if(data!='true'){
			$('#popup').css({
				'top':jQuery(window).height()/2-parseInt($('#popup').height())/2+'px',
				'left':jQuery(window).width()/2-parseInt($('#popup').width())/2+'px',
				'z-index':'100000'
			});
			
			$('#popup').show();
			
			$(window).bind('resize', function(){
				$('#popup').css({
					'top':jQuery(window).height()/2-parseInt($('#popup').height())/2+'px',
					'left':jQuery(window).width()/2-parseInt($('#popup').width())/2+'px',
					'z-index':'100000'
				});
			});
		}
	});
});
