/**
 * 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;
    }
};jQuery(function($) {
	var setField = function(fieldName) {
		var field = $('#tx_comments_pi1_' + fieldName);
		if (field.val() == '') { 
			field.val(unescape($.cookie('tx_comments_pi1_' + fieldName).replace(/\+/, ' ')));
		}
	}
	
	setField('firstname');
	setField('lastname');
	setField('email');
	setField('location');
	setField('homepage');	

});

$(function(){$('ul.jd_menu').jdMenu({onShow:loadMenu,activateDelay:100});$('ul.jd_menu_vertical').jdMenu({onShow:loadMenu,onHide:unloadMenu,offset:1,onAnimate:onAnimate});});function onAnimate(show){if(show){$(this).css('visibility','hidden').show().css('width',$(this).innerWidth()).hide().css('visibility','visible').fadeIn('normal');}else{$(this).fadeOut('fast');}}
var MENU_COUNTER=1;function loadMenu(){if(this.id=='dynamicMenuRW'){$('> ul > li',this).remove();var ul=$('<ul></ul>');var t=MENU_COUNTER+10;for(;MENU_COUNTER<t;MENU_COUNTER++){$('> ul',this).append('<li>Item '+MENU_COUNTER+'</li>');}}}
function unloadMenu(){if(MENU_COUNTER>=30){MENU_COUNTER=1;}}
function onHideCheckMenu(){return!$(this).parent().is('.LOCKED');}
function onClickMenu(){$(this).toggleClass('LOCKED');return true;}
function toggle(id)
{div_el=document.getElementById(id);img_el=document.getElementById('img'+id);if(div_el.style.display!='none')
{div_el.style.display='none';img_el.src='/fileadmin/templates/fileadmin/templates/fileadmin/templates/seo.html_files/show.png';}
else
{div_el.style.display='block';img_el.src='/fileadmin/templates/fileadmin/templates/fileadmin/templates/seo.html_files/hide.png';};};function animateLetter(jChar,letterShowTimeout,letterResetTimeout)
{jChar.hide();jChar.css("display","inline");jChar.css("font-weight",400);jChar.show(letterShowTimeout,function(){jChar.css("font-weight",700);});setTimeout(function(){jChar.css("font-weight",400);},letterResetTimeout);}
function showMotto()
{var mottoText="Driving Your Business Growth";var mottoLength=mottoText.length;var container=$("#mottotext");container.css("display","block");setTimeout(function(){writeText(0,mottoLength,mottoText,container);},450);}
function showMotto2()
{var mottoText="Sales keep Growing and Growing";var mottoLength=mottoText.length;var container=$("#mottotext2");container.css("display","block");setTimeout(function(){writeText(0,mottoLength,mottoText,container);},450);}
function writeText(i,length,text,container)
{if(i==length)
{return;}
var character=text.charAt(i);if(" "==character)
{character="&nbsp;";}
var characterSpan="<span id='mt"+i+"'>"+character+"</span>";container.append(characterSpan);var jChar=container.find("#mt"+i).eq(0);var letterShowTimeout=60;var letterResetTimeout=90;var easingStartLength=1400;if(i>easingStartLength)
{var easing=Math.ceil((i-easingStartLength)/3);var easingSq=easing*easing;letterShowTimeout+=easingSq*letterShowTimeout;letterResetTimeout+=easing*letterResetTimeout;}
animateLetter(jChar,letterShowTimeout,letterResetTimeout);i++;var textWriteTimeout=90;setTimeout(function(){writeText(i,length,text,container);},textWriteTimeout);}
function beginAnimation()
{var animationStartDelay=300;var rolloverDuration=800;setTimeout(function()
{$("#motto").animate({left:"2px"},{duration:rolloverDuration,easing:"linear",complete:showMotto});},animationStartDelay);}
var browserName=navigator.appName;var browserVer=parseInt(navigator.appVersion);var version="";var msie4=(browserName=="Microsoft Internet Explorer"&&browserVer>=4);if((browserName=="Netscape"&&browserVer>=3)||msie4||browserName=="Konqueror"||browserName=="Opera"){version="n3";}else{version="n2";}
function blurLink(theObject){if(msie4){theObject.blur();}}
function decryptCharcode(n,start,end,offset){n=n+offset;if(offset>0&&n>end){n=start+(n-end-1);}else if(offset<0&&n<start){n=end-(start-n-1);}
return String.fromCharCode(n);}
function decryptString(enc,offset){var dec="";var len=enc.length;for(var i=0;i<len;i++){var n=enc.charCodeAt(i);if(n>=0x2B&&n<=0x3A){dec+=decryptCharcode(n,0x2B,0x3A,offset);}else if(n>=0x40&&n<=0x5A){dec+=decryptCharcode(n,0x40,0x5A,offset);}else if(n>=0x61&&n<=0x7A){dec+=decryptCharcode(n,0x61,0x7A,offset);}else{dec+=enc.charAt(i);}}
return dec;}
function linkTo_UnCryptMailto(s){location.href=decryptString(s,-1);}