function pokaz(ident,id){
   	Hide('info_0'); //bezpłatne
    Hide('info_1');	//pogrubione
    Hide('info_2');	//Zdjęcie
    Hide('info_34');//pogrubione z ceną malejącą
    Hide('info_18');//pogrubione z hasłem
    Hide('info_19');//zdjęcie z hasłem
    Hide('info_35');//aukcja
    Show('info_'+id);
    _get('rodzaj').value=id;    
}


function updateHaslo(){
    ident=_get('Thaslo');
    ident2=_get('Phaslo2');
    if(ident!=null && ident2!=null)
	if(ident.value!='') ident2.innerHTML=ident.value;
	else ident2.innerHTML='TWOJE HASŁO';
	updateHaslo2();

}
function updateHaslo2(){
    ident=_get('Thaslo1');
    ident2=_get('Phaslo3');
    if(ident!=null && ident2!=null)
	if(ident.value!='') ident2.innerHTML=ident.value;
	else ident2.innerHTML='TWOJE HASŁO';

}
function send(){
	_get('way').value='1';
	_get('bsend').style.display='none';
	_get('bsending').style.display='';	
	document.formularz.submit();
}

function showCalendar(){
    rodzajOgl=_get('button');
    rodzajOgl=(rodzajOgl!=null)? ((rodzajOgl.value!='')?rodzajOgl.value:'null'):'null';    
    if(rodzajOgl<2) Show('reg_bezpl'); else Hide('reg_bezpl');
    l_wyd=_get('l_wyd');
    //alert(l_wyd.value);
    l_wyd=(l_wyd!=null)? ((l_wyd.value!='')?l_wyd.value:'null'):'null';    
    rejon= _get('rejon');
    rejon=(rejon!=null)? ((rejon.value!='')?rejon.value:'null'):'null';  
    if(rodzajOgl==0) l_wyd=1;  
    //if(rodzajOgl==1) l_wyd=3;
   // if(rodzajOgl>0 && rodzajOgl<=3 )rodzajOgl-=1;
    if(rodzajOgl==34) rodzajOgl=1;
    if(rodzajOgl==18) rodzajOgl=1;
    if(rodzajOgl==19) rodzajOgl=2;
    if(rodzajOgl==0) l_wyd=1;
    //if(rodzajOgl>0)rodzajOgl-=1;
    var tmp=_get('kalendarium');
    if(tmp==null) return;
    var data_r=(_get('data_r')!=null)? _get('data_r').value:'';
    var url='/kupon/kalend/wydan/'+l_wyd+'/rejon/'+rejon+'/rodzaj/'+rodzajOgl+'/';
    if(data_r!='') url+='data/'+data_r+'/';
    advAJAX.get({
    	url: url,
    	onSuccess : function(obj) {
    		tmp.innerHTML=obj.responseText;
     		},
    	onLoading : function(obj){
    		tmp.innerHTML='<img src="/images/loading4.gif">';
    	},	
    	onError : function(obj) { alert("Error: " + obj.status); }
	});
	
	
}
function _get(ident){ return document.getElementById(ident); }


function Splatne(numer,emisje){
    var ident=_get('pole_pogrubione');
    if(ident!=null) ident.style.display='';
    var ident=_get('smsnumer');
    Show('sendOgl');
    if(ident!=null) ident.innerHTML=numer;
    var l_emisji=_get('l_wyd'); if(l_emisji!=undefined) l_emisji.value=emisje;
    showCalendar();
}

function Splatne2(nr,emisje){
    var ident=_get('pole_pogrubione');
    if(ident!=null) ident.style.display='';
    var ident=_get('smsnumer');
    Show('sendOgl');
    if(ident!=null) ident.innerHTML='7'+nr+'130';
    if(_get('smsnumer_txt')!=null)
   _get('smsnumer_txt').innerHTML=nr;   
    var l_emisji=_get('l_wyd'); if(l_emisji!=undefined) l_emisji.value=emisje;
    showCalendar();
}
function Splatne3(price,price_vat,emisje){
    var ident=_get('pole_pogrubione');
    if(ident!=null) ident.style.display='';
    var ident=_get('smsnumer');
    Show('sendOgl');
    if(ident!=null) ident.innerHTML='7'+price+'130';
    if(_get('smsnumer_txt')!=null)
   _get('smsnumer_txt').innerHTML=price;   
   if(_get('smsnumer_txt_vat')!=null)
   _get('smsnumer_txt_vat').innerHTML='('+price_vat+'zł z VAT)'; 
   
    var l_emisji=_get('l_wyd'); if(l_emisji!=undefined) l_emisji.value=emisje;
    showCalendar();
}


function finalizacja(){
	//alert('finalizacja');
	 var idt=_get('button');
    //if(idt!=null)    Semisje(_get('Price'),_get('rejon').value,idt.value);    
    Rsel2(_get('rejon').value);
    idt=(idt!=null)?idt.value:0;
    if(idt==34) idt=1;
    data_r=(_get('data_r')!=null)? _get('data_r').value:'';
    if(idt>0 && _get('kalendarz')!=null){
		var k = overload('kalendarz', TCzasRozpoczecia );	
		k.rejon=_get('rejon').value;
		k.rodzaj=idt;	
		if(data_r!='')  k.data=data_r;		
		k.getByAjax();	
		//alert('Data_r: '+data_r);
		//if(data_r!='') k.zmien_kalendarz_by_data(data_r);
		
		
	}
    
    return false;   
}
function imgMOver(image){
    if(image==null) return;
    image.lowsrc=image.getAttribute("src");
    image.high=new Image();
    image.high.src=image.getAttribute("highsrc");
    image.onmouseover = function (){ this.src=this.high.src; }
    image.onmouseout = function () { this.src=this.lowsrc; }	    	
}

function TTypeinit(ident2,inp){
    var ident=_get(ident2);
    if(ident==null) return;
    var rows=ident.rows;
    var cells=rows[0].cells;
    cells=ident.getElementsByTagName('TD');
    var Pid=_get(inp);
    if(Pid!=null)if(Pid.value!=''){
	Show('info_'+Pid.value);
	//alert(parseInt(Pid.value));
	//if(parseInt(Pid.value)==3) Show('pole_zdjecie');
	var pcells;
	//info(null,parseInt(Pid.value));
	if(parseInt(Pid.value)==18){	pcells=cells[5]; Show('info_18');   }else
	if(parseInt(Pid.value)==19){	pcells=cells[6]; Show('info_18'); Show('pole_zdjecie');}else
	pcells=cells[Pid.value];
	
	pcells.setAttribute('class','FbutonS');
	pcells.setAttribute('className','FbutonS');   
	
    }
    function Freset(cells){
	for(var i=0;i<cells.length;i++){
	    cells[i].setAttribute('class','');
	    cells[i].setAttribute('className','');
	}   
    }
    for(var i=0;i<cells.length;i++){
	cells[i].parent=cells;
	cells[i].lp=i;
	//cells[i].firstChild.parent=cells[i];
	cells[i].onclick=function(){
	if(this.getAttribute('rel')!='block'){
	    Freset(this.parent); 
	    this.setAttribute('class','FbutonS'); 
	    this.setAttribute('className','FbutonS'); 
	    //if(_get(inp)!=null) _get(inp).value=this.lp;
	    showCalendar();
	    }
	}
    }
}

function Semisje(ident,rejon,typ){
	if(ident==null) return;
	//alert(typ);
    var wynik='';
    //alert(typ);
    ident.innerHTML=wynik;
    if(rejon=='') return;
    Hide('pole_pogrubione');
    if(typ!=1) Show('sendOgl'); else Hide('sendOgl');

    if(typ=='1'){
    	if(rejon!='war'){
    		wynik+='<table cellspacing="0" border="0"  cellpadding="10" class="Fbuton2" id="Fbtp" align="center"><tr>';
			wynik+='<td valign="bottom"><a href="javascript:Splatne3(3,\'3.66\',1);"><img src="/images/low_1_emisja.gif" rel="buton" highsrc="/images/high_1_emisja.gif" border="0"><div>1 emisja (3zł+VAT)</div></a></td>';
	    	wynik+='<td valign="bottom"><a href="javascript:Splatne3(5,\'6.10\',2);"><img src="/images/low_2_emisje.gif" rel="buton" highsrc="/images/high_2_emisje.gif" border="0"><div>2 emisje (5zł+VAT)</div></a></td>';
	    	wynik+='<td valign="bottom"><a href="javascript:Splatne3(9,\'10.98\',4);"><img src="/images/low_4_emisje.gif" rel="buton" highsrc="/images/high_4_emisje.gif" border="0"><div>4 emisje (9zł+VAT)</div></a></td>';
	    	wynik+='<tr></table>';
			ident.innerHTML=wynik;
			ident=ident.firstChild.firstChild.firstChild;
			for(var i=0;i<ident.cells.length;i++)
	  	  		imgMOver(ident.cells[i].firstChild.firstChild);
			TTypeinit('Fbtp','Fdtp');
		}
		else{
			wynik+='<table cellspacing="0" border="0"  cellpadding="10" class="Fbuton2" id="Fbtp" align="center"><tr>';
			wynik+='<td valign="bottom"><a href="javascript:Splatne3(5,\'6.10\',1);"><img src="/images/low_1_emisja.gif" rel="buton" highsrc="/images/high_1_emisja.gif" border="0"><div>1 emisja (5zł+VAT)</div></a></td>';
	    	wynik+='<td valign="bottom"><a href="javascript:Splatne3(9,\'10.98\',2);"><img src="/images/low_2_emisje.gif" rel="buton" highsrc="/images/high_2_emisje.gif" border="0"><div>2 emisje (9zł+VAT)</div></a></td>';
	    	
			wynik+='<tr></table>';
			ident.innerHTML=wynik;
			ident=ident.firstChild.firstChild.firstChild;
			for(var i=0;i<ident.cells.length;i++)
	  	  		imgMOver(ident.cells[i].firstChild.firstChild);
			TTypeinit('Fbtp','Fdtp');
		}
			
    	
    }  
    if(typ=='18'){
    	Splatne3(9,'10.98',1);
    }
      
    if(typ=='34'){
    	if(rejon=='war') Splatne3(5,'6.10',3); else Splatne3(5,'6.10',3);
    }    
    if(typ=='2'){
    	
    	if(rejon!='war'){
    		wynik+='<table cellspacing="0" border="0"  cellpadding="10" class="Fbuton2" id="Fbtp" align="center"><tr>';
			wynik+='<td valign="bottom"><a href="javascript:SFoto2(3,\'3.66\',1);"><img src="/images/low_1_emisja.gif" rel="buton" highsrc="/images/high_1_emisja.gif" border="0"><div>1 emisja (3zł+VAT)</div></a></td>';
	    	wynik+='<td valign="bottom"><a href="javascript:SFoto2(5,\'6.10\',2);"><img src="/images/low_2_emisje.gif" rel="buton" highsrc="/images/high_2_emisje.gif" border="0"><div>2 emisje (5zł+VAT)</div></a></td>';
	    	wynik+='<td valign="bottom"><a href="javascript:SFoto2(9,\'10.98\',4);"><img src="/images/low_4_emisje.gif" rel="buton" highsrc="/images/high_4_emisje.gif" border="0"><div>4 emisje (9zł+VAT)</div></a></td>';
	    	wynik+='<tr></table>';
			ident.innerHTML=wynik;
			ident=ident.firstChild.firstChild.firstChild;
			for(var i=0;i<ident.cells.length;i++)
	  	  		imgMOver(ident.cells[i].firstChild.firstChild);
			TTypeinit('Fbtp','Fdtp');
		}
		else{
			wynik+='<table cellspacing="0" border="0"  cellpadding="10" class="Fbuton2" id="Fbtp" align="center"><tr>';
			wynik+='<td valign="bottom"><a href="javascript:SFoto2(5,\'6.10\',1);"><img src="/images/low_1_emisja.gif" rel="buton" highsrc="/images/high_1_emisja.gif" border="0"><div>1 emisja (5zł+VAT)</div></a></td>';
	    	wynik+='<td valign="bottom"><a href="javascript:SFoto2(9,\'10.98\',2);"><img src="/images/low_2_emisje.gif" rel="buton" highsrc="/images/high_2_emisje.gif" border="0"><div>2 emisje (9zł+VAT)</div></a></td>';
	    	
			wynik+='<tr></table>';
			ident.innerHTML=wynik;
			ident=ident.firstChild.firstChild.firstChild;
			for(var i=0;i<ident.cells.length;i++)
	  	  		imgMOver(ident.cells[i].firstChild.firstChild);
			TTypeinit('Fbtp','Fdtp');
		}
    	
//		var nr="3";
//		if(rejon=="war") nr="5";	
//		Show('pole_zdjecie');
//		_get('foto_price').innerHTML='7'+nr+'130';
//		_get('foto_price_txt').innerHTML=nr;    
    }   
    if(typ=='18'){ //ogłoszenie wyrużnione - HASŁO
		Splatne3(9,'10.98',1);
    } 
        
    if(typ=='19'){ //ogłoszenie ze zdjęciem - HASŁO
    	SFoto2(9,'10.98',1);
    }   
    if(typ=='35'){ //aukcja
		Splatne3(1,'1.22',1);
    } 

}

function SFoto(nr,emisje){
	Show('pole_zdjecie');
	_get('foto_price').innerHTML='7'+nr+'130';
	_get('foto_price_txt').innerHTML=nr;   
	var l_emisji=_get('l_wyd'); if(l_emisji!=undefined) l_emisji.value=emisje;
    showCalendar();
}

function SFoto2(price,price_vat,emisje){
	Show('pole_zdjecie');
	_get('foto_price').innerHTML='7'+price+'130';
	_get('foto_price_txt').innerHTML=price;   
	_get('foto_price_txt_vat').innerHTML='('+price_vat+'zł z VAT)'; 
	var l_emisji=_get('l_wyd'); if(l_emisji!=undefined) l_emisji.value=emisje;
    showCalendar();
}
function Rsel(ident){
    var ident2=ident.parentNode.parentNode;
    var Tident=ident2.parentNode.parentNode;
    var rowIndex=ident2.rowIndex;
    _get('rejon').value=ident.value;
    var idt=_get('button');
    if(idt!=null)
    Semisje(_get('Price'),ident.value,idt.value);
    //alert(idt.value);
    for(var i=1;i<Tident.rows.length;i++)
    Tident.rows[i].cells[0].style.backgroundColor = (i==rowIndex)? "#FFFF80":"#FFFFFF";
    showCalendar()
    Show('finalizacja');


}
function Rsel2(rejon){
    var idt=_get('button');
    if(idt!=null)
    Semisje(_get('Price'),rejon,idt.value);
    showCalendar()
    Show('finalizacja');

    var reg_platne=_get('reg_platne');
    if(reg_platne!=null)   reg_platne.href='/regulamin/reg.internet.sms.'+rejon+'.html';
    var reg_foto=_get('reg_foto');
    if(reg_foto!=null)   reg_foto.href='/regulamin/reg.internet.sms.'+rejon+'.html';		
	/*	
    if(idt.value=='0'){
    //if(TRac[rejon]==0){
	_get('Price').innerHTML='<center><font color="red" style="font-size:16px;font-weight:bold;">Ogłoszenie bezpłatne dostępne tylko dla Oferty Śląskiej</font></center>';
	Hide('sendOgl');
    }else{
	_get('Price').innerHTML='';
	if(idt.value!='2')	Show('sendOgl');

    }
    
    }*/

}

function ObjStyle(ident,style){
    ident.setAttribute('class',style);    
    ident.setAttribute('className',style);    
}


