var lang = "ro";

var url = window.top.location.toString();
var pageHash = unescape(self.document.location.hash.substring(1));

var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
var IE7 = false /*@cc_on || @_jscript_version == 5.7 @*/;
var isMSIE = /*@cc_on!@*/false;
try {document.execCommand("BackgroundImageCache", false, true);} catch(err) {}

//This function is used to put a unique number at the end of each ajax call to prevent ie from caching it.
var nocache = function(url) {
	var rand = Math.floor(Math.random()*8999999999)+1000000000;
	url = url + (url.indexOf("?") == -1?'?nocache=':'&nocache=') + rand;
	return url;
};


$(function(){
	//	site succesfully loaded ...
	$('body').addClass('site');

	//	css dimensions
	var w = $(window).width();
	var h = $(window).height();
		
	//	disable caching of AJAX responses
	$.ajaxSetup ({
		cache: false
	});
	
	//	do nothing on no href
	$('a[href="#"]').click(function(){ return false; }); 

	//	sets links with the rel of "blank" to open in a new window
	$('a[rel$="blank"]').attr('target', '_blank'); 
	
	//	printing articles
	$('.printing').bind('click', function(){
		window.print();
		return false;
	});
	
	//	animated scrolling for same page links
	$('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body').animate({scrollTop: targetOffset}, 1000);
				return false;
			}
		}
	});
	
	//	language selector
	if( $('.ls').length > 0 ) {
		var A = $('.ls');
		var B = $('ul:first', A);
		var C = $('.selector span', A);
		
        C.click(function () {
			$(this).toggleClass('active');
			B.toggleClass('active');
			return false;
		})
	}
	
	//	newsletter & contact form validation
	if( $('form').length > 0 ){
		var D = $('form');
		
		D.each(function(){
			$(this).validate({errorElement:'span'});
		})
	}

	//	homepage slider
	if( $('.slider', '.mainbar').length > 0  ){
		var E = $('.slider', '.mainbar');
		var F = $('.timeout', E);
		if(!E.hasClass('first'))
			E.slideshow({
				timeout: (F.text() * 1000),
				type: 'random'
			});
	}

	// hotel tabs
	if( $('.tabbed', '.mainbar').length > 0  ){
		$('.tabbed', '.mainbar').menutabs();
	}

	//	photo enlargement =))
	if( $('a[rel="colorbox"]').length > 0 ) {
		$('a[rel="colorbox"]').colorbox(
			{	slideshow:true, 
				transition:"elastic", 
				opacity: 0.75, 
				current: '{current} din {total} ',
				slideshowStart: 'porneste slideshow', 
				slideshowStop: 'opreste slideshow',
				previous: 'Precedenta',
				next: 'Urmatoarea',
				close: 'Inchide'
			}
		);
	}

});
