//

//Object.prototype.$=function $(val){if(val)this.valueOf=this.toSource=this.toString=function(){return val};return val;};

//testInterval = Object(testInterval);
var shout_height1 = 0;
var shout_height2 = 0;

var PATH_PREFIX_I = 'include/';
var PATH_PREFIX_M = 'modules/';

/*
// przesniecie zawartosci wiadomosci w dol
var objDiv = document.getElementById('shoutMessages');
objDiv.scrollTop = objDiv.scrollHeight;
shout_height2 = objDiv.scrollHeight;
//alert(shout_height1+':'+shout_height2);
*/

var shoutShow = function()
{
    this.path_prefix = PATH_PREFIX_M;
    //ajaxRefresh(path_prefix+'m_pshout2.php?opt=init&aja=1','shoutMessages','ajaxIntervalMessages',0);
    document.getElementById('shoutall').style.display = 'block';
    document.getElementById('shout').style.display = 'block';
    Shout1.stopPoll();
    Shout1.init();
    //document.getElementById('shoutMessages').innerHTML = "<img src='include/ajax-loader_ab_m.gif' border='0'>";
    //document.getElementById('shoutUsers').innerHTML = "<img src='include/ajax-loader_ab_u.gif' border='0'>";
    //Shout2.init();
    //Shout3.init();
    // przesniecie zawartosci wiadomosci w dol
    //alert(shout_height1+':'+shout_height2);
}

function shoutHide(div)
{
    Shout1.stopPoll();
    if (div!='')
    {
        document.getElementById(div).style.display = 'none';
    }
}

function addsmiley(code)  
{
	var pretext = document.getElementById('shoutbox_form').shout_message.value;
	this.code = code;
	document.getElementById('shoutbox_form').shout_message.value = pretext + ' ' + code + ' ';
}


function windowFile(filename,title)
{
	window.open(filename, title, 'width=600,height=400,toolbars=no,status=no,resizable=yes,scrollbars=yes,toolbars=0,status=0,resizable=1,scrollbars=1,left=1,top=1,screenX=1,screenY=1');
}

function menu(id,id2,id3,id4,id5) 
{
    document.getElementById(id).style.backgroundColor = 'transparent';
    document.getElementById(id).style.color = '#dd2';
    document.getElementById(id).style.zIndex = '2';
    document.getElementById(id2).style.zIndex = '0';
    document.getElementById(id2).style.backgroundColor = '';
    document.getElementById(id2).style.color = '';
    document.getElementById(id3).disabled = ( id=='slive'?false:true );
    document.getElementById(id4).style.visibility = ( id=='slive'?'visible':'hidden' );
    document.getElementById(id5).style.visibility = ( id=='slive'?'visible':'hidden' );
}

function sLive() 
{
    //document.getElementById('shoutMessages').innerHTML = "<img src='include/ajax-loader_ab_m.gif'>";
    document.getElementById('slive_i').innerHTML = "<img src='include/ajax-loader_my2.gif'>";
    Shout2.stopPoll();
    Shout2.init();
    document.getElementById('shoutbox_form').shout_message.focus();
}
function sArch() 
{
    //document.getElementById('shoutMessages').innerHTML = "<img src='include/ajax-loader_ab_m.gif'>";
    document.getElementById('sarch_i').innerHTML = "<img src='include/ajax-loader_my2.gif'>";
    Shout2.stopPoll();
    Shout4.init();
}
function zapisz (who,ip,message) 
{
    Shout2.stopPoll();
    Shout5.init( '&kto=' + who + '&ip=' + ip + '&message=' + encodeURI(message) );
    Shout2.init();
    document.getElementById('shoutbox_form').shout_message.value='';
    document.getElementById('shoutbox_form').shout_message.focus();
}
function runScript (scriptText) 
{
    var scriptContainer = document.createElement('SCRIPT');
    scriptContainer.text = scriptText;
    document.body.appendChild(scriptContainer);
}
function actCounter(counter) 
{
    document.getElementById('licznik').innerHTML = counter;
    //document.getElementById(id).innerHTML = c;
    //acount = clearInterval(acount); setInterval(\"document.getElementById('\"+id+\"').innerHTML='\"+counter+\"'\",3000);
}

function sleep(milliseconds)
{
    var start = new Date().getTime();
    for (var i = 0; i < 1e7; i++)
    {
        if ((new Date().getTime() - start) > milliseconds)
        {
            break;
        }
    }
}


// remember div scroll position -->
function divRescroll(name) 
{
	var name2 = name+'=';
	var strCook = document.cookie.split(';');
	for( var i=0;i<strCook.length;i++ ) 
    {
		var c = strCook[i];
		while( c.charAt(0)==' ' ) 
        {
            c = c.substring(1,c.length);
        }
		if( c.indexOf(name2)==0 ) 
        {
			if( document.getElementById(name)!=null ) 
            {
				document.getElementById(name).scrollTop = c.substring(name2.length,c.length);
			}
		}
	}
}

function SetDivPosition(name)
{
	var intY = document.getElementById(name).scrollTop;
	document.cookie = name+'='+intY;
	//alert(document.cookie);
}
// <-- remember div scroll position

// submit ENTER -->
function submitenter(myfield,e) 
{
	var keycode;
	if (window.event) 
    {
        keycode = window.event.keyCode;
    } else if (e) 
    {
        keycode = e.which;
    } else 
    {
		return true;
	}
	// alert(keycode);
	if (keycode == 13) 
    {
	   myfield.form.submit();
	   return false;
	} else
    {
        return true;
    }
}
// <-- submit ENTER

// clock -->
var timerRunning = false;
var timerID = null;

function stopclock() 
{
	if(timerRunning)
    {
		clearTimeout(timerID);
    }
	timerRunning = false;
}

function startclock(name) 
{
	stopclock();
	showtime(name);
}

function showtime(name) 
{
	var now = new Date();
	var hours = now.getHours();
	var minutes = now.getMinutes();
	var seconds = now.getSeconds();
	timeValue = '';
	timeValue += ((hours < 10) ? '0' : '') + hours;
	timeValue += ((minutes < 10) ? ':0' : ':') + minutes;
	timeValueSec = ((seconds < 10) ? ' 0' : ' ') + seconds;
	dateValue = now.getDate()+'.'+((now.getMonth()+1)<10?'0'+(now.getMonth()+1):now.getMonth()+1)+'.'+now.getFullYear();
	timeValue = '<font style=\"color:#555555;\">'+dateValue+'</font>, <font style=\"color:#336699;\">'+timeValue+'</font><font style=\"font-size:10px;color:#5588bb;\">'+timeValueSec+'</font>';
	if( document.getElementById ) 
    {
        document.getElementById(name).innerHTML = timeValue;
    }
	timerID = setTimeout("showtime('"+name+"')",1000);
	timerRunning = true;
}
// <-- clock

// cookies -->
function dc_setCookie(name,value,days) 
{
	if (days) 
    {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = '; expires='+date.toGMTString();
	} else 
    {
        var expires = '';
    }
	document.cookie = name+'='+value+expires+'; path=/';
}
function dc_getCookie(name) 
{
	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 null;
}
function dc_delCookie(name) 
{
	createCookie(name,'',-1);
}
// <-- cookies

function trim(stringToTrim)
{
    return stringToTrim.replace(/^\s+|\s+$/g,""); 
}
