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 pokaz(ref) {
	if (ref) document.getElementById(ref).style.display = 'block';	
}

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

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


function addStyle(el, s){
  if(typeof(el) == 'string'){el = document.getElementById(el);}
  var st = s.split(';');
  for(var i=0; i<st.length; i++){
    var stl = st[i].split(':');
    if(stl.length == 2){
      stl[0] = stl[0].replace(/^\s*|\s*$/g,"");
      stl[1] = stl[1].replace(/^\s*|\s*$/g,"");
      stl[1] = stl[1].replace(/'/g, "\"");
      tmpStl = stl[0].split('-');
      stl[0] = tmpStl[0];
      for(var j=1; j < tmpStl.length; j++){
        stl[0] += tmpStl[j].charAt(0).toUpperCase() + tmpStl[j].substr(1).toLowerCase();
      }
      delete tmpStl;
      if(stl[0].length > 3){eval('el.style.' + stl[0] + ' = \'' + stl[1] + '\';');}
    }
  }
  return false;
}

function sub(id) {

for (i = 1; i < 20; i++) {
    						if (document.getElementById('sub'+i)) ukryj('sub'+i);	
						}
if (document.getElementById('sub'+id)) pokaz('sub'+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 klik(id) {
	  document.getElementById(id).click();
}
    
    
function showspec() {
	var ref = 'specdetails';	
    if (document.getElementById(ref).style.display == 'none') pokaz(ref); else ukryj(ref);
}
function ai(id, fraza) {
if (document.getElementById(id).value == fraza)
	document.getElementById(id).value = '';
	
	document.getElementById(id).style.color='#242424';
}

function di(id, fraza) {
	if (document.getElementById(id).value == '') {
	document.getElementById(id).value = fraza;
	document.getElementById(id).style.color='#cccccc';
	}
}

function markSize(id) {

		for (i=1; i<=3; i++) {
		turnoff = document.getElementById('text'+i);
		turnoff.style.color = '#999999';
		}

		turnon = document.getElementById('text'+id);
		turnon.style.color = '#EC5519';
}

if ( document.getElementById('dw_scrollObj') && dw_scrollObj.isSupported() ) {
		   dw_Event.add( window, 'load', init_dw_Scroll_v);
}

function closeRokbox() {
    window.parent.window.klik('rokbox-overlay');
}

function setDate(pole, wartosc, tresc) {
	window.parent.window.document.getElementById(pole+'date').value = wartosc;
	window.parent.window.document.getElementById(pole).innerHTML = tresc;
	closeRokbox();	
}

function submitForm(id) {
	pokaz('uploadPrelo');
	ukryj('updatePhotos');
	document.getElementById(id).submit();
}

function submitArtForm(id) {
	pokaz('uploadArtPrelo');
	ukryj('updateArt');
	document.getElementById(id).submit();
}

function switchSelect(id) {

	ajaxpage('ajax/objectKind.php?'+id, 'objectKind');

}

 function init_dw_Scroll_v() {
    var wndo = new dw_scrollObj('wn', 'lyr1');
    wndo.setUpScrollbar("dragBar", "track", "v", 1, 1);
    wndo.setUpScrollControls('scrollbar');
    incontent = getHeight('incontent');   
    
    if (incontent < 290) {
    
    			var style = 'display: none;';
				addStyle('track', style);    
    
    }
}

function getpost() {

	post = document.getElementById('voice').value;
	
	ajaxpage('ajax/getPost.php?mypost='+post, 'chats'); 
	
	document.getElementById('voice').value = '';
		
	return false;

}

function refreshShoutBox() {

	init_dw_Scroll_v();

}


function tick() {

	ajaxpage('ajax/getPost.php', 'chats'); 
	ajaxpage('ajax/online.php', 'onlines'); 
	
	init_dw_Scroll_v();

 setTimeout("tick()", 5000);
}


