/***************************************************************************
 *       ___ _   _                    ____           _       _
 *      |  _| | | |_ __  _ _  ___    / ___|  ___ _ _(_)_ __ | |_
 *      | |_| |_| | '_ \| '_)/ _ \   \___ \ / __| '_) | '_ \| __| 
 *      |  _|  _  | |_) | | | (_) |   ___) | (__| | | | |_) | |_ 
 *      |_| |_| |_| .__/|_|  \___/   |____/ \___|_| |_| .__/ \__|
 *                |_|  www.fhpro.de                   |_|
 *
 *   Copyright            : (c) 2006 Frank Hinkel
 *   Kontakt              : info@fhpro.de
 *
 ***************************************************************************/

/*** RELOAD ***/
function FhproReload() {
    this._timerID;
    this._timerReload;
    this._reloadCounter;
}
FhproReload.prototype = {
	initialize: function() 
	{
		this.setTimer(this.loadPosition());
	},
	changeTimer: function(el)
	{
		var myTime = el.options[el.selectedIndex].value;		
		if (this._timerReload == myTime)
			return;
		
		this.setTimer(myTime);
	},
	setTimer: function(myTime)
	{			
		clearTimeout(this._timerID);
		
		this._reloadCounter = 0;
		this._timerReload   = myTime;			
		this.savePosition();
		/*this.setSelected(CLweb2.getElem('FormReload'),this._timerReload);*/		
		
		/*
		if (myTime != 0)
		{
			CLweb2.getElem('reloadStatus').innerHTML = myTime + ' Sek.';
			this._timerID = window.setInterval("CLreload.reloadPage();", 1000);
		}		
		else
			CLweb2.getElem('reloadStatus').innerHTML = '';		
		*/
	},
	setSelected: function(el, position)
	{		
		for (var i = 0; i < el.options.length; i++)
		{
			if (el.options[i].value == position)
			{
				el.selectedIndex = i;
				break;
			}
		}
	},
	loadPosition: function()
	{
		var dl = document.location.href.split('?');
		if (dl[1] != 'reload')
			return 0;
			
        var name   = 'blogReload';
        var nameEQ = name + "=";		
		var ca = document.cookie.split(';');
        for(var i=0;i < ca.length;i++) 
	    {
            var c = ca[i];
            while (c.charAt(0)==' ') c = c.substring(1,c.length);
            if (c.indexOf(nameEQ) == 0) 
            {
                return c.substring(nameEQ.length,c.length);
            }
        }
        return 0;		
	},
	savePosition: function()
	{
        var d = new Date();
        d = new Date(d.getTime() +1000*60*60*24);        
        document.cookie = 'blogReload='+this._timerReload+'; expires='+d.toGMTString()+'; domain=.100-prozent-projekt.de; path=/;'; 		
	},
	reloadPage: function()
	{
		this._reloadCounter++;
		CLweb2.getElem('reloadStatus').innerHTML = (this._timerReload-this._reloadCounter) + ' Sek.';
		
		if (this._reloadCounter == this._timerReload)
			document.location.href = '/web-213/mein_blog.html?reload';
	},
	stopReload: function()
	{
		this.setTimer(0);
	}
}

/*** COMMENTS ***/
function FhproComments() {
    this._openID;
}
FhproComments.prototype = {
	initialize: function() 
	{
		
	},
	showHideComments: function(num)
	{
		var anchors = document.getElementsByTagName('div');
		for (var i=0; i<anchors.length; i++)
		{
			var anchor = anchors[i];			
			if (anchor.getAttribute('name') == 'comBox')
				CLweb2.getElem(anchor.getAttribute('id')).style.display = 'none';
		}				
		
		if (CLweb2.getElem('comBox' + num).style.display == 'none' && this._openID != num)
		{
			this._openID = num;	
			CLweb2.getElem('comBox' + num).style.display = 'block';
		}
		else
			this._openID = 0;
			
	}
}

/*** INITS ***/
function initComments()
{        
	CLcom.initialize();
}
function initReload()
{        
	CLreload.initialize();
}
var CLcom = new FhproComments();
var CLreload = new FhproReload(); 
CLweb2.setOnLoad("initComments();"); 
CLweb2.setOnLoad("initReload();"); 

