google.load("jquery", "1.2.6");
google.setOnLoadCallback(init);
function init() {
$('#contentContainer .content').hide();
$('#contentContainer').show();
var url = location.href.substr(location.href.indexOf('#') +1);
currentPage = (url) ? url : 'home';
initMenu();
initContactForm();
//setTimeout(showPage, 800)
showPage();
}
function showPage () {$('#'+currentPage).show(); }
function initMenu () {
$('#menu .item a').click(menuClick);
}
function menuClick() {
var menuItem = this.href.substr(this.href.indexOf('#') +1);
if(menuItem != currentPage){
pageTracker._trackPageview('/' + menuItem);
$('#contentContainer #' + currentPage).slideUp("fast", function (){ $('#contentContainer #' + menuItem).slideDown("fast"); });
var title = "Razor Films LA >> ";
document.title = title + capitalizeFirstLettter(menuItem);
currentPage = menuItem;
}
}
function capitalizeFirstLettter(str) {
var firstLetter = str.substring(0,1).toUpperCase();
return firstLetter + str.substr(1);
}
function resetContactForm () {
//$("#contactForm").reset();
$('#contactForm .requiredField').each(function() {
$(this).val('');
});
$('.thanks').remove();
$('form#contactForm').slideDown("fast");
}
function initContactForm () {
if($("#contactForm")){
$('form#contactForm').submit(function() {
$('form#contactForm .error').remove();
var hasError = false;
$('.requiredField').each(function() {
var labelText = $(this).attr("id");
switch(labelText){
case "contactName":
labelText = "name";
break;
case "commentsText":
labelText = "comments";
break;
}
if(jQuery.trim($(this).val()) == '') {
$(this).parent().append('You forgot to enter your '+labelText+'.');
hasError = true;
} else if($(this).hasClass('email')) {
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
if(!emailReg.test(jQuery.trim($(this).val()))) {
$(this).parent().append('You entered an invalid '+labelText+'.');
hasError = true;
}
}
});
if(!hasError) {
$('#contactForm buttons').fadeOut('normal', function() {
$(this).parent().append('');
});
var formInput = $(this).serialize();
$.post($(this).attr('action'),formInput, function(data){
$('form#contactForm').before('
Thanks for contacting us. Your comments were successfully sent.