﻿function Load() {

    UserInterface();
    NivoSlider();
    TextResizer();
    Uniform();
    UItoTop();
    TipsyTooltips();
    FancyBoxInit();
    OnFocusTooltips();
    CycleInit();

    $(".print").click(function () { PrintDocument(); });

    function UserInterface() {
        //jQuery UI elements (more info can be found at http://jqueryui.com/demos/)

        // Sidenav Accordion Config
        $("ul#accordion").accordion({
            collapsible: true,
            active: false,
            header: 'li a.top_level',
            autoHeight: false,
            icons: false
        });

        // Top Nav Dropdown Accordion Config				
        $("ul.dropdown").accordion({
            collapsible: true,
            active: false,
            header: 'li a.has_slide', // this is the element that will be clicked to activate the accordion 
            autoHeight: false,
            event: 'mousedown',
            icons: false
        });

        // Content Box Toggle Config 
        $("a.toggle").click(function () {
            $(this).toggleClass("toggle_closed").next().slideToggle("slow");
            $(this).siblings(".box_head").removeClass("round_top").toggleClass("round_all");
            return false; //Prevent the browser jump to the link anchor
        });

        // Content Box Tabs Config
        $(".tabs").tabs({
            fx: { opacity: 'toggle', duration: 'slow' }
        });

        $(".side_tabs").tabs({
            fx: { opacity: 'toggle', duration: 'slow', height: 'auto' }
        });


        // Content Box Accordion Config		
        $(".content_accordion").accordion({
            collapsible: true,
            active: false,
            header: 'h3.bar', // this is the element that will be clicked to activate the accordion 
            autoHeight: false,
            event: 'mousedown',
            icons: false,
            animated: true
        });

        // Sortable Content Boxes Config				
        $(".main_container").sortable({
            handle: '.grabber',  // the element which is used to 'grab' the item
            items: 'div.box', // the item to be sorted when grabbed!
            opacity: 0.8,
            revert: true,
            tolerance: 'pointer',
            helper: 'original',
            forceHelperSize: true,
            placeholder: 'dashed_placeholder',
            forcePlaceholderSize: true
        });

        // Sortable Accordion Items Config			
        $(".content_accordion").sortable({
            handle: 'a.handle',
            axis: 'y', // the items can only be sorted along the y axis
            revert: true,
            tolerance: 'pointer',
            forcePlaceholderSize: true
        });

        // Input Datepicker Config --
        $(".datepicker").datepicker();

        $.datepicker.regional['tr'] = {
            closeText: 'kapat',
            prevText: '&#x3c;geri',
            nextText: 'ileri&#x3e',
            currentText: 'bugün',
            monthNames: ['Ocak', 'Şubat', 'Mart', 'Nisan', 'Mayıs', 'Haziran',
		'Temmuz', 'Ağustos', 'Eylül', 'Ekim', 'Kasım', 'Aralık'],
            monthNamesShort: ['Oca', 'Şub', 'Mar', 'Nis', 'May', 'Haz',
		'Tem', 'Ağu', 'Eyl', 'Eki', 'Kas', 'Ara'],
            dayNames: ['Pazar', 'Pazartesi', 'Salı', 'Çarşamba', 'Perşembe', 'Cuma', 'Cumartesi'],
            dayNamesShort: ['Pz', 'Pt', 'Sa', 'Ça', 'Pe', 'Cu', 'Ct'],
            dayNamesMin: ['Pz', 'Pt', 'Sa', 'Ça', 'Pe', 'Cu', 'Ct'],
            weekHeader: 'Hf',
            dateFormat: 'd MM yy DD',
            firstDay: 1,
            isRTL: false,
            showMonthAfterYear: false,
            yearSuffix: ''
        };
        $.datepicker.setDefaults($.datepicker.regional['tr']);

        //-- End Config

        // input Slider	Config
        $(".slider").slider(); // creates a simple slider with default settings


        // input Range Slider Config	
        $(".slider_range").slider({
            range: true, // creates a range slider
            min: 0,
            max: 500,
            values: [75, 300],
            slide: function (event, ui) {
                $("#amount").val("$" + ui.values[0] + " - $" + ui.values[1]);
            }
        });

        $("#amount").val("$" + $("#slider_range").slider("values", 0) +
			" - $" + $("#slider_range").slider("values", 1));

        // Dialog Config
        $("#dialog").dialog({
            autoOpen: false,
            show: "fade",
            hide: "fade",
            modal: true
        });

        $("#opener").click(function () {
            $("#dialog").dialog("open"); // the #dialog element activates the modal box specified above
            return false;
        });

        //Progress Bar Config
        $("#progressbar").progressbar({
            value: 25
        });

        // Dismiss alert box
        $(".alert").click(function () {
            $(this).fadeOut('slow');
        });

        // target nav items with a dropdown for styling.
        $('ul.dropdown').parent().addClass('has_dropdown');


        // loading box
        function loadingOverlay() {
            $("#loading_overlay .loading_message").delay(200).fadeOut(function () { });
            $("#loading_overlay").delay(500).fadeOut();
        }

        window.onload = function () {
            loadingOverlay();
        };

        // static tables alternating rows
        $('table.static tr:even').addClass("even");

    };

    function NivoSlider() {
        $('#slider').nivoSlider();
    }

    function PrintDocument() {
        //printing(more info http://projects.erikzaadi.com/jQueryPlugins/jQuery.printElement/)
        $('.printDiv').printElement({
            pageTitle: '',
            printMode: 'popup',
            leaveOpen: true,
            overrideElementCSS: ['/css/framework/print/print.css',
                { href: '/css/framework/print/print.css', media: 'print'}]
        });
    }

    function TextResizer() {
        jQuery(".tools a").textresizer({
            target: ".printDiv",
            type: "fontSize",
            sizes: ["13px", "15px", "13px"],
            selectedIndex: 1
        })
    }

    function Uniform() {
        // Uniform Config (more info can found at http://pixelmatrixdesign.com/uniform/)
        $("select, input:checkbox, input:radio, input:file, input:text, input:password,").uniform();
    }

    function UItoTop() {
        //Slide to top link
        $().UItoTop({ easingType: 'easeOutQuart' });
    }

    function TipsyTooltips() {
        // Tipsy Top Config (more info found at http://onehackoranother.com/projects/jquery/tipsy/)
        $('.tooltip').tipsy({
            fade: true,     // fade tooltips in/out?
            fallback: '',    // fallback text to use when no tooltip text
            gravity: 's',    // gravity
            opacity: 1,    // opacity of tooltip
            title: 'title',  // attribute/callback containing tooltip text
            trigger: 'hover' // how tooltip is triggered - hover | focus | manual 
        });
    }
	
	function FancyBoxInit(){
	
	$("a[rel=example_group]").fancybox({
	    'overlayShow': true,
	    'enableEscapeButton': true,
	    'transitionIn': 'elastic',
	    'transitionOut': 'elastic',
        'easingIn': 'swing',
        'easingOut': 'swing',
		'overlayOpacity': 0.8,
		'overlayColor': "#FFF",
        'showNavArrows': true,
		'showCloseButton': true,
		'titlePosition': 'inside',
		'titleFormat': function(title, currentArray, currentIndex, currentOpts) {
		 return '<span id="fancybox-title-over">' + title + '</span>';
		}

    });


    $(".iframeExt").fancybox({
        'width': '75%',
        'height': '75%',
        'autoScale': false,
        'transitionIn': 'none',
        'transitionOut': 'none',
        'type': 'iframe'
    });


    $("#Modal_1").fancybox({
        'modal': true
    });
	
	
}

    function OnFocusTooltips() {
        //Onfocus Tooltips Text
        $('input[type="text"]').each(function () {

            this.value = $(this).attr('title');

            $(this).focus(function () {
                if (this.value == $(this).attr('title')) {
                    this.value = '';
                }
            });

            $(this).blur(function () {
                if (this.value == '') {
                    this.value = $(this).attr('title');
                }
            });
        });
    }



    function CycleInit(){

        $('.NewsBar').cycle({
            fx: 'fade',
            speed: 300,
            timeout: 3000,
            next: '_next',
            pause: 1
        });

    }



}
