function validate() {
    valid = true;

    if ( document.mailform.title.value == "" )
    {
        alert ( "Proszę podać tytuł wiadomości" );
        valid = false;
        return valid;
    }
    
    if ( document.mailform.body.value == "" )
    {
        alert ( "Proszę wpisać treść wiadomości" );
        valid = false;
        return valid;
    }
    
    if ( document.mailform.author.value == "" )
    {
        alert ( "Proszę podać swoje imię i nazwisko" );
        valid = false;
        return valid; 
    }
    
    if ( document.mailform.email.value == "" )
    {
        alert ( "Proszę podać adres e-mail" );
        valid = false;
        return valid; 
    }

    return valid;
}


function tg(ind,id,max){
	var showdiv = document.getElementById('switch'+ind+'div'+id)

	for (i=1; i<=max; i++) {
		hidediv = document.getElementById('switch'+ind+'div'+ i)
		hidediv.style.display = 'none'
		}

		showdiv.style.display = 'block'
}

function sm(id, myID) {
	
	var max = 4;
	
	wyczysc('quotations');
	
	ajaxpage('ajax/quotations.php?'+myID, 'quotations', '');
	
	pokaz("quotationsPrelo"); ukryj ("quotations");
	
	var showdiv = document.getElementById('stock'+id);
	var showtit = document.getElementById('sT'+id);
	var showrss = document.getElementById('sRSS'+id)	

	for (i=1; i<=max; i++) {
		hidediv = document.getElementById('stock'+i)
		hidediv.style.display = 'none'
			
		hidetit = document.getElementById('sT'+i)
		hidetit.style.display = 'none'			
			
		stockMarker = document.getElementById('st'+i)
		stockMarker.style.fontWeight = 'normal'
			
		}
		stockMarker = document.getElementById('st'+id)
		stockMarker.style.fontWeight = 'bold'
			
		showdiv.style.display = 'block'	
		showtit.style.display = 'block'	
			
		init_dw_Scroll()			
}

function pokaz(ref) {
	if (ref) document.getElementById(ref).style.display = 'block';	
}

function ukryj(ref) {
	if (ref) document.getElementById(ref).style.display = 'none';	
}

function pokazSF(ref) {
	if (disp == false) {		
		document.getElementById(ref).style.height = 200+'px';
		document.getElementById(ref).style.overflow = 'visible';
		disp = true;
	}
	else {		
		document.getElementById(ref).style.height = 0+'px';
		document.getElementById(ref).style.overflow = 'hidden';		
		disp = false;
	}
}

function nS(user,domain) {
         locationstring = "mailto:" + user + "@" + domain;
         window.location = locationstring;
} 

function hideFlash() {
	ukryj('fastFlash');
	pokaz('slowFlash');
}

function showFlash() {
	ukryj('slowFlash');
	pokaz('fastFlash');
}

function setUserDate(pole, wartosc, slownie) {	
	document.getElementById(pole).value=(wartosc);     
	document.getElementById(pole + '_label').value=(slownie);   
	document.getElementById('calendar_' + pole).style.display = 'none';	
}

function inputFocus(id, action) {
	if (action == true) {
	document.getElementById(id).style.border='1px solid #506c0d';
	}
	
	if (action == false) {
		document.getElementById(id).style.border='1px solid #aaaaaa';
	}
}

function isNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }

function init_dw_Scroll() {
    var wndo = new dw_scrollObj('wn', 'lyr1', 't1');
    wndo.setUpScrollbar("dragBar", "track", "h", 1, 1);
    wndo.setUpScrollControls('scrollbar');
}

function init_dw_Scroll_v() {
    var wndo = new dw_scrollObj('wn', 'lyr1');
    wndo.setUpScrollbar("dragBar", "track", "v", 1, 1);
    wndo.setUpScrollControls('scrollbar');
}

function switchChart(id, rzad, wybrany, suma, tablica) {
	
	ask = 'ajax/chart.php?'+tablica+','+id;
			
	ukryj("chartHolder"); pokaz("chartPrelo");
	ajaxpage(ask, 'chartHolder', tablica, id);
	
	var thisLi = document.getElementById('btt'+rzad+'_'+wybrany)	
	
	for (i=1; i<=suma; i++) {
		allLi = document.getElementById('btt'+rzad+'_'+i)
		allLi.style.backgroundImage = "url('gfx/stockPosBg_l.png')";	
		}

		thisLi.style.backgroundImage = "url('gfx/stockPosBg_l_hv.png')";
		
}

function pageDown() {
	if (window.scrollBy)
	window.scrollBy(0, window.innerHeight ? window.innerHeight : 
	document.body.clientHeight);
}

function pageUp() {
	if (window.scrollBy)
	window.scrollBy(0, window.innerHeight ? -window.innerHeight : -
	document.body.clientHeight);
}

function wyczysc(id) {
	document.getElementById(id).innerHTML = '';
}

function validRegister(id) {
	
	document.getElementById('confirm_'+id).innerHTML = '<img src="gfx/small_ajax-loader.gif" alt="" />';		
		
	myValue = document.getElementById(id).value;
	
	if (id == 'password_confirm') myValue = myValue + '{*}' + document.getElementById('password').value;
	
	if (id == 'country' && myValue != 'Polska') ukryj('showVoivodship');
	if (id == 'country' && myValue == 'Polska') pokaz('showVoivodship');
	
	ajaxpage('ajax/validRegister.php?'+id+','+myValue, 'confirm_'+id, '');
		
}

if(typeof HTMLElement!='undefined'&&!HTMLElement.prototype.click)
    HTMLElement.prototype.click=function()
    {
        var evt = this.ownerDocument.createEvent('MouseEvents');
        evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
        this.dispatchEvent(evt);
    }

function showrokbox(id) {     
   document.getElementById(id).click();
}
function openPan(id) {     
	   pokaz(id);
	   document.getElementById(id).click();
}
function noValue (id) {
	document.getElementById(id).value=''; 	
}	

function switchButton() {
	if (document.getElementById('switch').innerHTML == 'nowy temat') document.getElementById('switch').innerHTML = 'anuluj'
	else document.getElementById('switch').innerHTML = 'nowy temat'
}

uploaded = 0;

function stopUpload(success, newfile, rawname, size){
			
	uploaded++;
	
	if (uploaded == 3) ukryj('f1_upload_form');
	
	pokaz('uploads');
	
	document.getElementById('uploaded_info'+uploaded).innerHTML = newfile + ' &raquo ' + size + ' | <a href="javascript:void(0);" onclick="ajaxpage(\'ajax/deattach.php?'+rawname+'\', \'uploaded_info'+ uploaded +'\', \'\'); noValue(\'plik'+uploaded+'\');" title="Usuń załącznik">usuń</a>';
	document.getElementById('plik'+uploaded).value = rawname;
	
    ukryj('f1_upload_process');  
    
    if (uploaded < 3)
    pokaz('f1_upload_form');   
    
    return true;   
}

function stopUploadFoto(){
	
    ukryj('f1_upload_process');
    pokaz('f1_upload_form');
    
    return true;   
}

function stopUploadInlineFoto(id, newfile){
			
    ukryj('f2_upload_process');  
    pokaz('f1_upload_form'); 
    pokaz('inline'+id);
    
    return true;   
}

function klik(id) {
	  document.getElementById(id).click();
}
function klikandscroll(id) {
	  document.getElementById(id).click();
	  showIt(id);
}
function sendPost() {

    valid = true;
    
	if ( document.addTitleForm.tresc.value == "" && document.addTitleForm.plik1.value == "") {
        valid = false;
		klik('noData');
	}

	if (valid == true) {	
		klik('switch');
		pokaz('newPostPrelo');
	}
	
	return valid;
	
}

function clearit(form, id) {
	document.getElementById(id).value = '';
}
function clearElement(id) {
	document.getElementById(id).innerHTML = '';
}
function setValue(id, val) {
	document.getElementById(id).value = val;	
}

function showIt(elID) {
  var el = document.getElementById(elID);
  el.scrollIntoView(true);
}
