function sendMessage()
{	
	jQuery.post(host+"/index.php?a=sendmailAjax",{
			name: $("#contactName").val(),
			phone: $("#contactPhone").val(),
			email: $("#contactEmail").val(),
			company: $("#contactCompany").val(),
			content: $("#contactMessage").val(),
			url: $("#contactUrl").val(),			
		 },
		 function(data) { 
		 				 
				 
			 var result = parseInt(data);
			 
			 if(result==1)
			 {
			 	$("#messageFailed").hide('slow');				 	
				$("#messageSend").show('slow');
				setTimeout("$('#messageSend').hide('slow');", 3000);
			 }
			 else
			 {
			 	$("#messageSend").hide('slow');
				$("#messageFailed").show('slow');
				setTimeout("$('#messageFailed').hide('slow');", 3000);
			 }
		 }
	);
	return false;			
}
function sendMessagePartners()
{	
	jQuery.post(host+"/index.php?a=sendFormAjax",{
			name: $("#contactNamePartners").val(),
			phone: $("#contactPhonePartners").val(),
			email: $("#contactEmailPartners").val(),
			clientname: $("#contactNameClient").val(),
			clientcontact: $("#contactContactClient").val(),
			clientemail: $("#contactEmailClient").val(),
			content: $("#contactMessage").val(),
			url: $("#url").val(),				
		 },
		 function(data) { 
		 				 
				 
			 var result = parseInt(data);
			 
			 if(result==1)
			 {
			 	$("#messageFailedPartners").hide('slow');				 	
				$("#messageSendPartners").show('slow');
				setTimeout("$('#messageSendPartners').hide('slow');", 3000);
			 }
			 else
			 {
			 	$("#messageSendPartners").hide('slow');
				$("#messageFailedPartners").show('slow');
				setTimeout("$('#messageFailedPartners').hide('slow');", 3000);
			 }
		 }
	);
	return false;			
}
function checkForm()
{
	var ok = true;
	if($('#name').val()=="" || $('#name').val()=="Imię i nazwisko*")
	{
		ok = false;
		$('#name').addClass('inputFormError');
	}
	if($('#email').val()=="" || $('#email').val()=="Adres e-mail*")
	{
		ok = false;
		$('#email').addClass('inputFormError');
	}
	if($('#phone').val()=="" || $('#phone').val()=="Telefon*")
	{
		ok = false;
		$('#phone').addClass('inputFormError');
	}
	if($('#message').val()=="" || $('#message').val()=="Treść wiadomości")
	{
		ok = false;
		$('#message').addClass('inputFormError');
	}
	if(ok)
		$('#contactSimpleForm').submit();
	else
		return false;
}

function scrollTo(){
	$('html, body').animate({
	scrollTop: $('#global').offset().top
	}, 1500);
}
var timeout;
var waiting = 0;

function waitSlideshow()
{
	if(waiting==0)
		setTimeout("$('#nextButton').click();", 0);
}
/**
 * type-type of gallery empty value means big gallery, 2-small gallery 
 */
function getNext(type)
{
	$.ajax({
		   type: "POST",
		   url: host+"/index.php?a=getGalleryItem",
		   data: "nr="+actual,
		   dataType: "xml",
		   success: function(xml){
			
			 var width = type == '' ? 945 : 333;
			  //alert($(xml).find('result').text());
			 var msg = $(xml).find('result').text();
			 var imageName = $(xml).find('name').text();
			 prevoius = actual;
			 actual = msg;
			 if(actual=='')
			 {
				actual = start;
				prevoius = '';
				$('#galleryImages'+type).animate({"left": "0px"}, "slow");				
			 }
			 else if($('#galleryContainer'+type+' #img_'+actual).length <= 0)
			 {
				 var img = document.createElement('img');
				 $(img).attr('id', 'img_'+actual);
				 $(img).attr('src', host+'/var/file/thumbs/'+actual);
				 if(type=='')
				 {
					 $(img).attr('width', '945');
					 $(img).attr('height', '283');
				 }
				 else
				  {
					 $(img).attr('width', '333');
					 $(img).attr('height', '250');
				 }
				
				 var a = document.createElement('a');
				 $(a).attr('href', host+'/var/file/'+actual);
				 $(a).attr('rel', 'galeria');				
				 $(a).attr('title',imageName);
				 $(a).attr('class', 'cboxelement');
				 $(a).append(img);				 
				 $(a).colorbox(
					{
						slideshow:false, 
						slideshowSpeed: 3000,
						slideshowStart: '',
						slideshowStop: '',
						current: "",
						previous: "",
						next: "",
						close: "Zamknij",
						maxHeight: "800px"
					}
				);

				 var div = document.createElement('div');
				 $(div).attr('class', 'galleryImageBox'+type);
				 $(div).append(a);
				 
				 $('#galleryImages'+type).append(div);			
				 $('#galleryImages'+type).animate({"width": "+="+width+"px"}, 'fast');
				 $('#galleryImages'+type).animate({"left": "-="+width+"px"}, "slow");
			 }
			 else
			 {
				 $('#galleryImages'+type).animate({"left": "-="+width+"px"}, "slow");
			 }
			
				 
	      }
		 });

}

function getPrev(type)
{
        var width = type == '' ? 945 : 333;

	if(start==actual || prevoius == '')
		return false;
	if($('#galleryImages'+type).css('left') == '0px')
		return false;
	$('#galleryImages'+type).animate({"left": "+="+width+"px"}, "slow");	
	
}

function loadGalleryBox(path, title)
{$('#'+path.replace('.','')).click();
}


function hideMenu(){
    $('#top').animate({
        height: '141px'
      }, 150, function() {
        $('#hideMenuButton').fadeOut(0);
        $('#showMenuButton').fadeIn(0);
    });
}

function showMenu(){
    $('#top').animate({
        height: '244px'
      }, 150, function() {
        $('#showMenuButton').fadeOut(0);
        $('#hideMenuButton').fadeIn(0);
    });
}

function showRightPanel() {
    $('#rightpanel').css('top','25%'); //($(window).height() - $('#rightpanel').height()) / 2);
    $('#rightpanel').fadeIn(300);
}

