//window.document.frames.if_內容.document.designMode="On";
//window.document.frames.if_內容.document.body.innerHTML=window.document.form1.all.內容.value;
//window.document.frames.if_內容.document.body.innerHTML="12345";
//alert ("window.document.form1.all.amdp.text")

var xmlHttp;
function createXMLHttpRequest() {
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } 
    else if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
}

function first_clk() 
{
if (document.form1.all.record_now.value=="0"){
alert("已是第一筆")
}
else{
createXMLHttpRequest();    
url="a91_xdat.aspx?amdp=s&record_now=0"
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
document.form1.all.record_now.value="0"
}
}

function prev_clk() 
{
if (document.form1.all.record_now.value=="0"){
alert("已是第一筆")
}
else{
createXMLHttpRequest();    
url="a91_xdat.aspx?amdp=s&record_now="+((window.document.form1.record_now.value*1)-1)
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
window.document.form1.record_now.value=(window.document.form1.record_now.value*1)-1
document.getElementById("nowShow").innerHTML =(window.document.form1.record_now.value*1)+1
}
}

function nextr_clk() 
{
if (document.form1.all.record_now.value==(document.form1.all.record_total.value*1)-1){
alert("已是最後一筆")
}
else{
createXMLHttpRequest();    
url="a91_xdat.aspx?amdp=s&record_now="+((window.document.form1.record_now.value*1)+1)
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
window.document.form1.record_now.value=(window.document.form1.record_now.value*1)+1
document.getElementById("nowShow").innerHTML =(window.document.form1.record_now.value*1)+1
}
}

function endr_clk() 
{
if (document.form1.all.record_now.value == (document.form1.all.record_total.value*1)-1){
alert("已是最後一筆")
}
else{
createXMLHttpRequest();    
url="a91_xdat.aspx?amdp=s&record_now="+((window.document.form1.record_total.value*1)-1)
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
document.form1.all.record_now.value=((document.form1.all.record_total.value*1)-1)
document.getElementById("nowShow").innerHTML =(window.document.form1.record_now.value*1)+1
}
}

function add_clk() 
{
document.form1.all.dtl.style.color ="darkblue"
document.form1.all.dtl.style.display ="none"; 　　　　//""是指出現的意思，"none"是指隱藏的意思
document.form1.all.dsp.style.color ="darkblue"
document.form1.all.dsp.style.display =""; 　　　　//""是指出現的意思，"none"是指隱藏的意思

document.form1.all.T6.style.borderWidth="";document.form1.all.T6.readOnly = false;document.form1.all.T6.value = "";
document.form1.all.標題.style.borderWidth="";document.form1.all.標題.readOnly = false;document.form1.all.標題.value = "";
document.form1.all.內容_visible.style.borderWidth="1";document.form1.all.內容_visible.readOnly = false;document.form1.all.內容.value = "";window.document.frames.內容_visible.document.body.innerHTML = "";
getnum()
}

function mix_clk() 
{
document.form1.all.dtl.style.color ="darkblue"
document.form1.all.dtl.style.display =""; 　　　　//""是指出現的意思，"hidden"是指隱藏的意思
document.form1.all.dsp.style.color ="darkblue"
document.form1.all.dsp.style.display =""; 　　　　//""是指出現的意思，"none"是指隱藏的意思

document.form1.all.T6.style.borderWidth="";document.form1.all.T6.readOnly = false;
document.form1.all.標題.style.borderWidth="";document.form1.all.標題.readOnly = false;
document.form1.all.內容_visible.style.borderWidth="1";document.form1.all.內容_visible.readOnly = false;
}

function del_clk() 
{
document.form1.all.dtl.style.color ="darkblue"
document.form1.all.dtl.style.display =""; 　　　　//""是指出現的意思，"hidden"是指隱藏的意思
document.form1.all.dsp.style.color ="darkblue"
document.form1.all.dsp.style.display =""; 　　　　//""是指出現的意思，"none"是指隱藏的意思

document.form1.all.T6.style.borderWidth="0";document.form1.all.T6.readOnly = true;
document.form1.all.標題.style.borderWidth="0";document.form1.all.標題.readOnly = true;
document.form1.all.內容_visible.style.borderWidth="0";document.form1.all.內容_visible.readOnly = true;
}

function dtl_clk() 
{
document.form1.all.dtl.style.color ="red"
document.form1.all.dtl.style.display =""; 　　　　//""是指出現的意思，"hidden"是指隱藏的意思
document.form1.all.dsp.style.color ="darkblue"
document.form1.all.dsp.style.display =""; 　　　　//""是指出現的意思，"none"是指隱藏的意思

document.form1.all.T6.style.borderWidth="0";document.form1.all.T6.readOnly = true;
document.form1.all.標題.style.borderWidth="0";document.form1.all.標題.readOnly = true;
document.form1.all.內容_visible.style.borderWidth="0";document.form1.all.內容_visible.readOnly = true;
}

function dsp_clk() 
{
window.location.href ="a90_show.aspx"
}


function getdata() 
{
dtl_clk() 
createXMLHttpRequest();    
url="a91_xdat.aspx?amdp=p&id="+window.document.form1.識別碼.value
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);  
}

function handleStateChange() 
{//s1
if(xmlHttp.readyState == 4) 
{//s2
//alert ("4")
if(xmlHttp.status == 200)
{//s3
//alert ("200")
//==================================
//alert ("xmldoc")
var xmldoc = xmlHttp.responsexml;

window.document.form1.識別碼.value=xmldoc.getElementsByTagName('DefaultView')[0].getElementsByTagName('識別碼')[0].childNodes[0].nodeValue
window.document.form1.系統編碼.value=xmldoc.getElementsByTagName('DefaultView')[0].getElementsByTagName('系統編碼')[0].childNodes[0].nodeValue
window.document.form1.T6.value=xmldoc.getElementsByTagName('DefaultView')[0].getElementsByTagName('公佈時間')[0].childNodes[0].nodeValue
window.document.form1.標題.value=xmldoc.getElementsByTagName('DefaultView')[0].getElementsByTagName('標題')[0].childNodes[0].nodeValue
window.document.form1.內容.value=xmldoc.getElementsByTagName('DefaultView')[0].getElementsByTagName('內容')[0].childNodes[0].nodeValue
//window.document.frames.內容_visible.document.body.innerHTML=window.document.form1.all.內容.value;
//alert (xmldoc.getElementsByTagName('DefaultView')[0].getElementsByTagName('內容')[0].childNodes[0].nodeValue)

//alert (window.document.form1.標題.value)

texttohtml("內容")
//window.document.form1.all.showdetail.innerHTML=window.document.form1.all[k0].value;

//==================================
}//s3
}//s2
}//s1

function gosave_clk() 
{//function000
//alert ("gosave")
if (window.document.form1.Button1.value=="確定新增"){
var r0="add"
}

if (window.document.form1.Button1.value=="確定修改"){
//alert ("mix")
var r0="mix"
}

if (window.document.form1.Button1.value=="確定刪除"){
//alert ("del")
var r0="del"
}

url="a91_save.aspx"
createXMLHttpRequest();
xmlHttp.open("POST", url, true);
xmlHttp.onreadystatechange = gosaveback;
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");    
var r1=window.document.form1.系統編碼.value
var r2=window.document.form1.T6.value
var r3=window.document.form1.標題.value
var r4=window.document.form1.內容.value
//var r4=window.document.frames.內容_visible.document.body.innerHTML
//var r4=encodeURIComponent("「&lt;U&gt;世界&lt;/U&gt;地球日傳遞環保經典影片競賽活&lt;STRONG&gt;動」&lt;/STRONG&gt;")
//var r4=encodeURIComponent(window.document.frames.內容_visible.document.body.innerHTML)
r4=r4.replace(/</g,"&lt;")
r4=r4.replace(/>/g,"&gt;")
r4=encodeURIComponent(r4)

//alert (r4)
xmlHttp.send("r0="+r0+"&r1="+r1+"&r2="+r2+"&r3="+r3+"&r4="+r4); 

//xmlHttp.send()
}//function000
    
function gosaveback() 
{//s1
if(xmlHttp.readyState == 4) 
{//s2
//alert ("4")
if(xmlHttp.status == 200)
{//s3
//alert ("200")
//==================================
var xmldoc = xmlHttp.responsexml;
alert ("存檔完成")
//alert (xmldoc)

window.location.href ="a00_disp.aspx"

//==================================
}//s3
}//s2
}//s1

function getnum() 
{
//alert ("getnum")
createXMLHttpRequest();    
url="a91_xnum.aspx"
xmlHttp.onreadystatechange = getnum_back;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);  
}

function getnum_back() 
{//s1
if(xmlHttp.readyState == 4) 
{//s2
//alert ("4")
if(xmlHttp.status == 200)
{//s3
//alert ("200")
//==================================
var xmldoc = xmlHttp.responsexml;
//alert (xmldoc.getElementsByTagName('DefaultView')[0].getElementsByTagName('num_sys')[0].childNodes[0].nodeValue)
window.document.form1.系統編碼.value=xmldoc.getElementsByTagName('DefaultView')[0].getElementsByTagName('系統編碼')[0].childNodes[0].nodeValue

//==================================
}//s3
}//s2
}//s1

function backone() 
{
window.location.href ="a02_disp.aspx?dvdid="+window.document.form1.DVD代碼.value
}



//--htmledit的必要函式--//
function texttohtml(k0)
{
//window.document.frames[k0+"_visible"].document.body.innerHTML=window.document.form1.all[k0].value;
window.document.form1.all[k0+"_visible"].innerHTML=window.document.form1.all[k0].value;
}

function gethtmledit_clk(k0,k1,k2,k3,k4,k5) 
{
//k0=moveablewindow(可移動的視窗)
//k1=moveablewindow的寬度
//k2=moveablewindow的高度
//k3=contain(要放置iframe的容器)
//k4=contain裡的iframe
//k5=backinto(從iframe內的工具所得到的值要放到那裡)
//k6=當離開這項工具的時候,要執行那一個javascript function
document.form1.all[k0].style.display=''
document.form1.all[k0].style.width=k1
document.form1.all[k0].style.height=k2
document.form1.all[k0].style.left=document.form1.all[k0].offsetLeft;
document.form1.all[k0].style.top=document.form1.all[k0].offsetTop; 
//document.form1.all[k3].innerHTML="<iframe id='iframe_"+k5+"' name='iframe_"+k5+"' marginwidth='1' marginheight='1' frameborder='0' scrolling='no' style='border:0px solid LightSteelBlue; padding:0; width:"+k1+";height:"+k2+";' onblur=htmltotext('"+k5+"') src="+k4+"?backinto="+k5+"></iframe>"
document.form1.all[k3].innerHTML="<iframe id='iframe_"+k5+"' name='iframe_"+k5+"' marginwidth='1' marginheight='1' frameborder='0' scrolling='no' style='border:0px solid LightSteelBlue; padding:0; width:"+k1+";height:"+k2+"'; src='"+k4+"?backinto="+k5+"'></iframe>"
}

function gettools_clk(k0,k1,k2,k3,k4,k5) 
{
//alert (k0+k1+k2+k3+k4+k5)
//var k55="公佈時間"
document.form1.all[k0].style.display=''
document.form1.all[k0].style.width=k1
document.form1.all[k0].style.height=k2
document.form1.all[k0].style.left=document.form1.all[k0].offsetLeft;
document.form1.all[k0].style.top=document.form1.all[k0].offsetTop; 
document.form1.all[k3].innerHTML="<iframe id='iframe_"+k5+"' name='iframe_"+k5+"' marginwidth='1' marginheight='1' frameborder='0' scrolling='no' style='border:0px solid LightSteelBlue; padding:0; width:"+k1+";height:"+k2+"'; src='"+k4+"?moveablewindow="+k0+"&backinto="+k5+"'></iframe>"
//document.form1.all[k3].innerHTML="<iframe id='iframe_"+k5+"' name='iframe_"+k5+"' marginwidth='1' marginheight='1' frameborder='0' scrolling='no' style='border:0px solid LightSteelBlue; padding:0; width:"+k1+";height:"+k2+"'; src='"+k4+"?moveablewindow="+k0+"&backinto=公佈時間'></iframe>"
}

function htmltotext(k0)
{
window.document.form1.all[k0].value=window.document.frames[k0+"_visible"].document.body.innerHTML;
//window.document.form1.all[k0].value=window.document.frames[k0+"_visible"].document.body.innerTEXT;
}
//-----------------------//

//--moveablewindow的必要函式--//
var dragapproved=false;
var z,x,y
function drags()
{
dragapproved=true;
z=event.srcElement;
temp1=z.style.pixelLeft;
temp2=z.style.pixelTop;
x=event.clientX;
y=event.clientY;
document.onmousemove=move
}

function move()
{
if (event.button==1&&dragapproved)
{
z.style.pixelLeft=temp1+event.clientX-x;
z.style.pixelTop=temp2+event.clientY-y;
return false
}
}

document.onmousedown=drags;
document.onmouseup=new Function("dragapproved=false")
//----------------------------//
