
function changeSrtClass(obj){
        if(hasClass(obj, 'vis')){ removeClass(obj, 'vis'); addClass(obj, 'nvis') }
        else { removeClass(obj, 'nvis'); addClass(obj, 'vis') }
}
function changeClass(obj){
        if(hasClass(obj, 'vis')){ removeClass(obj, 'vis'); addClass(obj, 'nvis') }
        else { removeClass(obj, 'nvis'); addClass(obj, 'vis') }
}
function changeSrchClass(i){
 var j;
 for( j=1; j<4; j++){
    if( j!=i){
	hideClass(getElement('srch_'+j));
	showClass(getElement('srchL_'+j));
    }
 }
 hideClass(getElement('srchL_'+i));
 showClass(getElement('srch_'+i));
}

function hideClass(obj){
        removeClass(obj, 'vis');
        addClass(obj, 'nvis');
}

function showClass(obj){
        removeClass(obj, 'nvis');
        addClass(obj, 'vis');
}

function group_ch(fn){ 
 for(i=0; i<fn.length;i++){ 
  with (fn.elements[i]) { 
   if (type=='checkbox') {checked= !checked; }; 
  }; 
 }; 
}; 

function glosuj(x,fx)
{
if (confirm('Jesteś pewien, że ten post powinien być skasowany ?')){
 window.open('http://forum.gazeta.pl/forum/info/forum/zgloszenie.jsp?f='+fx+'&glos=0&a='+x,'_blank','toolbar=no, directories=no, location=no,status=yes, menubar=no, resizable=no, scrollbars=no, width=300, height=200, top=200,left=200');
}
return;
}


function createCookie(name,value,days,hours,domain){
	if(days){
		var date=new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000)+(hours*60*60*1000));
		var expires="; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie=name+"="+value+expires+"; path=/"+((domain)?';domain='+domain : '');
}

function readCookie(name){
	var nameEQ=name+"=";
	var ca=document.cookie.split(';');
	for(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 pushThreadCookie(){
	var max_cookie_length=300;
	var cookie_name="ForumThreads";
	try{
	var threadsCookie=readCookie(cookie_name);
	var tId = getThreadParam();
	if( tId == null ) return null;
	var tIdhex = d2h(tId);
	var newTab = new Array();
	newTab[0] = tIdhex;

	if( threadsCookie != null ){
		var ttab = threadsCookie.split(' ');
		var j=1;
		for(i=0;i<ttab.length;i++){
		 if( ttab[i] != null && ttab[i] != tIdhex && ttab[i] != 0){
				
			newTab[j++]=ttab[i];
		}
	    }
	}

	var newCookie = "";
	for(i=0;i<newTab.length;i++){
		if( newCookie.length + (" "+newTab[i]).length > max_cookie_length )
			break;
		if( i>0 )
			newCookie += " ";
		newCookie += newTab[i];
	}

	if( newCookie != threadsCookie ){
	  	createCookie(cookie_name,newCookie,30,0,'');
	 }
	}catch(e){
	}

	return null;
}

function getForumParam(){
   var fId = getQParam("f");
   if( fId == null ){
   	var m = /\/forum\/0[123],(\d*),.*/.exec(window.location.href);
   	if ( m != null && m.length > 0 ) {
		fId = m[1];
	}
	if( fId == null ){
   	m = /\/forum\/[fw],(\d*),.*/.exec(window.location.href);
   	if (m != null && m.length > 0 ) {
		fId = m[1];
	}
   }
   }
   return fId;
}

function getThreadParam(){
   var wId = getQParam("w");
   if( wId == null ){
   	var m = /\/forum\/0[123],\d*,(\d*),.*/.exec(window.location.href);
   	if ( m != null && m.length > 0 ) {
		wId = m[1];
	}
	if( wId == null ){
   	m = /\/forum\/[fw],\d*,(\d*),.*/.exec(window.location.href);
   	if (m != null && m.length > 0 ) {
		wId = m[1];
	}
   }
   }
   return wId;
}



function getQParam ( pName ) {
   var qstring = window.location.href;
   if ( qstring.length > 0 ) {
      begin = qstring.indexOf ( pName+ "=" );
      if( begin != -1 ) {
        begin += pName.length+1;
	end = qstring.indexOf ( "&" , begin );
	if ( end == -1 )
	 	end = qstring.indexOf ( "#" , begin );
	if ( end == -1 )
		end = qstring.length;
        return unescape ( qstring.substring ( begin, end ) );
      }
      return null;
   }
}

function d2h(d) {
	var hD="0123456789ABCDEF";
	var h = hD.substr(d&15,1);
	while(d>15) {d>>=4;h=hD.substr(d&15,1)+h;}
	return h;
}

function h2d(h) {return parseInt(h,16);}
pushThreadCookie();


function cancellMsg(cId){
  if( cId==null) cId="c1";
  hideElement("topMsgBx0");
  var cv = getCookieValue('fUC');
  if( cv==null || cv.indexOf(cId)<0){
    if( cv==null ){
	cv = cId;
    }else{
	cv += ","+cId;
    }
    setCookie('fUC',cv,360);  
  }
}


