// JavaScript Document

$j(window).load( function() {
	/*if (getUrlVars()["b"] != undefined) {
		imagew = $j("img.backimg").width();
		imageh = $j("img.backimg").height();
		
		fs(imagew, imageh);
	}*/
});

function fs(w, h) {
	var FullscreenrOptions = {  width: w, height: h, bgID: '.backimg' };
	jQuery.fn.fullscreenr(FullscreenrOptions);	
}
		

$j(document).ajaxSend(function() { loader(true); });
$j(document).ajaxStart(function() { loader(true); });
$j(document).ajaxStop(function() { loader(false); });

$j(window).resize(function() {
	resizeapp();
});

function resizeapp() {
	obj_slider = $j(".slider");
	
	hh = $j("#Header").height();
	fh = $j("#Footer").height();
	dh = $j(document).height();
	
	mh = dh - hh - fh;
	
	$j("#Middle").css( { 'height' : ''+mh+'px' } );
	
	$j("#Middle .container").css( { 'height' : ''+mh-20+'px' } );

	w1 = $j("#Middle .container").height();
	obj_slider.css( { 'margin-top' : ''+(w1-obj_slider.height())/2+'px' } );
	
	ww1 = $j(".slider-control").width() / 2;
	w2 = $j(".slider-control ul").width() / 2;
	
	$j(".slider-control ul").css( { 'left' : ''+ww1-w2+'px' } );
}

$j(document).ready(function() {
	$j("a.circle").draggable( {
		axis:"x", 
		containment: ".slider-control ul", 
		grid: [ 150,0 ],
		zIndex: 2700,
		iframeFix: true,
		stop: function(event, ui) { 
			t = Math.round(ui.position.left / 100); 
			
			switch(t) {
				case 2: $j(".slider-control li.premisses a").trigger('click'); break;
				case 3: $j(".slider-control li.pools a").trigger('click'); break;
				case 5: $j(".slider-control li.restaurant-bar a").trigger('click'); break;
				case 6: $j(".slider-control li.rooms a").trigger('click'); break;
				case 8: $j(".slider-control li.location a").trigger('click'); break;
			}
		}
	});
	

    $j("a.c").mouseover(function(){
		var animSpeed=1200;
		var easeType="swing";		
		
		h_max = 0;
		h_min = $j("img.backimg").height() - $j("#Middle").height();			
		istop = $j(this).hasClass("top");
		
		if (istop) {
			$j("img.backimg").stop().animate({top: h_max}, animSpeed,easeType);
		} else {
			$j("img.backimg").stop().animate({top: -h_min}, animSpeed,easeType);
		}
    }).mouseout(function(){
		$j("img.backimg").stop();
    });
	
	$j(".backimage").simpletip({ content: 'Click to close', fixed: false, offset: [20, -120]  });
	
	$j('img.backimg, a.close1, a.c').live("click", function() {
		if (getUrlVars()["b"] != undefined) {
			history.go(-1);
			return false;
		} else {
			$j(".backimage").fadeOut('fast', function() {
				$j('.slider').fadeIn("fast");
			});
		}
	});
	
	$j(".box .image a").live("click", function() {
		loader(true);
		
		obj_this = $j(this);
		thisimage = obj_this.find("img").attr("src").replace("small.","");
		obj_bi = $j(".backimage");
		
		var img = new Image();
		
		$j(img).load(function () {
			$j(this).addClass("backimg");
			
			temptitle = obj_this.parent().parent().find(".bottom h2").html();
			tempsubtitle = obj_this.parent().parent().find(".bottom div").html();	
			
			obj_bi.find(".title").html(temptitle);
			obj_bi.find(".subtitle div").html(tempsubtitle);		
			obj_bi.find(".i").html($j(this));
			
			image_width = img.width;
			image_height = img.height;
			
			$j('.slider').fadeOut('fast', function() {
				obj_bi.removeClass("hidden");
				obj_bi.fadeIn('fast', function() {
					loader(false);
				});
				
				fs(image_width, image_height);
			});	
        }).attr('src', thisimage);

		return false;
	});
	

	$j("button, input:submit, input:reset, a.close1").button();
	
	$j('.textbody .padd').jScrollPane();
			
	$j(".slider-control ul a").click(function() {
		thisa = $j(this);
		slider = $j("ul.slidermain");
		
		$j(".slider-control li").removeClass("active");
		$j(".slider-content a").addClass("hidden");
											  
		q = $j(this).attr("href");
			
		$j.ajax({
			url: q,
			cache: false,
			success: function(html) {
				if (html != "") {
					slider.html(html);
					
					total = $j("ul.slidermain li").length;
					
					if (total > 1) {
						$j(".sliderx").jCarouselLite({
							btnNext: ".slider .next",
							btnPrev: ".slider .prev",
							visible: 1,
							easing: "easeOutQuad",
							speed: 500,
							circular: false
						});
						
						$j(".slider-content a").removeClass("hidden");
					}
					
					$j("ul.slidermain .box").each(function(intIndex) {
						thisid = $j(this).attr("id");
						Node = document.getElementById(thisid);
						
						function slideritem_show() { $j(this).css({'z-index':'1'}); }
						function slideritem_hide() { $j(this).css({'z-index':'0'}); }
												
						var config = {    
							 over: slideritem_show,   
							 timeout: 500, 
							 out: slideritem_hide    
						};
						
						$j(this).hoverIntent(config);
						
						cbox1 = $j(this).hasClass("box1");
						cbox2 = $j(this).hasClass("box2");
						cbox3 = $j(this).hasClass("box3");
						
						if (cbox2) { deg = "10"; } 
						if (cbox3) { deg = "7"; } 
						
						if (!cbox1) { cssSandpaper.setTransform(Node, "rotate("+deg+"deg)"); } 
						
						cssSandpaper.setBoxShadow(Node, "-1px -1px 10px #dddddd");
					});
				} 
				
				slider.css({ 'left':'0' } );
				thisa.parent().addClass("active");
				
				ind = 190 + (thisa.parent().index() * 150);
				$j("a.circle").stop().animate({left: ind}, 400,"swing");
			}
		});			
		return false;
	});
	
	$j(".slider-control li:first a").trigger('click');
	
	resizeapp();
	
	$j('a.thumb').lightBox({fixedNavigation:true});
	$j("body").append('<div class="loading"></div>')
		
	$j('input[title!=""]').hint();

	/* FORM SUBMIT */
	var walloptions = { 
        beforeSubmit: wall_validate,
        success: wall_success,
        resetForm: true,
        clearForm: true
    }; 
	
	function wall_validate(formData, jqForm) { return $j("#"+jqForm[0].name+"").xvalidate(); }
	function wall_success(responseText) { message("Μήνυμα", responseText); }
	
	$j('#contact, #newsletter').ajaxForm(walloptions); 
	
	/* END OF FORM SUBMIT */
});

function loader(x) { 
	if (x) { $j(".loading").fadeIn("fast"); } else { $j(".loading").fadeOut("fast"); }
}

function getUrlVars() {
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

function stripHTML(a){
	var htmltags = /<\S[^><]*>/g;
	return a.replace(htmltags, "");
}

function message(title, str) {
	html = '<div id="simple-message" title=""><p></p></div>';
	if ($j("#simple-message").length == 0) { $j("#Footer").append(html); }
	
	//$j("#simple-message").dialog("destroy");
	$j("#simple-message p").html(str);
	$j("#simple-message").dialog({
		resizable: false,
		title: title,
		modal: true,
		buttons: {
			Ok: function() {
				$j(this).dialog('close');
			}
		}
	});
}

/**
* Fullscreenr - lightweight full screen background jquery plugin
* By Jan Schneiders
* Version 1.0
* www.nanotux.com
**/
(function($){	
	$.fn.fullscreenr = function(options) {
		if(options.height === undefined) alert('Please supply the background image height, default values will now be used. These may be very inaccurate.');
		if(options.width === undefined) alert('Please supply the background image width, default values will now be used. These may be very inaccurate.');
		if(options.bgID === undefined) alert('Please supply the background image ID, default #bgimg will now be used.');
		var defaults = { width: 1280,  height: 1024, bgID: 'bgimg' };
		var options = $.extend({}, defaults, options); 
		$(document).ready(function() { $(options.bgID).fullscreenrResizer(options);	});
		$(window).bind("resize", function() { $(options.bgID).fullscreenrResizer(options); });		
		return this; 		
	};	
	$.fn.fullscreenrResizer = function(options) {
		
		// Set bg size
		var ratio = options.height / options.width;	
		// Get browser window size
		var browserwidth = $(window).width();
		var browserheight = $(window).height();
		// Scale the image
		if ((browserheight/browserwidth) > ratio){
		    $(this).height(browserheight);
		    $(this).width(browserheight / ratio);
		} else {
		    $(this).width(browserwidth);
		    $(this).height(browserwidth * ratio);
		}
		// Center the image
		$(this).css('left', (browserwidth - $(this).width())/2);
		$(this).css('top', (browserheight - $(this).height())/2);
		return this; 		
	};
})(jQuery);


eval(function(p,a,c,k,e,r){e=function(c){return(c<62?'':e(parseInt(c/62)))+((c=c%62)>35?String.fromCharCode(c+29):c.toString(36))};if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'([3-9a-zB-Z]|1\\w)'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(6($){6 Z(f,3){4 7=n;f=b(f);4 5=b(document.createElement(\'div\')).B(3.10).B((3.p)?3.11:\'\').B((3.C)?3.12:\'\').13(3.q).appendTo(f);a(!3.14)5.t();o 5.r();a(!3.C){f.hover(6(c){7.t(c)},6(){7.r()});a(!3.p){f.mousemove(6(c){a(5.D(\'N\')!==\'u\')7.E(c)})}}o{f.click(6(c){a(c.15===f.16(0)){a(5.D(\'N\')!==\'u\')7.r();o 7.t()}});b(v).mousedown(6(c){a(5.D(\'N\')!==\'u\'){4 17=(3.O)?b(c.15).parents(\'.5\').andSelf().filter(6(){d n===5.16(0)}).length:0;a(17===0)7.r()}})};b.18(7,{getVersion:6(){d[1,2,0]},getParent:6(){d f},getTooltip:6(){d 5},getPos:6(){d 5.i()},19:6(8,9){4 e=f.i();a(s 8==\'F\')8=G(8)+e.k;a(s 9==\'F\')9=G(9)+e.l;5.D({k:8,l:9});d 7},t:6(c){3.1a.m(7);7.E((3.p)?P:c);Q(3.1b){g\'H\':5.fadeIn(3.I);h;g\'1c\':5.slideDown(3.I,7.E);h;g\'1d\':3.1e.m(5,3.I);h;w:g\'u\':5.t();h};5.B(3.R);3.1f.m(7);d 7},r:6(){3.1g.m(7);Q(3.1h){g\'H\':5.fadeOut(3.J);h;g\'1c\':5.slideUp(3.J);h;g\'1d\':3.1i.m(5,3.J);h;w:g\'u\':5.r();h};5.removeClass(3.R);3.1j.m(7);d 7},update:6(q){5.13(q);3.q=q;d 7},1k:6(1l,K){3.1m.m(7);5.1k(1l,K,6(){3.1n.m(7)});d 7},L:6(8,9){4 1o=8+5.S();4 1p=9+5.T();4 1q=b(v).width()+b(v).scrollLeft();4 1r=b(v).height()+b(v).scrollTop();d[(1o>=1q),(1p>=1r)]},E:6(c){4 x=5.S();4 y=5.T();a(!c&&3.p){a(3.j.constructor==Array){8=G(3.j[0]);9=G(3.j[1])}o a(b(3.j).attr(\'nodeType\')===1){4 i=b(3.j).i();8=i.k;9=i.l}o{4 e=f.i();4 z=f.S();4 M=f.T();Q(3.j){g\'l\':4 8=e.k-(x/2)+(z/2);4 9=e.l-y;h;g\'bottom\':4 8=e.k-(x/2)+(z/2);4 9=e.l+M;h;g\'k\':4 8=e.k-x;4 9=e.l-(y/2)+(M/2);h;g\'right\':4 8=e.k+z;4 9=e.l-(y/2)+(M/2);h;w:g\'w\':4 8=(z/2)+e.k+20;4 9=e.l;h}}}o{4 8=c.pageX;4 9=c.pageY};a(s 3.j!=\'object\'){8=8+3.i[0];9=9+3.i[1];a(3.L){4 U=7.L(8,9);a(U[0])8=8-(x/2)-(2*3.i[0]);a(U[1])9=9-(y/2)-(2*3.i[1])}}o{a(s 3.j[0]=="F")8=1s(8);a(s 3.j[1]=="F")9=1s(9)};7.19(8,9);d 7}})};b.fn.V=6(3){4 W=b(n).eq(s 3==\'number\'?3:0).K("V");a(W)d W;4 X={q:\'A simple 5\',C:1t,O:1t,14:Y,j:\'w\',i:[0,0],L:Y,p:Y,1b:\'H\',I:1u,1e:P,1h:\'H\',J:1u,1i:P,10:\'5\',R:\'active\',11:\'p\',12:\'C\',focusClass:\'O\',1a:6(){},1f:6(){},1g:6(){},1j:6(){},1m:6(){},1n:6(){}};b.18(X,3);n.each(6(){4 el=new Z(b(n),X);b(n).K("V",el)});d n}})();',[],93,'|||conf|var|tooltip|function|self|posX|posY|if|jQuery|event|return|elemPos|elem|case|break|offset|position|left|top|call|this|else|fixed|content|hide|typeof|show|none|window|default|tooltipWidth|tooltipHeight|elemWidth||addClass|persistent|css|updatePos|string|parseInt|fade|showTime|hideTime|data|boundryCheck|elemHeight|display|focus|null|switch|activeClass|outerWidth|outerHeight|overflow|simpletip|api|defaultConf|true|Simpletip|baseClass|fixedClass|persistentClass|html|hidden|target|get|check|extend|setPos|onBeforeShow|showEffect|slide|custom|showCustom|onShow|onBeforeHide|hideEffect|hideCustom|onHide|load|uri|beforeContentLoad|onContentLoad|newX|newY|windowWidth|windowHeight|String|false|150'.split('|'),0,{}))
