$(document).ready(function(){
    $("#main-rotator").scrollable({circular:true,speed:1000}).navigator().autoscroll({autopause:true,autoplay:true,interval:6000});
    $(".sub-menu li").click(function(){
        window.location=$(this).children('a').attr("href");
    });
    dropdown();
});
function dropdown(){

    $(".dd-trigger").hover(function(){
        $(this).parent('li').find('.sub-menu').show();
    },function(){
        $(this).parent('li').find('.sub-menu').hide();
    });
    $(".sub-menu").hover(function(){
        $(this).parent('li').addClass('active');
        $(this).show();
    },function(){
        if($(this).parent('li').attr('class') == 'active current'){
            $(this).hide();
        }
        else{
            $(this).parent('li').removeClass('active');
            $(this).hide();
        }
    });
}
function toggleAttorneys($this){
    $this.children('img').toggle();
    var profile = $this.parent('li').children('div.attorney-profile');
    if (profile.css('display') == 'none'){
        profile.slideDown(function(){});
    }
    else {
        profile.slideUp(function(){});
    }
}
function toggleIssues($this){
    $this.children('img').toggle();
    var profile = $this.parent('li').children('div.issues-contents');
    if (profile.css('display') == 'none'){
        profile.slideDown(function(){});
    }
    else {
        profile.slideUp(function(){});
    }
}
function toggleCases($this){
    $this.children('img').toggle();
    var profile = $this.parent('li').children('div.cases-contents');
    if (profile.css('display') == 'none'){
        profile.slideDown(function(){});
    }
    else {
        profile.slideUp(function(){});
    }
}
function toggleSlideshow() {
    $.scrollTo(".contents",{duration:800});
}
function toggleForms($this){
    var form = $this.parent('li').find('.forms-contents');
    if(form.css("display") == "none"){
        form.slideDown(function(){});
    }
    else{
        form.slideUp(function(){});
    }
}
function resetform() {
    $("input[type='text'], textarea").val("");
}
function validateemail(value) {
    var re = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;
    return re.test(value);
}
function loading() {
    $("#loading").show();
}
function loaded() {
    $("#loading").hide();
}
function showmessage(msg){
    $("#messages span").html(msg);
    $("#messages").show();
    setTimeout('hidemessage()',2000);
    $("#messages").click(function(){
        hidemessage();
    });
}
function hidemessage(){
    $("#messages").hide();
}
function togglePasswords(id) {
    var password = $("input.password");
    var x ="";
    if ($("#" + id).attr('checked')) {
        for (x in password) {
            password[x].type = "password"
        }
    }
    else {
        for (x in password) {
            password[x].type = "text"
        }
    }
}
