
/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

/**
 * Create a cookie with the given name and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 * @param String name The name of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};// JavaScript Document

jQuery(document).ready(function() {
	
jQuery(".palvelut").show();
jQuery(".pallot ul").hide(); /* loader */
jQuery(".muutto").show();

jQuery(".box").hide();

jQuery("a.tervetuloa").hover(
  function () {
    jQuery(".palvelut ul li a").removeClass("active");
	jQuery(this).addClass("active");
	jQuery(".palvelut .boxes").children().hide();
    jQuery('.tervetuloa-box').slideToggle(20);
  },
  function () {
     jQuery('.tervetuloa-box').show();
  }
);;
jQuery("a.hyvinvointi").hover(
  function () {
    jQuery(".palvelut ul li a").removeClass("active");
	jQuery(this).addClass("active");
	jQuery(".palvelut .boxes").children().hide();
    jQuery('.hyvinvointi-box').slideToggle(20);
  },
  function () {
     jQuery('.hyvinvointi-box').show();
  }
);;  
jQuery("a.koulu").hover(
  function () {
    jQuery(".palvelut ul li a").removeClass("active");
	jQuery(this).addClass("active");
	jQuery(".palvelut .boxes").children().hide();
    jQuery('.koulu-box').slideToggle(20);
  },
  function () {
     jQuery('.koulu-box').show();
  }
);;  
jQuery("a.koti").hover(
  function () {
    jQuery(".palvelut ul li a").removeClass("active");
	jQuery(this).addClass("active");
	jQuery(".palvelut .boxes").children().hide();
    jQuery('.koti-box').slideToggle(20);
  },
  function () {
     jQuery('.koti-box').show();
  }
);;
jQuery("a.vapaa").hover(
  function () {
    jQuery(".palvelut ul li a").removeClass("active");
	jQuery(this).addClass("active");
	jQuery(".palvelut .boxes").children().hide();
    jQuery('.vapaa-box').slideToggle(20);
  },
  function () {
     jQuery('.vapaa-box').show();
  }
);;
jQuery("a.raha").hover(
  function () {
    jQuery(".palvelut ul li a").removeClass("active");
	jQuery(this).addClass("active");
	jQuery(".palvelut .boxes").children().hide();
    jQuery('.raha-box').slideToggle(20);
  },
  function () {
     jQuery('.raha-box').show();
  }
);;

jQuery('.palvelut .close a').click(function() {
	jQuery(".palvelut ul li a").removeClass("active");
	jQuery(".palvelut .box").fadeOut(20);
	return false;
});   

jQuery('.muutto ul li a').click(function() { return false; } );
jQuery('.palvelut ul li a').click(function() { return false; } );

jQuery(".palvelut ul li a").hover(
  function () {
    jQuery(this).addClass("hover");
  },
  function () {
    jQuery(this).removeClass("hover");
  }
);

jQuery("a.muuttaminen").hover(
  function () {
	jQuery(".muutto .boxes").children().hide();  
	jQuery('.muutto-box').slideToggle(10);
    jQuery(".muutto ul li a").removeClass("active");
	jQuery(this).addClass("active"); 
  },
  function () {
     jQuery('.muutto-box').show();
  }
);

jQuery("a.asuminen").hover(
  function () {
	jQuery(".muutto .boxes").children().hide();
	jQuery('.asuminen-box').slideToggle(10);
    jQuery(".muutto ul li a").removeClass("active");
	jQuery(this).addClass("active");
  },
  function () {
     jQuery('.asuminen-box').show();
  }
);;  

jQuery("a.opiskelu").hover(
  function () {
	jQuery(".muutto .boxes").children().hide();
    jQuery(".muutto ul li a").removeClass("active");
	jQuery(this).addClass("active");
    jQuery('.opiskelu-box').slideToggle(10);
  },
  function () {
     jQuery('.opiskelu-box').show();
  }
);; 
jQuery("a.tyot").hover(
  function () {
	jQuery(".muutto .boxes").children().hide();
    jQuery(".muutto ul li a").removeClass("active");
	jQuery(this).addClass("active");
    jQuery('.tyo-box').slideToggle(10);
  },
  function () {
     jQuery('.tyo-box').show();
  }
);;  
   
jQuery('.muutto .close a').click(function() {
	jQuery(".muutto ul li a").removeClass("active");
	jQuery(".muutto .box").fadeOut(20);
	return false;
});   

jQuery(".muutto ul li a").hover(
  function () {
    jQuery(this).addClass("hover");
  },
  function () {
    jQuery(this).removeClass("hover");
  }
);


jQuery('.accordion h3').click(function() {
	jQuery(this).toggleClass("active");
	jQuery(this).next().slideToggle(100);
	return false;
}).next().hide();

jQuery('.en').hide();
jQuery('.viro').hide();
jQuery('.ru').hide();
jQuery('.thai').hide();
jQuery('.fail').hide();
		
jQuery('a.english').click(function(){	
		jQuery('.fi').hide();
		jQuery('.viro').hide();
		jQuery('.ru').hide();
		jQuery('.thai').hide();
		jQuery('.en').show();
		jQuery.cookie('lang', 'en', { expires: 7 });
		return false;
});	
jQuery('a.suomenna').click(function(){	
		jQuery('.fi').show();
		jQuery('.viro').hide();
		jQuery('.ru').hide();
		jQuery('.thai').hide();
		jQuery('.en').hide();
		jQuery.cookie('lang', '', { expires: 7 });	
		return false;		
});
jQuery('a.viroks').click(function(){		
		jQuery('.fi').hide();
		jQuery('.viro').show();
		jQuery('.ru').hide();
		jQuery('.thai').hide();
		jQuery('.en').hide();
		jQuery.cookie('lang', 'viro', { expires: 7 });		
		return false;
});
jQuery('a.russian').click(function(){		
		jQuery('.fi').hide();
		jQuery('.viro').hide();
		jQuery('.ru').show();
		jQuery('.thai').hide();
		jQuery('.en').hide();
		jQuery.cookie('lang', 'ru', { expires: 7 });
		return false;			
});
jQuery('a.inthai').click(function(){
		jQuery('.fi').hide();
		jQuery('.viro').hide();
		jQuery('.ru').hide();
		jQuery('.thai').show();
		jQuery('.en').hide();
		jQuery.cookie('lang', 'thai', { expires: 7 });	
		return false;	
});
jQuery(".palvelut .lang-selector a").click(function(){
	jQuery(".lang-selector a").removeClass("active");
	jQuery(this).addClass("active");
});

jQuery(".loader").remove();
jQuery(".pallot ul").show();
		
var lang = jQuery.cookie('lang');
if (lang=='en') {
		jQuery('.fi').hide();
		jQuery('.viro').hide();
		jQuery('.ru').hide();
		jQuery('.thai').hide();
		jQuery('.en').show();
}else if (lang=='viro') {
		jQuery('.fi').hide();
		jQuery('.viro').show();
		jQuery('.ru').hide();
		jQuery('.thai').hide();
		jQuery('.en').hide();
}else if (lang=='ru') {
		jQuery('.fi').hide();
		jQuery('.viro').hide();
		jQuery('.ru').show();
		jQuery('.thai').hide();
		jQuery('.en').hide();
}else if (lang=='thai') {
		jQuery('.fi').hide();
		jQuery('.viro').hide();
		jQuery('.ru').hide();
		jQuery('.thai').show();
		jQuery('.en').hide();
}else {
		jQuery('.fi').show();
		jQuery('.viro').hide();
		jQuery('.ru').hide();
		jQuery('.thai').hide();
		jQuery('.en').hide();
};

});
