var menu_selected = "All 全部";
var keyword = "tv";
var current_menu;
var temp_menu;
var adurl = "";
var searchText = "Search All Videos 搜索视频..."
var recep_email_text = "Support multiple email addresses, separated with commas, max 200 chars."
var share_msg_text = "Optional, max 200 chars."
var kw = "all"; //keyword
$.refreshads = function() {
    $("#AdFrame").attr("src", adurl + "?nc=" + Math.random());
}

$(document).ready(
	function() {
	    $.determinePlayer();
	    $.initialize();
        adurl = $("#AdFrame").attr("src");

	    $.showonloadmenu();

	    $.bindstars();
	    $.bindmenu();

	    current_menu = $(".menu-selected");

	    $(".active_tab").bind("click", function() {
	        $(this).attr("class", $(this).attr("class") == "inactive_tab" ? "active" : "inactive_tab");
	    });

	    $(".inactive_tab").bind("click", function() {
	        $(this).attr("class", $(this).attr("class") == "inactive_tab" ? "active" : "inactive_tab");
	    });
	    $.textBoxEffect();
	    $(function() {
	        $("ul.tabs").tabs("div.panes > div");
	        var api = $("ul.tabs").tabs("div.panes > div");
	        api.onClick(function(index) {
	            if (index == 1) {
	                ShowValidImage_cmt();
	            } else if (index == 2) {
	                ShowValidImage();
	            }

	        });
	    });

	    $("#search").keyup(function(e) {
	        if (e.keyCode == 13) { $.searchvideo(); }
	    });

	    $("#search-button").bind("click", function() {
	        $.searchvideo();
	    });

	    $("div.scrollable").scrollable({
	        size: 4,
	        items: '#thumbs',
	        hoverClass: 'hover'
	    });

	    $("#download p a").unbind("click");

	    $("#download p a").bind("click", function() {
	        OmnitureTrackDownloads($("#this-video-title").text(), $(this).attr("fmt"), $(".allcomments").attr("ugc_id"));
	    });

	    OmnitureTrackPage("home");

	    $.bindrelatedarticle();
	    $("#video-list-pagination-2").css("top", $("#body").height() - 35);
	    
	    $.countUniqueVistor();
	});

	$.showonloadmenu = function() {
	    var key_word_from_url = window.location.toString().replace(/(https?:\/\/)([^\/]+)\/([^\/]+)(.*)/, "$3").toLowerCase();
	    key_word_from_url = key_word_from_url.replace("#", "");
	    if (key_word_from_url != "all" && key_word_from_url != "default.aspx" && window.location.pathname != "/") {
	        $("#editor-pick").hide();
	        $("#SponsorAd").attr("src", location.protocol + "//" + location.host + "/Ad.aspx?k=" + key_word_from_url + "&p=Right&ord=" + (new Date).getTime());
	        kw = key_word_from_url;
	        GetSkin();
	    }
	    else $(".menu-item:eq(0)").addClass("menu-selected");

	    $(".menu-item").each(function(n) {
	        if ($(".menu-item:eq(" + n + ")").attr("href").replace(/^\/([^\/]+)\/?/, "$1").toLowerCase() == key_word_from_url) {
	            $(".menu-item").removeClass("menu-selected");
	            $(".menu-item:eq(" + n + ")").addClass("menu-selected");
	            menu_selected = $(".menu-item:eq(" + n + ")").text();
	            return;
	        }
	    });

	    $(".sub-menu-item").each(function(n) {
	        if ($(".sub-menu-item:eq(" + n + ")").attr("href").replace(/^\/([^\/]+)\/?/, "$1").toLowerCase() == key_word_from_url) {
	            $(".menu-item").removeClass("menu-selected");
	            $(".sub-menu-item:eq(" + n + ")").parent().parent().parent().prev("a").addClass("menu-selected");
	            menu_selected = $(".sub-menu-item:eq(" + n + ")").text();
	            return;
	        }
	    });

	    $(".sub-sub-menu-item").each(function(n) {
	        if ($(".sub-sub-menu-item:eq(" + n + ")").attr("href").replace(/^\/([^\/]+)\/?/, "$1").toLowerCase() == key_word_from_url) {
	            $(".menu-item").removeClass("menu-selected");
	            $(".sub-sub-menu-item:eq(" + n + ")").parent().parent().parent().parent().prev("a").addClass("menu-selected");
	            menu_selected = $(".sub-sub-menu-item:eq(" + n + ")").text();
	            return;
	        }
	    });
	}

$.reloadplaylist = function() {
    $.getJSON("/j_playlist.aspx?a=dd&nc=" + Math.random(), function(json) {
        for (i = 0; i < json.length; i++) {
            AddVideo(json[i].ItemID, json[i].Title, json[i].VideoURL, json[i].ImageURL);            
        }
    });
}

$.selectfirsttab = function() {
    var api = $("ul.tabs").tabs("div.panes > div");
    var idx = api.getIndex();
    for (i = 0; i < idx; i++) api.prev();
}

var playingID;
function PlayingVideo(mediaID, mediaTitle, mediaTotalLengthInSeconds, mediaCurrentPositionInSeconds) {
    if (playingID == mediaID) {
        return;
    }
    $.get("/add_views.aspx?ugc_id=" + encodeURI(mediaID) + "&nc=" + Math.random(), function(d) {
        if (d != "-1") {
            $("#video-info").load("/j_vid_info.aspx?ugc_id=" + encodeURI(mediaID) + "&nc=" + Math.random(), function() {
                $("#rating-views").load("/j_rate_views.aspx?views=" + $("#url").attr("views") + "&ratings=" + $("#url").attr("ratings") + "&nc=" + Math.random(), function() {
                        $.bindstars();
                });
                $.bindrelatedarticle();
                $.bindthumbnail();
                $.selectfirsttab();
           });
           
           loadinfo(mediaID);
        
            $("#views-counter").text("VIEWS 观看次数: " + d);
            $(".thumbnail").each(function (i) {
                var n = $(".thumbnail:eq("+i+")");
                if (n.attr("ugc_id") == mediaID) {
                    n.next("p.views").children("img")[0].nextSibling.data = d;
                }
            });

            $("#rating-views").load("/j_rate_views.aspx?views=" + d + "&ratings=" + $("#url").attr("ratings") + "&nc=" + Math.random(), function() {
                $.bindstars();
            });            
            OmniturePlay(mediaTitle, mediaTotalLengthInSeconds, mediaCurrentPositionInSeconds);
        }
    });
    playingID = mediaID;
}

function SetFirstVideo() {
    $.reloadplaylist();
    var imageurl = unescape($("#url").attr("imageurl")).replace("/92/71/VideoImage", "/360/270/VideoImage");
    var videourl = unescape($("#url").attr("videourl"));
    if (window.location.toString().match(/https?:\/\/[^\/]+\/[0-9]+\/?/) != null) {
        menu_selected = "";
        PlayVideo($("#url").attr("ugc_id"), $("#this-video-title").text(), videourl, imageurl);
    }
    else SetVideo($("#url").attr("ugc_id"), $("#this-video-title").text(), videourl, imageurl);	
}

$.bindstars = function() {
	$("#star-rating").children().not("select, #rating-title").hide();
	var $caption = $('<div id="rating-caption"/>');
	$("#star-rating").stars(
    {
        inputType: "select",
        oneVoteOnly: true,
        captionEl: $caption,
        callback: function(ui, type, value)
        {
            $("#messages").text(" Saving...").fadeIn(30);
            $.post("/add_ratings.aspx", {"ratings": value, "ugc_id": $("#url").attr("ugc_id")}, function(json)
            {
                $("#views-counter").hide();
                $("#rating-title").text("Average rating: " + json);
                $("#messages").text(" Rating saved (" + value + "). Thanks!").stop().css("opacity", 1).fadeIn(30);

                OmnitureTrackRatings($("#this-video-title").text(),$("#url").attr("ugc_id"));

                setTimeout(function(){
                    $("#messages").fadeOut(1000);
                    $("#views-counter").show();
                }, 2000);
            }, "json");					
        }
    });
	
	// Since the <option value="3"> was selected by default, we must remove this selection from Stars.
	//$("#star-rating").stars("selectID", -1);
	$("#star-rating").stars("selectID", $("#url").attr("ratings") - 1);
	
	// Append caption element !after! the Stars
	$caption.appendTo("#star-rating");
	
	// Create element to use for confirmation messages
	$('<div id="messages"/>').appendTo("#star-rating");
	
	$("#rate").show();
}

$.bindthumbnail = function() {
    $(".play-this-1").unbind("click");
    $(".play-this-2").unbind("click");
    $(".playlist-add").unbind("click");
    $("#comment-button").unbind("click");
    $(".playlist-remove").unbind("click");

    var ugc_id = "";
    var title = "";
    $(".play-this-1").bind("click", function() {
        $.playthumbnail($(this));
    });

    $(".play-this-2").bind("click", function() {
        $.playthumbnail($(this));
    });

    $(".playlist-add").bind("click", function() {
        $.getJSON("/j_playlist.aspx?a=a&id=" + $(this).parent().parent().parent().attr("ugc_id") + "&nc=" + Math.random(), function(json) {
            $.jGrowl(json.message, { theme: "myjgrowl" });
            if (json.itemid == null) return;
            var imageurl = json.imageurl;
            imageurl = imageurl.replace("/92/71/VideoImage", "/360/270/VideoImage");
            AddVideo(json.itemid, json.title, json.videourl, imageurl);
        });
    });

    $.bindplaylist();
}

$.playthumbnail = function(obj) {
   o = obj.parent().parent().parent();
   img = o.next(".views").children("img");
   if (!isNaN(o.attr("idx"))) SelectVideo(o.attr("idx"));
       else $.play(o.attr("ugc_id"), img.attr("alt"), $.getthumbnailimage(obj));
}

$.bindmenu = function() {
    $(".menu-item").bind("click", function() {
        $(".sub-menu").hide();
        menu_selected = $(this).text();
        OmnitureTrackPage(menu_selected);
    });

    $(".sub-menu-item").bind("click", function() {
        $(".sub-menu").hide();
        current_menu = $.selectmenu($(this).parents(".sub-menu").prev(".menu-item"));
        menu_selected = $(this).text();
        OmnitureTrackPage(menu_selected);
    });

    $(".menu-item").hover(function() {
        $(".sub-menu").hide();
        $(this).next(".sub-menu").show();
        $.hideVideosorter1();
        temp_menu = $.selectmenu($(this));
    }, function() {
        $(".sub-menu").hide();
        $.selectmenu(current_menu);
        $.showVideosorter1();
        
    });

    $(".sub-menu-item").hover(function() {
        $(this).parents(".sub-menu").show();
        $.selectmenu(temp_menu);
        $.hideVideosorter1();
    }, function() {
        $(".sub-menu").hide();
        $.selectmenu(current_menu);
        $.showVideosorter1();
        
    });
}

$.selectmenu = function(selector) {
    $(".menu-item").removeClass("menu-selected");
    selector.addClass("menu-selected");
    return $(".menu-selected");
}

$.bindpages = function() {
	$("#cmt_pg ul li").unbind("click");
	$(".video-pages ul li").unbind("click");
	$(".search-pages ul li").unbind("click");
	$(".playlist-pages ul li").unbind("click");

	$("#cmt_pg ul li").bind("click", function() {
        $.showcommentlist($(this).attr("page"));
    });
	
	$(".video-pages ul li").bind("click", function() {
		$.showvideolist($(".video-pages").attr("keyword"), $(".video-pages").attr("itemid"), $(this).attr("page"));
    });
	
	$(".search-pages ul li").bind("click", function() {
        $.showsearchlist($(this).attr("page"));
    });
	
	$(".playlist-pages ul li").bind("click", function() {
		$.showplaylist($(this).attr("page"));
    });
}

$.bindplaylist = function () {
    $(".playlist-remove").bind("click", function() {
        $.getJSON("/j_playlist.aspx?a=r&id=" + $(this).parent().parent().parent().attr("ugc_id") + "&nc=" + Math.random(), function(json) {
            $.jGrowl(json.message, { theme: "myjgrowl" });
            $.showplaylist($(".playlist-pages").attr("page"));
            if (json.index >= 0) RemoveVideo(json.index);
        });
    });
}
   
$.bindcomments = function() {
    $("#add-comment").unbind("click");
    $("#comment-button").unbind("click");
    $("#comment-form-close").unbind("click");
    $("#tb_cmt_captcha").attr("value", "");
    $("#add-comment").bind("click", function () {
		var name = $("#input_name").attr("value");
		var comment = $("#input_comment").attr("value");
		var msg = "Thank you for commenting.";
		var cmt_captcha = $("#tb_cmt_captcha").attr("value");					
		if(name.length * comment.length * cmt_captcha.length == 0)
		{
			alert("All fields are mandatory. Please fill them in."); 
		}
		else {
		        $.post("/add_comments.aspx", { "ugc_id": $(".allcomments").attr("ugc_id"), "name": name, "comment":comment,"cmt_captcha":cmt_captcha }, function (data) {
					if (data != "1") {
					alert(data);
				}
				else {
					$.blockUI({message: $("#thankyou_comment") });					
					$.showcommentlist($("#cmt_pg ul .page_itm_currentpg").attr("page"));
					setTimeout($.unblockUI, 1000); 
					$("#video-player").show();
					OmnitureTrackComments();//Omniture tagging for Comments
				}
				ShowValidImage_cmt();
		   });
		}
	});
	
	$("#comment-button").bind("click", function () {
		$("#input_name").val("");
		$("#input_comment").val("");
		$("#video-player").hide();
		$.blockUI({message: $("#comment-form"), css: { cursor: "default", width: "370px" } });
	});
	
	$("#comment-form-close").bind("click", function () {
		$.unblockUI();
		$("#video-player").show();
	});
}

$.bindshare = function() {
    $("#sharenow").unbind("click");
    $("#sharenow").bind("click", function () {
		var sh_name = $("#sender_name").attr("value");
		var sh_email = $("#recep_email").attr("value");
		var sh_msg = $("#share_msg").attr("value");
		var msg = "Thank you for sharing.";
		var capcha_value = $("#tb_capcha").attr("value");
		if(sh_name.length * sh_email.length * sh_msg.length  == 0)
		{
			alert("All fields are mandatory. Please fill them in."); 
		}
		else {
				$.post("/add_share.aspx", { "url": $("#url").val(), "name":sh_name, "email": sh_email, "message":sh_msg, "captcha_value":capcha_value }, function (data) {
				if (data != "1") {
					alert(data);
				}
				else {
				   $.blockUI({message: $("#thankyou_share") }); 
				   setTimeout($.unblockUI, 1000);

				   OmnitureTrackShare(); //Omniture tagging for share
				   
				   $("#sender_name").attr("value","");
				   $("#recep_email").attr("value", "Support multiple email addresses, separated with commas, max 200 chars.");
		           $("#share_msg").attr("value", "Optional, max 200 chars.");
		           $("#tb_capcha").attr("value","");
				}
				 ShowValidImage();
		   });
		}
    });	
}

$.searchvideo = function() {
    keyword = $("#search").attr("value");
   if (keyword.indexOf("All Videos") > 0) {
        //alert("Please input keyword!");
        return;
    }
    else {
        $("#video-list-container").load("/j_vid_search.aspx?search=" + encodeURI($("#search").attr("value")) + "&nc=" + Math.random(), function() {
            $.initialize();
            fixpaginationposition();
            OmnitureTrackSearch(encodeURI($("#search").attr("value")), $(".search-pages:eq(1)").attr("total"));
        });
        $("#editor-pick").hide();
    }
}

function fixpaginationposition()
{
    $("#video-list-pagination-2").css("top", $("#body").height() - 35);
}

$.showsearchlist=function(page) {
    $("#video-list-container").load("/j_vid_search.aspx?search=" + encodeURI($(".search-pages").attr("search")) + "&page=" + page + "&orderby=" + $("#sort_video1").val() + "&nc=" + Math.random(), function() {
        $.initialize();
        fixpaginationposition();
    });
}

$.showcommentlist = function(page) {
    $("#comments").load("/j_more_comment.aspx?ugc_id=" + $(".allcomments").attr("ugc_id") + "&page=" + page + "&nc=" + Math.random(), function() {
        $.initialize();
    });
}

$.showvideolist = function(param_keyword, itemid, page) {
    if (param_keyword == "")
        keyword = "all";
    else
        keyword = param_keyword;

    if (param_keyword.toString().toLowerCase() == "all") {
        $("#editor-pick").show();
    }
    else {
        $("#editor-pick").hide();
    }
    $.refreshads();

    var content = "/j_vid_listing.aspx?keyword=" + encodeURI(param_keyword) + "&itemid=" + itemid + "&page=" + page + "&orderby=" + $(".video-sorter").attr("orderby") + "&nc=" + Math.random();
    $("#video-list-container").load(content, function() {
        $("#menu-selected").text(menu_selected);
        $.initialize();
        fixpaginationposition();
    });
    // alert(location.protocol + "//" + location.host + "/Ad.aspx?k=" + param_keyword + "&p=Right&ord=" + (new Date).getTime())
    $("#SponsorAd").attr("src", location.protocol + "//" + location.host + "/Ad.aspx?k=" + param_keyword + "&p=Right&ord=" + (new Date).getTime());
    kw = param_keyword;
    GetSkin();
}

$.showplaylist=function(page){
	// set keyword to be 'playlist' so that the height of the videolisting will not be shorten to 610px
	keyword = "playlist";
	$("#editor-pick").hide();
	if (page == null) page = 1;
	$("#video-list-container").load("/j_playlist.aspx?a=d&page=" + page + "&nc=" + Math.random(), function() {
		$.initialize();
		fixpaginationposition();
	});
}

$.bindrelatedarticle = function() {
    $("div.related-scrollable").scrollable({ 
	    size: 2, 
	    items: '#related-thumbs',   
	    prevPage: '.related-prev',
	    nextPage: '.related-next',
	    speed: 100
    });
}

function loadinfo(ugc_id)
{
    $("#comments").load("/j_more_comment.aspx?ugc_id=" + encodeURI(ugc_id) + "&nc=" + Math.random(), function() {
       $.bindcomments();
       $.bindpages();
   });

   $("#download").load("/j_vid_dwnld.aspx?ugc_id=" + encodeURI(ugc_id) + "&nc=" + Math.random(), function() {
        $("#download p a").unbind("click");
        $("#download p a").bind("click", function() {
            OmnitureTrackDownloads($("#this-video-title").text(), $(this).attr("fmt"), $(".allcomments").attr("ugc_id"));
        });
   });    

   $.bindshare();
}

$.play=function(ugc_id, title, image_url)
{
    $("#video-info").load("/j_vid_info.aspx?ugc_id=" + encodeURI(ugc_id) + "&nc=" + Math.random(), function() {
        PlayVideo(ugc_id, title, $("#url").attr("videourl"), image_url.replace("/92/71/VideoImage", "/360/270/VideoImage"));
//        $("#rating-views").load("/j_rate_views.aspx?views=" + $("#url").attr("views") + "&ratings=" + $("#url").attr("ratings") + "&nc=" + Math.random(), function() {
//                $.bindstars();
//        });
//        $.bindrelatedarticle();
//        $.bindthumbnail();
        $.selectfirsttab();
   });

   loadinfo(ugc_id);
}

$.getthumbnailimage = function(obj) {
    return obj.parent().parent().parent().css("background-image").replace(/(url\("?)([^\)"]+)"?\)/, "$2");
}

$.additem=function() {
    $.get("/j_more_article.aspx?i=" + $("#related-articles").children(":last").attr("idx") + "&ugc_id=" +  $("#related-articles").attr("ugc_id") + "&nc=" + Math.random(), function(data) {
        $("#related-articles").append(data);
        $("#related-article-list").scrollTo("max");
    });
}

$.removeitem=function() {
    j = parseInt($("#related-articles").children().length) % 8;
    for (i = 0; i < j; i++)
    {
        $("#related-articles").children(":last").remove();
        $("#related-article-list").scrollTo("max");
    }
}

$.isname=function(name){
	var regexp = "^[a-zA-Z]+(\.)*(,)*[a-zA-Z]+$";
	if( name ) { return name.match(regexp); }
	else { return false; }
}

$.initialize = function() {
    $(".sort_sel").val($(".video-sorter").attr("orderby"));
    $(".sort_sel").change(function() {
        $(".video-sorter").attr("orderby", $(this).val());
        if ($(".search-pages").length > 0) $.showsearchlist(1);
        else $.showvideolist($(".video-pages").attr("keyword"), $(".video-pages").attr("itemid"), 1);
    });

    $.bindpages();
    $.bindplaylist();
    $.bindthumbnail();
    $.bindcomments();
    $.bindshare();

    if ($("#video-list-container").height() < 850) $("#body").css("height", $("#right-pane").height());
}
$.determinePlayer = function(){
    var isInstalled = false;
    var installedVersion = 0;
	    var v;
	    for( v=5; v>=0; v-- ){
	        if(Silverlight.isInstalled(v.toString() + ".0")==true)
	        {
    	      //alert(v.toString() + ".0");  
    	      if ( v > 1 && isInstalled == false) {
    	        $("#video-player").css("display","");
    	        $("#no-player").css("display","none");
    	        isInstalled = true;
    	        installedVersion = v;
    	        break;
    	      }
	        }
	        if(v==1 && isInstalled == true)
	        {
	            isInstalled = false;
	            installedVersion = 1;
	        }
	        if(v==0)
	        {
	            installedVersion = 0;
	        }
	        
	    }
        if(isInstalled == false)
        {
	          $("#video-player").css("display","none");
	          $("#no-player").css("display","");
        }  
       //alert(isInstalled + ":" + $.cookie("Installed") + ":" + $.cookie("FirstLoad"));
        if((isInstalled == false && $.cookie("Installed") == null) || (isInstalled == true && $.cookie("Installed") =="false") )
        {
            $.get("/SilverLight_Adoption.aspx?v=" + installedVersion + "&nc=" + Math.random(), function(d) {
                   if(d == "-1")
                   {
                        alert("Insert SilverLight_Adoption table failed!");
                        return;
                   }
              });
              if (installedVersion > 1)
              {
                $.cookie("Installed","true", {expires:1});//1 Day
              }
              else
              {
                $.cookie("Installed", "false",{expires:1});//1 Day
              }
        }
}
$.countUniqueVistor = function() {
    //alert($.cookie("FirstLoad"));
    if ($.cookie("FirstLoad") == null) {
        $.get("/CountUnqiueVisitor.aspx?nc=" + Math.random(), function(d) {
            if (d.toString() == "-1") {
                alert("Insert UniqueVistor table failed!");
                return;
            }
            else {
                //alert(data.toString() + " Vistor updated");
                $.cookie("FirstLoad", "false", { expires: 1 }); //1 Day
            }
        });
    }
}
var GetTries = 0; // Global variable
function GetSkin() {
    $.ajax({
        type: "POST",
        url: location.protocol + "//" + location.host + "/Default.aspx/GetSkin",
        data: "{keyword:'" + kw + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(obj) {
            var skin = obj.d;
            $("#right-pane").css("background-color", skin.Color).css("background-image", "url(" + skin.Image + ")").css("background-repeat", skin.Repeat);
            $("#video-list").css("background-color", "Transparent");
        },
        error: function(err) {
            //alert("GetSkin Error");
        if (GetTries < 2) { setTimeout("GetSkin()", 100 * (GetTries * 10)); GetTries += 1; }
        }
    });

}
$.textBoxEffect = function() {
$("#search").css("color", "#666666").val(searchText);

$("#search").focus(function() {
    $(this).filter(function() {
        return $(this).val() == "" || $(this).val() == searchText
    }).css("color", "#000000").val("");
});
$("#search").blur(function() {
    $(this).filter(function() {
        return jQuery.trim($(this).val()) == ""
    }).css("color", "#666666").val(searchText);
});

$("#recep_email").css("color", "#666666").val(recep_email_text);
$("#recep_email").focus(function() {
    $(this).filter(function() {
        return $(this).val() == "" || $(this).val() == recep_email_text
    }).css("color", "#000000").val("");
});
$("#recep_email").blur(function() {
    $(this).filter(function() {
        return $(this).val() == ""
    }).css("color", "#666666").val(recep_email_text);
});

$("#share_msg").css("color", "#666666").val(share_msg_text);
$("#share_msg").focus(function() {
    $(this).filter(function() {
        return $(this).val() == "" || $(this).val() == share_msg_text
    }).css("color", "#000000").val("");
});
$("#share_msg").blur(function() {
    $(this).filter(function() {
        return $(this).val() == ""
    }).css("color", "#666666").val(share_msg_text);
});
}

$.hideVideosorter1 = function() {
//    if ($("#editor-pick").css("display") == "none") {
//        $("#video-list-pagination-1 div.video-sorter").css("display", "none");
//    }
//    else {
//        $("#video-list-pagination-1 div.video-sorter").css("display", "");
//    }

}
$.showVideosorter1 = function() {
//$("#video-list-pagination-1 div.video-sorter").css("display", "");
}

String.prototype.trim = function() {
    a = this.replace(/^\s+/, '');
    return a.replace(/\s+$/, '');
};

 function VerifyCodeWrong() {
        ShowValidImage();
    }
    function ShowValidImage() {
        var numkey = Math.random();
        $("#imgRandom").attr("src","/HiCapCha.aspx?NumKey=" + numkey);
    }
       function ShowValidImage_cmt() {
        var numkey = Math.random();
        $("#cmt_imgRandom").attr("src","/HiCapCha.aspx?NumKey=" + numkey);
    }
    
 
    