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;
} 


 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 closeRokbox() {
    window.parent.window.klik('rokbox-overlay');
}

function getH(divID) {

				if (document.getElementById(divID)) {
				var divHeight = document.getElementById(divID).clientHeight;								
				return(divHeight);
				}
}

function getW(divID) {

				if (document.getElementById(divID)) {
				var divWidth = document.getElementById(divID).clientWidth;								
				return(divWidth);
				}
}

function getY( el ) {
    var _x = 0;
    var _y = 0;
    while( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) {
        _x += el.offsetLeft - el.scrollLeft;
        _y += el.offsetTop - el.scrollTop;
        el = el.parentNode;
    }
    return (_y);
}


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 windowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  
  return(myHeight);
}



function bookmark() {

 title = "Katowice: heart of Silesia"; 

 url = "http://invest.katowice.pl";

	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
 }
 
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='#AFAFAF';
	}
}
 
 function addSubscription() {
 
 	email = document.getElementById('subscription').value;
 	
 	if (validateEmail(email)) {
 	
 	pokaz('subPrelo'); ukryj('subsField');
 	ajaxpage('ajax/addSubscription.php?address='+email, 'inField');
 	
 	}
 
 }
 
 function validateEmail(email) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   
   if(reg.test(email) == false) {
      alert('Niewłaściwy adres e-mail / Invalid email address');
      return false;
   } else return true;
}

function cf(id) {

	if (id.value == 'wyszukaj...' || id.value == 'search...') {
	id.style.color = '#ffffff';
	id.value = '';
	}
	
	
}

function mf(id) {
	id.style.color = '#000000';
	id.value = '';
}

function subscribeNewsletter() {

	email = document.getElementById('newsLetterMail').value;
	
	if (validateEmail(email)) {
	
		document.getElementById('newsLetterMail').value = 'zapisywanie...';
		document.getElementById('newsLetterMail').disabled = true;
	
		ajaxpage('ajax/addSubscription.php?email='+email, 'innerNewsLetter');
	
	}

}

function goto(myURL) {
	window.location = myURL;
}

function setFooter() {
	
	var body = document.body,
	    html = document.documentElement;
	    
	    footerHeight = 86;
	    
	var height = Math.max( body.scrollHeight, body.offsetHeight, 
	                       html.clientHeight, html.scrollHeight, html.offsetHeight );
		
			if ((body.offsetHeight + footerHeight) < html.clientHeight) {
			document.getElementById('footer').style.top = (html.clientHeight - footerHeight) + 'px';
			
			
			
			} else {			
			
			document.getElementById('footer').style.top = (body.scrollHeight) + 'px';
			
			
			}
			fadeIn('footer');
				
	}
	
	function swapFoto(id, foto, podpis, suma) {
	
		for (i = 1; i <= suma; i++)
		document.getElementById('f'+i).style.background = 'none';
		
		document.getElementById('f'+id).style.background = "url('gfx/imgBg.png') no-repeat center center";
	
		inlineFoto = '<a href="pix/'+foto+'_800x.jpg" title="'+podpis+'"><img src="pix/'+foto+'_550x283.jpg" title="'+podpis+'" alt="'+podpis+'" /></a>';
		
		document.getElementById('fotoBrowser').innerHTML = inlineFoto;
		
		fadeIn('fotoBrowser');
	
	}
