/*************************** List Styling ***************************/

jQuery(document).ready(function(){	
    jQuery("ul li:first-child").addClass("li-first");
    jQuery("ul li:last-child").addClass("li-last");		
});


/*************************** Navigation Menu ***************************/

jQuery(document).ready(function(){	

    var nav = jQuery("#nav");

    nav.find("li").each(function() {
        Cufon.replace('#nav', {
            hover: true
        });
        if (jQuery(this).find("ul").length > 0) {

            jQuery("<span/>").html("<img src='"+rootFolder+"/images/nav_arrow.png' alt=''/").appendTo(jQuery(this).children(":first"));

            jQuery(this).mouseenter(function() {
                jQuery(this).find("ul:first").filter(':not(:animated)').slideDown(600);
            });

            jQuery(this).mouseleave(function() {
                jQuery(this).find("ul:first").slideUp(0);
            });
			
        }
    });
	
});


/*************************** Tool Tips ***************************/

jQuery(document).ready(function() { 
    jQuery("#social-icons img[title]").tooltip({
        tip: '.social-tooltip', 
        effect: 'slide', 
        position: "bottom center",         
        offset: [25, 20] 
    });
    jQuery("#similar-posts img[title]").tooltip({
        tip: '.similar-tooltip', 
        effect: 'slide', 
        position: "bottom left",         
        offset: [20, 340] 
    });
});


/*************************** Image Hover Effects ***************************/

jQuery(document).ready(function() { 

    jQuery('.circle-content-text').css({
        'opacity':'0'
    });
    jQuery('.circle').hover(
        function() {
            jQuery(this).find('.circle-content-text').stop(true,true).fadeTo(500, 0.95);
            jQuery(this).addClass('circle-active');
            jQuery(this).css("border-width","0");
        },
        function() {
            jQuery(this).find('.circle-content-text').stop(true,true).fadeTo(500, 0);
            jQuery(this).removeClass('circle-active');		
            jQuery(this).css("border-width","2px");		
        }
        );
	
    jQuery('.circle-content-image').css({
        'opacity':'0'
    });
    jQuery('.circle').hover(
        function() {
            jQuery(this).find('.circle-content-image').stop(true,true).fadeTo(800, 1);
            jQuery(this).addClass('circle-active');
            jQuery(this).css("border-width","0");
        },
        function() {
            jQuery(this).find('.circle-content-image').stop(true,true).fadeTo(800, 0);
            jQuery(this).removeClass('circle-active');		
            jQuery(this).css("border-width","2px");		
        }
        );
	
	
    jQuery("#circle1").hover(
        function() {
            jQuery(this).stop(true,true).animate({
                width:"210px",
                height:"255px"
            },500);
        },
        function() {
            jQuery(this).stop(true,true).animate({
                width:"70px",
                height:"70px"
            },300);
        }	
        );
    jQuery("#circle2").hover(
        function() {
            jQuery(this).stop(true,true).animate({
                width:"210px",
                height:"255px"
            },500);
        },
        function() {
            jQuery(this).stop(true,true).animate({
                width:"110px",
                height:"110px"
            },300);
        }	
        );
    jQuery("#circle3").hover(
        function() {
            jQuery(this).stop(true,true).animate({
                width:"210px",
                height:"255px"
            },500);
        },
        function() {
            jQuery(this).stop(true,true).animate({
                width:"88px",
                height:"88px"
            },300);
        }	
        );
    jQuery("#circle4").hover(
        function() {
            jQuery(this).stop(true,true).animate({
                width:"210px",
                height:"255px"
            },500);
        },
        function() {
            jQuery(this).stop(true,true).animate({
                width:"79px",
                height:"79px"
            },300);
        }	
        );
    jQuery("#circle5").hover(
        function() {
            jQuery(this).stop(true,true).animate({
                width:"210px",
                height:"255px"
            },500);
        },
        function() {
            jQuery(this).stop(true,true).animate({
                width:"56px",
                height:"56px"
            },300);
        }	
        );
    jQuery("#circle6").hover(
        function() {
            jQuery(this).stop(true,true).animate({
                width:"210px",
                height:"255px"
            },500);
        },
        function() {
            jQuery(this).stop(true,true).animate({
                width:"82px",
                height:"82px"
            },300);
        }	
        );
    jQuery("#circle7").hover(
        function() {
            jQuery(this).stop(true,true).animate({
                width:"210px",
                height:"255px"
            },500);
        },
        function() {
            jQuery(this).stop(true,true).animate({
                width:"88px",
                height:"88px"
            },300);
        }	
        );
    jQuery("#circle8").hover(
        function() {
            jQuery(this).stop(true,true).animate({
                width:"210px",
                height:"255px"
            },500);
        },
        function() {
            jQuery(this).stop(true,true).animate({
                width:"70px",
                height:"70px"
            },300);
        }	
        );
    jQuery("#circle9").hover(
        function() {
            jQuery(this).stop(true,true).animate({
                width:"210px",
                height:"255px"
            },500);
        },
        function() {
            jQuery(this).stop(true,true).animate({
                width:"110px",
                height:"110px"
            },300);
        }	
        );
           
    jQuery("#circle10").hover(
        function() {
            jQuery(this).stop(true,true).animate({
                width:"200px",
                height:"200px"
            },500);
        },
        function() {
            jQuery(this).stop(true,true).animate({
                width:"56px",
                height:"56px"
            },300);
        }	
        );
            
    jQuery("#circle11").hover(
        function() {
            jQuery(this).stop(true,true).animate({
                width:"210px",
                height:"255px"
            },500);
        },
        function() {
            jQuery(this).stop(true,true).animate({
                width:"56px",
                height:"56px"
            },300);
        }	
        );
            
    jQuery("#circle12").hover(
        function() {
            jQuery(this).stop(true,true).animate({
                width:"210px",
                height:"255px"
            },500);
        },
        function() {
            jQuery(this).stop(true,true).animate({
                width:"70px",
                height:"70px"
            },300);
        }	
        );
            
    jQuery("#circle13").hover(
        function() {
            jQuery(this).stop(true,true).animate({
                width:"210px",
                height:"255px"
            },500);
        },
        function() {
            jQuery(this).stop(true,true).animate({
                width:"79px",
                height:"79px"
            },300);
        }	
        );
            
    jQuery("#circle14").hover(
        function() {
            jQuery(this).stop(true,true).animate({
                width:"210px",
                height:"255px"
            },500);
        },
        function() {
            jQuery(this).stop(true,true).animate({
                width:"82px",
                height:"82px"
            },300);
        }	
        );
            
    jQuery("#circle15").hover(
        function() {
            jQuery(this).stop(true,true).animate({
                width:"210px",
                height:"255px"
            },500);
        },
        function() {
            jQuery(this).stop(true,true).animate({
                width:"88px",
                height:"88px"
            },300);
        }	
        );
            
    jQuery("#circle16").hover(
        function() {
            jQuery(this).stop(true,true).animate({
                width:"210px",
                height:"255px"
            },500);
        },
        function() {
            jQuery(this).stop(true,true).animate({
                width:"110px",
                height:"110px"
            },300);
        }	
        );
            
    jQuery("#circle17").hover(
        function() {
            jQuery(this).stop(true,true).animate({
                width:"210px",
                height:"255px"
            },500);
        },
        function() {
            jQuery(this).stop(true,true).animate({
                width:"90px",
                height:"90px"
            },300);
        }	
        );
            
    jQuery("#circle18").hover(
        function() {
            jQuery(this).stop(true,true).animate({
                width:"210px",
                height:"255px"
            },500);
        },
        function() {
            jQuery(this).stop(true,true).animate({
                width:"90px",
                height:"90px"
            },300);
        }	
        );

});


/*************************** Lightbox ***************************/

jQuery(document).ready(function(){

    jQuery("div.gallery-item .gallery-icon a").attr("rel", "prettyPhoto[gallery]");
	
    jQuery("a[rel^='prettyPhoto']").prettyPhoto({
        theme: 'facebook',
        animationSpeed: 'fast'
    });

});


/*************************** Toggle Content ***************************/

jQuery(document).ready(function(){	

    jQuery(".toggle-box").hide(); 
	
    jQuery(".toggle").toggle(function(){
        jQuery(this).addClass("toggle-active");
    }, function () {
        jQuery(this).removeClass("toggle-active");
    });
	
    jQuery(".toggle").click(function(){
        jQuery(this).next(".toggle-box").slideToggle();
    });

});


/*************************** Contact Form ***************************/

jQuery(document).ready(function(){
	
    jQuery('#contact-form').submit(function() {

        jQuery('.contact-error').remove();
        var hasError = false;
        jQuery('.requiredFieldContact').each(function() {
            if(jQuery.trim(jQuery(this).val()) == '') {
                jQuery(this).addClass('input-error');
                hasError = true;
            } else if(jQuery(this).hasClass('email')) {
                var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
                if(!emailReg.test(jQuery.trim(jQuery(this).val()))) {
                    jQuery(this).addClass('input-error');
                    hasError = true;
                }
            }
        });
	
    });
				
    jQuery('#contact-form .contact-submit').click(function() {
        jQuery('.loader').css({
            display:"block"
        });
    });	

});


/*************************** Image Preloader ***************************/

jQuery(function () {
    jQuery('.preload').hide();//hide all the images on the page
});

var i = 0;//initialize
var int=0;//Internet Explorer Fix
jQuery(window).bind("load", function() {//The load event will only fire if the entire page or document is fully loaded
    var int = setInterval("doThis(i)",10);//500 is the fade in speed in milliseconds
});

function doThis() {
    var images = jQuery('.preload').length;//count the number of images on the page
    if (i >= images) {// Loop the images
        clearInterval(int);//When it reaches the last image the loop ends
    }
    jQuery('.preload:hidden').eq(0).fadeIn(500);//fades in the hidden images one by one
    i++;//add 1 to the count
}
