$(document).ready(function(){
						   
	$.browser.msie || $(".ellipsis>li").each(function(){
		$this = $(this);
		if(this.scrollWidth > this.clientWidth){
			trimli(this);
		}
	});
	function trimli(element){
		text = $(element).text();
		$(element).find("a").text(text.slice(0,-6)+'...');
		if(element.scrollWidth > element.clientWidth){
			trimli(element);
		}
	}
	
	$(".MenuTitle").each(function(i){
			$(this).mouseover(function(){
				$(".MenuContent").eq(i).show(
				).mouseout(function(){
					$(this).hide();
				}).mouseover(function(){
					$(this).show();
				});
			}).mouseout(function(){
				$(".MenuContent").eq(i).hide();
			});
		})
	$(".LinkTab").each(function(i){
		$(this).mouseover(function(){
			$(".LinkTab").removeClass("active");
			$(this).addClass("active");
			$(".LinkContent").hide();				   
			$(".LinkContent").eq(i).show();
		})
	});
	
  $( "#SignInForm" ).submit( function(){
    jCore.start( 'passport.signin', $( 'input[name]', $( this ) ), function( response ){
      if (response.success){
        $( "#UserPanel" ).html( response.userPanel );
      }
      else{
        $( "input[@name=Password]", $( this ) ).val( "" );
        alert( response.message );
      }
    } );
   } );
	  $(".SearchKeyWord").each(function(i){
        var SearchKeyWord = this;
        var KeyColor = $(this).css("color");
        var KeyCue = "请输入关键字!";
        var KeyCueColor = "#bbbbbb";
        var KeyAlertColor = "#ff0000";
        $(this).val() == "" && $(this).val(KeyCue) && $(this).css("color", KeyCueColor);
        $(this).focus(function(){
            if ($(this).val() == KeyCue) {
                $(this).val("");
            }
            $(this).css("color") != KeyColor && $(this).css("color", KeyColor);
        });
        $(this).blur(function(){
            $(this).val() == "" && $(this).val(KeyCue) && $(this).css("color", KeyCueColor);
        });
        $(this).parents("form").submit(function(){
            if ($(SearchKeyWord).val() == KeyCue) {
                $(SearchKeyWord).css("color", KeyAlertColor);
                return false;
            }
        });
    });
	if (location.search.search(/__ShowPageLabels__/) !== -1) {
		$.getScript('/themes/console/js/pagelabels.js');
    }
	$( ".SuffrageContainer" ).click( function( evt ){
	    var container = this;
	    var self = evt.target;
	    construct = function( result ){

	    }
	    switch (true) {
	      case $( self ).is( '.submit' ):
	        if ( !$( '.SuffrageForm input.Suffrage[checked]', $( container ) ).length){
	          alert( '未选择任何表单项' );
	          break;
	        }
	        $( self ).remove();
	        $( 'input.view', $( container ) ).remove();
	        $( ".SuffrageForm", $( container ) ).hide();
	        jCore.start( 'api.suffrage.append', $( '.SuffrageForm input', $( container ) ).serialize(), function( response ){
	          $( ".SuffrageResult", $( container ) ).show().find('.resultg').html( response.suffrage );
	        } );
	        break;
	      case $( self ).is( '.view' ):
	        $( ".SuffrageForm,.SuffrageResult", $( container ) ).toggle();
	        $( self ).val( $( ".SuffrageResult", $( container ) ).is( ':visible' ) ? '返回' : '查看' );
	        break;
	    }
	  } );

});
