﻿$().ready(function(){
    $('a','#Nav').each(function(){
        if(window.location.href.toLowerCase().indexOf($(this).attr('href').toLowerCase())!=-1){
            $(this).removeAttr('href');
            $(this).attr('style','font-weight:bold');
        }
    });
    
    if(window.location.href.toLowerCase().indexOf("index.aspx")>0 || window.location.href.indexOf(".aspx")==-1){
        if($('.PicsNames').val()!=""){
            new ImagesScorll(5,270,155,30,'center','.PicsNames','.LinksUrls','.TextsTitles','_blank','ImagesScorllDiv','picScorllDiv','pageCountDiv','textsDiv');
        }
        FloatDivMove('.Float_Div_Class');
        $('.txt_Id_Class').val($('#txt_Id').val());
    }
    
    if(window.location.href.toLowerCase().indexOf("searchlist.aspx")>0){
        $('#kWords').val($('span','#keyWordsTD').text());
        $('#sType').val($('span','#stTD').text());
    }
    
    if(window.location.href.toLowerCase().indexOf("newsview.aspx")>0){
        $('#GoToMore').attr('href','NewsList.aspx?CategoryId='+$('span','#categoryIdTD').text());
    }
});

function Search(url,target){
    $('#kw').val($('#kWords').val());
    $('#st').val($('#sType').val());
    $('#htmlForm').attr('action',url);
    $('#htmlForm').attr('target',target);
    document.forms[1].submit();
}

function LawsuitSearch(url,target){
    $('#sName').val($('#txt_CName_').val());
    $('#sTel').val($('#txt_CTel_').val());
    $('#sCKeyWords').val($('#txt_CKeyWords_').val());
    $('#cSType').val('综合查询');
    $('#htmlForm').attr('action',url);
    $('#htmlForm').attr('target',target);
    document.forms[1].submit(); 
}

var floatFlagX = true;
var floatFlagY = true;

function FloatDivMove(srcClass){
    if($('img',srcClass).attr('src')!=null && $('img',srcClass).attr('src')!=''){
        $(srcClass).each(function(){
            if(parseInt(this.style.left)==750){
                floatFlagX = false;
            }else if(parseInt(this.style.left)==10){
                floatFlagX = true;
            }
            if(floatFlagX)
                $(this).css({'left':parseInt(this.style.left)+1});
            else
                $(this).css({'left':parseInt(this.style.left)-1});
        });
        $(srcClass).each(function(){
            if(parseInt(this.style.top)==550){
                floatFlagY = false;
            }else if(parseInt(this.style.top)==180){
                floatFlagY = true;
            }
            if(floatFlagY)
                $(this).css({'top':parseInt(this.style.top)+1});
            else
                $(this).css({'top':parseInt(this.style.top)-1});
        });
        setTimeout("FloatDivMove('"+srcClass+"')",50);
    }
}

function SetFunction(obj){
    var childObj = $('a',obj);
    var hrefStr = childObj.attr('href');
    if(hrefStr!=null && hrefStr!='' && childObj.attr('onclick')==null){
        childObj.attr('onclick','avd');
        childObj.click(function(){
            GotoView(obj,hrefStr);
            return false;
        });
    }
}

function SetFontSize(size){
    $('.NewsContent').each(function(){
        $(this).css({'font-size':$(this).attr('font-size')+size});
    });
    $('*','.NewsContent').each(function(){
        $(this).css({'font-size':$(this).attr('font-size')+size});
    });
}

function GotoView(obj,hrefStr){
    $('#CategoryName').val($(obj).attr('CategoryName'));
    $('#NewsTypeName').val($(obj).attr('NewsTypeName'));
    $('#CategoryId').val($(obj).attr('CategoryId'));
    $('#Id').val($(obj).attr('Id'));
    $('#htmlForm').attr('action',hrefStr);
    $('#htmlForm').attr('target',$('a',obj).attr('target'));
    document.forms[1].submit();
}

function GotoMore(categoryName,newsTypeName,obj){
    $('#CategoryName').val(categoryName);
    $('#NewsTypeName').val(newsTypeName);
    $('#htmlForm').attr('action','NewsList.aspx');
    $('#htmlForm').attr('target',$(obj).attr('target'));
    document.forms[1].submit();
}

function GotoDown(categoryName,newsTypeName,obj){
    $('#CategoryName').val(categoryName);
    $('#NewsTypeName').val(newsTypeName);
    $('#htmlForm').attr('action','DownList.aspx');
    $('#htmlForm').attr('target',$(obj).attr('target'));
    document.forms[1].submit();
}

function GotoFishSpace(obj){
    $('#CategoryName').val($(obj).text());
    $('#NewsTypeName').val('渔业新时空');
    $('#htmlForm').attr('action','NewsList.aspx');
    $('#htmlForm').attr('target',$(obj).attr('target'));
    document.forms[1].submit();
}

function GotoOrgan(categoryName,newsTypeName,obj){
    $('#CategoryName').val(categoryName);
    $('#NewsTypeName').val(newsTypeName);
    $('#htmlForm').attr('action','OrganView.aspx');
    $('#htmlForm').attr('target',$(obj).attr('target'));
    document.forms[1].submit();
}

function RefreshPage(categoryName,newsTypeName,Id){
    $('#CategoryName').val(categoryName);
    $('#NewsTypeName').val(newsTypeName);
    $('#Id').val(Id);
    $('#htmlForm').attr('action','VoteListView.aspx');
    $('#htmlForm').attr('target','_self');
    document.forms[1].submit();
}

function resetByPrefix(_prefix,dataTag){
    if(!dataTag || dataTag==-1) dataTag='';
    $('*[id]','.bpEdit'+dataTag).each(function(){
        ctl=this;
        if(ctl.id.indexOf(_prefix)>0 || ctl.id.indexOf('chk_')>0)
        {
            if(ctl.type == 'text' || ctl.className == 'text')
                ctl.value = '';
            else if(ctl.type == 'select-one')
                ctl.selectedIndex = 0;
            else if(ctl.type == 'checkbox')
                ctl.checked = false;
        }
    });
}