$(document).ready(function() {
//Load Quote Rotator
$('ul#quotes').quote_rotator({
rotation_speed: 7000,    
pause_on_hover: true
});//End Quote Rotator

//Load Quote Banner
$("#quote-banner").delay(3000).animate({ 
duration: 'slow',
easing: 'easeOutBack',
top: "51px"
}, 1700 );//End Quote Banner

//Add FancyBox PopUp to Quote Link
$("#linky").fancybox({
'scrolling'		: 'no',
'titleShow'			: false,
'transitionIn': 'elastic',
'transitionOut': 'elastic',
'onStart'		: function() {
$("#quote-wrapper").show();
},
'onClosed'		: function() {
$("#submiterror").hide();
$("#quote-wrapper").hide();
}

});//End Add FancyBox PopUp to Quote Link

//Attach action and validation to form
$("#submitquote").bind("submit", function() {
if($("#yourname").val().length < 2 || $("#yourtitle").val().length < 2) {
$("#submiterror").show();
$.fancybox.resize();
return false;
}

$.ajax({
type: "POST",
url: "http://dovlive.com/scripts/quote/add.php",
data: $("#submitquote").serialize(),
success: function(msg) {
$("#submitquote").hide();
$("#quotesubmitted").show();
$("#quotesubmitted").prepend('<h2 style="text-align:center;">Your Quote Has Been Submitted</h2>'+msg+'<br />');
$("#removebutton").show();
$("#close").show();
}
});//End Ajax
return false;
});//End bind function


$("#removebutton").click(function() {
var token = $("#token").val();
$.ajax({
type: "POST",
url: "http://dovlive.com/scripts/quote/remove.php",
data: "token="+token,
success: function(msg) {
$("#quotesubmitted").hide();
$("#removebutton").hide();
$("#quoteremoved").show();
$("#quoteremoved").prepend(msg);
}
});//End Ajax
return false;
});//End click function


$('textarea[maxlength]').keyup(function(){
//get the limit from maxlength attribute
var limit = parseInt($(this).attr('maxlength'));
//get the current text inside the textarea
var text = $(this).val();
//count the number of characters in the text
var chars = text.length;

//check if there are more characters then allowed
if(chars > limit){
//and if there are use substr to get the text before the limit
var new_text = text.substr(0, limit);

//and change the current text with the new text
$(this).val(new_text);
}
});


$('a.menu_class').click(function () {
$('div#login-form').toggle();
return false;
});

// OPACITY OF BUTTON SET TO 50%
$(".social-image").css("opacity","0.5");

// ON MOUSE OVER
$(".social-image").hover(function () {

// SET OPACITY TO 100%
$(this).stop().animate({
opacity: 1.0
}, "medium");
},

// ON MOUSE OUT
function () {

// SET OPACITY BACK TO 50%
$(this).stop().animate({
opacity: 0.5
}, "slow");
});

//Constant Contact

$("#cc_link").fancybox({
'scrolling'		: 'no',
'titleShow'			: false,
'transitionIn': 'elastic',
'transitionOut': 'elastic',
});

});//End opening function
