
$(document).ready(function(){

   $('#oferta_box_bg').fadeTo(1, 0.6); 
    
   if($('#gMap').length > 0) 
   {
       if(GBrowserIsCompatible())
       { 
           var map = new GMap2(document.getElementById("gMap")); 
           map.setCenter(new GLatLng(49.8915393422883, 19.355828762054443),12);
           map.addControl(new GSmallMapControl());
      	   map.addControl(new GMapTypeControl());
           var pointMarker = new GMarker(new GLatLng(49.8915393422883, 19.355828762054443),{clickable: false});
           map.addOverlay(pointMarker); 

       } 
   }

   var showBoxOferta = true;
   $('.oferr_jq').mouseover(function() {
   	//alert('koko');
       $('#oferta_box, #oferta_box_bg').show();              
   });

   $('#oferta_box, #oferta_box_bg').mouseover(function() {
       showBoxOferta = false;
   });

   $('#oferta_box, #oferta_box_bg').mouseout(function() {
       //$('#oferta_box').hide();
   });

   function hideBoxOferta() {
       if(showBoxOferta == true) {
        $('#oferta_box, #oferta_box_bg').hide();
       }
   }

    $('.no_oferr_jq').mouseover(function() {
        clearTimeout();       
       $('#oferta_box, #oferta_box_bg').hide();
   });
   

}); 

function formSend()
{

  $('#formError').hide();
  name = $('input[name=name]').val();  
  mail = $('input[name=mail]').val();
  phone = $('input[name=phone]').val();
  question = $('textarea[name=question]').val();
  
  mail = validateEmail2(mail);  

  if(name && mail && phone && question)
  {
    $('#contactFormSend').ajaxSubmit(function(msg) {

    if(msg.indexOf('true') != -1)
    {
      $('#formOk').show();
       $('input[name=name]').val('');  
  		$('input[name=mail]').val('');
  		$('input[name=phone]').val('');
  		$('textarea[name=question]').val('');
    }
  });  
  }
  else
  {
    $('#formError').show();
    return false;
  }
}

function validateEmail2(x) {
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) 
		return true;
	else 
	{
		//alert('Wpisz poprawny adres email!');
		return false;
	}
}




