var increase = false;
var decrease = false;
var cw=0;
function left(nr) {
    var l;
    if (document.getElementById)
        l = document.getElementById(nr).style.left;
    else if (document.all)
        l = document.all[nr].style.left;
    
    var le = parseInt(l.substring(0,l.indexOf("px")));
    if (isNaN(le)) le = 0;
    return le;
}

function display(id, wartosc)
{
  if (wartosc)
  {
  	//alert(id);
    if (document.getElementById) document.getElementById(id).style.display = wartosc;
    else if (document.all) document.all[id].style.display = wartosc;
  }
  else
  {
  	//alert('2 '+id);
    var wart = "";
    if (document.getElementById) wart = document.getElementById(id).style.display;
    else if (document.all) wart = document.all[id].style.display;
    return wart;
  }
}

function scrollLeft( nr, lef, width, step )
{
	div_container=document.getElementById(nr);
    var l = left(nr);

    if (l > lef - width) {
			if(l - step < lef - width)
			{
				l = lef-width;
			}
			else
			{
				l = l - step;
			}

	 decrease = true;
	   div_container.style.left = l+'px';
       return;
    } else if (l <= lef - width) {
        return;
    }
}

function contScroll(){
   var l1=left('ds_0');
   var road=Math.round(cw/2);
   var first='ds_0';
  
   if(l1>(-road)){
      scrollLeft('ds_0',0,road,1);
   }else{
      div_container=document.getElementById('ds_0');
      div_container.style.left = 0+'px';
   }
   setTimeout('contScroll()', 25);
   return;
}

var menuchilds=new Array();
menuchilds[0]='menu_pop1';
menuchilds[1]='menu_pop2';

function shMnuCh(id)
{
   for (i=0; i<menuchilds.length; i++)
   {
      if(id==menuchilds[i])
      {
         document.getElementById(menuchilds[i]).style.display='block';   
      }
      else
      {
         document.getElementById(menuchilds[i]).style.display='none';   
      }
   }
   return;
} 

function chText(id){
   obj=document.getElementById(id);
   if(obj.value==''){
      alert('Nie wpisałeś wymaganych danych');
      obj.style.backgroundColor="yellow";
      return false;
   }else{
      return true;
   }
}

function checkEmail(email){
    if( email.match(/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/)) {
        return true;
    } else {
        return false;
    }
}

function check_kontakt(){
   if(!chText('name')){
      return false;
   }
   if(!checkEmail(document.getElementById("kon2").value)){
      alert('Wpisz prawidłowy adres email');
      document.getElementById("kon2").style.backgroundColor="yellow";
      return false;
   }
   if(!chText('tresc')){
      return false;
   }
   return true;
} 


