// JavaScript Document
function MM_findObj(n, d) { //v4.01
  var p,i,x;  
  if(!d) d=document; 
  if((p=n.indexOf("?"))>0&&parent.frames.length) 
  {
    d=parent.frames[n.substring(p+1)].document; 
	n=n.substring(0,p);
  }
  if(!(x=d[n])&&d.all) 
    x=d.all[n]; 
  for (i=0;!x&&i<d.forms.length;i++) 
    x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
    x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) 
    x=d.getElementById(n); 
  return x;
}
//中英文版本切换
function locationedtion()
{
	for (var k = 0; k < document.getElementById("selectid").options.length; k++) 
	{ 
		if (document.getElementById("selectid").options[k].selected && k==2)
		{
			location.href='/English/';
		}
		else if (document.getElementById("selectid").options[k].selected && k==1)
		{
			location.href='/';	
		}
	} 
} 
//运价搜索
function MM_select(POLObjId,PODObjId,URL) 
{
 var POLSelect = MM_findObj(POLObjId);
 var PODSelect=MM_findObj(PODObjId);
 if (!URL) URL="/freight/ocean-freight/list-";
 else 
 {
	 if (URL.length=0) URL="/freight/ocean-freight/list-";
 }
 URL+=POLSelect.value.substr(POLSelect.value.indexOf('－')+1)+'-'+PODSelect.value.substr(PODSelect.value.indexOf('－')+1)+"-1-10.aspx";
 window.open(URL,'newwindow','');
}
function subsearch()
{
	/*if($("#txtStartport").val() == "") 
		alert('请输入起始港！') 
	else 
		MM_select('txtStartport','txtDestport','http://www.95105556.com/freight/ocean-freight/list-')*/
	if($("#Yjstartport").val()=="" || $("#Yjstartport").val()=="请输入起始港")
	{
		alert('请输入起始港！');
		return false;
	}
	else if($("#Yjendport").val()=="" || $("#Yjendport").val()=="请输入目的港")
	{
		alert('请输入目的港！');
		return false;
	}
	MM_selectnew('Yjstartport','Yjendport','http://www.95105556.com/freight/ocean-freight/list-')
}
function MM_selectnew(POLObjId,PODObjId,URL) {
	var POLSelect ="";
	var PODSelec ="";
 if(MM_findObj(POLObjId).value.indexOf('[')=='-1')
 {
         POLSelect = MM_findObj(POLObjId).value;
 }
 else
 { 
	 	 POLSelect = MM_findObj(POLObjId).value.substr(0,MM_findObj(POLObjId).value.indexOf('['));
 }
 if(MM_findObj(PODObjId).value.indexOf('[')=='-1')
 {
	     PODSelect=MM_findObj(PODObjId).value; 
 }
 else
 {
	 	 PODSelect = MM_findObj(PODObjId).value.substr(0,MM_findObj(PODObjId).value.indexOf('['));
 }
 if (!URL)
 {
	 URL="/freight/ocean-freight/list-";
 }
 else 
 {
	 if (URL.length=0) URL="/freight/ocean-freight/list-";
 }
 URL+=POLSelect+'-'+PODSelect+"-1-10.aspx";
 window.open(URL,'newwindow','');
}
//集团内刊
function MM_jumpMenu(targ,selObj,restore)
{ 
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

/*
lastDiv上一次作用的对象
initClass非作用对象的样式表
currentClass当前作用对象的样式表
lastContentDiv上一次作用对象对应的内容
*/
var _DivBgChange = function(lastDiv,initClass,currentClass,lastContentDiv){
	this.lastDiv = lastDiv;
	this.init = initClass;
	this.current = currentClass;	
	this.lastContentDiv = lastContentDiv;
}
_DivBgChange.prototype = {
	OverA : function(currentDiv,currentContentDiv){
		MM_findObj(this.lastDiv).className = this.init;
		MM_findObj(this.lastContentDiv).style.display = "none";
		MM_findObj(currentDiv).className = this.current;
		MM_findObj(currentContentDiv).style.display = "";
		this.lastDiv = currentDiv;
		this.lastContentDiv = currentContentDiv;
	},
	OverB : function(currentDiv,otherDiv,currentContentDiv,currentImg,otherImg){		
		MM_findObj(currentDiv).style.background = "url(" + currentImg + ")";
		MM_findObj(this.lastContentDiv).style.display = "none";
		MM_findObj(otherDiv).style.background = "url(" + otherImg + ")";
		MM_findObj(currentContentDiv).style.display = "";
		this.lastDiv = currentDiv;
		this.lastContentDiv = currentContentDiv; 
	},
	OverC : function(currentDiv){
		//this.lastDiv.className = this.current;
		this.lastDiv.getElementsByTagName(this.lastContentDiv)[0].style.display = "none";
		//currentDiv.className = this.init;
		currentDiv.getElementsByTagName(this.lastContentDiv)[0].style.display = "";
		this.lastDiv = currentDiv;	
	}
}

/*
商务通
*/
var _Swt = function(r,p,e,portname,TportClass,TonlineClass,OnlineText,breaken){
	this.r = r == "" ? "" : "&r=" + encodeURI(r);
	this.p = p == "" ? "" : "&p=" + encodeURI(p);
	this.e = e == "" ? "" : "&e=" + encodeURI(e);
	this.lk = breaken == 1 ? "http://www.95105556.com/files/html/swt_jump.html" : "http://www.95105556.com/swt_error.html";
	this.portClass = TportClass;
	this.onlineClass = TonlineClass;
	this.portname = portname;
	this.href =  this.lk + this.e + this.r + this.p;
	this.onlineText = OnlineText != "" ? OnlineText : "[在线]";
}
_Swt.prototype = {
	DocWrite : function(){
		var li = "";
		var portArray = this.portname.split(',');
		for(var i = 0; i<portArray.length; i++){
			li += "<li><a href=\"" + this.href + "\" target=\"_blank\"><span class=\"" + this.portClass + "\">"+portArray[i]+"</span><span class=\"" + this.onlineClass + "\">" + this.onlineText + "</span></a></li>";
		}
		document.writeln(li);
	},
	Single : function(){
		var portArray = this.portname.split(',');
		document.writeln("<a href=\"" + this.href + "\" target=\"_blank\"><span class=\"" + this.portClass + "\">"+portArray[0]+"</span><span class=\"" + this.onlineClass + "\">[在线]</span></a>");
	},
	Img : function(Img){
		document.writeln("<a href=\"" + this.href + "\" target=\"_blank\"><img src=\"" + Img + "\" /></a>");
	}
}

/*
广告一 滚动
*/
var _Ad1 = function(W,H){
	this.browser = window.ActiveXObject ? "IE" : "OTHER";
	this.focus_width = W;
	this.focus_height = H;
	this.text_height = 0;
	this.swf_height = this.focus_height + this.text_height;		
	this.texts = "";
	this.pics = "";
	this.links = "";
}
_Ad1.prototype = {
	AdShow : function(x,node){
		var xmlDoc = loadXML("/editor/xml/" + x + ".xml");
		var root = xmlDoc.getElementsByTagName("NewDataSet")[0];
		var tables = root.getElementsByTagName("table");
		var EndStr = "";
		var Nsplit = node.split(",");
		for(var i = 0;i < tables.length;i++)
		{
			i == tables.length-1 ? EndStr = "" : EndStr = "|";
			if(this.browser == "IE")
			{
				this.pics += tables[i].childNodes[Nsplit[0]].firstChild.nodeValue + EndStr;
				this.links += tables[i].childNodes[Nsplit[1]].firstChild.nodeValue + EndStr;
			}
			else
			{
				this.pics += tables[i].childNodes[Nsplit[0]*2+1].firstChild.nodeValue + EndStr;
				this.links += tables[i].childNodes[Nsplit[1]*2+1].firstChild.nodeValue + EndStr;
			}
		}
		document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ this.focus_width +'" height="'+ this.swf_height +'">');
		document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="/ad/focus.swf"> <param name="quality" value="high"><param name="bgcolor" value="#ffffff">');
		document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
		document.write('<param name="FlashVars" value="pics='+this.pics+'&links='+this.links+'&texts='+this.texts+'&borderwidth='+this.focus_width+'&borderheight='+this.focus_height+'&textheight='+this.text_height+'">');
		document.write('<embed src="/ad/focus.swf" wmode="opaque" FlashVars="pics='+this.pics+'&links='+this.links+'&texts='+this.texts+'&borderwidth='+this.focus_width+'&borderheight='+this.focus_height+'&textheight='+this.text_height+'" menu="false" bgcolor="#ffffff" quality="high" width="'+ this.focus_width +'" height="'+ this.swf_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); 
		document.write('</object>');
	}
}

/*广告二:浮动
HTML代码：
<div id="oImg" style="position: absolute; z-index: 2000; top: 0px; left: 0px;"></div>
应用：
var C_GM = new _Ad2("oImg",10);
C_GM.move();
*/
var _Ad2 = function(P,D){
    this.floatImg = MM_findObj(P);
	this.delay = D;
    this.speed = 1; 	
    this.flagX = 0;
    this.flagY = 0;
	this.imgInterval = "";
}
_Ad2.prototype = {
    toPixel : function (str1){
        var oldLen = str1.length;
        var newLen = oldLen - 2;        
        str2 = str1.slice(0, newLen);
        str3 = parseInt(str2);        
        return str3;
    },	
    flowImg : function(){
        var bWidth = document.body.clientWidth;
        var bHeight = document.body.clientHeight;
        var bLeft = document.body.scrollLeft;
        var bTop = document.body.scrollTop;

        var iWidth = this.floatImg.offsetWidth;
        var iHeight = this.floatImg.offsetHeight;
        var iLeft = this.toPixel(this.floatImg.style.left);
        var iTop = this.toPixel(this.floatImg.style.top);
        
        if(iLeft < (bWidth - iWidth) && this.flagX == 0) {
            this.floatImg.style.left = (iLeft + this.speed) + "px";
        }
        else if(iLeft >= (bWidth - iWidth) && this.flagX ==0) {
            this.flagX = 1;
        }
        else if(iLeft > 0 && this.flagX == 1) {
            this.floatImg.style.left = (iLeft - this.speed) + "px";
        }
        else if(0 >= iLeft && this.flagX == 1) {
            this.flagX = 0;
        }
        
        if(iTop < (bHeight - iHeight) && this.flagY == 0) {
            this.floatImg.style.top = (iTop + this.speed) + "px";
        }
        else if(iTop >= (bHeight - iHeight) && this.flagY ==0) {
            this.flagY = 1;
        }
        else if(iTop > 0 && this.flagY == 1) {
            this.floatImg.style.top = (iTop - this.speed) + "px";
        }
        else if(0 >= iTop && this.flagY == 1) {
            this.flagY = 0;
        }
    },
	move : function(){
		var obj=this;
		obj.imgInterval = setInterval(function(){obj.flowImg.call(obj)}, obj.delay);
		obj.floatImg.onmouseover = function() {clearInterval(obj.imgInterval)};
		obj.floatImg.onmouseout = function() {obj.imgInterval = setInterval(function(){obj.flowImg.call(obj)}, obj.delay)};
	}
}

/*横向文字滚动*/
var _Hscroll = function(speed){
	this.speed=speed;//速度数值越大速度越慢
	this.demo=MM_findObj("demo");
	this.demo1=MM_findObj("demo1");
	this.demo2=MM_findObj("demo2");
	this.demo2.innerHTML=this.demo1.innerHTML;
	this.mymar="";
}
_Hscroll.prototype = {
	Marquee : function(){
		if(this.demo2.offsetWidth-this.demo.scrollLeft<=0)
			this.demo.scrollLeft-=this.demo1.offsetWidth;
		else
			this.demo.scrollLeft++;
	},
	Scrolling : function(){
		var obj=this;
		obj.mymar=setInterval(function(){obj.Marquee()},obj.speed);
		obj.demo.onmouseover=function() {clearInterval(obj.mymar)};
		obj.demo.onmouseout=function() {obj.mymar=setInterval(function(){obj.Marquee()},obj.speed)};
	}
}

/*右下角浮动
<div id="ShowAD" style="position:absolute; z-index:100;">
	<span style="position:absolute; z-index: 105;display:block;width:35px;height:20px;background:red;right:-240px;top:3px;cursor: pointer;text-align:center;" id="closestr"><a href="javascript:fddiv.Close(true);" style="color:#ffcc00">关闭</a></span>
	<div id="ImgLayer" style="position:absolute; z-index:1; left: 0px;">放置内容</div>
    <span style="position:absolute; z-index: 105;display:block;right:-240px;top:50px;cursor: pointer;display:none;" id="ShowAd_xt" onclick="javascript:fddiv.ShowAd();">放置缩略内容</span>
</div>
*/
var _Rbdiv = function(id)
{
	this.bodyfrm = ( document.compatMode.toLowerCase()=="css1compat" ) ? document.documentElement : document.body;
	this.adst = MM_findObj(id).style;
	this.adst.top = (this.bodyfrm.clientHeight - 250) + "px";
	this.adst.left = (this.bodyfrm.clientWidth - 250) + "px";
}
_Rbdiv.prototype = {
	Pos : function(){
		var obj = this;
		obj.adst.top = (obj.bodyfrm.scrollTop + obj.bodyfrm.clientHeight - 250) + "px";
    	obj.adst.left = (obj.bodyfrm.scrollLeft + obj.bodyfrm.clientWidth - 260) + "px";		
	},
	Move : function(){
		var obj = this;
		setInterval(function(){obj.Pos()}, 80);
	},
	ShowAd : function()
	{
		MM_findObj("closestr").style.display="";
		MM_findObj("ImgLayer").style.display="";
		MM_findObj("ShowAd_xt").style.display="none";	
	},
	//BOOL xtflag是滞需要关闭停靠
	Close : function(xtflag){
		if(xtflag)
		{
			MM_findObj("closestr").style.display="none";
			MM_findObj("ImgLayer").style.display="none";
			MM_findObj("ShowAd_xt").style.display="";
		}
		else
		{
			var obj=this;
    		obj.adst.display='none';
		}
	}	
}

/*顶端横幅下拉
<div class="W960" id="banner_top" style="margin:auto; display:none; top:0px; height:0px; position:relative; overflow:hidden; text-align:center;"></div>
<div id="banner_topA" class="W960" style="display:none;text-align:center;"></div>
var s = new _TopAd("banner_top",257);
s.showAds(10000);
*/
var _TopAd = function(id,height)
{
		this.id = id;
		this.time = 500;
		this.h = 0;
		this.T = 500;
		this.N = this.H = height; //高
}
_TopAd.prototype = {
    addCount : function(){
		var obj = this;
        if(obj.time>0)
        {
            obj.time--;
            obj.h = obj.h+5;
        }
        else
		{
            return;
		}
        if(obj.h>=obj.H)
		{
            return;
		}
        MM_findObj(obj.id).style.display = "";
        MM_findObj(obj.id).style.height = obj.h+"px";
        setTimeout(function(){obj.addCount()},30); 
    },
	noneAds : function(){
		var obj = this;
        if(obj.T>0)
        {
            obj.T--;
            obj.N = obj.N-5;
        }
        else
            return;
        if(obj.N<=0)
        {  
			MM_findObj(obj.id).style.display = "none";
			MM_findObj("banner_topA").style.display = "";
            return;
        }        
        MM_findObj(obj.id).style.height = obj.N+"px";
        setTimeout(function(){obj.noneAds()},30); 
    },
	showAds : function(stayTime)
    {
        var obj = this;
		obj.addCount();
        setTimeout(function(){obj.noneAds()},stayTime); 
    }    
}

/*cookie*/
var Cookie = function(name,days){
	this.name = name;
	this.days = !days?30:days;//此 cookie 将被保存 30 天
}
Cookie.prototype = {
//写cookies函数 
	SetCookie : function (value)
	{
		var exp  = new Date();    //new Date("December 31, 9998");
		exp.setTime(exp.getTime() + this.days*24*60*60*1000);
		document.cookie = this.name + "="+ escape (value) + ";expires=" + exp.toGMTString() + ";path=/";
	},
//取cookies函数 
	getCookie : function ()       
	{
		var arr = document.cookie.match(new RegExp("(^| )"+this.name+"=([^;]*)(;|$)"));
		if(arr != null) return unescape(arr[2]); return null;
	},
//删除cookie
	delCookie : function ()
	{
		var exp = new Date();
		exp.setTime(exp.getTime() - 1);
		var cval=getCookie();
		if(cval!=null) document.cookie= this.name + "="+cval+";expires="+exp.toGMTString();
	}
}

/*flash加载*/
var _LoadFlash = function(w,h,t,u){
	this.height = h;
	this.width = w;
	this.wmode = t;
	this.url = u;
}
_LoadFlash.prototype = {
	ShowFlash : function(){
		document.write('<embed src="' + this.url + '" wmode=' + this.wmode + ' quality="high" pluginspage=http://www.macromedia.com/go/getflashplayer type="application/x-shockwave-flash" width="' + this.width + '" height="' + this.height + '"></embed>'); 
	}
}

/*横向文字滚动*/
var _Hscroll = function(speed){
	this.speed=speed;//速度数值越大速度越慢
	this.demo=MM_findObj("demo");
	this.demo1=MM_findObj("demo1");
	this.demo2=MM_findObj("demo2");
	this.demo2.innerHTML=this.demo1.innerHTML;
	this.mymar="";
}
_Hscroll.prototype = {
	Marquee : function(){
		if(this.demo2.offsetWidth-this.demo.scrollLeft<=0)
			this.demo.scrollLeft-=this.demo1.offsetWidth;
		else
			this.demo.scrollLeft++;
	},
	Scrolling : function(){
		var obj=this;
		obj.mymar=setInterval(function(){obj.Marquee()},obj.speed);
		obj.demo.onmouseover=function() {clearInterval(obj.mymar)};
		obj.demo.onmouseout=function() {obj.mymar=setInterval(function(){obj.Marquee()},obj.speed)};
	}
}

/*滑动菜单*/
var _roller = function() {
}
//sx:隐藏
_roller.prototype =
{
    init: function(el, ty, sx, ex, d, st, id) {

        e = document.getElementById(el);
        if (!e) { return; } a = e.getElementsByTagName("a");
        for (i = 0; i < a.length; i++) {
            if (i != id) {
                if (!a[i].id) { a[i].id = el.id + i; }
                a[i].n = a[i].o = sx;
                a[i].en = ex;
                a[i].ty = ty;
                //if (a[i].ty == 'v') { a[i].style.backgroundPosition = '0px ' + a[i].n + 'px'; }
                if (a[i].ty == 'h') {
                    a[i].style.backgroundPosition = a[i].n + 'px 0px';
                }
                else {
                    return;
                }
                a[i].onmouseover = _roller.prototype.o;
                a[i].onmouseout = _roller.prototype.o;
                a[i].st = Math.abs(Math.abs(ex - sx) / st);
                a[i].t = d / st;
            }
        }
    },
    o: function(e) {
        e = e || window.event;
        c = e.target != null ? e.target :
        e.srcElement;
        if (c.nodeName == 'A' && e.type == "mouseover") {
            c.w = c.en; _roller.prototype.s(c);
        }
        else if (c.nodeName == 'A') {
            c.w = c.o; _roller.prototype.s(c);
        }
    },
    s: function(e) {
        if (e.ti) {
            clearTimeout(e.ti);
        }
        if (Math.abs(e.n - e.w) < e.st) {
            e.n = e.w;
        }
        else if (e.n < e.w) {
            e.n = e.n + e.st;
        }
        else if (e.n > e.w) {
            e.n = e.n - e.st;
        }
        if (e.ty == 'v') {
            e.style.backgroundPosition = '0px ' + e.n + 'px';
        }
        else {
            e.style.backgroundPosition = e.n + 'px 7px';
        }
        if (e.n == e.w) {
            clearTimeout(e.ti); return;
        }
        e.ti = setTimeout(function() { _roller.prototype.s(e); }, e.t);

    }
}

/*根据图片控制左右滚动*/
var _PCScroll = function(scrolldiv,targetx,liwidth){
	this.scrolldiv = MM_findObj(scrolldiv);
	this.liwidth = liwidth;
	this.maxWidth = this.scrolldiv.getElementsByTagName("ul")[0].getElementsByTagName("li").length*this.liwidth;
	this.targetx = targetx;//一次滚动距离
	this.dx = 0;
	this.a = null;
}
_PCScroll.prototype = {
	moveLeft : function(){
		var le = parseInt(this.scrolldiv.scrollLeft);
		if(le>200)
			this.targetx = parseInt(this.scrolldiv.scrollLeft)-200;
		else
			this.targetx = parseInt(this.scrolldiv.scrollLeft)-le-1;
		this.scLeft();
	},
	scLeft : function(){
		var obj=this;
		obj.dx = parseInt(obj.scrolldiv.scrollLeft) - obj.targetx;
		obj.scrolldiv.scrollLeft -= obj.dx*.3;
		var clearScroll = setTimeout(function(){obj.scLeft()},50);
		if(obj.dx*.3<1)
		clearTimeout(clearScroll);
	},
	moveRight : function(){
		var le = parseInt(this.scrolldiv.scrollLeft)+200;
		var maxL = this.maxWidth-550;
		if(le<maxL){
			this.targetx = parseInt(this.scrolldiv.scrollLeft)+200;
		}
		else{
			this.targetx = maxL;
		}
		this.scRight();
	},
	scRight : function(){
		var obj = this;
		obj.dx = obj.targetx-parseInt(obj.scrolldiv.scrollLeft);
		obj.scrolldiv.scrollLeft += obj.dx*.3;
		obj.a = setTimeout(function(){obj.scRight()},50);
		if(obj.dx*.3<1){
			clearTimeout(obj.a)
		}
	}
}

