var featured_count;
var featured_interval;
var old_featured = 0;
var current_featured = 0;
var direction = 'left';
$(function(){
if($('.autocomplete').length > 0 ){
$(".autocomplete").autocomplete(
root_path+'postcodes/locality', {
minChars : 3.,
matchContains : 0,
onItemSelect : assignVal
}
);
}
function assignVal(li){
if( li == null ) return false;
if( !!li.extra ) var sValue = li.extra[0];
else var sValue = li.selectValue;
$('#Notes_postcodes_id').val(sValue);
}
if($('#ajax-login').length > 0 ){
$('#ajax-login').click(function(){
$.post( root_path+'users/login?layout=ajax', $('#login-form').serialize(), function(data){
if(data == true){
window.location.reload(true);
}else{
alert(data);
}
});
return false;
});
}
if($('#Note-tracker').length > 0 ){
$('#track-note').click(function(){
$('#Note-tracker').after('
');
$.post( root_path+'notes/add?layout=ajax', $('#Note-tracker').serialize(), function(data){
alert(data);
window.location.reload(true);
});
return false;
});
}
if($('#register').length > 0 ){
$('#register-now').click(function(){
$.post( root_path+'users/register?layout=ajax', $('#register').serialize(), function(data){
if(data == true){
window.location = root_path+"users\/nextstep";
}else{
alert(data);
}
});
return false;
});
}
if($('.list-latest').length > 0){
$('.list-latest li').css({position: 'absolute', left: '220px'})
featured_count = $(".list-latest li").size();
$(".list-latest li:eq("+current_featured+")").css('left', '0');
featured_interval = setInterval(rotate_left,5000);
$('.list-latest').mouseover(function(){
clearInterval(featured_interval);
//create_controls();
});
$('.list-latest').mouseout(function() {
featured_interval = setInterval(rotate_left,5000);
//hide_controls();
});
}
});
function rotate_left(){
current_featured = (old_featured + 1) % featured_count;
$(".list-latest li:eq(" + old_featured + ")").animate({left: -805},"slow", function() {
$(this).css('left', '800px');
});
$(".list-latest li:eq(" + current_featured + ")").animate({left: 0},"slow");
old_featured = current_featured;
}
function setcookie(name, value){
var date = new Date();
date.setTime(date.getTime()+(30*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
document.cookie = name+"="+value+expires+"; path=/";
}