﻿var xmlHttp,guid,flag,checkFish,fishInfo,seawaterData;
var tempId,strFlag;
var fId,strF,strM;
var getsurfFlag = 0;

var AdRotator = null;

var mapLeft=116.313296;
var mapTop=27.751511;
var mapRight=122.106642;
var mapBottom=22.679065;



function getInfo(guid,flag)
{  
    checkFish = flag;
    createXMLHTTP();
    url = "CreateOceanForecastInfo.aspx?guid="+guid+"&flag="+flag;
    xmlHttp.open("GET", url, true); 
    if(flag!="Tide")
        xmlHttp.onreadystatechange=outInfo;
    else
        xmlHttp.onreadystatechange=outCom;
    xmlHttp.send(null); 
}

function createXMLHTTP()
{
    if(window.XMLHTTPRequest)
    {
        xmlHttp=new XMLHTTPRequest();       
        if (request.overrideMimeType) 
        {
                request.overrideMimeType("text/xml");
        }
    }
    else if(window.ActiveXObject)
    {      
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); 
    }
    else 
    {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");     
    }
    if(!xmlHttp)
    {
        window.alert("XMLHttpRequest");
        return false;
    }
}

/*---输出表格{---*/
function outInfo()
{
    if(xmlHttp.readyState==4)
    {
        if(xmlHttp.status==200)
        {
            if(checkFish == "surf")
            {
                if(xmlHttp.responseText != "")
                {
                    document.getElementById("showMessageDiv").innerHTML = xmlHttp.responseText;
                }
                else
                {
                    alert("提示信息：抱歉，当前无海浪预报数据！");
                }
            }
            if(checkFish == "fishery")
            {
                fishInfo = xmlHttp.responseText;
                if(fishInfo != "")
                {
                    var arr = fishInfo.split("#");
                    document.getElementById("yyqxTitle").innerHTML = arr[0];
                    document.getElementById("yyqxPubDate").innerHTML = arr[1];
                    var contentArr1 = arr[2].split("|");
                    var contentArr2 = arr[3].split("|");Fdate1
                    document.getElementById("Fdate1").innerHTML = contentArr1[0];
                    document.getElementById("Fdate2").innerHTML = contentArr2[0];
                    document.getElementById("yyqxWerther1").innerHTML = contentArr1[1];
                    document.getElementById("yyqxWerther2").innerHTML = contentArr2[1];
                    document.getElementById("yyqxWind1").innerHTML = contentArr1[2];
                    document.getElementById("yyqxWind2").innerHTML = contentArr2[2];
                    document.getElementById("yyqxWindDiretion1").innerHTML = contentArr1[3];
                    document.getElementById("yyqxWindDiretion2").innerHTML = contentArr2[3];
                    document.getElementById("yyqxWaveHeight1").innerHTML = contentArr1[4];
                    document.getElementById("yyqxWaveHeight2").innerHTML = contentArr2[4];
                    document.getElementById("yyqxWaveLevel1").innerHTML = contentArr1[5];
                    document.getElementById("yyqxWaveLevel2").innerHTML = contentArr2[5];
                    document.getElementById("yyqxWaterTemperature1").innerHTML = contentArr1[6];
                    document.getElementById("yyqxWaterTemperature2").innerHTML = contentArr2[6];
                }
                else
                {
                    alert("提示信息：抱歉，该渔场当前无数据！");
                }
            }
            
            if(checkFish == "seawater")
            {
                var arr;
                var contentArr;
                var d = new Date();
                s = (d.getMonth() + 1); 
                //s = 10;
                if(s*1 >= 5 && s*1 <= 10)
                {
                    document.getElementById("hsycTable").style.visibility = "visible";
                    seawaterData = xmlHttp.responseText;
                    arr = seawaterData.split("@");
                    contentArr = arr[1].split("|");
                }
                else
                {
                    seawaterData = xmlHttp.responseText;
                    arr = seawaterData.split("@");
                    contentArr = arr[1].split("|");
                    document.getElementById("HidInfo").value = arr[1];
                    seawaterData = "0";
                    for(var i = 0; i < arr.length; i++)
                    {
                        arr[i] = "";
                    }
                }
                if(seawaterData != "0")
                {
                    if(seawaterData != "")
                    {
                        
                        contentArr = arr[1].split("|");
                        if(arr[2] != "") {document.getElementById("HidInfo").value = arr[2]; document.getElementById("photoDiv").style.visibility = "visible";}
                        else { document.getElementById("photoDiv").style.visibility = "hidden"; }
                        document.getElementById("hsycTitle").innerHTML = arr[0];
                        document.getElementById("hsycFDate").innerHTML = contentArr[0];
                        document.getElementById("hsycPubdate").innerHTML = "发布时间：" + contentArr[1];
                        document.getElementById("hsycWave").innerHTML = contentArr[2];
                        document.getElementById("hsycWaveLevel").innerHTML = contentArr[3];
                        document.getElementById("hsycWaterT").innerHTML = contentArr[4];
                        document.getElementById("hsycWater").innerHTML = contentArr[5];
                        document.getElementById("hsycSwhealthindex").innerHTML = contentArr[6];
                        document.getElementById("hsycSwimming").innerHTML = contentArr[7];
                        document.getElementById("hsycSwimTime").innerHTML = contentArr[8];
                        document.getElementById("hsycRemarks").innerHTML = contentArr[9];
                    }
                    else
                    {
                        alert("提示信息：抱歉，该浴场当前无数据！");
                    }
                }
                else
                {
                    document.getElementById("hsycTip").innerText = "海水浴场预报时间为每年5月至10月，每年11月至翌年4月不开展预报工作。";
                }
            }
            if(document.getElementById("HidInfo").value != "")
            {
                displayPhoto();
            }

        }
        else
        {
            alert("status is " + xmlHttp.status);
        }
    }
  
}
/*---}输出表格---*/

/*潮位预报数据处理*/
function outCom()
{
 if(xmlHttp.readyState==4)
    {
        if(xmlHttp.status==200)
        {
          var httpstr= xmlHttp.responseText;
       //   alert(httpstr);
            if(httpstr != "")
            {
                var arr=httpstr.split("&");
                
               DisForecastInfo(arr);
            }
            else
            {
                alert("站点无信息");
            }
         }
        else
        {
            alert("status is " + xmlHttp.status);
        }
    }
}

/*---经纬度转换{---*/
function ConvertCood(value)
{
    var arrxy=value.split("-");
    value=(arrxy[0])*1+arrxy[1]/60;
    return value;

}

function getpxbyj(Lon)
{

    var jwWidth=mapRight-mapLeft;
    var x=((Lon-mapLeft)/jwWidth)*mapwidth;
    return x;

}

function getpxbyw(Lat)
{
    var jwHeight=mapTop-mapBottom;
    var y=((mapTop-Lat)/jwHeight)*mapheight;
    return y;
}
/*---}经纬度转换---*/

var SeawaterInfo=function()
{

    this.TX=0;
    this.TY=0;
    this.TideName="";
    this.ID="";
 }
 var FisheryInfo=function()
{

    this.TX=0;
    this.TY=0;
    this.LX=0;
    this.LY=0;
    this.TideName="";
    this.ID="";
 }
 
var fisheryInfo;
function disSeawaterSidt(str)
{
    fisheryInfo = str;
    var Htmlstr="";
    var map=document.getElementById("SeawaterMapDiv");
    this.SeawaterList = new Array();
    

    var arr=fisheryInfo.split("#");
    var id;
    for(var j=0; j<arr.length; j++)
    {
        if(arr[j].split("|")[3] == "1")
        {
            id = arr[j].split("|")[0];
            break;
        }
    }
    for(var i=0;i<arr.length;i++)
       {
            var seawaterInfo= new SeawaterInfo();
            var aryTide=arr[i].split("|");
            seawaterInfo.ID=aryTide[0];
            seawaterInfo.TideName=aryTide[1];
            aryPoint=aryTide[2].slice().split(",");	
            seawaterInfo.TX = ConvertCood(aryPoint[0]);
            seawaterInfo.TY = ConvertCood(aryPoint[1]);
            var stop = getpxbyw(seawaterInfo.TY)-8;
            var sleft = getpxbyj(seawaterInfo.TX);
            this.SeawaterList.push(seawaterInfo);
            if(arr[i].split("|")[3] == "1")  
            { 
                Htmlstr+="<div id='"+seawaterInfo.ID+"' style='left:"+ sleft+"px;top:"+stop+"px; visibility:visible; position:absolute;' onclick=disSTideInfo('"+seawaterInfo.ID +"','seawater')><div class='seawaterimg'></div><div><br /><b>"+seawaterInfo.TideName+"</b></div></div>";
	        }
	        else
	        {
	            Htmlstr+="<div id='"+seawaterInfo.ID+"' style='left:"+ sleft+"px;top:"+stop+"px;visibility:hidden; position:absolute;' onclick=disSTideInfo('"+seawaterInfo.ID +"','seawater')><div class='seawaterimg'></div><div><br /><b>"+seawaterInfo.TideName+"</b></div></div>";
	        }
	    }
	    map.innerHTML=Htmlstr;
	    disSTideInfo(id,'seawater');
}

function disSTideInfo(id,flag)
{
    var arr=fisheryInfo.split("#");
    for(var i=0; i<arr.length; i++)
    {
        var tempArr = arr[i].split("|");
        
        document.getElementById(tempArr[0]).className = "backS";       
    }
    document.getElementById(id).className = "changeS";    
    getInfo(id,flag);   
}
//渔场坐标
var fmapLeft=116.776675;
var fmapTop=28.730544;
var fmapRight=126.565017;
var fmapBottom=20.216876;

function Fgetpxbyj(Lon)
{

    var jwWidth=fmapRight-fmapLeft;
    var x=((Lon-fmapLeft)/jwWidth)*mapwidth;
    return x;

}

function Fgetpxbyw(Lat)
{
    var jwHeight=fmapTop-fmapBottom;
    var y=((fmapTop-Lat)/jwHeight)*mapheight;
    return y;
}
var strGUID
function getFisheryStation()
{
    this.FisheryList = new Array();
    strGUID = document.all.HidAllInfo.value;
    var arr=strGUID.split("#");

    var content = "";
    var id;
    for(var j=0; j<arr.length; j++)
    {
        if(arr[j].split("|")[3] == "1")
        {
            id = arr[j].split("|")[0];
            break;
        }
    }
    var nameTable = "<table style='width: 100%'><tr><td style='text-align: center'></td></tr></table>";
    for(var i=0; i<arr.length; i++)
    {
        var fisheryInfo= new FisheryInfo();
        var aryTide=arr[i].split("|");
        fisheryInfo.ID=aryTide[0];
        fisheryInfo.TideName=aryTide[1];
        aryPoint=aryTide[2].slice().split(";");	
        fisheryInfo.TX = aryPoint[0].split(",")[1];
        fisheryInfo.TY = aryPoint[0].split(",")[0];
        
        fisheryInfo.LX = aryPoint[1].split(",")[1];
        fisheryInfo.LY = aryPoint[1].split(",")[0];
        
        var ftop = Fgetpxbyw(ConvertCood(fisheryInfo.TX));
        var fleft = Fgetpxbyj(ConvertCood(fisheryInfo.TY));
        
        var fheight = Fgetpxbyw(ConvertCood(fisheryInfo.LX)) - Fgetpxbyw(ConvertCood(fisheryInfo.TX));
        var fwidth = Fgetpxbyj(ConvertCood(fisheryInfo.LY)) -Fgetpxbyj(ConvertCood(fisheryInfo.TY));
        fwidth = fwidth - 1;
        fheight = fheight - 1;
        this.FisheryList.push(fisheryInfo);
        if(arr[i].split("|")[3] == "1")  
        {
            if(arr[i].split("|")[1] == "闽中渔场")
            {
                fheight = fheight - 1.5;
                content +="<span id='"+arr[i].split("|")[0]+"' style=\"z-index:0; visibility:visible; width: "+fwidth+"px; height: "+fheight+"px;position:absolute; left:"+fleft+"px; top:"+ftop+"px; \" onclick=\"disFTideInfo('"+arr[i].split("|")[0]+"','fishery');\" onmouseover=\"Fchange_bg('"+arr[i].split("|")[0]+"');\" onmouseout=\"Fback_bg('"+arr[i].split("|")[0]+"');\" ><table style='width: 100%; height: 100%; text-align: center;'><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font size='2px'><b>"+arr[i].split("|")[1]+"</b></font></td></tr></table></span>";
            }
            else
            {
                content +="<span id='"+arr[i].split("|")[0]+"' style=\"z-index:0; visibility:visible; width: "+fwidth+"px; height: "+fheight+"px;position:absolute; left:"+fleft+"px; top:"+ftop+"px; \" onclick=\"disFTideInfo('"+arr[i].split("|")[0]+"','fishery');\" onmouseover=\"Fchange_bg('"+arr[i].split("|")[0]+"');\" onmouseout=\"Fback_bg('"+arr[i].split("|")[0]+"');\" ><table style='width: 100%; height: 100%; text-align: center;'><tr><td><font size='2px'><b>"+arr[i].split("|")[1]+"</b></font></td></tr></table></span>";
            }
        }
        else
        {
            content +="<span id='"+arr[i].split("|")[0]+"' style=\"z-index:0;visibility:hidden; width: "+fwidth+"px; height: "+fheight+"px;position:absolute; left:"+fleft+"px; top:"+ftop+"px; \" onclick=\"disFTideInfo('"+arr[i].split("|")[0]+"','fishery');\" onmouseover=\"Fchange_bg('"+arr[i].split("|")[0]+"');\" onmouseout=\"Fback_bg('"+arr[i].split("|")[0]+"');\" ><table style='width: 100%; height: 100%; text-align: center;'><tr><td><font size='2px'><b>"+arr[i].split("|")[1]+"</b></font></td></tr></table></span>";
        }
    }
    document.getElementById("MapMidDiv").innerHTML = content;  
    disFTideInfo(id,'fishery');
}

function disFTideInfo(id,flag)
{
    var arr=strGUID.split("#");
    for(var i=0; i<arr.length; i++)
    {
        var tempArr = arr[i].split("|");
        document.getElementById(tempArr[0]).className = "back";       
    }
    document.getElementById(id).className = "change"; 
    strF = flag;   
    getInfo(id,flag);   
}

function Fchange_bg(id)
{
    if(document.getElementById(id).className == "change")
    {
        document.getElementById(id).className = "change";
    }
    else if(document.getElementById(id).className == "backouton")
    {
        document.getElementById(id).className = "change";
    }
    else
    {
        document.getElementById(id).className = "changeover";
    }
}
function Fback_bg(id)
{
    if(document.getElementById(id).className == "changeoveron")
    {
        document.getElementById(id).className = "change";
    }
    else if(document.getElementById(id).className == "change")
    {
        document.getElementById(id).className = "change";
    }
    else
    {
        document.getElementById(id).className = "backout";
    }
    
}

var sGUDI;
function getSurfStation()
{
    
    sGUDI = document.all.HidAllInfo.value;
    var arr=sGUDI.split("#");

    var content = "";
    var id = arr[2].split("|")[0];
    for(var i=0; i<arr.length; i++)
    {
        switch(arr[i].split("|")[1])
        {
            case "台湾海峡北部":
                var taibie = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;台<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;湾<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;海<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;峡<br />&nbsp;&nbsp;&nbsp;北<br />部";
                if(arr[i].split("|")[2] == "1")
                {
                    content += "<div id=\""+arr[i].split("|")[0]+"\" style=\"width:60px; height:100px; visibility:visible; position:absolute; left:300px; top:160px; text-align:left; cursor:hand\" onmouseover=\"disSurfInfo('"+arr[i].split("|")[0]+"','surf')\"  ><b>"+taibie+"</b></div>";
                }
                else
                {
                    content += "<div id=\""+arr[i].split("|")[0]+"\" style=\"width:60px; height:100px; visibility:hidden; position:absolute; left:300px; top:160px; text-align:left; cursor:hand\" onmouseover=\"disSurfInfo('"+arr[i].split("|")[0]+"','surf')\"  ><b>"+taibie+"</b></div>";
                }
                break;
            case "台湾海峡南部":
                var tainan = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;台<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;湾<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;海<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;峡<br />&nbsp;&nbsp;&nbsp;南<br />部";
                if(arr[i].split("|")[2] == "1")
                {
                    content += "<div id=\""+arr[i].split("|")[0]+"\" style=\"width:60px; height:100px;visibility:visible; position:absolute; left:180px; top:335px; text-align:left; cursor:hand\" onmouseover=\"disSurfInfo('"+arr[i].split("|")[0]+"','surf')\"  ><b>"+tainan+"</b></div>";
                }
                else
                {
                    content += "<div id=\""+arr[i].split("|")[0]+"\" style=\"width:60px; height:100px;visibility:hidden; position:absolute; left:180px; top:335px; text-align:left; cursor:hand\" onmouseover=\"disSurfInfo('"+arr[i].split("|")[0]+"','surf')\"  ><b>"+tainan+"</b></div>";
                }
                break;
            case "宁德沿海":
                if(arr[i].split("|")[2] == "1")
                {
                    content +="<div id=\""+arr[i].split("|")[0]+"\" style=\"width:80px; height:20px;visibility:visible; position:absolute; left:290px; top:85px;cursor:hand\" onmouseover=\"disSurfInfo('"+arr[i].split("|")[0]+"','surf')\"  ><b>"+arr[2].split("|")[1]+"</b></div>";
                }
                else
                {
                    content +="<div id=\""+arr[i].split("|")[0]+"\" style=\"width:80px; height:20px;visibility:hidden; position:absolute; left:290px; top:85px;cursor:hand\" onmouseover=\"disSurfInfo('"+arr[i].split("|")[0]+"','surf')\"  ><b>"+arr[2].split("|")[1]+"</b></div>";
                }
                break;
            case "福州沿海":
                if(arr[i].split("|")[2] == "1")
                {
                    content += "<div id=\""+arr[i].split("|")[0]+"\" style=\"width:80px; height:20px;visibility:visible; position:absolute; left:255px; top:135px;cursor:hand\" onmouseover=\"disSurfInfo('"+arr[i].split("|")[0]+"','surf')\"  ><b>"+arr[3].split("|")[1]+"</b></div>";
                }
                else
                {
                    content += "<div id=\""+arr[i].split("|")[0]+"\" style=\"width:80px; height:20px;visibility:hidden; position:absolute; left:255px; top:135px;cursor:hand\" onmouseover=\"disSurfInfo('"+arr[i].split("|")[0]+"','surf')\"  ><b>"+arr[3].split("|")[1]+"</b></div>";
                }
                break;
            case "莆田沿海":
                if(arr[i].split("|")[2] == "1")
                {
                    content += "<div id=\""+arr[i].split("|")[0]+"\" style=\"width:80px; height:20px;visibility:visible; position:absolute; left:245px; top:190px;cursor:hand\" onmouseover=\"disSurfInfo('"+arr[i].split("|")[0]+"','surf')\"  ><b>"+arr[4].split("|")[1]+"</b></div>";
                }
                else
                {
                    content += "<div id=\""+arr[i].split("|")[0]+"\" style=\"width:80px; height:20px; visibility:hidden;position:absolute; left:245px; top:190px;cursor:hand\" onmouseover=\"disSurfInfo('"+arr[i].split("|")[0]+"','surf')\"  ><b>"+arr[4].split("|")[1]+"</b></div>";
                }
                break;
            case "泉州沿海":
                if(arr[i].split("|")[2] == "1")
                {
                    content += "<div id=\""+arr[i].split("|")[0]+"\" style=\"width:80px; height:20px;visibility:visible; position:absolute; left:195px; top:240px;cursor:hand\" onmouseover=\"disSurfInfo('"+arr[i].split("|")[0]+"','surf')\"  ><b>"+arr[5].split("|")[1]+"</b></div>";
                }
                else
                {
                    content += "<div id=\""+arr[i].split("|")[0]+"\" style=\"width:80px; height:20px; visibility:hidden;position:absolute; left:195px; top:240px;cursor:hand\" onmouseover=\"disSurfInfo('"+arr[i].split("|")[0]+"','surf')\"  ><b>"+arr[5].split("|")[1]+"</b></div>";
                }
                break;
            case "厦门沿海":
                if(arr[i].split("|")[2] == "1")
                {
                    content += "<div id=\""+arr[i].split("|")[0]+"\" style=\"width:80px; height:20px;visibility:visible; position:absolute; left:160px; top:280px;cursor:hand\" onmouseover=\"disSurfInfo('"+arr[i].split("|")[0]+"','surf')\"  ><b>"+arr[6].split("|")[1]+"</b></div>";
                }
                else
                {
                    content += "<div id=\""+arr[i].split("|")[0]+"\" style=\"width:80px; height:20px;visibility:hidden; position:absolute; left:160px; top:280px;cursor:hand\" onmouseover=\"disSurfInfo('"+arr[i].split("|")[0]+"','surf')\"  ><b>"+arr[6].split("|")[1]+"</b></div>";
                }
                break;
            case "漳州沿海":
                if(arr[i].split("|")[2] == "1")
                {
                    content += "<div id=\""+arr[i].split("|")[0]+"\" style=\"width:80px; height:20px;visibility:visible; position:absolute; left:100px; top:330px;cursor:hand\" onmouseover=\"disSurfInfo('"+arr[i].split("|")[0]+"','surf')\"  ><b>"+arr[7].split("|")[1]+"</b></div>";
                }
                else
                {
                    content += "<div id=\""+arr[i].split("|")[0]+"\" style=\"width:80px; height:20px;visibility:hidden; position:absolute; left:100px; top:330px;cursor:hand\" onmouseover=\"disSurfInfo('"+arr[i].split("|")[0]+"','surf')\"  ><b>"+arr[7].split("|")[1]+"</b></div>";
                }
                break;
           
        }
    }
    document.getElementById("mapDiv").innerHTML = content;  
    disSurfInfo(id,"surf");
    
}

function disSurfInfo(id,flag)
{
    strFlag = flag;
    var arr=sGUDI.split("#");
    for(var i=0; i<arr.length; i++)
    {
        var tempArr = arr[i].split("|");
        document.getElementById(tempArr[0]).className = "backW"; 
    }
    
    
     
    if(getsurfFlag == 1)
    {
        for(var i=0; i<arr.length; i++)
        {
            var tempArr = arr[i].split("|");
            tempId = tempArr[0]+'s';
            if(document.getElementById(tempId) == "[object]")
            {
                document.getElementById(tempId).className = "backW"; 
            }
        }
        tempId = id+'s';
        if(document.getElementById(id) == "[object]")
        {
            document.getElementById(id).className = "changeW";
        }
        if(document.getElementById(tempId) == "[object]")
        {
            document.getElementById(tempId).className = "changeWtr"; 
        }
    }
    if(getsurfFlag == 0)
    {  
        getInfo(id,flag);
        getsurfFlag = getsurfFlag + 1;
    }
}


function displayPhoto()
{
    imgPath = document.getElementById("HidInfo").value;
    if( AdRotator != null )
    {
        AdRotator.stop();
        AdRotator.del();
        getRef("photoDiv").innerHTML = "";
    }    
    AdRotator = adRotator.initialize("photoDiv");
    if(imgPath != "")
    {
        src = imgPath.split("#");
        for(var j=0; j < src.length ; j++)
        {
            AdRotator.add(src[j].split("|")[0]);
        }
        AdRotator.play();
    }
}



function adRotator() {};
adRotator.initialize=function(o)
{
    // script by blueDestiny
    this._t = new Array();
    this._l = new Array();
    this._p = new Array();
    this._i = new Image();
    this._c = 0;
    this._f = false;
    this._o = o;
    this._timeout = null;
    this._html = "";
    // configration.
    // @ image width
    // @ image height
    // @ rotator speed
    // @ filter type
    this._w = 335;
    this._h = 168;
    this._s = 4;
    this._x = 23;
    return this;
};
adRotator.add=function(p,t,l)
{ 
    with (this)
    {
        _p.push(p);
        _t.push(t);
        _l.push(l);
    }
};
adRotator.del=function()
{
    with(this)
    {
        if(_p != null)
        {
            while(_p.length > 0)
                _p.pop();
        }
        if(_t != null)
        {
            while(_t.length > 0)
                _t.pop();
        }
        if(_l != null)
        {
            while(_l.length > 0)
                _l.pop();
        }
    }
};
adRotator.load=function() 
{ 
    with (adRotator)
    {
        if( _i.readyState=='complete' )
        {
	        if(_p.length-1==_c)
	        {
		        _f = true;
		        _c = 0;
		        window.clearTimeout(_timeout);
		        adRotator.play();
	        }
	        else
	        {
		        _c++;
		        _timeout=window.setTimeout(adRotator.load,10)
	        }
        }
        else
        {
	        _timeout=window.setTimeout(adRotator.load,10)
        }
    }
};
adRotator.play=function()
{ 
    with (adRotator)
    {
        if( _f )
        {
	        _html = "";
	        _html += '<table ><tr><td style="font-size:9pt;font-family:tahoma;font-weight:bold;">'
	        _html += '<div id="rotatorPlayer"'
	        + ' style="width:' + _w + ''
	        + ';height:"' + _h + '"'
	        + '>'
	        _html += '<img id="rotatorPic" src="' + _p[_c] + '"'
	        + ' width="' + _w + '"'
	        + ' height="' + _h + '"'
	        + (_t[_c]?' title="' + _t[_c] + '"':'')
	        + ' style="border:1px solid #806AB5;FILTER:revealTrans(transition=' + _x + ',duration=2);"'
	        + ' >';   
	        _html += "</div>";
	        _html += "</td></tr></table>";
	        getRef(_o).innerHTML = _html;
	        getRef("rotatorPic").filters[0].Apply();
	        getRef("rotatorPic").filters[0].Play();
	        next();		
        }
        else
        {
	        if( _p.length > 0 )
	        {
	            _i.src = _p[_c];
	            adRotator.load();
	        }
	        else
	        {
	            getRef(_o).innerHTML = _html;
	        }
        }
    }
};
adRotator.next=function()
{ 
    with (this)
    {
        (_p.length-1==_c) ? _c=0 : _c++;
        _timeout=window.setTimeout(adRotator.play,_s*1000);
		
    }
};
adRotator.select=function(i) 
{ 
    with (this)
    {
        window.clearTimeout(_timeout);
        _c=i;
        adRotator.play();
    }
};

adRotator.stop=function() 
{ 
    with (this)
    {
        window.clearTimeout(_timeout);
        _c=0;
        adRotator._f = false;
    }
};

function getRef(id)
{
    return (document.all?document.all(id):document.getElementById(id));
}