$(document).ready(function(){
	//form input focus/blur
	$("input[type=password], input[type=text], textarea").focus(function() {
		val = $(this).attr('def');
		if ($(this).val() == val) $(this).val('');
		$(this).blur(function(){
			if ($(this).val() == '') $(this).val(val);
		});
	});
	
	$('#callbackForm .form-submit').click(function(){
		if ($('#cbname').val() == "Full Name" || !$('#cbname').val()){
			alert('Full Name field is required');
			$('#cbname')[0].focus();
			return false;
		}
		if ($('#cbphone').val() == "Phone Number" || !$('#cbphone').val()){
			alert('Phone Number field is required');
			$('#cbphone')[0].focus();
			return false;
		}
		if ($('#cbcompany').val() == "Company Name" || !$('#cbcompany').val()){
			alert('Company Name field is required');
			$('#cbcompany')[0].focus();
			return false;
		}
	});
	
	$('#carousel').jcarousel();
	
	//tourGallery
	$('.controls a').click(function(event){
		var dir = ($(this).hasClass('next')) ? 1 : 0;
		var num = Number($('#tourGallery .num span').html());
		var total = $('.tour-item').size();
		if (dir == 1 && num+1 > total){
			str = 1;
		} else if (dir == 0 && num-1 <= 0){
			str = total;
		} else {
			str = (dir == 1) ? ++num : --num;
		}
		$('#tourGallery .num').html('Process <span>'+str+'</span> of '+total);
		$('.tour-item', '#tourGallery').removeClass('tour-active');
		$('.tour-item:nth-child('+ ++str +')').addClass('tour-active');
		
		$('.col1 img', '#tour-pg').removeClass('active');
		$('.col1 img:nth-child('+ --str +')').addClass('active');
		event.preventDefault();
	});
});

function swf(name, w, h){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+w+'" height="'+h+'" />\n');
	document.write('<param name="movie" value="'+name+'.swf" />\n');
	document.write('<param name="quality" value="high" />\n');
	document.write('<param name="menu" value="false" />\n');
	document.write('<param name="wmode" value="transparent" />\n');
	document.write('<param name="align" value="center" />\n');
	document.write('<param name="BGCOLOR" value="#000000" />\n');
	document.write('<embed src="'+name+'.swf" BGCOLOR="#000000" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+w+'" align="center" height="'+h+'" menu="false" />\n');
	document.write('</embed>\n');
	document.write('</object>\n');
}
