﻿jQuery.noConflict();

jQuery(document).ready(function(){    
	RedLight.initialize();
});
 
RedLight={
    state:{
	},
	
	initialize:function(){
	    //create carousel on main page
	    jQuery("ul#links").jcarousel();
	    
	    //create gallery
        jQuery("img.image1", jQuery("div#gallery")).data("ad-desc", "");
       
        if (jQuery("div#gallery.ad-gallery").length > 0){
            var galleries = jQuery("div#gallery.ad-gallery").adGallery();
            jQuery("#switch-effect", jQuery("div#gallery")).change(function() {
                galleries[0].settings.effect = jQuery(this).val();
                return false;
            });
            jQuery("#toggle-slideshow", jQuery("div#gallery")).click(function() {
                galleries[0].slideshow.toggle();
                return false;
            });
        }
        
        //carousel arrows
        jQuery(".jcarousel-next-horizontal").hover(
                  function() {
                    jQuery(this).addClass("jcarousel-next-horizontal-over");
                  }, 
                  function() {
                    jQuery(this).removeClass("jcarousel-next-horizontal-over");
                  }
            );		
        jQuery(".jcarousel-prev-horizontal").hover(
                  function() {
                    jQuery(this).addClass("jcarousel-prev-horizontal-over");
                  }, 
                  function() {
                    jQuery(this).removeClass("jcarousel-prev-horizontal-over");
                  }
            );		
		
        //page controls
        jQuery("input.orderButton").click(function() {
            window.location = "default.aspx?nodeid=700";
            return false;
        });       
        
        //email
        jQuery("li.email a").click(function() {
            var url = location.href;
            var title = document.title;
            location.href = "mailto:?subject=" + title + "&body=" + url;
            return false;
        });      
        //print
        jQuery("li.print a").click(function() {
            window.print();
            return false;
        });           
        
        //share
        jQuery("li.smallBlogger a").click(function() {
            var url = location.href;
            var title = document.title;
            
            var Q = '';

            if (jQuery(".menyholder").length)
            {
                // Q = jQuery(".menyholder").html();
                return true;
            }

            if (jQuery(".eventContent").length)
            {
                if (jQuery("[id$=eventImage]").length)
                {
                    var src = jQuery("[id$=eventImage]").attr('src').replace('images/redlight/', 'http://redlight.aikongroup.com/images/redlight/');	                           
                    Q = '<img src="' + src + '"/><br/>';
                }
                Q += jQuery(".eventContent").html();

                var destURL = 'http://www.blogger.com/blog_this.pyra?' +
                't=' + encodeURIComponent(Q) +
                '&u=' + encodeURIComponent(url) +
                '&n=' + encodeURIComponent(title);

                window.open(destURL, 'sharer', 'toolbar=0,status=0,width=626,height=436');
            }
            return false;

        });      
        jQuery("li.smallFbook a").click(function() {
            var url = location.href;
            var title = document.title;
            window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(url) + '&t=' + encodeURIComponent(title), 'sharer', 'toolbar=0,status=0,width=626,height=436');
            return false;
        });      
        jQuery("li.smallTweet a").click(function() {
            var url = location.href;
            var title = document.title;
            window.open('http://twitter.com/home?status=' + encodeURIComponent(url), 'sharer', 'toolbar=0,status=0,width=626,height=436');
            return false;
        });           
		
        //click next in the carousel
		setTimeout( function() {jQuery(".jcarousel-next-horizontal").triggerHandler("click");}, 500)		
	}	
}
