﻿function killErrors() {
    return true;
}

Array.prototype.unique = function()
{
    var a = {};
    for(var i=0; i<this.length; i++)
    {
        if(typeof a[this[i]] == "undefined")
            a[this[i]] = 1;
    }
    this.length = 0;
    for(var e in a)
        this[this.length] = e;
    return this;
}

String.prototype.trim = function()   
{
    return this.replace(/(^\s*)|(\s*$)/g,"");   
}

function JsLoader() {
    this.load = function(url) {
        //获取所有的<scrcipt>标记
        var ss = document.getElementsByTagName("script");
        //判断指定的文件是否已经包含，如果已包含则触发onsuccess事件并返回
        for (i = 0; i < ss.length; i++) {
            if (ss[i].src && ss[i].src.indexOf(url) != -1) {
                this.onsuccess();
                return;
            }
        }
        //创建script结点，并将其属性设为为外联JavaScript文件
        s = document.createElement("script");
        s.type = "text/javascript";
        s.src = url;
        //获取head结点，并将<script>插入到其中
        var head = document.getElementsByTagName("head")[0];
        head.appendChild(s);
        //获取对象自身的引用
        var self = this;

        //对于IE浏览器，使用readystatechange事件判断是否载入成功
        //对于其他浏览器，使用onload事件判断载入是否成功
        s.onload = s.onreadystatechange = function() {
            //在此函数中this指针指的是s结点对象，而不是JsLoader实例，
            //所以必须用self来调用onsuccess事件，下同。
            if (this.readyState && this.readyState == "loading") return;
            self.onsuccess();
        }
        s.onerror = function() {
            //如果发生错误，则删除插入的结点，并触发失败事件
            head.removeChild(s);
            self.onfailure();
        }
    };
    //定义载入成功事件
    this.onsuccess = function() { };
    //定义载入失败事件
    this.onfailure = function() { };
}

function loadJS(src,fos) {
    var jl = new JsLoader();
    //定义载入成功处理程序
    jl.onsuccess = function() {
        if(fos)fos();
    }
    //定义载入失败处理程序
    jl.onfailure = function() {
        
    }
    //开始载入
    jl.load(src);
}

function CheckObj(obj)
{
    if(!obj)return false;
    if(obj===undefined)return false;
    if(obj==null)return false;
    return true;    
}

function $getintf(s,f)
{
    var r=$getstr(s).replace(f,"");
    return $getint(r);
}
function $getint(s)
{
    try
    {
        return parseInt(s);
    }
    catch(ex)
    {
        return 0;
    }
}

function $getstr(s)
{
    try
    {
        return s+"";
    }
    catch(ex)
    {
        return "";
    }
}

function $gettext(s)
{
    try
    {
        var obj=$ce("div");
        obj.innerHTML=s;
        return obj.innerTEXT;
        obj=null;
    }
    catch(ex)
    {
        return " ";
    }
}

function $e(id)
{
	try
	{
		return 	$('#'+id).get(0);
	}
	catch(e)
	{
		return document.getElementById(id);
	}
}

function GetStrInArray(str,sp,d)
{
	var arr=str.split(sp);
	if(d<arr.length)return arr[d];
	else return "";
}
  
function LoadJs(jspath)
{
	$($ce("script",""))
	.attr('src',  jspath)
	.attr('type', 'text/javascript') 
	.appendTo('head'); 
}

function CPos(x, y)
{
    this.x = x;
    this.y = y;
}

function GetObjPos(ATarget)
{
    var target = ATarget;
    var pos = new CPos(target.offsetLeft, target.offsetTop);
    
    target = target.parentElement;
    while (target)
    {
        pos.x += target.offsetLeft;
        pos.y += target.offsetTop;        
        target = target.parentElement
    }
    
    return pos;
}

function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY)
	{ 
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	}
	else if (document.body.scrollHeight > document.body.offsetHeight)
	{
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	}
	else
	{
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var pageWidth,pageHeight,windowWidth,windowHeight;
	if (self.innerHeight)
	{
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{
		
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	} 
	
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	if(xScroll < windowWidth){ 
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function $ce(etype,evalue)
{
	var eobj=document.createElement(etype);
	if(evalue)eobj.innerHTML=evalue;
	return eobj;
}
function $cdiv(ev)
{
	if(ev) return $ce("div");
	else return $ce("div",ev);
}
function $cspan(ev)
{
	if(ev) return $ce("span",ev);
	else return $ce("span");
}

var GetRandomNumObj={};
GetRandomNumObj.today=new Date(); 
GetRandomNumObj.seed=GetRandomNumObj.today.getTime(); 
function GetRandomNumHelper() { 
	GetRandomNumObj.seed = (GetRandomNumObj.seed*9301+49297) % 233280; 
	return GetRandomNumObj.seed/(233280.0); 
}
function GetRandomNum(num) {
	if(num)return Math.ceil(GetRandomNumHelper()*num);
	else return Math.ceil(GetRandomNumHelper()*100000000);
}

function PageADTimer(areaid)
{
	var area=$(areaid);
	var obj;
	if(area.childNodes.length<1)return;
	obj=area.childNodes[0];
	if(obj.tagName.toLowerCase()!='img')return;
	obj.onLoad=PageADTimerOpen(areaid,5);
}

function PageADTimerOpen(areaid,sc)
{
	eval("ADTimer_"+$(areaid).id+"=window.setInterval(\"PageADTimerClose('"+$(areaid).id+"')\",sc*1000);");
}

function PageADTimerClose(areaid)
{
	$(areaid).style.display='none';
	window.clearInterval(window.eval("ADTimer_"+$(areaid).id));
}

function FlashNews(areaid,tempjs,nwidth,nheight,ntitle)
{
	try{eval(tempjs);}
	catch(ex){$(areaid).innerHTML='';return false;}
	var so = new SWFObject("/images/focus.swf", "nPageFlashNews", nwidth, nheight, "7", "#ffffff");
	so.addParam('wmode','transparent');
	so.addVariable("picurl",tempfile);
	so.addVariable("pictext",temptext);
	so.addVariable("piclink",templink);
	so.addVariable("pictime","5");
	so.addVariable("borderwidth",nwidth);
	so.addVariable("borderheight",nheight);
	so.addVariable("borderw","false");
	so.addVariable("buttondisplay","true");
	so.addVariable("textheight",ntitle);
	so.write(areaid);
}

function FlashNewsPN(areaid, tempfile, temptext, templink, nwidth, nheight, ntitle) {
    var so = new SWFObject("/images/focus.swf", "nPageFlashNews", nwidth, nheight, "7", "#ffffff");
    so.addParam('wmode', 'transparent');
    so.addVariable("picurl", tempfile);
    so.addVariable("pictext", temptext);
    so.addVariable("piclink", templink);
    so.addVariable("pictime", "5");
    so.addVariable("borderwidth", nwidth);
    so.addVariable("borderheight", nheight);
    so.addVariable("borderw", "false");
    so.addVariable("buttondisplay", "true");
    so.addVariable("textheight", ntitle);
    so.write(areaid);
}

var LoadShowImg=true;
var LoadShowImgUrl="/images/PageLoading.gif";

$.ajaxSetup({global: false,type:"GET",async:false});

function LoadUrl(url,oncomplated)
{
	var objid="LoadUrl_"+GetRandomNum(1000000);
	var objurl = url;
	if(LoadShowImg)
		document.write("<div id=\""+objid+"\"><img border=0 src="+LoadShowImgUrl+"></div>");
	else
		document.write("<div id=\""+objid+"\"></div>");
	if(oncomplated)
	{
		$.ajax({url:objurl,success:function(rpt){$('#'+objid).html('');oncomplated(objid,rpt)}});
	}
	else
	{
		$('#'+objid).load(objurl);
	}
}


function LoadPart(name,oncomplated)
{
	var objid="LoadPart_"+GetRandomNum(1000000);
	var objurl = "/getjs/getpartjs.aspx?part="+name;
	if(LoadShowImg)
		document.write("<div id=\""+objid+"\"><img border=0 src="+LoadShowImgUrl+"></div>");
	else
		document.write("<div id=\""+objid+"\"></div>");
	if(oncomplated)
	{
		$.ajax({url:objurl,success:function(rpt){$('#'+objid).html('');oncomplated(objid,rpt)}});
	}
	else
	{
		$('#'+objid).load(objurl);
	}
}

function LoadUc(path,oncomplated)
{
	var objid="LoadUc_"+GetRandomNum(1000000);
	var objurl = "/getjs/getucjs.aspx?file="+path;
	if(LoadShowImg)
		document.write("<div id=\""+objid+"\"><img border=0 src="+LoadShowImgUrl+"></div>");
	else
		document.write("<div id=\""+objid+"\"></div>");
	if(oncomplated)
	{
		$.ajax({url:objurl,success:function(rpt){$('#'+objid).html('');oncomplated(objid,rpt)}});
	}
	else
	{
		$('#'+objid).load(objurl);
	}
}

function LoadUcIframe(w, h, path) {
    var q = location.search.substr(1);
    var objid = "LoadUc_" + GetRandomNum(1000000);
    var objurl = "/getjs/getuciframe.aspx?file=" + path + "&" + q;
    document.write("<iframe id=\"" + objid + "\" frameborder=\"0\" scrolling=\"no\" width=\"" + w + "\" height=\"" + h + "\" src=\"" + objurl + "\"></iframe>");
}

function fillImg(img,w,h,fill)
{
	try
	{
        var imageArr=img;
        var maxWidth=w;
        var maxHeight=h;
	    imageArr.style.display="";
        var imageRate = imageArr.offsetWidth / imageArr.offsetHeight;    
        
    	
        if(imageArr.offsetWidth > maxWidth)
        {
            imageArr.style.width=maxWidth + "px";
            imageArr.style.Height=maxWidth / imageRate + "px";
        }
	    else
	    {
		    if(fill==0)
		    {
			    imageArr.style.width=maxWidth + "px";
			    imageArr.style.Height=maxWidth / imageRate + "px";		
		    }
	    }
        
        if(imageArr.offsetHeight > maxHeight)
        {
            imageArr.style.width = maxHeight * imageRate + "px";
            imageArr.style.Height = maxHeight + "px";
        }
	    else
	    {
		    if(fill==1)
		    {
			    imageArr.style.width = maxHeight * imageRate + "px";
			    imageArr.style.Height = maxHeight + "px";
		    }
	    }
	}
	catch(ex)
	{
	    $(img).css("display","none");
	}
}

function autoImg(img,w,h)
{
    var imageArr=img;
    var maxWidth=w;
    var maxHeight=h;
    if(imageArr.style.display)
    {imageArr.style.display="";}
    var imageRate = imageArr.offsetWidth / imageArr.offsetHeight;    
    
    if(imageArr.offsetWidth > maxWidth)
    {
        imageArr.style.width=maxWidth + "px";
        imageArr.style.Height=maxWidth / imageRate + "px";
    }
    
    if(imageArr.offsetHeight > maxHeight)
    {
        imageArr.style.width = maxHeight * imageRate + "px";
        imageArr.style.Height = maxHeight + "px";
    }

    if(!CheckObj($(img).parent().attr("href")) || $(img).parent().attr("href")=="")
    {
    	img.style.cursor='hand';
    	img.onclick=Function("window.oper=null;window.open(this.src)");
    }	
}
FixImgWidth=autoImg

var autoImage_Count=0;
function autoImage(spath,w,h)
{
    var stemp="<img id=\"autoImageObjLoad{lid}\" src=\"/images/PageLoading.gif\" border=\"0\">";
    stemp=stemp.replace("{lid}",autoImage_Count);
    //project
    stemp+="<img id=\"autoImageObj{id}\" src=\"{path}\" border=\"0\" style=\"display:none;width:{width}px;height:{height}px\" onLoad=\"javascript:autoImg(this,{w},{h})\">";
    stemp=stemp.replace("{id}",autoImage_Count);
    stemp=stemp.replace("{path}",spath);
    stemp=stemp.replace("{width}",w);
    stemp=stemp.replace("{height}",h);
    stemp=stemp.replace("{w}",w);
	stemp=stemp.replace("{h}",h);
    document.write(stemp);
    autoImage_Count+=1;
}

function autoImageLink(spath, slink, w, h) {
    var stemp = "<img id=\"autoImageObjLoad{lid}\" src=\"/images/PageLoading.gif\" border=\"0\">";
    stemp = stemp.replace("{lid}", autoImage_Count);
    //project
    stemp += "<a href=\"{link}\" target=\"_blank\"><img id=\"autoImageObj{id}\" src=\"{path}\" border=\"0\" style=\"display:none;width:{width}px;height:{height}px\" onLoad=\"javascript:autoImg(this,{w},{h})\"></a>";
    stemp = stemp.replace("{id}", autoImage_Count);
    stemp = stemp.replace("{path}", spath);
    stemp = stemp.replace("{link}", slink);
    stemp = stemp.replace("{width}", w);
    stemp = stemp.replace("{height}", h);
    stemp = stemp.replace("{w}", w);
    stemp = stemp.replace("{h}", h);
    document.write(stemp);
    autoImage_Count += 1;
}

function autoImgsl(spath,slink,w,h)
{
document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\""+w+"\" height=\""+h+"\"><param name=\"movie\" value=\"/images/swfoto.swf?image="+spath+"&imageLink="+slink+"\"><embed src=\"/images/swfoto.swf?image="+spath+"&imageLink="+slink+"\" width=\""+w+"\" height=\""+h+"\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\"></embed></object>");
}

function setHomePage(obj)
{
	obj.homepage.style.behavior='url(#default#homepage)';
	obj.homepage.sethomepage(site_url);
}
function setFavorite()
{
	window.external.AddFavorite(site_url,site_name);
}


function openWin(url)
{
	window.oper=null;
	window.open(url);
}

function fixContentImg(objname)
{
	var imgObj;
	var contentObj=document.getElementById(objname);
	if(contentObj) fixContentImgDo(contentObj);	
}

function fixContentImgDo(cobj)
{
	var imgObj;
	var contentObj=cobj
	for(i = 0; i < contentObj.childNodes.length; i++)
	{
		imgObj = contentObj.childNodes[i];
		if(imgObj.hasChildNodes())fixContentImgDo(imgObj);
		if(!imgObj)continue;
		if(!imgObj.tagName)continue;
		if(imgObj.tagName.toLowerCase()=="img")
		{
			if (imgObj.width >500)
			{ 
				autoImg(imgObj,500,1000);
				imgObj.style.cursor='hand';
				//imgObj.alt='点击查看大图';
				imgObj.onclick=Function("window.oper=null;window.open(this.src)");
			} 
		}
	}	
}

function setfontas(obj,size)
{
	$('#'+obj).css("font-size",size);
}

function DataTimePicker(obj)
{
	new WdatePicker(obj,'%Y-%M-%D %h:%m',true,'default');	
}

function DataPicker(obj)
{
	new WdatePicker(obj,'%Y-%M-%D',true,'default');	
}

//var tab1_on=1;
//var tab1_num=2;
//var tab1_name="tab1";
//tab_init("tab1");
//
//t:tab1_t1 c:tab1_c1
//onclick="tab_chg(tab1_name,tab1_name,2)"
//css:tab1_t_on tab1_t_off
function tab_chgfs(pre,cre,d,fs)
{
    tab_chg(pre,cre,d);
    if(fs)
    {
        fs();
    }
}
function tab_chg(pre,cre,d)
{
	var dt=document.getElementById(pre+"_t"+d);
	var dto=document.getElementById(pre+"_t"+eval(pre+"_on+0"));
	var dc=document.getElementById(pre+"_c"+d);
	var dco=document.getElementById(pre+"_c"+eval(pre+"_on+0"));
	if(dt && dto)
	{
		dto.className=cre+"_off";
		dt.className=cre+"_on";			
		dco.style.display="none";
		dc.style.display="block";			
		eval(pre+"_on="+d);
	}
}
function tab_chgfs(pre,fs,d) {
    var dt = document.getElementById(pre + "_t" + d);
    var dto = document.getElementById(pre + "_t" + eval(pre + "_on+0"));
    var dc = document.getElementById(pre + "_c" + d);
    var dco = document.getElementById(pre + "_c" + eval(pre + "_on+0"));
    if (dt && dto) {
        dto.className = pre + "_off";
        dt.className = pre + "_on";
        dco.style.display = "none";
        dc.style.display = "block";
        if (fs) {
            fs(pre, d);
        }
        eval(pre + "_on=" + d);
    }

}
function tab_init(pre,cre)
{
	var i;
	var dt,dc
	for(i=1;i<=eval(pre+"_num+0");i++) {
	    dt = $e(pre + "_t" + i);
	    dc = $e(pre + "_c" + i);
		if(!dt)
		{alert(pre+"_t"+i+" error!");return;}
		if(!dc)
		{ alert(pre + "_c" + i + " error!"); return; }
		//dt.onClick = function() { tab_chg(pre, cre, i) };
		if(eval(pre+"_on+0")==i)
		{
		    dt.className = cre + "_on";
			dc.style.display="block";
		}
		else
		{
			dt.className=cre+"_off";			
			dc.style.display="none";
		}
	}
}

//ProjectWork


function pageLink()
{
	$("a").each(
		function()
		{
			var linkobj=$(this);
			if(linkobj.attr("title")=="" || CheckObj(linkobj.attr("title"))==false)
			{
			    linkobj=linkobj.html();
			    if(linkobj.indexOf("script")||linkobj.indexOf("img"))
			    {return;}
			    linkobj.attr("title",linkobj.html());
			}
		}
	);
}

var ss=new Array();
function $pageExec()
{
	if($pageinit_timer!=0)
	{
		window.clearTimeout($pageinit_timer);
		$pageinit_timer=0;
	}
	else
	{
	    return;
	}
	var tempObj=new Array();
	for(i=0;i<autoImage_Count;i++)
	{
	    $("#autoImageObjLoad"+i).remove();
	    tempObj[0]=$("#autoImageObj"+i);
	    tempObj[1]=tempObj[0].get(0);
	    if(CheckObj(tempObj[1]))
	    {
	        tempObj[2]=$getintf(tempObj[0].css("width"),"px");
	        tempObj[0].css("width","");
	        tempObj[3]=$getintf(tempObj[0].css("height"),"px");
	        tempObj[0].css("height","");
	        ss[i]="";
	        ss[i]+="2:"+tempObj[2];
	        ss[i]+=" ";
	        ss[i]+="3:"+tempObj[3];
	        ss[i]+="\n";
	        tempObj[0].ready(
	            function(){
	                autoImg(tempObj[1],tempObj[2],tempObj[3])
	            }
	        );
	    }
	}
	pageLink();
}
function $pageInit()
{
	var pagesize=getPageSize();
	window.pageWidth=pagesize[0];
	window.pageHeight=pagesize[1];
	window.windowWidth=pagesize[2];
	window.windowHeight=pagesize[3];
	$pageinit_timer=window.setTimeout($pageExec,1000);
}
$(document).ready(function(){$pageInit()});

var getNewDate=new Date();
var getNewInt="";
getNewInt+=getNewDate.getFullYear();
if(getNewDate.getMonth()+1<10)getNewInt+="0";
getNewInt+=getNewDate.getMonth()+1;
if(getNewDate.getDate()<10)getNewInt+="0";
getNewInt+=getNewDate.getDate();
function getNewIco(d)
{
if((getNewInt-d)<=3)
document.write("<img border=0 src=/images/inner/iconew.gif>");
}



