/* cookies */
function getCookie(name) {

    var arg = name + "=";

    var alen = arg.length;

    var clen = document.cookie.length;

    var i = 0;

    while (i < clen) {

        var j = i + alen;

        if (document.cookie.substring(i, j) == arg) {

            return getCookieVal(j);

        }

        i = document.cookie.indexOf(" ", i) + 1;

        if (i == 0) break; 

    }

    return "";

}
function setCookie(name, value, expires, path, domain, secure) {

var expiresvalue='';
if (expires){
    var exp  = new Date(); 
        exp.setTime(exp.getTime() + expires*24*60*60*1000);
        expiresvalue = exp.toGMTString();
}
    document.cookie = name + "=" + escape (value) +

        ((expires) ? "; expires=" + expiresvalue : "") +

        ((path) ? "; path=" + path : "") +

        ((domain) ? "; domain=" + domain : "") +

        ((secure) ? "; secure" : "");

}  
function deleteCookie(name,path,domain) {

    if (getCookie(name)) {

        document.cookie = name + "=" +

            ((path) ? "; path=" + path : "") +

            ((domain) ? "; domain=" + domain : "") +

            "; expires=Thu, 01-Jan-70 00:00:01 GMT";

    }

}
function getCookieVal(offset) {
    var endstr = document.cookie.indexOf (";", offset);

    if (endstr == -1) {
        endstr = document.cookie.length;
    }
    return unescape(document.cookie.substring(offset, endstr));
} 

(function($){ 
    $.fn.center=function(settings){ 
        var style=$.extend({ 
                          position:'fixed',//absolute or fixed 
                          top:'50%',            //50%即居中，将应用负边距计算，溢出不予考虑了。 
                          left:'50%', 
                          zIndex:99, 
                          relative:true        //相对于包含它的容器居中还是整个页面 
                          }, settings || {}); 
         
        return this.each(function(){ 
                  var $this=$(this); 
                   
                  if(style.top == '50%') style.marginTop=-$this.outerHeight()/2; 
                  if(style.left == '50%') style.marginLeft=-$this.outerWidth()/2; 
                  if(style.relative && !$this.parent().is('body') && $this.parent().css('position') == 'static') 
                      $this.parent().css('position','relative'); 
                  delete style.relative; 
                  //ie6 
                  if(style.position == 'fixed' && $.browser.version=='6.0'){ 
                      style.marginTop += $(window).scrollTop(); 
                      style.position = 'absolute'; 
                      $(window).scroll(function(){ 
                                                    $this.stop().animate({ 
                                                                      marginTop:$(window).scrollTop()-$this.outerHeight()/2 
                                                                      }); 
                                                    }); 
                  } 
                   
                  $this.css(style); 
                  }); 
    }; 
})(jQuery); 


function ShowLoading(){
	$("#yun_loading").center();    
    $('#yun_loading').show();
}

function HideLoading(){
    $('#yun_loading').hide();
    
}
function CheckAll(form) {
 for (var i=0;i<form.elements.length;i++) {
 var e = form.elements[i];
 if (e.name != 'chkall') e.checked = form.chkall.checked; 
 }
 }
      
function yun_submit(id,c){    
    
    $('#'+id).ajaxSubmit(
    {
         beforeSubmit: function(){
             if(typeof(c)!='undefined') if(!confirm(c)) return false;
            
            ShowLoading();
         },
        success:function(text){
           HideLoading();
           eval(text);           
        }      
        });
    return false;
        }
        
 function yun_send(u,c){
     
                $.ajax(
                {
                    async:false,
                    url:u,
                    cache:false,
          beforeSend: function(){            
           if(typeof(c)!='undefined') if(!confirm(c)) return false;            
            ShowLoading();            
         },
        success:function(text){
            HideLoading();
           eval(text);
        }      
        });
                    
}  
	function yun_onfocus(e){	   
	setTimeout("$('#"+e+"').focus()",300);		
	}
        
 function yun_mshow(e,id){
    if($('#'+id).css('display')=='none'){
       e.className='m-off'; 
       $('#'+id).show(200);        
    }else{
       e.className='m-open';  
       $('#'+id).hide(200); 
    }
 }       
        
 
 

        
        
        
        
