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 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 getStyle(myID) {
        var oDiv = document.getElementById(myID);
      	myS = oDiv.style.marginTop;
      
       return(myS);
}

function getH(divID) {

				var docH = document.body.clientHeight;
												
				if (parseInt(navigator.appVersion)>3) {
				 if (navigator.appName=="Netscape") {
				  winH = window.innerHeight;
				 }
				 if (navigator.appName.indexOf("Microsoft")!=-1) {
				  winH = document.body.offsetHeight;
				 }
				}
				
				return(winH);
}

function getmail() {
   
   	var alertMessage = '';
   
    if (!document.getElementById("title").value) { alertMessage = alertMessage + 'ProszÄ™ podaÄ‡ tytuÅ‚ wiadomoÅ›ci. '; }
    if (!document.getElementById("message").value) { alertMessage = alertMessage + 'ProszÄ™ podaÄ‡ ÅºrÃ³dÅ‚o informacji o naszej firmie. '; }  
    if (!document.getElementById("from").value) { alertMessage = alertMessage + 'ProszÄ™ podaÄ‡ imiÄ™ i nazwisko. '; } 
    if (!document.getElementById("email").value) { alertMessage = alertMessage + 'ProszÄ™ podaÄ‡ adres e-mail. '; } 
   
   	if (alertMessage == '') {
   						get(document.getElementById('contactForm'));
						pokaz('contactPrelo'); 
						ukryj('contactForm');
	}
	else alert(alertMessage);
   }
   
function goto(url) {
	window.location=url;	
}

function init() {



}

function getCursorY(e) {

	if (!e) var e = window.event;

	myMenu = 'col1';
	myKlik = 'scrollMenu';
	
	maxMargin = 170;

	Y = (window.Event) ? e.pageY : event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
	
	menuY = parseInt(getOffset(myMenu));	
	
			
	if (Y > maxMargin && menuY >= 0) {		
		klik(myKlik);

		
	}
	
	if (Y < maxMargin && menuY == -62) {		
		klik(myKlik);
		
		
		
	}

}

function getOffset(myID) {
	return getStyle(myID, 'margin-top');
}

function mouseMoveHandler (evt) {
  var x = document.all ? event.clientX : document.layers ? evt.x : evt.clientX;
  var y = document.all ? event.clientY : document.layers ? evt.y : evt.clientY;
  window.status = x + ':' + y;
}

function rezerwuj(data) {

	newData = data;
			
	klik('rsvOpen');
	
}

function testData() {
	alert(newData);
}

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


 function getHeight2(divID) {
 
	//var divHeight = document.getElementById(divID).clientHeight;	
	
				if (parseInt(navigator.appVersion)>3) {
				 if (navigator.appName=="Netscape") {
				  divHeight = document.getElementById(divID).clientHeight;	
				 }
				 if (navigator.appName.indexOf("Microsoft")!=-1) {
				  divHeight = document.getElementById(divID).offsetHeight;
				 }
				}
	
	return divHeight;
}

function clearInput(myID, fraza) {

	if (document.getElementById(myID).value == fraza) {

	document.getElementById(myID).value = '';
	document.getElementById(myID).style.color = '#242424';
	document.getElementById('searchButton').style.display = 'block';	
	
	}
}

function fillInput(myID, fraza) {

	if (document.getElementById(myID).value == '') {

	document.getElementById(myID).value = fraza;
	document.getElementById(myID).style.color = '#666666';
	document.getElementById('searchButton').style.display = 'none';
	
	}
}

function bookmark() {

 title = "Best-Pest"; 

 url = "http://www.bestpest.com.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 swapCreature(num) {
 	ukryj('creatures');
 	pokaz('creaturesPrelo'); 	
 	
 	ajaxpage('ajax/swapCreature.php?'+num, 'creaturesHolder');
 }
 
 function noValue(myID) {
 		
 		if(document.getElementById(myID).value != 'Podaj swój adres e-mail')
 		document.getElementById(myID).value = '';
 		
 }
 
 function mark(myID, myVal) {

	var sondaID = 'sonda'+myID;
	
	ukryj('sondaContent'+myID);
	pokaz('prelo'+myID);
	
	ajaxpage('ajax/vote.php?'+myID+','+myVal, sondaID);

}
