function showSwf(){
	$('.flashInvitation img').hide();
	$('.flashInvitation').append('<object type="application/x-shockwave-flash" data="/swf/zaproszenie.swf" width="500" height="350"><param name="movie" value="/swf/zaproszenie.swf" /></object>');
}

$(document).ready(
	function() {
		Cufon.replace('#header h1#header_hoopoe', {
			textShadow: '#7f9344 0px 2px, #9ab152 0px -2px, #9ab152 -2px 0px, #9ab152 2px 0px',
			hover: {
				textShadow: '#95ab52 0px 2px, #adc85f 0px -2px, #adc85f -2px 0px, #adc85f 2px 0px'
			}
		});
		Cufon.replace('#header_hoopoe_lang', {
			textShadow: '#c9d6a2 0px 2px, #c9d6a2 0px -2px, #c9d6a2 -2px 0px, #c9d6a2 2px 0px'
		});
		
		$("a[href$='.jpg'], a[href$='.png']").each(function() {
			$(this).fancybox({
				'titlePosition'	: 'inside',
				'title'			: $(this).next('div:first').html()
			});
		});

		$('#flashbox_ul').innerfade({
			speed: 'slow',
			timeout: 4000,
			type: 'random_start',
			containerheight: 'auto'
		});
		
		$('.flashInvitation').click(showSwf);
	}
);

function reset(id) {
	if (document.getElementById(id)) {
		document.getElementById(id).reset();
	}
}

function submit(id) {
	if (document.getElementById(id) && checkform(id)) {
		document.getElementById(id).submit();
	}
}

function checkform(id) {
	if (id == 'gb_form') {
		return checkGuestbookForm();
	}
	else if (id == 'message_form') {
		return checkMessageForm();
	}
	else if (id == 'contact_form') {
		return checkContactForm();
	}
	else if (id == 'cart_form') {
		document.getElementById('update').value = 'true';
		return true;
	}
	else if (id == 'order_form') {
		return checkOrderForm();
	}
	return false;
}

function checkGuestbookForm() {
	if (document.getElementById('name').value == "" || document.getElementById('email').value == "" || document.getElementById('comment').value == "") {
		return false;
	}
	return true;
}

function checkMessageForm() {
	if (document.getElementById('email').value == "" || document.getElementById('message').value == "") {
		return false;
	}
	document.getElementById('send_message').value = 'true';
	return true;
}

function checkContactForm() {
	if (document.getElementById('email').value == "" || document.getElementById('name').value == "") {
		return false;
	}
	document.getElementById('send_form').value = 'true';
	return true;
}

function checkOrderForm() {
	var error = false;
	var errorMessage = i18n.errorForm;	
	
	if (document.getElementById('name').value == "") {
		errorMessage += i18n.errorFirstName;
		error = true;
	}
	if (document.getElementById('surname').value == "") {
		errorMessage += i18n.errorName;
		error = true;
	}
	if (document.getElementById('company').value != "" && document.getElementById('nip').value == "") {
		errorMessage += i18n.errorNIP;
		error = true;
	}
	if (document.getElementById('email').value == "") {
		errorMessage += i18n.errorEmail;
		error = true;
	}
	if (document.getElementById('address').value == "") {
		errorMessage += i18n.errorStreet;
		error = true;
	}
	if (document.getElementById('postcode').value == "") {
		errorMessage += i18n.errorPostalCode;
		error = true;
	}
	if (document.getElementById('place').value == "") {
		errorMessage += i18n.errorCity;
		error = true;
	}
	if (document.getElementById('district').selectedIndex == 0) {
		errorMessage += i18n.errorVoivodeship; 
		error = true;
	}
	if (document.getElementById('phone').value == "") {
		errorMessage += i18n.errorPhone;
		error = true;
	}
	if (document.getElementById('payment_form').selectedIndex == 0) {
		errorMessage += i18n.errorPaymentWay;
		error = true; 
	}	
	if (document.getElementById('agreement').checked == false)	{
		errorMessage += i18n.errorData;
		error = true; 
	}
		
	if (error) {
		alert(errorMessage);
		return false;
	}
	else {
		return true;
	}
}



function initialize(title, zoom) {
    if (GBrowserIsCompatible()) {
      var map = new GMap2(document.getElementById("map_canvas"), {size: new GSize(500, 330) });
      
      var coords = new GLatLng(52.585216,14.821329);
      map.setCenter(coords, zoom);
      map.setUIToDefault();
      var pompa = new GMarker(coords);
      map.addOverlay(pompa);
      var textNode = "<p class='fl c no_indent' style='margin: 15px 0 0 15px; width: 130px; font-weight: bold;'>"+ title +"</p><img style='margin: 5px 30px 0 0' src='/img/dudek_maly.png' alt='BTP Dudek'/>";


      pompa.bindInfoWindowHtml(textNode);        
      pompa.openInfoWindowHtml(textNode);
    }
  }





