$(document).ready(function() {
	
	
/* client login form*/

$('#form1 .button').click(function(){
	$('#form1 #username').addClass('incorrect');
	$('#form1 #password').addClass('incorrect');
	$('#form1 .red').show();
});


$('#commentform').validate();

/* end login form*/
	
/* scrolling feature images */

$('#features').cycle({ 
    fx:     'scrollRight',
	pause:   1,
	timeout: 6000,
	easing: 'easeOutQuart',
	speed: 1500
});


$('#nt').append($('.twitter-message:nth-child(3)'), $('.twitter-message:nth-child(4)'), $('.twitter-message:nth-child(5)'));

$('.twitter-link').attr('target', '_blank');


$('#tweetdivs').cycle({ 
    fx:     'scrollUp',
	pause:   1,
	timeout: 6000,
	speed: 1500,
	easing: 'easeOutQuart'
});

/* scrolling features */

/* nav tree */
$('.bobfan').each(function(){
	$('a:first', this).click(function(){
	$(this).siblings('ul').slideToggle(400, 'easeOutQuart');
	$(this).toggleClass('sesame');
});
});

$('.bobby').click(function(){
	$(this).siblings('ul:first').slideToggle(400, 'easeOutQuart');
});

/* end nav tree */


/* share feature */

function shareThis(type){
	$('#share-modal').fadeIn(400);
}

function closeShare(){
	$('#share-modal').fadeOut(400);
}

$('#fb').click(function(){
	var sLink = $(this).attr('rel');
	$('#share-modal').fadeIn(400);
	$('#share-modal textarea').val("Check out this project from Toast Design - " + sLink).attr('maxlength','440');
	$('#sname').html('on Facebook');
});


$('#tw').click(function(){
	var sLink = $(this).attr('rel');
	$('#share-modal').fadeIn(400);
	$('#share-modal textarea').val("Check out this project from Toast Design - " + sLink).attr('maxlength','140');
	$('#sname').html('on Twitter');
});


$('#em').click(function(){
	var sLink = $(this).attr('rel');
	$('#share-modal').fadeIn(400);
	$('#share-modal textarea').val("Check out this project from Toast Design - " + sLink).removeAttr('maxlength');
	$('#sname').html('via Email');
});

$('#close-btn').click(function(){
	$('#share-modal').fadeOut(400);
});

/* share feature */

/* quote form */

$("#quoteform").submit(function(){

var str = $(this).serialize();
   $.ajax({
   type: "POST",
   url: "http://toastdesign.com.au/php/quoteForm.php",
   data: str,
   success: function(msg){
$("#note").ajaxComplete(function(event, request, settings){
if(msg == 'OK') // Message Sent? Show the 'Thank You' message and hide the form
{
$("#qform").fadeOut(200);
$("#confirmed").delay(200).fadeIn(500);
$("#note").fadeOut(200);
$('#adwordstracksaget').html('<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/995069457/?label=uwrBCJ_PkAMQkZy-2gM&amp;guid=ON&amp;script=0"/>');
}
else
{
$('#note').fadeIn(500);
result = msg;
$(this).html(result);
}

});
}
});
return false;
});


/* end quote form */

/* employment form */

$("#employform").submit(function(){

var str = $(this).serialize();
   $.ajax({
   type: "POST",
   url: "http://toastdesign.com.au/php/employForm.php",
   data: str,
   success: function(msg){
$("#note").ajaxComplete(function(event, request, settings){
if(msg == 'OK') // Message Sent? Show the 'Thank You' message and hide the form
{
$("#eform").fadeOut(200);
$("#confirmed").delay(200).fadeIn(500);
$("#note").fadeOut(200);
}
else
{
$('#note').fadeIn(500);
result = msg;
}
$(this).html(result);
});
}
});
return false;
});


/* end employment form */


/* video */

VideoJS.setupAllWhenReady();


/* end video */

});

$(window).scroll(function(){
	
	dh = $(document).height();
	wh = $(window).height();
	st =  $(window).scrollTop();
	th = wh + st + 20;
	
	if(th >= dh && $('.blog-post').length>0){
		loadPosts();
	}
	
});


var ajaxurl = 'http://toastdesign.com.au/wp-admin/admin-ajax.php';
var page_number = 2;
var loading = false;

function loadPosts(){
if(!loading){
$('.loading-more').html('');	
$('.loading-more').addClass('loader');
loading = true;
$.post(ajaxurl, {
action: 'and_action',
paged: page_number
}, function(data) {
if(data == "") {
$('.loading-more').html('');
$('.loading-more').html('<strong>There are no more posts.</strong>');
$('.loading-more').removeClass('loader');
}else{
$('.empty-div').append(data);
$('.loading-more').html('');
$('.loading-more').removeClass('loader');
page_number += 1;
loading = false;
}
});
}else{

}

}

 







