function maillist(setmail){
	var obj = document.getElementById('newsmail');
	if(obj != null)
	{
		document.getElementById('newsmail').value = setmail;
	}
}
////////////////////////////////////////////////////////////////////////////////////
function checkEmail (email) {
      invalid = " /:,;";
      if (email=="") { return false }
      for (i=0; i<invalid.length; i++) {
        bad = invalid.charAt(i);
        if (email.indexOf (bad, 0) != -1) { return false }
      }
      at = email.indexOf ("@", 0);
      if ((at == -1) || (at == 0)) { return false }
      if (email.indexOf ("@", at+1) != -1) { return false }
      period = email.indexOf (".", at);
      if ((period == -1) || (period == at+1)) { return false }
	  znak = email.charAt(email.length - 1);
      if (znak ==  ".") { return false }
      at = email.indexOf (".",email.length - 4);
      if (at == -1) { return false };
      return true;
}
//////////////////////////////////////////////////////////////////////////////////
function zapisz(form,msg) {
	if (!(checkEmail(form.email.value))) {
		alert(msg);
		form.email.focus();
		form.email.select();
		return false;
	}
	else {
		return true;
	}
}
//////////////////////////////////////////////////////////////////////////////////
function zapiszCustomer(form,msg) {
	var ifNewsletter = form.newsletter.checked;

	if (ifNewsletter) {
		if (!(checkEmail(form.email.value))) {
			alert(msg);
			form.email.focus();
			form.email.select();
			return false;
		} else {
			return true;
		}
	} else {
		if (!(checkEmail(form.email.value))) {
			alert(msg);
			form.email.focus();
			form.email.select();
			return false;
		} else {
			return true;
		}
	}
}
//////////////////////////////////////////////////////////////////////////////////
function sendOpinion(form,msg) {
	var key = 0;
	for (var i = 0; i < form.my_opinion.length; i++){
		if (form.my_opinion[i].checked){
			key = form.my_opinion[i].value;
			break;
		}
	}

	if (key == 0) {
		alert(msg);
		return false;
	} else {
		if (key == form.klucz.value) {
			form.action.value = "form";
		} else {
//			form.set.value = "tak";
		}
	}
	return true;
}
//////////////////////////////////////////////////////////////////////////////////
function sendAnnounce(form,msg) {
	var key = 0;
	for (var i = 0; i < form.status.length; i++){
		if (form.status[i].checked){ return true; }
	}
	alert(msg);
	return false;
}
//////////////////////////////////////////////////////////////////////////////////
function submitForm(name){
	if (document.forms[name])   {
		document.forms[name].submit();
	}
}
//////////////////////////////////////////////////////////////////////////////////
function submitFormOrder(section){
	var obj = document.getElementById('section');
	if(obj != null)
	{
		document.getElementById('section').value = section;
	}
	document.forms['order'].submit();
}
//////////////////////////////////////////////////////////////////////////////////
function updateForm(){
	var obj = document.getElementById('section');
	if(obj != null)
	{
		document.getElementById('section').value = 'update';
	}
}
//////////////////////////////////////////////////////////////////////////////////
function cleartxt(set){
	var obj = document.getElementsByName('clear_txt');
	if(obj != null)
	{
		document.forms['frm'].clear_txt.value = set;
	}
	document.forms['frm'].submit();
}
//////////////////////////////////////////////////////////////////////////////////
function odswiezObject() {
	objects = document.getElementsByTagName("object");
	for (var i = 0; i < objects.length; i++)
	{
		objects[i].outerHTML = objects[i].outerHTML;
	}
}
//////////////////////////////////////////////////////////////////////////////////
function zmianaSelect(nazwa, podnazwa) {
	select	= document.getElementById(nazwa + "_id");
	if (select ==  null) {return;}
	id	= select.options[select.selectedIndex].value;

	ile = select.length;

	for (i = 0; i < ile; i++) {
		val	= select.options[i].value;
		pokazDiv(nazwa + "div_" + val, (val == id) );
	}

      if (podnazwa != '') {
      	zmianaSelect(podnazwa + "_" + id,'');
      }
}
//////////////////////////////////////////////////////////////////////////////////
function zmianaDiv(div_name) {
	select	= document.getElementById(div_name + "_id");
	id		= select.options[select.selectedIndex].value;

	ile = select.length;
	for (i = 0; i < ile; i++) {
		val	= select.options[i].value;
		pokazDiv(div_name + "div_" + val, val == id);
	}
}
//////////////////////////////////////////////////////////////////////////////////
function pokazDiv(nazwa, warunek) {
	div	= document.getElementById(nazwa);
	if (div != null) {
		div.style.display = (warunek) ? "block" : "none";
	}
}
//////////////////////////////////////////////////////////////////////////////////
function zmianaGaleria(msg) {
	select	= document.getElementById("gallery_id");
	selected= document.getElementById("gallery_selected");
	id		= select.options[select.selectedIndex].value;

	if (id == -1) {
		alert(msg);
		for (var i = 0; i < select.length; i++) {
			if (select.options[i].value == selected.value) {
				select.options[i].selected = true;
			}
		}
	} else {
		window.location = "/index.php?action=gallery&gallery_id=" + id;
	}
}
//////////////////////////////////////////////////////////////////////////////////
function setViewHide(button) {

	pokazDiv("beton_div", button.value == 1);
	pokazDiv("prefabrykat_div", button.value == 2);
/*
//	document.getElementById('l_size').style.display	= view;
//	document.getElementById('c_size').style.display	= view;
	document.getElementById('l_height').style.display	= view;
	document.getElementById('c_height').style.display	= view;
	document.getElementById('l_width').style.display	= view;
	document.getElementById('c_width').style.display	= view;
	document.getElementById('l_length').style.display	= view;
	document.getElementById('c_length').style.display	= view;
	document.getElementById('l_temperature').style.display	= view;
	document.getElementById('c_temperature').style.display	= view;
	document.getElementById('l_typ').style.display	= view;
	document.getElementById('c_typ').style.display	= view;
*/
}
//////////////////////////////////////////////////////////////////////////////////
function show_gallery(frag)
{
	var d;

	for(i = 1 ; i <= realmod; i++) {

		if (d = document.getElementById('gallery_'+i)) {
			if(i == frag) {
				d.className = 'gallery_show';
			}
			else	{
				d.className = 'gallery_hide';
			}
		}
	}
}
/************************************************************************************/
function UpdateTimer() {
	if(timerID) {
      	clearTimeout(timerID);
		clockID  = 0;
	}

	if(timer % timeout == 0) {
		show_gallery(active%realmod + 1);
		active++;
	}

	timer++;

	timerID  = setTimeout("UpdateTimer()", 1000);
}
/************************************************************************************/
function start_gallery() {
	tStart   = new Date();
	timerID  = setTimeout("UpdateTimer()", 1000);
}
/************************************************************************************/
function stop_gallery() {
	if(timerID) {
		clearTimeout(timerID);
		timerID  = 0;
	}

	tStart = null;
	active = 0;
}
/************************************************************************************/
function reset_gallery() {
	tStart = null;
}
/************************************************************************************/

function displayMenuBox(id, maxid) {
	var browser = navigator.userAgent.toLowerCase();
	var isIE = ((browser.indexOf("msie") != -1) && (browser .indexOf( "opera" ) == -1) && (browser .indexOf( "webtv" ) == -1));
//alert(isIE);
//	if (!isIE) {return;}
	div = document.getElementById("menu" + id);
	if(div != null && div.style.display == "block") {
		return;
	}
	for (var i = 1; i <= maxid; i++){
		div = document.getElementById("menu" + i);
//alert(div);
//alert(i == id);
		if(div != null)	{
			div.style.display = (i == id) ? "block" : "none";
		}
	}
}
/************************************************************************************/
function hideMenuBox(id) {
	var browser = navigator.userAgent.toLowerCase();
	var isIE = ((browser.indexOf("msie") != -1) && (browser .indexOf( "opera" ) == -1) && (browser .indexOf( "webtv" ) == -1));
//	if (!isIE) {return;}
	div = document.getElementById("menu" + id);
	if (div != null)	{
		div.style.display = "none";
	}
}
/************************************************************************************/


