/*
 * Url preview script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 
this.screenshotPreview = function(){	
	/* CONFIG */
		
		xOffset = 200;
		yOffset = -130;
		xOffset2 = -100;
		yOffset2 = -300;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.screenshot").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='screenshot'><img src='"+ this.rel +"' alt='url preview' />"+ c +"</p>");								 
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#screenshot").remove();
    });	
	$("a.screenshot").mousemove(function(e){
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});
			
};


// starting the script on page load
$(document).ready(function(){

               debugging = true;

                $.fn.ceebox.videos.base.param.allowScriptAccess = "sameDomain" //added to kill the permissions problem
                $.extend($.fn.ceebox.videos,{
                        uctv:{
                                siteRgx: /uctv\.tv\/search\-details/i,
                                idRgx: /(?:showID=)([0-9]+)/i,
                                src: "http://www.uctv.tv/player/player_uctv_bug.swf",
                                flashvars: {previewImage : "http://www.uctv.tv/images/programs/[id].jpg", movie : "rtmp://webcast.ucsd.edu/vod/mp4:[id]",videosize:0,buffer:1,volume:50,repeat:false,smoothing:true}
                        }
                });
                //$().ceebox(); //used to test to make sure the init call works.
                //$(".ceebox").ceebox({boxColor:'#fff',borderColor:'#525252',textColor:'#333',videoJSON:"js/humor.json"});
                $(".ceebox").ceebox({titles:false, borderColor:'#dcdcdc',boxColor:"#fff"});
                //$("map").ceebox({fadeOut:"slow",fadeIn:"slow",onload:function(){$("#cee_box").animate({backgroundColor:"#F00"},function(){$(this).animate({backgroundColor:"#fff"})});}});
                $("map").ceebox();
                $(".ceebox2").ceebox({unload:function(){$("body").css({background:"#ddf"})}});
                //window.console.log($.fn.ceebox.videos.colbertFull)
                //$("body").ceebox(); //uncomment and every link on the page is in one gallery
                var testhtml = "<a href='http://balsaman.org' title='Balsa Man'>Balsa Man</a>"
                var testhtml2 = "<div style='padding:20px;text-align:center'><h2>Hi I am some content built as a javascript variable!</h2><p><a href='#' class='cee_close'>Close Me</a></p></div>"
                $("#testlink").click(function(){
                        $.fn.ceebox.overlay();
                        $.fn.ceebox.popup(testhtml,{onload:true,htmlWidth:600,htmlHeight:450});
                        return false;
                });
                $("#testlink2").click(function(){
                        $.fn.ceebox.overlay();
                        $.fn.ceebox.popup(testhtml2,{width:600,height:400});
                        return false;
                });
                //$.fn.ceebox.popup(testhtml,{onload:true,htmlWidth:600,htmlHeight:450});


	    $(".popupwindow").popupwindow();
	screenshotPreview();
	$('.map').maphilight();
            $("#shadow").css("height", $(document).height()).hide();
            $(".lightSwitcher").click(function(){
                $("#shadow").toggle();
                if ($("#shadow").is(":hidden")){
                    $(this).html("Turn off the lights").removeClass("turnedOff");
			toggle('center');
			player.sendEvent('STOP');}
                 else{
                    $(this).html("Turn on the lights").addClass("turnedOff");
			toggle('center');
			player.sendEvent('PLAY');}
            });

});

