﻿	
function openPopup(href, pWidth, pHeight, showAll){
	show 	= (showAll) ? "yes" : "no";
	width = (pWidth) 	? pWidth : 550;
	height = (pHeight) ? pHeight : 700;
	var popup = window.open(href, "popup", "width="+width+",height="+height+",toolbar="+show+",scrollbars=yes,resizable=yes,menubar="+show+",location="+show+",status="+show);
	if(popup.focus)
		popup.focus();
	return false;
}

function set_cookie( name, value, expires, path, domain, secure ) {
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );

	/*
	if the expires variable is set, make the correct
	expires time, the current script below will set
	it for x number of days, to make it for hours,
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );

	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}


function get_cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}

function closeOverlay(id) {
	$('#'+id).click();
}

/*
 * **********************************************************************************************************************************************************************
 */
/* jquery.fontsize.js  */

(function($){ 
     $.fn.extend({  
         fontsizer: function(options) {       
            $.fn.fontsizer.defaults = {
					plus_selector: '.enlarge',
					minus_selector: '.small',
					reset_selector: '.reset',
					size2_selector: '.size2',
					size3_selector: '.size3',
					sizes: 3,
					current_size: 1,
					default_size: 1,
					title_base: 'Textsize ',
					cookie_name: 'fontsize',
					cookie_expires: 10
			};
			
			// build main options before element iteration
			var opts = $.extend({}, $.fn.fontsizer.defaults, options);
			
			return this.each(function() {
				var $this = $(this);
				
				var curr_size = $.cookie(opts.cookie_name);
				if (curr_size != null && curr_size > 0 && curr_size <= opts.sizes) changeTextSize(parseInt(curr_size));
				
				//click events -----------------------------------------
				$this.find(opts.plus_selector).click(function(e){
					var new_size = opts.current_size + 1;
					if (new_size > 0 && new_size <= opts.sizes) changeTextSize(new_size);
					return false;
				});
				
				$this.find(opts.minus_selector).click(function(e){
					var new_size = opts.current_size - 1;
					if (new_size > 0 && new_size <= opts.sizes) changeTextSize(new_size);
					return false;
				});
				
				$this.find(opts.reset_selector).click(function(e){
					changeTextSize(opts.default_size);
					return false;
				});

				$this.find(opts.size2_selector).click(function(e){
					changeTextSize(2);
					return false;
				});
				
				$this.find(opts.size3_selector).click(function(e){
					changeTextSize(3);
					return false;
				});
				
				function changeTextSize(size){
					$('link[rel*=style][title*='+opts.title_base+']').each(
						function(i) {
							this.disabled = true;
							if ($(this).attr('title') == opts.title_base+size) {
								this.disabled = false;
								opts.current_size = size;
								$.cookie(opts.cookie_name, size, { expires: opts.cookie_expires, path: '/' });
								//alert (size);
							}	
						}
					);
					
					$('img#fontsizerControl').attr('src', '/html/img/main/fontsize_module_control_size' + size + '.gif');					
				}
				
            });
        } 
    }); 
})(jQuery);

/**
 * jQuery Cookie plugin
 *
 * Copyright (c) 2010 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
 *
 */
jQuery.cookie = function (key, value, options) {

    // key and at least value given, set cookie...
    if (arguments.length > 1 && String(value) !== "[object Object]") {
        options = jQuery.extend({}, options);

        if (value === null || value === undefined) {
            options.expires = -1;
        }

        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }

        value = String(value);

        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? value : encodeURIComponent(value),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }

    // key and possibly options given, get cookie...
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};


