 /*-----------------------------------------------
'	Company: Community Engine (www.communityengine.com)
'	Copyright (c) 2010, All rights reserved.
'	Date Created: April 2010
'
'	Last Modified Date: 21st April, 2010
'	Last Modified By: Benjamin -> ben.ruhe@communityengine.com
'
'	DO NOT MODIFY THIS DOCUMENT WITHOUT
'	NOTIFYING THE AUTHOR FIRST
'
------------------------------------------------*/
var $j = jQuery.noConflict();
// Kentico media library affects jQuery so use $j NOT $


$j(function() {

    $j('.slider').anythingSlider({
        easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
        autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
        delay: 5000,                    // How long between slide transitions in AutoPlay mode
        startStopped: false,            // If autoPlay is on, this can force it to start stopped
        animationTime: 1000,             // How long the slide transition takes
        hashTags: true,                 // Should links change the hashtag in the URL?
        buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
        pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
        startText: "Go",             // Start text
        stopText: "Stop"               // Stop text
    });

    $j("ul.top-nav").supersubs({
    	maxWidth: 40,
    	extraWidth: 1
    }).superfish({
    	hoverClass: "hover",
    	animation: { opacity: 'show', height: 'show' },
    	delay: 1400,
    	autoArrows: false
    
    });
    $j.fn.defaultVal = function() {
        return this.focus(function() {
            if (this.value == this.defaultValue) {
                this.value = "";
            }
        }).blur(function() {
            if (!this.value.length) {
                this.value = this.defaultValue;
            }
        });
    };
    $j(".defaultVal").defaultVal();

    function ShowValueLength(srcEl) {
        var charLength = $j(srcEl).val().length;
        var charCount = $j(srcEl).closest('li').find('.charCount');
        var maxChars = $j(srcEl).closest('li').find('.maxChars').text();
        $j(charCount).html(charLength);
        if (charLength > maxChars) {
            $j(charCount).html('<strong>You have exceeded the maximum </strong>');
        }
    }
    
    


    // controls character input/counter
    $j('textarea.countChars').each(function() {
        ShowValueLength(this);
    });
    $j('textarea.countChars').keyup(function() {
        ShowValueLength(this);
    });

    // End Function
});



//Funtion to init Jquery Form Select Option Dropdown
function jqueryDropDownInit(dropdownOption){
    $j(document).ready(function() {
        $j("." + dropdownOption + " img.flag").addClass("flagvisibility");

        $j("." + dropdownOption + " dt a").click(function() {
        $j("." + dropdownOption + " dd ul").toggle(); 
            return false;
        });

        $j("." + dropdownOption + " dd ul li a").click(function() {
            var text = $j(this).html();
            $j("." + dropdownOption + " dt a span").html(text);
            $j("." + dropdownOption + " dd ul").hide();
        });

        function getSelectedValue(id) {
            return $j("#" + id).find("dt a span.value").html();
        }

        $j(document).bind('click', function(e) {
            var $clicked = $j(e.target);
            if (!$clicked.parents().hasClass(dropdownOption)) {
                $j("." + dropdownOption + " dd ul").hide();
            }
        });


        $j("#flagSwitcher").click(function() {
            $j("." + dropdownOption + " img.flag").toggleClass("flagvisibility");
        });
    });
}

//Funtion to set value to form element by ID
function setFormValue(formID,inputValue){
	document.getElementById(formID).value = inputValue;
}