/*
 * Image preview script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Aaron.xue (http://icpark.com)
 * 
 *
 */
 
var a=0;
var b=1;
var t;

$(document).ready(function(){
	pageinit();
	grouptodayhover();
	imagePreview();
	startgroup();
});

this.pageinit = function(){
    $("#ulgrouptoday li:first dl").addClass("bgyellowthin");
    $("#ulgrouptoday :not(li:first) dl").hide();
    $("#ulgrouptoday li:first").find("span.arrowright4").hide();
};

this.grouptodayhover = function(){
//$("#ulgrouptoday :not(li:first)").hover(function(){
	$("#ulgrouptoday li").hover(function(){
			//$(this).find("dl").addClass("bgredthin");
		    $("#ulgrouptoday li span.arrowright4").show();	
			$("#ulgrouptoday li").removeClass("bgyellowthin");
            $("#ulgrouptoday li dl").hide();
			$(this).addClass("bgyellowthin");
			$(this).find("dl").show();
			$(this).find("span.arrowright4").hide();	
		},
       	function(){
				//$(this).find("dl").removeClass("bgredthin");
		});
};

 
this.imagePreview = function(){	
	xOffset = 10;
	yOffset = 30;
		
	$("a.preview2").hover(function(e){
		var fsrc = $(this).attr("ref");//default face img
		
	var fdir = fsrc.substring(0,fsrc.lastIndexOf("/")+1);
	//alert(fdir);


	var b=fsrc.split("/"); 
	var c=b.slice(b.length-1, b.length).toString(String).split("."); 
	var fname = c.slice(0,1);


	var fext = fsrc.substring(fsrc.lastIndexOf('.') + 1);
	//alert(fext);

	var fsrclage = fdir + fname + "_b." + fext;
	//alert(fsrclage);

		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='preview'><img src='"+ fsrclage +"' alt='" + this.ref + "' />"+ c +"</p>");								 
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });
	$("a.preview2").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};
     this.startgroup=function() {
            var hl=$("#hot_movies_menu li"),content=$(".movie_headerline .content");
            hl.mouseover(function() {
                $(".menu li .newclearfix").removeClass("on");
                $("#"+this.id+" .newclearfix").addClass("on");
                content.hide();
                $("#content_"+this.id).show();
                return false;
            });
        };

