﻿/***
* MENU GENERATION
*/
//var cssmenuids = ["MainMenu"] //Enter id(s) of CSS Horizontal UL menus, separated by commas
//var csssubmenuoffset = 5 //Offset of submenus from main menu. Default is 0 pixels.

//function createcssmenu2(){
//    for (var i = 0; i < cssmenuids.length; i++) {
//        var ultags = document.getElementById(cssmenuids[i]).getElementsByTagName("ul");
//        for (var t = 0; t < ultags.length; t++) {
//            ultags[t].style.top = ultags[t].parentNode.offsetHeight + csssubmenuoffset + "px";
//	        var spanref = document.createElement("span");
//		    spanref.className = "arrowdiv";
//		    spanref.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;";
//		    ultags[t].parentNode.onmouseover = function(){
//	            this.style.zIndex = 100;
//	            this.getElementsByTagName("ul")[0].style.visibility = "visible";
//				this.getElementsByTagName("ul")[0].style.zIndex = 0;
//	        }
//	        ultags[t].parentNode.onmouseout = function(){
//	            this.style.zIndex = 0;
//	            this.getElementsByTagName("ul")[0].style.visibility = "hidden";
//				this.getElementsByTagName("ul")[0].style.zIndex = 100;
//	        }
//        }
//    }
//}

//if (window.addEventListener)
//    window.addEventListener("load", createcssmenu2, false);
//else if (window.attachEvent)
//    window.attachEvent("onload", createcssmenu2);

/***
* CAROUSEL
*/
$(document).ready(function () {

    //jCarousel Plugin
    $('#carousel').jcarousel({
        buttonNextHTML: null,
        buttonPrevHTML: null,
        vertical: true,
        scroll: 1,
        auto: 5,
        wrap: 'last',
        initCallback: mycarousel_initCallback
    });

    //Front page Carousel - Initial Setup
    $('div#slideshow-carousel a img').css({ 'opacity': '0.75' });
    $('div#slideshow-carousel a img:first').css({ 'opacity': '1.0' });
    $('div#slideshow-carousel li a:first').append('<span class="arrow"></span>')


    //Combine jCarousel with Image Display
    $('div#slideshow-carousel li a').hover(
       	function () {

       	    if (!$(this).has('span').length) {
       	        $('div#slideshow-carousel li a img').stop(true, true).css({ 'opacity': '0.75' });
       	        $(this).stop(true, true).children('img').css({ 'opacity': '1.0' });
       	    }
       	},
       	function () {

       	    $('div#slideshow-carousel li a img').stop(true, true).css({ 'opacity': '0.75' });
       	    $('div#slideshow-carousel li a').each(function () {

       	        if ($(this).has('span').length) $(this).children('img').css({ 'opacity': '1.0' });

       	    });

       	}
	).click(function () {

	    $('span.arrow').remove();
	    $(this).append('<span class="arrow"></span>');
	    $('div#slideshow-main li').removeClass('active');
	    $('div#slideshow-main li.' + $(this).attr('rel')).addClass('active');

	    return false;
	});


});


//Carousel Tweaking

function mycarousel_initCallback(carousel) {

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function () {
        carousel.stopAuto();
    }, function () {
        carousel.startAuto();
    });
}

/***
* Lightbox
*/
$(function () { $('#gallery01 a').lightBox({ fixedNavigation: true }); });
$(function () { $('#gallery02 a').lightBox({ fixedNavigation: true }); });
$(function () { $('#gallery03 a').lightBox({ fixedNavigation: true }); });

/***
* Lazyload
*/
$(document).ready(function () {
    $(function () {
        $('#HomeContentRight img').lazyload({
            placeholder: '/lib/img/lazyload/grey.gif',
            effect: 'fadeIn',
            failurelimit: 30
        });
    });
});
