var formReqMsg = 'required';
var formOptMsg = 'optional';
var imgArray = [
	{
		src:'images/girls-in-speedboat.jpg',
		from: '100% 0% 1x',
		to: '100% 100% 0.8x',
		time:1.5
	},
	{
		src:'images/luxury-motor-cruiser.jpg',
		from: '50% 30% 0.9x',
		to: '50% 90% 0.7x',
		time:2
	},
//	{
//		src:'images/ist2_9300445-barcelona-harbor.jpg',
//		from: '0% 50%',
//		to: '100% 100%',
//		time:1
//	},
	{
		src:'images/game-fishing-boat.jpg',
		from: '0% 55% 0.8x',
		to: '100% 55% 0.8x',
		time:1
	},
	{
		src:'images/red-ski-boat.jpg',
		from: '100% 80% 0.9x',
		to: '0% 70% 0.7x',
		time:1.5
	},
	{
		src:'images/small-fishing-boat.jpg',
		from: '0% 60%',
		to: '100% 60%',
		time:1
	},
	{
		src:'images/speedboat-in-sunset.jpg',
		from: '100% 100% ',
		to: '0% 0%',
		time:2
	},
	{
		src:'images/boat-and-suv.jpg',
		from: '0% 70% 0.9x',
		to: '100% 50% 0.9x',
		time:2
	}
]

function pngFix() {
  DD_belatedPNG.fix('#head h1');
  DD_belatedPNG.fix('#wrap');
  DD_belatedPNG.fix('#foot');
  DD_belatedPNG.fix('#globe-map');
  DD_belatedPNG.fix('#nav');
  DD_belatedPNG.fix('#nav ul');
  DD_belatedPNG.fix('.png');
}

function formFriend() {
	$('input[type=text]').each(function(){
		if ($(this).val() == '') {
			if ($(this).hasClass('required')) {
				$(this).val(formReqMsg).addClass('quiet');
			}
			else {
				$(this).val(formOptMsg).addClass('quiet').addClass('optional');
			}
		}
	});

	$('input[type=text]').focus(function(){
		if ($(this).val() == formReqMsg || $(this).val() == formOptMsg) {
			$(this).val('');
		}
		$(this).removeClass('quiet');
	});

	$('input[type=text]').blur(function(){
		if ($(this).hasClass('required') && $(this).val() == '') {
			$(this).val(formReqMsg).addClass('quiet');
		}
		else if ($(this).hasClass('optional') && $(this).val() == '') {
			$(this).val(formOptMsg).addClass('quiet');
		}
	});

	$('textarea').each(function(){
		if ($(this).val() == '') {
			if ($(this).hasClass('required')) {
				$(this).val(formReqMsg).addClass('quiet');
			}
			else {
				$(this).val(formOptMsg).addClass('quiet').addClass('optional');
			}
		}
	});

	$('textarea').focus(function(){
		if ($(this).val() == formReqMsg || $(this).val() == formOptMsg) {
			$(this).val('');
		}
		$(this).removeClass('quiet');
	});

	$('textarea').blur(function(){
		if ($(this).hasClass('required') && $(this).val() == '') {
			$(this).val(formReqMsg).addClass('quiet');
		}
		else if ($(this).hasClass('optional') && $(this).val() == '') {
			$(this).val(formOptMsg).addClass('quiet');
		}
	});

	$('form').submit(function(){
		$('input[type=text]').each(function(){
			if ($(this).hasClass('required') && $(this).val() == formReqMsg) {
				$(this).val('');
			}
			else if ($(this).hasClass('optional') && $(this).val() == formOptMsg) {
				$(this).val('');
			}
		});

		$('textarea').each(function(){
			if ($(this).hasClass('required') && $(this).val() == formReqMsg) {
				$(this).val('');
			}
			else if ($(this).hasClass('optional') && $(this).val() == formOptMsg) {
				$(this).val('');
			}
		});

	});
}

function crossSlide() {
	$('#cross-slide').crossSlide({
	//		sleep: 4,
			fade: 2
		},
		imgArray
//		,
//		function(idx, img, idxOut, imgOut) {
//			if (idxOut == undefined) {
//				// starting single image phase, put up caption
//				$('div.caption').text(captions[idx]).fadeIn()
//			}
//			else {
//				// starting cross-fade phase, take out caption
//				$('div.caption').fadeOut()
//			}
//		}
	);
}

$(function(){
	if (typeof(DD_belatedPNG) != 'undefined') pngFix();
	if ($('form').size()) formFriend();
	if ($('#cross-slide').size()) crossSlide();

	if ($('ul.fancybox').size()) {
//console.log('fancybox is go!');
		$('ul.fancybox li a').fancybox();
	}
	
});


