var Languages = {


	Init: function()
	{		
		/*$('#LanList a').click(function(){
			Languages.ChangeThroughUrl($(this).attr('href'));		
			return false;
		})*/
		
		
		$('#CurrentSelection a').mouseover(function(){ 
			$('#CurrentSelection span').text($(this).attr('title'));
		}).mouseout(function(){
			$('#CurrentSelection span').text('');
		})
	},
	

	ToggleDropdown: function()
	{	
		
		var List = $('#LanList');
		var CurSel = $('#CurrentSelection');
	
		if($(List).css('height') == '0px')
		{
			$(List).animate({height: '60px', padding: '10px'}, 1000);
			$(CurSel).text('Current: ' + Preferences.Language.Name);
		} else {
			$(List).animate({height: '0px', padding: '0px'}, 100);
			$(CurSel).text('Change Language');
		}
	},


	ChangeThroughUrl: function(Location)
	{
		$('#CurrentSelection').text('Changing...');
		window.location.replace(Location);
	},


	Change: function(LanID)
	{
		$('#CurrentSelection').text('Changing...');
	}
	
}


var Curr = {
	
	Huf: 0,
	
	EuroToFlorint: function()
	{
		var Val = parseFloat($('#CurrEuro').val().replace(',', '.'));
		
		if(!isNaN(Val))
			$('#CurrHuf').val((parseFloat(Curr.Huf * Val).toFixed(2)).replace('.', ','));
		else $('#CurrHuf').val('Error');
	},
	
	
	FlorintToEuro: function()
	{
		var Val = parseFloat($('#CurrHuf').val().replace(',', '.'));
		
		if(!isNaN(Val))
			$('#CurrEuro').val((parseFloat(Val / Curr.Huf).toFixed(2)).replace('.', ','));
		else $('#CurrEuro').val('Error');
	}
}


$(document).ready(function(){

	Languages.Init();
	
	$('a.Zoom').lightBox(
		{	
			imageLoading: Preferences.Location + '/images/lightbox/loading.gif',
			imageBtnClose: Preferences.Location + '/images/lightbox/close.gif',
			imageBtnPrev: Preferences.Location + '/images/lightbox/prev.gif',
			imageBtnNext: Preferences.Location + '/images/lightbox/next.gif',
			containerResizeSpeed: 350
		}
	);
	

	if($('#Weather').length > 0)
	{
		$.get(Preferences.Location + '/weather.php', {}, function(Data){
		
			$('#Weather').html(Data);
		
		}, 'html');
		
		
		$.get(Preferences.Location + '/huf.php', {}, function(Data){
		
			Curr.Huf = parseFloat(Data);
			
			$('#CurrHuf').keyup(function(){Curr.FlorintToEuro();});
			$('#CurrEuro').keyup(function(){Curr.EuroToFlorint();});
		});
	
	}
	
	$('#Counter').append(
		$('<img src="http://nl.nedstatbasic.net/cgi-bin/referstat.gif?name=vakantieparadijs&refer=' +
		escape(top.document.referrer) +
		'" width="1" height="1"/>')
	);
	
	if($('a.Zoom img').size() > 20)
	{
		$('a.Zoom img').parent().addClass('GalleryImage');	
		$('h2').css('clear', 'both');
		$('p').css('display', 'inline');
	}
	
});









/**
 * sprintf() for JavaScript v.0.4
 *
 * Copyright (c) 2007 Alexandru Marasteanu <http://alexei.417.ro/>
 * Thanks to David Baird (unit test and patch).
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Suite 330, Boston, MA 02111-1307 USA
 */

function str_repeat(i, m) { for (var o = []; m > 0; o[--m] = i); return(o.join('')); }

function sprintf () {
  var i = 0, a, f = arguments[i++], o = [], m, p, c, x;
  while (f) {
    if (m = /^[^\x25]+/.exec(f)) o.push(m[0]);
    else if (m = /^\x25{2}/.exec(f)) o.push('%');
    else if (m = /^\x25(?:(\d+)\$)?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(f)) {
      if (((a = arguments[m[1] || i++]) == null) || (a == undefined)) throw("Too few arguments.");
      if (/[^s]/.test(m[7]) && (typeof(a) != 'number'))
        throw("Expecting number but found " + typeof(a));
      switch (m[7]) {
        case 'b': a = a.toString(2); break;
        case 'c': a = String.fromCharCode(a); break;
        case 'd': a = parseInt(a); break;
        case 'e': a = m[6] ? a.toExponential(m[6]) : a.toExponential(); break;
        case 'f': a = m[6] ? parseFloat(a).toFixed(m[6]) : parseFloat(a); break;
        case 'o': a = a.toString(8); break;
        case 's': a = ((a = String(a)) && m[6] ? a.substring(0, m[6]) : a); break;
        case 'u': a = Math.abs(a); break;
        case 'x': a = a.toString(16); break;
        case 'X': a = a.toString(16).toUpperCase(); break;
      }
      a = (/[def]/.test(m[7]) && m[2] && a > 0 ? '+' + a : a);
      c = m[3] ? m[3] == '0' ? '0' : m[3].charAt(1) : ' ';
      x = m[5] - String(a).length;
      p = m[5] ? str_repeat(c, x) : '';
      o.push(m[4] ? a + p : p + a);
    }
    else throw ("Huh ?!");
    f = f.substring(m[0].length);
  }
  return o.join('');
}
