/*
  *  tab切换
  *  @control 控制层id
  *  @show 显示层id
  *  @_class 控制层样式
  *  @调用:$.myPlugin.tab();
  */
$.myPlugin =  {
    tab : function(control,show,_class){
        $(control + "> a").each(function(){
            $(this).mouseover(function(){
                var c = $(control + "> a").index($(this));
                $(this).addClass(_class).siblings().removeClass(_class);
                $(show + "> div").eq(c).show().siblings().hide();
            })
        })
    }
}



/*
 *  alert模拟
 *  @_title 弹出框标题
 *  @_type 弹出类型 ok、warming、why
 *  @msg 正文内容
 *  @bool 是否显示"确定、取消" true or false
 *  Example :
 *  $("#visited_gzt").click(function(){
        _alert("提示","why","测试内容？",false)
    })
 */
function _alert(_title,_type,msg,bool,url,_time){
    var str = $('<div style="position: absolute; filter: alpha(opacity=20);background-color: rgb(0, 0, 0); width: 100%; z-index: 999; top: 0px; left: 0px; opacity: 0.2; height: 1552px; display: block;" id="alert_mc"></div>');
    var html = $('<div style="display: block; background: none repeat scroll 0% 0% rgb(255, 255, 255); z-index: 9999; width: 355px; left: 416.5px; top: 380.5px; position: absolute; border: 5px solid rgb(153, 153, 153); filter: alpha(opacity=50);opacity: 0.5;" id="alert_shade"></div>');
    var _conhtml = $('<div style="display: block; background: none repeat scroll 0% 0% rgb(255, 255, 255); z-index: 9999; width: 355px; left: 421.5px; top: 385.5px; position: absolute;" id="shake_card">'+
        '<div class="pop_up_card"><h3>'+_title+'</h3><a title="关闭" id="card_close_alert" href="javascript:;"></a></div>'+
        '<div class="card_p_con"><div class="card_c_top"><table border="0"><tr><td valign="top" width="40"><s class="alert_'+_type+'"></s></td><td><span>'+msg+'</span></td></tr></table></div>'+
        '<div class="yx_btu" id="button_card" style="display:none"><a class="upload_ip" id="card_sure" onclick="gotopage1('+"'"+url+"'"+');return false;" href="javascript:;" >确定</a> <a id="card_close_alert_b" class="close_ip" href="javascript:;">取消</a></div></div>'+
        '</div>');
    $("body").append(str);
    $("body").append(html);
    $("body").append(_conhtml);
    if(bool==true){
        $("#button_card").show();
    }else{
        $("#button_card").hide();
    }
    var _h = $(document).height();
    var _w = $(document).width();
    var _h1 = $("#shake_card").height();
    $("#shake_card").css("height",_h1);
    $("#alert_shade").css("height",_h1);
    $("#alert_mc").css('height',_h);
    $("#alert_mc").css('width',_w);
    $("#alert_shade").css('left',($(window).width() - $("#alert_shade").outerWidth())/2);
    $("#alert_shade").css('top',($(window).height() - $("#alert_shade").outerHeight())/2 + parseInt($(document).scrollTop()));
    $("#shake_card").css('left',($(window).width() - $("#shake_card").outerWidth())/2);
    $("#shake_card").css('top',($(window).height() - $("#shake_card").outerHeight())/2 + parseInt($(document).scrollTop()));
    var st;
    if(!_time){
       st =  setTimeout(function(){
         $(str).remove();
         $(html).remove();
         $(_conhtml).remove();
        },3000)
    }
    else{
        setTimeout(function(){
         $(str).remove();
         $(html).remove();
         $(_conhtml).remove();
        },_time*1000)
    }
    if(bool){
        clearTimeout(st)
    }
    /**
 * if(!url){
 *         setTimeout(function(){
 *             $(str).remove();
 *             $(html).remove();
 *             $(_conhtml).remove();
 *         },3000)
 *     } 
 */

    //关闭
    function card_close_alert(obj){
        $(obj).click(function(){
            $(str).remove();
            $(html).remove();
            $(_conhtml).remove();
        })
    }
    new card_close_alert("#card_close_alert");
    new card_close_alert("#card_close_alert_b");
    
}

function gotopage1(url) {
    $('#shake_card').remove();
    $('#alert_shade').remove();
    $('#alert_mc').remove();
    if (url.indexOf('/') == -1) {
        var urls = url.split('_');
        if (urls[1] == '3') {
            sure_do3(urls[0]);
        } else if (urls[1] == '4') {
            if (urls[2] == '')
            sure_do4(urls[0]); else
                sure_do4(urls[0],urls[2]);
        } else if(url) {
            sure_do(url);
        }
    } else {
        window.location.href = url;
    }
}

 
