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 checkFrame()
{
	if (!parent.frames["muzyka"])
	{
		str = document.location.href;
		str = str.substring(str.lastIndexOf("/") + 1, str.length);
		document.location.href = "index.php?file="+str;
	}
}

function CheckEMail(address) 
{
	return address != "" 	&& address.match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/);	
}

function divSwitch(hide, show)
{
	$(hide).style.display = "none";
	$(show).style.display = "block";
}

function checkKontakt()
{
	if (!$("nazwisko").value)
	{
		alert("Prosze podać imię i nazwisko...");
		$("nazwisko").focus();
		return false;
	}

	
	if (!$("email").value && !$("telefon").value)
	{
		alert("Prosze podać adres e-mail lub telefon kontaktowy...");
		$("email").focus();
		return false;
	}
	
	if ($("email").value && !CheckEMail($("email").value))
	{
		alert("Prosze podać poprawnie adres e-mail...");
		$("email").focus();
		return false;
	}
	
	if (!$("tresc").value)
	{
		alert("Prosze podać treść wiadomości...");
		$("tresc").focus();
		return false;
	}

	return true;
}




var height = 0;

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); 
	  
	//  height = myHeight;
	  
	  $(id).style.marginTop = ((myHeight - divHeight) / 2 ) + "px";
	  $(id).style.marginLeft = ((myWidth - divWidth) / 2 ) + "px";
	 
}


function Close()
{
		$("overlayMapa").style.display = "none";
		$("mapa").style.display = "none";

}




function Scroll(w, h)
{
	var scroller  = null;
	var scrollbar = null;
	scroller  = new jsScroller(document.getElementById("pole_1"), w, h);
	scrollbar = new jsScrollbar (document.getElementById("pole_1_winda"), scroller, false);

}


div = false;

function film()
{
	if (!div)
	{
		var toplayer = '<div id="film_overlay" onclick="closeFilm();"></div><div id="film_wraper" onclick="closeFilm();"><div class="film_close"><a href="#" onclick="closeFilm(); return false;"><img src="images/close.gif" width="17" height="17"></a></div><iframe id="film_content" src="film/damon.html" frameborder="0" marginheight="0" marginwidth="0" scrolling="no"></iframe></div>';
		
		var newDiv = document.createElement('div');
		newDiv.id = "film";
		newDiv.innerHTML = toplayer;
		
		document.body.insertBefore(newDiv, null);
		div = true;
	}
	else
	{
		$("film").style.display = "block";
		$("film_content").src = "film/damon.html";
	}
	
}


function closeFilm()
{
	$("film_content").src = "";
	$("film").style.display = "none";
}



/****************** COOKIE ***************************/
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

	  
var sound = true;
function soundSwitch()
{	
//	getFlashMovieObject("drzewo_v2").SetVariable("nauka", "leo_maluch.php"); 
	//window.document.drzewo_v2.SetVariable("nauka", "leo_maluch.php"); 

	if ( $("main") || $("small_clear") ) // wylaczenie dzwieku w drzewku
	{
		if (sound)
		{
			if ($("main")) getFlashMovieObject("main").ls_stopmusic();
//			if ($("small_clear")) getFlashMovieObject("small_clear").ls_stopmusic();
			$("nutka").src = "images/dzwiek_off.gif";
			sound = false
		}
		else
		{
			if ($("main")) getFlashMovieObject("main").ls_startmusic();
//			if ($("small_clear")) getFlashMovieObject("small_clear").ls_startmusic();
			$("nutka").src = "images/dzwiek.gif";
			sound = true
		}
	}

}


function getFlashMovieObject(movieName)
{
	if(document.embeds[movieName])
	return document.embeds[movieName];
	if(window.document[movieName])
	return window.document[movieName];
	if(window[movieName])
	return window[movieName];
	if(document[movieName])
	return document[movieName];
	return null;
}

	
function start()
{
	parent.frames["muzyka"].getFlashMovieObject("muz").ad_start();
	createCookie("isplaying", 1, 7);
}

//var bool1:Boolean = ExternalInterface.addCallback("ad_start", this, startmusic);
//var bool:Boolean = ExternalInterface.addCallback("ad_stop", this, stopmusic);


function stop()
{
	parent.frames["muzyka"].getFlashMovieObject("muz").ad_stop();
	createCookie("isplaying", 0, 7);
}


