function mywrite(flash)
{
	document.write(flash)
}


function $(name)
{
	obj =  document.getElementById(name);
	return obj;
}


function myMail(f)
{
	if (!CheckEMail(f.email.value))
	{
		alert("Prosze podać poprawnie adres e-mail...");
		f.email.focus();
		return false;
	}

	return true;
}


function checkKontakt(f)
{
	if (!f.nazwisko.value)
	{
		alert("Prosze podać imię i nazwisko...");
		f.nazwisko.focus();
		return false;
	}

	
	if (!f.email.value && !f.telefon.value)
	{
		alert("Prosze podać adres e-mail lub telefon kontaktowy...");
		f.email.focus();
		return false;
	}
	
	if (f.email.value && !CheckEMail(f.email.value))
	{
		alert("Prosze podać poprawnie adres e-mail...");
		f.email.focus();
		return false;
	}
	
/*
	if (!f.temat.value)
	{
		alert("Prosze podać temat wiadomości...");
		f.temat.focus();
		return false;
	}
*/

	if (!f.ftresc.value)
	{
		alert("Prosze podać treść wiadomości...");
		f.ftresc.focus();
		return false;
	}

	return true;
}





function SetOpacity(elem, opacityAsInt)
{

	if (opacityAsInt==0) 
		elem.style.display = "none";
	else
		elem.style.display = "block";
	
//	alert(elem.style.display);
	
	var opacityAsDecimal = opacityAsInt;
	
	if (opacityAsInt > 100)
		opacityAsInt = opacityAsDecimal = 100; 
	else if (opacityAsInt < 0)
		opacityAsInt = opacityAsDecimal = 0; 
	
	opacityAsDecimal /= 100;
	if (opacityAsInt < 1)
		opacityAsInt = 1; // IE7 bug, text smoothing cuts out if 0
	
	elem.style.opacity = opacityAsDecimal;
	elem.style.filter  = "alpha(opacity=" + opacityAsInt + ")";
}

function FadeOpacity(elemId, fromOpacity, toOpacity)
{
	var steps = 20;
	var delta = (toOpacity - fromOpacity) / steps;
	
	FadeOpacityStep(elemId, 0, steps, fromOpacity, delta, 10);
}

function FadeOpacityStep(elemId, stepNum, steps, fromOpacity, delta, timePerStep)
{
    SetOpacity($(elemId), Math.round(parseInt(fromOpacity) + (delta * stepNum)));

    if (stepNum < steps)
        setTimeout("FadeOpacityStep('" + elemId + "', " + (stepNum+1) + ", " + steps + ", " + fromOpacity + ", " + delta + ", " + timePerStep + ");", timePerStep);
}


function Center(id)
{

	 // wielkosc okna przegladarki
	 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;
	  }
	  
	  var divHeight = parseInt(($(id).offsetHeight), 10); 
	  var divWidth = parseInt(($(id).offsetWidth), 10); 
	  
	  $(id).style.marginTop = ((myHeight - divHeight) / 2 ) + "px";
	  $(id).style.marginLeft = ((myWidth - divWidth) / 2 ) + "px";
	 
}


function Close()
{
	$("main_box").style.display = "none";
	FadeOpacity("overlay", 80, 0);
}

function Show()
{
	$("main_box").style.display = "block";
	window.onresize = function () { Center("main_box"); }
	Center("main_box");	
	
	FadeOpacity("overlay", 0, 80);
	
	Scroll();
	SetOpacity(document.getElementById('wait'), 0);
//	isInitialized = false;
	sIFR.isActive = false;
	Fonts();
}


var akt = 0;
function Scroll(divId)
{
	
	var hx = 0;
	if ($("content"+divId).offsetHeight > h ) hx = h;
	else hx = $("content"+divId).offsetHeight + 12;
	
	$("content"+divId).innerHTML = '<div class="Kontener" id="pole_1_kontener"  ><div class="Scroller" id="pole_1" ><div class="Scroller-Container" id="content">' + $("content"+divId).innerHTML + '</div></div></div><div id="pole_1_winda" class="Scrollbar-Container"><img src="images/scroll_top.gif" width="7" height="6" class="Scrollbar-Up" alt="W górę" /><img src="images/scroll_bottom.gif" width="7" height="6" class="Scrollbar-Down" alt="W dół" /><div class="Scrollbar-Track" id="pole_1_track"><img src="images/bull.gif" width="8" height="8" class="Scrollbar-Handle" /></div></div><div class="clear"></div>';
	
	scroller  = null;
	scrollbar = null;
	scroller  = new jsScroller(document.getElementById("pole_1"), 780, hx);
	scrollbar = new jsScrollbar (document.getElementById("pole_1_winda"), scroller, false);

}



function updateDiv(divId, content) {
	var http = false;
	
	if(navigator.appName == "Microsoft Internet Explorer") {
	  http = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
	  http = new XMLHttpRequest();
	}

	http.abort();
  	http.open("GET", content, true);
  	http.onreadystatechange=function() {
	if(http.readyState == 4 || http.readyState=="complete")
    {
	  $("s"+divId).style.height = "";
	  $("content"+divId).style.height = "";
	  $("content"+divId).className = "content";
      $("content"+divId).innerHTML = http.responseText;
	  
//	  Fonts();  
//	  Scroll(divId);
	  show(divId);
	  
    }
  }
  http.send(null);
}



function loadTxt(id)
{
	// ukrywanie ostatniego diva
	if (last_tab)
	{
		last = last_tab;
		if (parseInt(last.style.height)>0) hide_div(last, h, -1);
		var id2 = last_tab.id;
		last_tab = 0;
	}	


	if ("s"+id != id2)
	{
		$("content"+id).innerHTML = "";
		$("s"+id).style.display = "block";
		$("s"+id).style.height = "100px";
		$("content"+id).className = "wait";
		
		// ladowanie nowej zawartosci
		updateDiv(id, "ajax_tresc.php?id="+id);
	}

}


var h = 0; // wysokosc elementu
var start = 1; // zakladka startowa 
var pos = 1; 


function getPageSize() // wysokosc i szerokosc okna przegladarki
{
    var windowWidth, windowHeight;
    if (self.innerHeight) {    // all except Explorer
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }    
    arrayPageSize = new Array(windowWidth,windowHeight) 
    return arrayPageSize;
}




window.onload=function() // okreslenie maksymalnej wysokosc okna z prezentacją
{
	var pom = getPageSize();
	wysokosc = pom[1]*0.85;
	h = wysokosc;
}



function hide_div(last, slide, dir) // ukrywjanie tresc
{
	last.childNodes[0].innerHTML = "";
	if (slide>0)
	{
		
		liczba = Math.ceil(slide/3);
		if (liczba>h/3) liczba = Math.ceil(h/3);
	
		if (!last.style.height) last.style.height = 0;

		if (dir<0 && parseInt(last.style.height)<liczba) liczba = parseInt(last.style.height);

		last.style.height = parseInt(last.style.height) + liczba*dir + "px";

		if (parseInt(last.style.height)>0) 
			slide = slide - liczba;
		else
			slide = 0;
		
		setTimeout("hide_div(last, "+slide+", "+dir+")", 1);	

	}
	else
	{
		// ostateczne ukrywanie diva
		last.style.height = 0;
		last.style.display = "none";
		last.childNodes[0].innerHTML = "";

	}
}


function show_div(obj, slide, dir) // pokazywanie tresci
{
	if (slide>0)
	{
		
		liczba = Math.ceil(slide/8);
		if (liczba>h/8) liczba = Math.ceil(h/8);		
		
		if (!obj.style.height) obj.style.height = 0;


		if (dir<0 && parseInt(obj.style.height)<liczba) liczba = parseInt(obj.style.height);

		obj.style.height = parseInt(obj.style.height) + liczba*dir + "px";

		if (parseInt(obj.style.height)>0) 
			slide = slide - liczba;
		else
			slide = 0;
		
		setTimeout("show_div(obj, "+slide+", "+dir+")", 1);
	}
	else
	{
		// przesuwanie okna we wlasciwe miejsce
		window.location.hash = "p"+obj.id.substr(1);
	}

}

var last_tab = 0;

function show(id)
{
	
	var hx = 0;
	if ($("content"+id).offsetHeight > h ) hx = h;
	else hx = $("content"+id).offsetHeight + 12;
/*
	$("content"+id).innerHTML = '<div class="Kontener" id="pole_1_kontener"  ><div class="Scroller" id="pole_1" ><div class="Scroller-Container" id="content">' + $("content"+id).innerHTML + '</div></div></div><div id="pole_1_winda" class="Scrollbar-Container"><img src="images/scroll_top.gif" width="7" height="6" class="Scrollbar-Up" alt="W górę" /><img src="images/scroll_bottom.gif" width="7" height="6" class="Scrollbar-Down" alt="W dół" /><div class="Scrollbar-Track" id="pole_1_track"><img src="images/bull.gif" width="8" height="8" class="Scrollbar-Handle" /></div></div><div class="clear"></div>';
	
	scroller  = null;
	scrollbar = null;
	scroller  = new jsScroller(document.getElementById("pole_1"), 770, hx);
	scrollbar = new jsScrollbar (document.getElementById("pole_1_winda"), scroller, false);
*/
	obj = document.getElementById("s"+id);
	last_tab = obj;
	
	obj.style.display = "block";

	// dopasowanie wielkosci okna do ilosci tresci
//	alert(hx);
	obj.childNodes[0].style.height = (obj.childNodes[0].offsetHeight) + "px";
	h_pom = obj.childNodes[0].offsetHeight +  ( (obj.childNodes[0].offsetHeight>h) ? 20:10);

	show_div(obj, h_pom, 1);
}

var lat_all = new Array();
var lng_all = new Array();
var name_all = new Array();
var opis_all = new Array();

lat_all[0] = 52.238585;
lng_all[0] = 20.988586;
name_all[0] = 'Grupa Białko';
opis_all[0] = '<strong>Makowiecki Wokitajtis Grupa Białko Sp. J.</strong><br />ul. Ogrodowa 31-35, 00-893 Warszawa';
		
function mapa()
{
	
		map = new GMap2($("mapa"));
		map.setCenter(new GLatLng(50, 13), 5);
		var customUI = map.getDefaultUI();
		customUI.controls.maptypes = true;
		customUI.maptypes.hybrid = true;
		customUI.maptypes.satellite = true;
		customUI.maptypes.physical  = true;
		map.setUI(customUI);
//		map.setMapType(G_HYBRID_MAP);

		
		// Deklaracja ikonek
		var ikona0 = new GIcon();   
		ikona0.image = "images/pin.png";   
		ikona0.shadow = "";//"images/blue-pushpin-s.png";   
		ikona0.iconSize = new GSize(131, 83);
		//ikona0.shadowSize = new GSize(59, 32); 
		ikona0.infoWindowAnchor = new GPoint(36,78);   
		ikona0.iconAnchor = new GPoint(36,78);   


		//Skalowanie obszaru
		var obszar = new GLatLngBounds();  


		var punkty = new Array();
		var markery = new Array();


    	function createMarker(point, info, title, icon) {   
          var marker = new GMarker(point, {title: title, icon: icon});   
          GEvent.addListener(marker, "click", function() {   
            marker.openInfoWindowHtml(info);//   ,{maxWidth:400}
          });   
          return marker;   
        } 
		
		
		punkty[0] = new GLatLng(lat_all[0], lng_all[0]);
		marker = createMarker(punkty[0], opis_all[0], name_all[0],ikona0);
		map.addOverlay(marker);
		//marker.openInfoWindowHtml(opis_all[0]); 
		obszar.extend(punkty[0]);  	
		

		var nowyZoom = map.getBoundsZoomLevel(obszar);  
		var nowyZoom = 16;
		var nowyPunkt = obszar.getCenter();   
		map.setCenter(nowyPunkt,nowyZoom);  

	
}

