/*
 * Create Date:2004-06-01
 * Author: Jeff.Zhou
 * pop-up a confirm window before delete a row
 */
function confirmDelete(obj) {
    var msg = "Are you sure you want to delete " + obj + "?";
	ans = confirm(msg);
	if (ans) {
        return true;
	} else {
        return false;
    }
}

/*
 * Create Date:2004-06-01
 * Author: Jeff.Zhou
 * Check all the checkbox in a form
 */
function checkAll(theForm) { // check all the checkboxes in the list
  for (var i=0;i<theForm.elements.length;i++) {
    var e = theForm.elements[i];
		var eName = e.name;
    	if (eName != 'allbox' &&
            (e.type.indexOf("checkbox") == 0)) {
        	e.checked = theForm.allbox.checked;
		}
	}
}

/*
 * Create Date:2004-06-01
 * Author: Jeff.Zhou
 * Request sublist data.
 */
function changeList(sUrl,selectList,changeList)
{
    var sName = changeList.name;
    document.getElementById("sub").src =
        sUrl + "mainId=" + selectList[selectList.selectedIndex].value + "&listName=" + sName;
}

/*
 * Create Date:2004-09-17
 * Author: Jeff.Zhou
 * Request sublist data.
 */
function changeExpertList(sUrl,radioButton,catId,changeList)
{
	/*
    	var sName = changeList.name;
	if(sName==undefined)
	{    
		sName = changeList[0].name;
	}*/	
    document.getElementById("sub").src =
        sUrl + "authorType=" + radioButton.value + "&catId=" + catId + "&listName=" + changeList ;
}


/*
 * Create Date:2004-06-01
 * Author: Jeff.Zhou
 * Reload the sublist data.
 */
function updateList(changeList,values)
{
    var list = document.getElementById(changeList);

	var len = list.length;
    for (var i = 1; i < len; i++)
    {
        list.remove(1);
    }

    nLen = values.length/2;
    for (var i = 0; i < nLen; i++)
    {
        list.options[i+1] = new Option(values[2*i+1],values[2*i]);
    }
    list.selectedIndex = 0;
}

/*
 * Create Date:2004-06-01
 * Author: Jeff.Zhou
 * Reload the sublist data.
 */
function updateWholeList(changeList,values)
{
    var list = document.getElementById(changeList);

	var len = list.length;
    for (var i = 0; i < len; i++)
    {
        list.remove(0);
    }

    nLen = values.length/2;
    for (var i = 0; i < nLen; i++)
    {
        list.options[i] = new Option(values[2*i+1],values[2*i]);
    }
    list.selectedIndex = 0;
}

function displayImage(image){
var extname,temp,str,strs,lens;

str= image;
strs=str.toLowerCase();
lens=strs.length;
extname=strs.substring(lens-4,lens);
temp="";
windowtitle = "";
if (image.toLowerCase().substring(0, 7) == "http://") {
	windowtitle = image;
} else {
	windowtitle = "http://"+location.host + image;
}
if (extname==".swf") {
	temp=temp+"<object width='100%' name='themovie' Classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'";
	temp=temp+" codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0'>";
	temp=temp+"<param name=movie value='" + image + "'><param name=quality value=high>";
	temp=temp+"<embed src='" + image + "' quality=high";
	temp=temp+" pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'" ;
	temp=temp+" type='application/x-shockwave-flash'></embed>";
	temp=temp+"</object>";	
	opendynawin(windowtitle,temp);
}
else if ((extname == ".gif") ||
					(extname == ".jpg") ||
					(extname == ".jpe") ||
					(extname == ".jpeg") ||
					(extname == ".png")) {
	temp=temp+"<img src='"+image+"'>";
	opendynawin(windowtitle,temp);
} else {
	window.open(image,'Preview','width=600,height=300,resizable=yes,scrollbars=yes');
}


}

function callopendynawin(theObj){
var extname,temp,str,strs,lens;
if (theObj.value.length==0) return 0;

str= theObj.value;
strs=str.toLowerCase();
lens=strs.length;
extname=strs.substring(lens-4,lens);
temp="";
windowtitle = "";
if (theObj.value.toLowerCase().substring(0, 7) == "http://") {
	windowtitle = theObj.value;
} else {
	windowtitle = "http://"+location.host + theObj.value;
}

if (extname==".swf") {
	temp=temp+"<object width='100%' name='themovie' Classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'";
	temp=temp+" codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0'>";
	temp=temp+"<param name=movie value='" + theObj.value + "'><param name=quality value=high>";
	temp=temp+"<embed src='" + theObj.value + "' quality=high";
	temp=temp+" pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'" ;
	temp=temp+" type='application/x-shockwave-flash'></embed>";
	temp=temp+"</object>";	
}
else
	temp=temp+"<img src='"+theObj.value+"'>";

opendynawin(windowtitle,temp);
}

function callopendynawinlocal(theObj){
var extname,temp,str,strs,lens;
if (theObj.value.length==0) return 0;

str= theObj.value;
strs=str.toLowerCase();
lens=strs.length;
extname=strs.substring(lens-4,lens);
temp="";

if (extname==".swf") {
	temp=temp+"<object width='100%' name='themovie' Classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'";
	temp=temp+" codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0'>";
	temp=temp+"<param name=movie value='" + theObj.value + "'><param name=quality value=high>";
	temp=temp+"<embed src='file:///" + theObj.value + "' quality=high";
	temp=temp+" pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'" ;
	temp=temp+" type='application/x-shockwave-flash'></embed>";
	temp=temp+"</object>";	
}
else
	temp=temp+"<img src='file:///"+theObj.value+"'>";

opendynawin(theObj.value,temp);
}

function callopendynawinonserver(theObj){
var extname,temp,str,strs,lens;
if (theObj.value.length==0) return 0;

str= theObj.value;
strs=str.toLowerCase();
lens=strs.length;
extname=strs.substring(lens-4,lens);
temp="";
windowtitle = "";
if (theObj.value.toLowerCase().substring(0, 7) == "http://") {
	windowtitle = theObj.value;
} else {
	windowtitle = "http://"+location.host + theObj.value;
}
if (extname==".swf") {
	temp=temp+"<object width='100%' name='themovie' Classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'";
	temp=temp+" codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0'>";
	temp=temp+"<param name=movie value='" + theObj.value + "'><param name=quality value=high>";
	temp=temp+"<embed src='" + theObj.value + "' quality=high";
	temp=temp+" pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'" ;
	temp=temp+" type='application/x-shockwave-flash'></embed>";
	temp=temp+"</object>";	
}
else
	temp=temp+"<img src='"+theObj.value+"'>";

opendynawin(windowtitle,temp);
}

function opendynawin(theTitle,theContent){
var winEx=window.open('','','width=600,height=300,resizable=yes,scrollbars=yes');

winEx.document.write("<html>");
winEx.document.write("<head>");
winEx.document.write("<title>" + theTitle+"</title>");
winEx.document.write("</head>");
winEx.document.write("<body>");
winEx.document.write("<table align='center' width='100%'>"); 
winEx.document.write("<tr><td align='center' >"+theContent+"</td></tr>"); 
//winEx.document.write("<tr><td align='center'><input type='button' style='font-size:9pt' value='¹Ø±Õ´°¿Ú' onclick='javascript:window.close()'></td></tr>"); 
winEx.document.write("</table>");
winEx.document.write("</body>");
winEx.document.write("</html>");
//winEx.document.title='Preview==='+themovie.stage.width; 
winEx.document.close();
}

function overwrite(msg)
{
	var doc = document.forms[0];
	if (confirm(msg)) {
	  document.forms[0].overwrite.value="true";
		doc.submit();
	} else {
	// do nothing
	} 
}