
function check_value(element, startValue)
{
    element.className = 'i_text';
    
    if (element.value == startValue || element.value == 'Podaj poprawny adres e-mail' || element.value == 'Write correct email')
    {
        element.value = '';
    } 
}

function email_validate(src) 
{
  var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
  return regex.test(src);
}



function newsMenu(mode)
{
 
 switch(mode)
 {
   case 'lsse':
       document.getElementById('BipNews').style.display = 'none';
       document.getElementById('HomeNews').style.display = 'block';
       document.getElementById('lsse').className = 'active';
       document.getElementById('bip').className = 'normal';
   break;
   
   case 'bip':
        document.getElementById('BipNews').style.display = 'block';
        document.getElementById('HomeNews').style.display = 'none';
        document.getElementById('lsse').className = 'normal';
        document.getElementById('bip').className = 'active';
   break;
 }
}


function search_clear(phras, language)
{       
        phrase = phras.value;
        
        if(phrase == 'Szukana fraza' && language == 'pl')
        {       
                document.getElementById('SearchInput').value = '';
        }
        
        if(phrase == 'Search phrase' && language == 'en')
        {      
                document.getElementById('SearchInput').value = '';
        }
}

function check_form(myform, lang)
{
   
   
   errors = 0;
   
   if(d = document.getElementById('ContactInfo'))
   {
       d.innerHTML = '';
   }
  
  if(myform.first_name.value == "" || myform.first_name.value == "Wpisz imię" || myform.first_name.value == "First name")
  { 
    myform.first_name.className = 'i_text i_error';
    
    myform.first_name.value = (lang == 'pl') ? 'Wpisz imię' : 'First name';
    
    errors++;
  }
  
  if(myform.second_name.value == "" || myform.second_name.value == "Wpisz nazwisko" || myform.second_name.value == "Second name")
  { 
    myform.second_name.className = 'i_text i_error';
    
    
    myform.second_name.value = (lang == 'pl') ? 'Wpisz nazwisko' : 'Second name';
    
    errors++;
  }
  
  if(myform.email.value == "" || myform.email.value == "Podaj swój adres e-mail" || myform.email.value == "Email")
  { 
    myform.email.className = 'i_text i_error';
    
    myform.email.value = (lang == 'pl') ? 'Podaj swój adres e-mail' : 'Email';
    
    errors++;
  }
  
  else
  {
      if (! email_validate(myform.email.value))
      {
        myform.email.className = 'i_text i_error';
        
        email_value = (lang == 'pl') ? 'Podaj poprawny adres e-mail' : 'Write correct email';
        
        myform.email.value = email_value;
        
        errors++;
      }
  }
  
  if(myform.subject.value == "" || myform.subject.value == "Podaj temat wiadomości" || myform.subject.value == "Subject")
  { 
    myform.subject.className = 'i_text i_error';
    
    myform.subject.value = (lang == 'pl') ? 'Podaj temat wiadomości' : 'Subject';
    
    errors++;
  }      
  
  if(myform.body.value == "" || myform.body.value == "Wpisz treść wiadomości" || myform.body.value == "Message")
  { 
    myform.body.className = 'i_text i_error';
    
    myform.body.value = (lang == 'pl') ? 'Wpisz treść wiadomości' : 'Message';
    
    errors++;
  }
     
  return (errors > 0) ? false : true;

}


function mapload() {
  if (GBrowserIsCompatible()) {
   var map = new GMap2(document.getElementById("GoogleMap"));
   map.addControl(new GLargeMapControl());
   map.addControl(new GOverviewMapControl());
   //map.setCenter(new GLatLng(51.210728, 16.15487), 16);
   map.setCenter(new GLatLng(51.200563, 16.152737), 17);


   //Create our "tiny" marker icon
   var icon = new GIcon();
   icon.image = map_icon;
   icon.iconSize = new GSize(47, 24);
   icon.iconAnchor = new GPoint(6, 20);
   icon.infoWindowAnchor = new GPoint(5, 1);

   map.addOverlay(new GMarker(new GLatLng(51.200563, 16.152737), icon)); // Legnica
  }
 }
