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 = 1;
	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()
{
	$("content").innerHTML = "";
	$("main_box").style.display = "none";
	FadeOpacity("overlay", 80, 0);
}

function Show()
{
	if ($("main_box").style.display != "block")
	{
		$("main_box").style.display = "block";
		window.onresize = function () { Center("main_box"); }
		Center("main_box");	
		
//		FadeOpacity("overlay", 0, 80);
		
		SetOpacity(document.getElementById('overlay'), 80);
		
	//	Scroll();
		SetOpacity(document.getElementById('wait'), 100);
	//	isInitialized = false;
//		sIFR.isActive = false;
//		Fonts();
	}
	else
	{
		FadeOpacity('wait', 0, 100);
	}
}


function Scroll()
{
	var scroller  = null;
	var scrollbar = null;
	scroller  = new jsScroller(document.getElementById("pole_1"), 820, 420);
	scrollbar = new jsScrollbar (document.getElementById("pole_1_winda"), scroller, false);

}



function updateDiv(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() {
	//alert(http.readyState);
	if(http.readyState == 4 || http.readyState=="complete")
    {
     // alert(http.responseText);
	  $("content").innerHTML = http.responseText;
	  
	  FadeOpacity('wait', 100, 0);
	  Scroll();
	  sIFR.isActive = false;
	  Fonts();
	  initSlide();
	}
  }
  http.send(null);
}


function loadTxt(id)
{
	Show();
	updateDiv("ajax_tresc.php?id="+id);
}



function resize() {
 
  // 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;
   }

 
    if (myWidth < 1000) 
		$("sensis").style.width = "1000px";
	else
		$("sensis").style.width = "100%";
	
    if (myHeight < 600)
		$("sensis").style.height = "600px";
    else
		$("sensis").style.height = "100%";

//	alert(myHeight);
}

window.onload = resize;
window.onresize = resize;