// JavaScript Document
var strMod="";
var tvHTML="<div><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\" width=\"470\" height=\"391\"><param name=\"movie\" value=\"TV.swf\" /><param name=\"quality\" value=\"high\" /><param name=\"wmode\" value=\"opaque\" /><embed src=\"TV.swf\" quality=\"high\" wmode=\"opaque\" pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"470\" height=\"391\"></embed></object></div>"
var bgObj=document.createElement("div");
function showMsgFrm(Mode,index){
	/*var sWidth,sHeight,wHeight;
	sWidth=document.body.offsetWidth;
	sHeight=document.body.offsetHeight;
	wHeight=window.screen.availHeight;
	if(sHeight<wHeight){
		sHeight=wHeight;
	}*/
	for(var i=1;i<=4;i++){
		if(getObject("liSel_"+i)){
			getObject("liSel_"+i).style.display="none";
		}
	}
	/*getObject("TipsDiv").style.zindex = 10002;
	bgObj.setAttribute('id','bgDiv');
	bgObj.style.position="absolute";
	bgObj.style.top="0";
	bgObj.style.background="#000";
	bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=2,opacity=40,finishOpacity=60";
	bgObj.style.opacity="0.6";
	bgObj.style.left="0";
	bgObj.style.width=sWidth + "px";
	bgObj.style.height=sHeight + "px";
	bgObj.style.zIndex = "10000";
	document.body.appendChild(bgObj);*/
	
	getObject("TipsDiv").style.display = "block";
	switch(Mode){
		case "WritePro":
			getObject("proWinDiv").innerHTML="<img src=\"images/loading.gif\" width=\"89\" height=\"90\" />"
			bgObj.style.display = "block";
			getObject("proWinDiv").style.display = "block";
			ajaxWebToShowPro(index);
			break;
		case "WriteMsg":
			bgObj.style.display = "block";
			getObject("sendMsg").style.display = "block";
			break;
		case "WriteTv":
			bgObj.style.display = "block";
			getObject("tvDiv").style.display = "block";
			getObject("tvDiv").innerHTML=tvHTML;
			break;
	}
	strMod=Mode;
}
function clsMsgFrm(){
	switch(strMod){
		case "WritePro":
			getObject("TipsDiv").style.display = "none";
			getObject("proWinDiv").style.display = "none";
			break;
		case "WriteMsg":
			getObject("TipsDiv").style.display = "none";
			getObject("sendMsg").style.display = "none";
			break;
		case "WriteTv":
			getObject("TipsDiv").style.display = "none";
			getObject("tvDiv").style.display = "none";
			getObject("tvDiv").innerHTML=""
			break;
	}
	for(var i=1;i<=4;i++){
		if(getObject("liSel_"+i)){
			getObject("liSel_"+i).style.display="block";
		}
	}
}
function CloseTips(){
	getObject("TipsDiv").style.display = "none";
}
function ajaxWebToShowPro(index){
	var xmlhttp;
	try{
		xmlhttp=new XMLHttpRequest();
	}catch(e){
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4){
			if (xmlhttp.status==200){
				var strText=xmlhttp.responseText;
				if(strText!=""){
					returnAjaxFun(strText,index);
				}else{
					returnAjaxFun("True|*|System Error: Unable to load data!",index);
				}
			}else if (xmlhttp.status == 404){
				returnAjaxFun("True|*|System Error: The system file does not exist!",index);
			}else{
				returnAjaxFun("True|*|System Error: Unable to load data!",index);
			}
		}
	}
	xmlhttp.open("post", "ajaxProInfo.asp", true);
	xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
	xmlhttp.send("Id="+escape(index));
}

function returnAjaxFun(str,idIndex){
	var arrStr=str.split("|*|");
	if(arrStr[0]=="False"){
		getObject("proWinDiv").innerHTML=arrStr[2];
	}else{
		alert(arrStr[1]);
		clsMsgFrm();
	}
}
function changProGroup(index,id_Select){
	if(index>0){
		removeCollectionOption();
		ajaxShowProGroup(index,id_Select)
	}else{
		removeCollectionOption();
	}
}
function ajaxShowProGroup(index,id_Select){
	var xmlhttp;
	try{
		xmlhttp=new XMLHttpRequest();
	}catch(e){
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4){
			if (xmlhttp.status==200){
				var strText=xmlhttp.responseText;
				if(strText!=""){
					insertOptionCollection(id_Select,strText);
				}else{
					alert("System Error: Unable to load data!");
				}
			}else if (xmlhttp.status == 404){
				alert("System Error: The system file does not exist!");
			}else{
				alert("System Error: Unable to load data!");
			}
		}
	}
	xmlhttp.open("post", "ajaxProGroup.asp", true);
	xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
	xmlhttp.send("Id="+escape(index));
}
function insertOptionCollection(id_Select,insertStr){
	var arrStr=insertStr.split("|*|");
	var j=0;
	for(var i=0;i<arrStr.length;i++){
		var arrVa=arrStr[i].split("|**|")
		if (arrVa.length>1){
			j++;
			getObject("Collection").options.add(new Option(arrVa[1],arrVa[0]));
			if(id_Select==arrVa[0]){
				getObject("Collection").selectedIndex=j;
			}
		}
	}
}
function removeCollectionOption(index){ 
	getObject("Collection").options.length=0;
	getObject("Collection").options.add(new Option("Collection(All)","0"));
}
