//SLIDESHOW
$(document).ready(function() {
    $('.slideshow').cycle({
		fx: 'fade',
		speed:    1000, 
    	timeout:  6000,
		before: onBefore,
		after: onAfter,
		next: '#next', 
    	prev: '#prev'
	});
	function onBefore() {
		$('.slideshow .content').animate({height:0});
	} 
	function onAfter() {
		if($('.slideshow .main').css('display') == 'none'){
			$('.slideshow .content').animate({height:100});
		}
	}
});

//GOOGLE MAPS
function hide_map (container) {
	var i = document.getElementById(container);
	i.style.visibility = "hidden";
	i.style.height = "0px";
	i.style.overflow = "hidden";
}

function load(address, city, province, country, container) {
  if (GBrowserIsCompatible()) {	
	var map = new GMap2(document.getElementById(container));
	map.disableInfoWindow();
	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());
	
	var geocoder = new GClientGeocoder();
	
	function showAddress(address) {
	  geocoder.getLatLng(
		address,
		function(point) {
		  if (!point) {
			hide_map(container);
		  } else {
			map.setCenter(point, 13);
			var marker = new GMarker(point);
			map.addOverlay(marker);
			marker.openInfoWindowHtml(address);
		  }
		}
	  );
	}
	
	
	var location = address + ", " + city + ", " + province + ", " + country;
	showAddress(location);
  }
}


function submitFile () {
	
	var f = document.getElementById("submitfile");
	
	var name = f.thisname.value;
	var company = f.company.value;
	var email = f.email.value;
	var phone = f.phone.value;
	var insured = f.insured.value;
	var filenum = f.filenum.value;
	var location = f.location.value;
	var validation = f.validation.value;
	var thefile = f.thefile.value;
	
	
	var success = true;
	
	if (name == "" || company == "" || email == "" || phone == "" || insured == "" || filenum == "" || location == "") {
		success = false;
		alert ("Please fill out all required fields.");
	} else if (validation != "792165") {
		success = false;
		alert ("Incorrect validation code.");
	}
	
		
	
	if (success) {
		f.submit();	
	}
}



